Using the Parallel Computing Toolbox for simultaneous evaluation of multiple Datasets
Mostra commenti meno recenti
Hello,
I am very new to the parallel toolbox and don't know how to run my code with it efficiently. I'll explain my situation.
I want to evaluate different results of image registration on different datasets, which are all stored in a common folder.
Right now I simply loop through the folder, and apply my function "Evaluation(x,y)" to every file in the folder serially, and save the result into a structure. In the end I add all these structures to one big structure since they have the same fields.
Inside my Evaluation function I call different functions, which calculate different things, which some of them are independent of another.
See the pseudo code.
for folder in listing...
%loop through folder and get the paths for the evaluation function
load(folder)...
path_fixed = [input_folder_dir_(8).folder,'\', input_folder_dir_(8).name];
res = Evaluation(path_fixed, path_moving, path_registerd, path_displacement, LMs);
res.name = listing(i).name;
struc_name = listing(i).name;
results.(struc_name) = res;
end
results_overview = [results.strucnameA, results.strucnameB,...]
function res = Evaluation(a,b,c,d)
res.Parameter_a = evaluate_metric1(a,b);
res.Parameter_b = evaluate_metric2(b,c,d);
.
.
.
end
So as far as I read into parallel computing I have 2 options:
I either can use a parfor loop for looping through the folder. This means that 2-4 datasets are evaluated at the same time. However, I don't know if that works, since both workers would then write the same variable 'res', right?
Otherwise I could use spmd blocks in the evaluation function itself to calculate multiple parameters at the same time.
Which would be the correct way?
Does doubling the workers also mean double the ram memory needed?
Thanks and regards
Michael
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!