필터 지우기
필터 지우기

Parallelize instructions inside for

조회 수: 2 (최근 30일)
Thales
Thales 2017년 12월 28일
댓글: Walter Roberson 2017년 12월 28일
Is there a way to parallelize independent instructions within a for loop? The loops themselves aren't independent, so parfor is not really an option.
What I would like to do is something like:
for ii=1:N
% initial stuff
[...]
% instructions 1
[...]
% instructions 2
[...]
% instructions 3
[...]
% instructions 4
[...]
% more stuff
[...]
end
The instructions1, instructions2 etc are all independent instructions, so they should be able to parallelize. Each loop in the for, however, is not independent, so is not just change the for to a parfor. Is there any way to do it in Matlab?

답변 (1개)

Matt J
Matt J 2017년 12월 28일
You could make scripts for each set of instructions and launch them (within the loop) on different workers using the batch command.
  댓글 수: 1
Walter Roberson
Walter Roberson 2017년 12월 28일
Or parfeval() instead of batch()

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by