serial and parallel
24 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Walter Roberson
el 9 de Ag. de 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 comentarios
Ver también
Categorías
Más información sobre Parallel Computing Toolbox en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!