フィルターのクリア

matlab parfor to evaluate a function in bunch of 4 rather than all at the same time

3 ビュー (過去 30 日間)
H-H
H-H 2014 年 9 月 11 日
回答済み: Edric Ellis 2014 年 9 月 11 日
Hi all, I want to use matlab parallel functionality of parfor. However, my function doesn't allow the parallel evaluation of more than 4 at the same time due to the license issue. Is there a way that matlab uses parallel but in bunch of 4? for example,
parfor i = 1:100
t = function;
end
This probably, run 100 function evaluations at the same time. I want matlab to run my function parallel in bunch of 4.
is there any way to do so?

回答 (1 件)

Edric Ellis
Edric Ellis 2014 年 9 月 11 日
The number of simultaneous function evaluations will be determined by the size of the parallel pool that you open. So, if you were to execute
parpool('local', 4)
before executing the PARFOR loop, then no more than 4 instances of 'function' would execute simultaneously. (If you're using an earlier release of MATLAB, you might need to say "matlabpool open local 4" instead of the 'parpool' command).

カテゴリ

Help Center および File ExchangeParallel Computing Fundamentals についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by