Effacer les filtres
Effacer les filtres

Loading mat files within parfor takes long time

1 vue (au cours des 30 derniers jours)
Dave Lee
Dave Lee le 24 Déc 2018
Commenté : Walter Roberson le 24 Déc 2018
Hi,
I am writing the code below to load/process 2627 files under parfor with the size of each file is 100MB, makes it total of 272GB. It is taking very long time to process. I actually use a progress bar for parfor, not shown in this simplified code, and the progress bar even hasn't started yet. I think it is still doing some overhead work. When I use for-loop, I think it is not slower than parfor. Can someone please give me a suggestion? My computer: 40 cores and RAM of 383GB
Merry Xmas,
clear all;
folder_mat_file = '.\Mat_files_full\';
mat_filename_valid = dir([folder_mat_file '*.mat']);
no_mat_files = numel(mat_filename_valid);
if isempty(gcp)
parpool;
end
poolobj = gcp;
for n=1:no_mat_files
filename_cell{n} = [folder_mat_file mat_filename_valid(n).name];
end
addAttachedFiles(poolobj,filename_cell)
parfor n=1:no_mat_files
% data_struct is temporary variable
data_struct = parload([folder_mat_file mat_filename_valid(n).name]);
%% Here we do processing
end
%% Below is the function parload use to load file within parfor
function x = parload(filename)
x = load(filename);
end
  7 commentaires
Dave Lee
Dave Lee le 24 Déc 2018
I am not sure if I understand you, using save within parfor as below?
save_within_parfor.png
Walter Roberson
Walter Roberson le 24 Déc 2018
Ah, they used to permit it, but it would give a transparency error if you did not name all of the variables.
Continue on with your parsave routine then.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Parallel for-Loops (parfor) dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by