parfor loop exit: deterministic concurrent?

2 ビュー (過去 30 日間)
Holger I. Meinhardt
Holger I. Meinhardt 2017 年 2 月 5 日
I have a set of independent problems, which I can transfer to a parfor loop. The return value of each of these iterations is false or true. To shorten the computation, I want to exit the parfor loop at the first time the return value "true" has materialized (deterministic concurrent). How can I accomplish this task?

採用された回答

Walter Roberson
Walter Roberson 2017 年 2 月 5 日
The documentation indicates
"If you change parfor to for, the use of s outside the reduction assignment relies on the iterations being performed in a particular order. In a parfor-loop, it matters that the loop "does not care" about the value of a reduction variable as it goes along. It is only after the loop that the reduction value becomes usable."
so there is nothing you can check in the loop to determine whether you should continue. Though I guess you could write to a file and check the file.
Cleaner would be to parfeval() and as the results come back, when you finally get a true, cancel the remaining futures.
  1 件のコメント
Holger I. Meinhardt
Holger I. Meinhardt 2017 年 2 月 6 日
Thanks a lot for your suggestion to use parfeval. It works as expected by some minor changes of my code.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParallel for-Loops (parfor) についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by