Hello fellow programmers.
I've been exploring the distributed arrays functionality on Matlab. I tried doing a simple matrix multiplication, where both matrices have the same dimension, and comparing the time it takes the serial and parallel execution to run.
Here's the code, not "parallelized" (is that a word?)
N = 5000;A = eye(N);B = magic(N);ticC = A*B;toc
I try to run it in parallel by distributing the array of the matrices between the 4 workers I have available.
N = 5000;A = eye(N);B = magic(N);spmd A = codistributed(A,codistributor1d()); B = codistributed(B,codistributor1d());endticspmd C = A*B;endtoc
However when I run this code it takes a lot of time to distribute the matrices between the workers (with the codistributed() function) and the matrix multiplication takes significantly longer (about 5/6 times longer).
If anyone could tell me what I'm doing wrong I'd appreciate. Am I not understanding how distributed arrays should be used?
Cheers Daniel
Best Answer