Alternatives to break command inside a spmd command

5 ビュー (過去 30 日間)
Daniel Jaló
Daniel Jaló 2013 年 2 月 16 日
コメント済み: John Nwankwo 2018 年 11 月 15 日
Hello. I was looking for an alternative to a break command inside an spmd block. Imagine we have a code with 4 loops in parallel, one for each lab. I want all the loops to stop when one condition is met. Now, whichever lab has the condition met will simply stop the loop by means of a break command. The other labs however will not know that the condition has already been met and will continue running. I want to find a way for they all to get out of the loop.
I thought about using the labSend/labReceive commands to warn the remaining labs that the condition has already been met. The problem is that for the other labs to receive it that would require me to put an additional condition in each lab, of the kind
if labReceive==1
break
end
The problem is that this conditions would require the labs to communicate to some degree every iteration, and I'm afraid that it will considerably slow my code...
Will the code get significantly slower? Are there other alternatives for me to stop all the loops?
Thanks. Cheers.

回答 (1 件)

Konrad Malkowski
Konrad Malkowski 2013 年 3 月 21 日
What you will need to implement is a parallel termination detection algorithm.
See the following link for references:
  1 件のコメント
John Nwankwo
John Nwankwo 2018 年 11 月 15 日
There is no information on your link

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by