Dual Parfor from different scripts
4 ビュー (過去 30 日間)
古いコメントを表示
Rishi Balasubramanian
2023 年 2 月 1 日
コメント済み: Walter Roberson
2023 年 2 月 2 日
So I have a Launcher.m script which executes a function.m using parfor. The function.m also has its own parfor. Will this work?
0 件のコメント
採用された回答
Walter Roberson
2023 年 2 月 1 日
編集済み: Walter Roberson
2023 年 2 月 2 日
it will be accepted but will execute the second one in serial order
4 件のコメント
Walter Roberson
2023 年 2 月 2 日
The nested parfor will be executed in serial, in reverse order. It is not possible to initiate parallel constructs within parallel constructs and have the nested ones operate in parallel.
(Though I am not certain what would happen if you were to parfeval() or batch() within a parallel construct.)
Walter Roberson
2023 年 2 月 2 日
Looks like parfeval() and parfor() cannot initiate parfeval() ...
p = parpool();
outer_results = parfevalOnAll(p, @test_outer, 0, p)
celldisp(outer_results.Error)
parfor K = 1 : p.NumWorkers
test_outer(p);
end
function test_outer(p)
ID = randi(99);
fprintf('outer about to start inner, ID = %d\n', ID);
inner_results = parfevalOnAll(p, @test_inner, 0, ID)
celldisp(inner_results.Error)
fprintf('outer fininished inners, ID = %d\n', ID);
end
function test_inner(ID)
subID = randi(99);
fprintf('inner ID %d subid %d reporting!\n', ID, subID);
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Parallel for-Loops (parfor) についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!