serial and parallel

조회 수: 19 (최근 30일)
Danielle
Danielle 2011년 8월 9일
Hello!
I'm trying to implement parallel computing and was testing it out on a simple example
%ex1
tic;
X = rand(326, 2); Y = rand(326, 60000);
b = lscov(X, Y);
toc;
%ex2
tic;
X = rand(326, 8000); Y = rand(326, 60000);
b = lscov(X, Y);
toc;
In serial, it takes 0.2,3.5 seconds.
It was my understanding that the 2nd example should run faster in parallel however when i use matlabpool (i have 4 cores), it takes 7.6 and 9.1 sec for ex1 and ex2 respectively.
Im pretty sure i setup the parallel config correctly so im not sure why its taking longer in parallel than serial?
Any input would be greatly appreciated
Thanks!

답변 (1개)

Walter Roberson
Walter Roberson 2011년 8월 9일
There is a lot of overhead in starting up pools and transferring work over to them. It is common that parallel is slower unless you give it "enough" work to do.
Also, in newer versions, some parts of MATLAB transparently use multiple cores for sufficiently large computations, even without the parallel toolbox. If those cores are not available because they are reserved for the pool, then the execution could slow down.
Just opening a pool does not trigger parallel computation: routines do not, usually, take advantage of an available pool, perhaps figuring that you must have something else in mind for the pool. You explicitly code parallelization with parfor or spmd or similar routines -- except, that is, for the parts that automatically use multiple cores even if you do not have a pool.

카테고리

Help CenterFile Exchange에서 Parallel Computing Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by