Effacer les filtres
Effacer les filtres

Parallelizing Independent Tasks Help

1 vue (au cours des 30 derniers jours)
Nimrod Sadeh
Nimrod Sadeh le 24 Jan 2018
Commenté : Greg le 25 Jan 2018
Hi,
I have a model that I'm trying to parallelize. In this section, I run the same function four times on four independent sets, each time the function outputs three tables of reaction probabilities. I struggled using parfor to parallelize because it behaves strangely with indexing order and I don't understand it. Can anyone chime in with advice about how they would parallelize this task?
[HF,HA,HS] = reactions(H,1,Hprobs);
[OF,OA,OS] = reactions(O,16,Oprobs);
[U25F,U25A,U25S] = reactions(U25,235,U25probs);
[U28F,U28A,U28S] = reactions(U28,238,U28probs);
Thank you!
  9 commentaires
Nimrod Sadeh
Nimrod Sadeh le 25 Jan 2018
You're right on all counts, Greg. The code works, too. Thanks for your answer - please post it so I can accept. Thank you Walter, too.
I ran the speed test on the data, and it seems the old method is about 4 times faster than the parfor loop, so I'll probably stick to that. But thanks for the help.
Greg
Greg le 25 Jan 2018
If you're looking for general performance improvement (rather than specifically multi-threading), run the profiler. It will identify individual lines of code that are taking especially long to execute. You can then post a new (related) question, identifying those lines and we can try to help optimize.

Connectez-vous pour commenter.

Réponse acceptée

Greg
Greg le 25 Jan 2018
Per the comments, I think you're having curly-brace vs. parenthesis problems, and 1:3 in input, not 1:4:
input = { H, 1, Hprobs; ...
O, 16, Oprobs; ...
U25,235,U25probs; ...
U28,238,U28probs};
parfor i=1:4
[F{i},A{i},S{i}] = reactions(input{i,1:3});
end

Plus de réponses (0)

Catégories

En savoir plus sur Particle & Nuclear Physics 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