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!