Loading mat files within parfor takes long time

4 次查看(过去 30 天)
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 个评论
Dave Lee
Dave Lee 2018-12-24
I am not sure if I understand you, using save within parfor as below?
save_within_parfor.png
Walter Roberson
Walter Roberson 2018-12-24
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by