Matlab Parfor with shared array?

Is there anyway to share an array between workers like below:
A = zeros(10,10)
parfor i = 1:10
for j = 1:10
A(i,j) = i*j;
end
end
I was able to run this but its slower than a regular for-loop.

 채택된 답변

Jason Ross
Jason Ross 2012년 3월 22일

0 개 추천

You aren't doing enough work to make the overhead of starting the workers worth it.

댓글 수: 3

Justin
Justin 2012년 3월 22일
Jason,
Yea, the 10 was just as an example. I scaled it up to like 5000 and its still slower. Both give the same results. In addition, the parfor does work 6 threads from the system monitor as well. For a matrix size of 5000x5000 it takes about 4-5 seconds with parfor and 0.3 seconds with a regular forloop
Justin
Justin 2012년 3월 22일
Ok, I read the link you sent and realize i need more work in the body. Thanks,
-Justin
Jason Ross
Jason Ross 2012년 3월 22일
No problem!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기

태그

질문:

2012년 3월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by