필터 지우기
필터 지우기

parfor and rng(1)

조회 수: 6 (최근 30일)
mingcheng nie
mingcheng nie 2022년 8월 19일
댓글: mingcheng nie 2022년 8월 24일
Hi there,
I was doing matlab simulation based on different SNR and rng, and want to use parfor to speed up, can we do like this?(can we use rng together with parfor?)
rng(1)
count=10000;
for SNR=20:5:50
for i = 1: count
chan_coef = randn(1,1)+1i*randn(1,1);
...
end
end
%Is It Correct to Change to
rng(1)
count=10000;
parfor SNR=20:5:50
parfor i = 1: count
chan_coef = randn(1,1)+1i*randn(1,1);
...
end
end
Thanks,
Charlie
  댓글 수: 1
mingcheng nie
mingcheng nie 2022년 8월 24일
thank you for your comments!

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

채택된 답변

Bruno Luong
Bruno Luong 2022년 8월 19일
편집: Bruno Luong 2022년 8월 19일
rdn(1) outside the parfor has no effect.
from the doc:
"For independent streams on the workers, use the default behavior or consider using a unique substream on each worker using RandStream."
So you should leave the parfor loop alone or use RandSteam inside parfor loop (but not rdn('shuffle') as warned the doc).

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Parallel Server에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by