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 个评论
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 Center 和 File Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!