From: anna anna on 5 Mar 2010 07:59 Hi all, I'm trying to solve a linear system Ax = b using the spmd tool (included in the parallel toolbox). I've found a small script on the internet which works fine where A is a 100x100 random matrix: matlabpool(4) spmd A = rand ( 100, 100, codistributor ( ) ); b = sum ( A, 2 ); x = A \ b; end matlabpool close Starting from this existing script, I've tried to adapt it to my problem where the A matrix is not random but is previously computed. A is a square matrix about 6000x6000. I've used the codistributed function to distribute (??) the A matrix on the 4 workers (defined in matlabpool) and obtaining a new distributed matrix called Ar: matlabpool(4) spmd Ar = codistributed(A,codistributor() ); b = sum ( Ar, 2 ); x = Ar \ b; end matlabpool close The problem is that I get an error I can not manage: ??? Error using ==> spmd_feval at 8 Error detected on lab(s) 1 2 3 4 Error in ==> CODE at 212 Ar = codistributed(A,codistributor() ); Caused by: Input A must be square. Error stack: mldivide.m at 41 Input A must be square. Error stack: mldivide.m at 41 Input A must be square. Error stack: mldivide.m at 41 Input A must be square. Error stack: mldivide.m at 41 Any ideas?
From: Jill Reese on 5 Mar 2010 09:51 Hello. The problem that you're seeing stems from the fact that the codistributed constructor changed between R2009a and R2009b. I think that you are using a pre-9b version of Matlab, while the example script that you found was intended for use with at least 9b. If you look at the help for codistributed, you will see that in your version of Matlab the constructor D = CODISTRIBUTED(L,DIST) (which you're using to create Ar from A) assumes that the input L is a local part on each lab that you want to stitch together using the codistributor DIST. So what is happening in your code is that A is getting repeatedly stitched together along the column direction (based on your using the default codistributor -- 1d along columns). If you try the following you will see that Ar is 6000 x 24000 rather than 6000 x 6000 as you intended. spmd Ar = codistributed(A,codistributor() ); size(Ar) end The constructor that you want is D = CODISTRIBUTED(X, 'convert'). So you should be all set using Ar = codistributed(A, 'convert'); inside your spmd block. Cheers, Jill "anna anna" <caucciam(a)yahoo.fr> wrote in message <hmqv7b$gvl$1(a)fred.mathworks.com>... > Hi all, > > I'm trying to solve a linear system Ax = b using the spmd tool (included in the parallel toolbox). I've found a small script on the internet which works fine where A is a 100x100 random matrix: > > matlabpool(4) > spmd > A = rand ( 100, 100, codistributor ( ) ); > b = sum ( A, 2 ); > x = A \ b; > end > matlabpool close > > Starting from this existing script, I've tried to adapt it to my problem where the A matrix is not random but is previously computed. A is a square matrix about 6000x6000. I've used the codistributed function to distribute (??) the A matrix on the 4 workers (defined in matlabpool) and obtaining a new distributed matrix called Ar: > matlabpool(4) > > spmd > Ar = codistributed(A,codistributor() ); > b = sum ( Ar, 2 ); > x = Ar \ b; > end > matlabpool close > > The problem is that I get an error I can not manage: > > ??? Error using ==> spmd_feval at 8 > Error detected on lab(s) 1 2 3 4 > > Error in ==> CODE at 212 > Ar = codistributed(A,codistributor() ); > > Caused by: > > Input A must be square. > > Error stack: > mldivide.m at 41 > > Input A must be square. > > Error stack: > mldivide.m at 41 > > Input A must be square. > > Error stack: > mldivide.m at 41 > > Input A must be square. > > Error stack: > mldivide.m at 41 > > Any ideas?
From: anna anna on 5 Mar 2010 10:45 Hi Jill, thanks for your kind help, it worked! However I have another question: I run my computations on 2 quad-core processors, i.e. I have 8 "labs"..the point is that if I use 8 labs the computation is much slower than using 4 or even only 1 lab. What am I missing?
From: Jill Reese on 5 Mar 2010 11:28 As more and more of Matlab is able to take advantage of multithreading, we sometimes find that using codistributed arrays can be slower than the serial version, particularly for small problems. The real advantage of codistributed arrays is when you want to work with a data set that cannot fit in memory on one worker (you can create a large array from smaller local parts stored on each lab). Since your 6000x6000 matrix fits in memory on each worker, you are probably seeing communication between labs outweighing any computational benefit you get from working in parallel. Hope this helps, Jill "anna anna" <caucciam(a)yahoo.fr> wrote in message <hmr8up$b0p$1(a)fred.mathworks.com>... > Hi Jill, > > thanks for your kind help, it worked! > > However I have another question: I run my computations on 2 quad-core processors, i.e. I have 8 "labs"..the point is that if I use 8 labs the computation is much slower than using 4 or even only 1 lab. What am I missing?
From: Gaurav Sharma on 5 Mar 2010 13:04 We recently posted a new demo in the demos section for Parallel Computing Toolbox that talks about how performance changes with problem size and number of workers. See the "Benchmarking Parallel "\" Operator (A\b)" demo under "Benchmarks and Performance" on the following page: http://www.mathworks.com/products/parallel-computing/demos.html Or, you can use the following to get to the demo directly: http://bit.ly/9zppcs "Jill Reese" <jill.reese(a)mathworks.com> wrote in message news:hmrbel$jsr$1(a)fred.mathworks.com... > As more and more of Matlab is able to take advantage of multithreading, we > sometimes find that using codistributed arrays can be slower than the > serial version, particularly for small problems. The real advantage of > codistributed arrays is when you want to work with a data set that cannot > fit in memory on one worker (you can create a large array from smaller > local parts stored on each lab). Since your 6000x6000 matrix fits in > memory on each worker, you are probably seeing communication between labs > outweighing any computational benefit you get from working in parallel. > Hope this helps, > > Jill > > "anna anna" <caucciam(a)yahoo.fr> wrote in message > <hmr8up$b0p$1(a)fred.mathworks.com>... >> Hi Jill, >> >> thanks for your kind help, it worked! >> >> However I have another question: I run my computations on 2 quad-core >> processors, i.e. I have 8 "labs"..the point is that if I use 8 labs the >> computation is much slower than using 4 or even only 1 lab. What am I >> missing?
|
Pages: 1 Prev: wavelet denoising using ddencmp funtion Next: pdepe in 2d |