Parallelizing Independent Tasks Help
古いコメントを表示
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 件のコメント
Walter Roberson
2018 年 1 月 24 日
We probably need to see the code for reactions() to get an idea of why there is a problem.
Nimrod Sadeh
2018 年 1 月 24 日
Walter Roberson
2018 年 1 月 24 日
Could you describe further what you mean by "it behaves strangely with indexing order" ?
Nimrod Sadeh
2018 年 1 月 25 日
Walter Roberson
2018 年 1 月 25 日
parfor i=1:4
temp = reaction(input(i,1:4));
output(i,1:3) = temp;
end
Nimrod Sadeh
2018 年 1 月 25 日
You've both missed the 's' in the function name reactions, but I'm assuming that's a typo in-comment only.
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
If this works, I'll move it to an Answer for acceptance.
Nimrod Sadeh
2018 年 1 月 25 日
Greg
2018 年 1 月 25 日
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.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Particle & Nuclear Physics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!