how can I write a parallel code in Matlab?
조회 수: 1 (최근 30일)
이전 댓글 표시
hi every one, can you help me to write a program with parfor and compare the time consumed in comparing with for? The code is: matlabpool open local 7 tic parfor i = 1:100000 k=i end toc matlabpool close Elapsed time is 1.846197 seconds.
tic,for i = 1:100000 k=i end toc Elapsed time is 0.000640 seconds.
댓글 수: 0
채택된 답변
Dima Lisin
2014년 8월 1일
The reason you are seeing this result is because your loop does not do anything. If you make each iteration of your loop do substantial work, you will see a speedup.
추가 답변 (1개)
Edric Ellis
2014년 8월 4일
Ideally, you should not open and close the pool for timing purposes - it's intended that you keep the pool open.
댓글 수: 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!