serial and parallel
24 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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!
0 Kommentare
Antworten (1)
Walter Roberson
am 9 Aug. 2011
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.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Parallel Computing Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!