Why is parfor so slow?
이전 댓글 표시
Hi,
I want to run Matlab on a cluster node with 4 processors and 48 cores (128GB ram). Typically what I do is 3D ffts. Toy example: -----------------------------------
function test(a)
N = 100;
FT = @(x)(fftshift(fftn(ifftshift(x))));
iFT = @(x)(fftshift(ifftn(ifftshift(x))));
X = randn(64,64,64);
for ii = 1:N
X = iFT(FT(X));
end
toc(a)
end
-----------------------------------
when calling this function from a parfor loop:
-----------------------------------
N = 8
poolSize = 11;
matlabpool(poolSize)
disp(['Pool created at ',num2str(toc(a))])
for ii = 1:N
test(a);
end
disp('Done processing')
toc(a)
matlabpool close
disp('Pool closed')
toc(a)
disp('DONE!!');
toc(a)
-----------------------------------
I almost not getting any speedup compared to running it serially on a single core. WHY? Is it reading and writing from RAM that takes all time?
Thankful for all answers, Anders
댓글 수: 2
cr
2013년 10월 7일
Just a comment to make sure that not so obvious things aren't taken for granted. Is the PCT installed?
Edric Ellis
2013년 10월 7일
We can assume PCT is installed otherwise the calls to matlabpool could not succeed.
답변 (1개)
Edric Ellis
2013년 10월 7일
1 개 추천
Firstly, I assume you meant to put a PARFOR loop in your example code for the 1:N loop. The reason you are not seeing any speedup is that the FFT operation is itself intrinsically multi-threaded by MATLAB. Intrinsic multi-threading is always more efficient than sending the data to the workers and executing (in a single-threaded manner) there.
카테고리
도움말 센터 및 File Exchange에서 Parallel and Cloud에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!