MATLAB: how to split and distribute a list of cell arrays over workers in a parallel loop?

I have a question about parallelizing code in MATLAB. I am using MATLAB 2017a.

Let's say I have an array of cells:

A = { A1, ..., A10}

and these matrices are quite large (size> 10000). Now I want to start manipulating these matrices in a parallel pool. In fact, the first worker only needs , the second worker needs only , etc. A1 A2

I have this code:

parfor i = 1:10
    matrix = A{i};
    blabla = manipulate(Ai);
    save(blabla);
end

I think MATLAB gives every employee all the matrices in A, but it really is not necessary. Is there any way to say:
"Give the i-th worker just a matrix " Ai

+4
source share
2 answers

parfor, , , A , . . , , , , , parfor.

0

spmd . , , , Matlab parfor.

parpool('myprofile',10)
spmd
   i = labindex; 
   B = foo(A{i});
end
for i = 1:10
   bar(B{i});
end
0

Source: https://habr.com/ru/post/1688123/


All Articles