Info
この質問は閉じられています。 編集または回答するには再度開いてください。
Is there a way to parallelize the function hygepdf?
1 回表示 (過去 30 日間)
古いコメントを表示
So I have a script that uses the hygepdf function in a for loop and the result of i=i+1 does not depend on the result that is calculated when i=i.
(Hopefully that makes sense.)
Given that, is there a way that I can use the parallel computing toolbox and multiple workers so that I will be able to compute each of the hygepdf computations in the for loop in parallel and then assemble the results back together as if it had ran it in the for loop?
i.e. here is the quasi-pseudocode:
original with a for loop
for i=1:16
thiper(i)=hygepdf(D1,linspace(N,N,minValue+1),linspace(D,D,minValue+1),linspace(m,m,minValue+1);
end
and then change is to that it can run each of those 16 loops in parallel:
something like
thiper(1)=hygepdf(D1,linspace(N,N,minValue+1),linspace(D,D,minValue+1),linspace(m,m,minValue+1);
thiper(2)=hygepdf(D1,linspace(N,N,minValue+1),linspace(D,D,minValue+1),linspace(m,m,minValue+1);
thiper(3)=hygepdf(D1,linspace(N,N,minValue+1),linspace(D,D,minValue+1),linspace(m,m,minValue+1);
thiper(...)=hygepdf(D1,linspace(N,N,minValue+1),linspace(D,D,minValue+1),linspace(m,m,minValue+1);
thiper(16)=hygepdf(D1,linspace(N,N,minValue+1),linspace(D,D,minValue+1),linspace(m,m,minValue+1);
thiper=[thiper(1);thiper(2);thiper(3);thiper(...);thiper(16)];
Hopefully I am able to articulate what I am trying to do sufficiently enough that people will understand what I am going for here.
Again, the basic premise in this for loop calculation is that the result of the current index isn't needed by the next index, so I want to see if there is a way to use multiple workers to run the for loop in parallel and then just assemble the results together at the end.
Thank you.
4 件のコメント
回答 (1 件)
Bernhard Suhm
2018 年 6 月 12 日
I am not an expert for the Parallel Computing toolbox, but if the calculation inside the for loop body is fairly simple (as it looks in your case), the loop bodies will actually be executed in groups, so there's no guarantee all workers will remain busy. I've added PCT as keyword so someone there can jump in if they have other suggestions.
0 件のコメント
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!