Parfor/spmd with random numbers
10 ビュー (過去 30 日間)
古いコメントを表示
In my code I want to run a function on each worker in parallel. The function is mexified C++ and (simply put) returns an image consisting of pixels with random intensity. Something like this:
parfor i = 1 : numiters
output(:,i) = myFn()
end
The trouble is that each output(:,i) is identical! Running the functions serially, like so:
for i = 1 : numiters
output(:,i) = myFn()
end
there are no troubles. Each output(:,i) is different. I thought that each worker is initialized with a random seed -- but I guess not. It seems that they are all initialized to the same seed. Any tips on how to overcome this issue?
Many thanks.
4 件のコメント
Brendan Hamm
2016 年 2 月 3 日
Walter Roberson
2024 年 11 月 18 日 19:31
These days, the appropriate link for help seems to be https://www.mathworks.com/help/parallel-computing/control-random-number-streams-on-workers.html
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Parallel Computing Fundamentals についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!