parfor slicing variables suggestions

1 view (last 30 days)
cedric W
cedric W on 10 Jan 2019
Edited: cedric W on 10 Jan 2019
I'm wondering what was the best way to split a big matrix (500000 x 1000) into 20 matrices of size 25000 x 1000. The aim is to use parfor to try to speed up the code
A and B have the same size
As you can see, I tried to split directly A and B but it gives me warning with broadcast variables (see commented part).
So I changed and the way i did it now, I'm loosing precious time to convert with mat2cell and cell2mat. It takes around 15% ot total computation time.
Do you have any suggestion ?
I did the following:
nbSlices=20;
SplitSize=size(S,1) / nbSlices * ones(nbSlices,1);
split_A=mat2cell(A,SplitSize,1000);
split_B=mat2cell(B,SplitSize,1000);
parfor ix=1:nbSlices
%A2=A(ix*nbSlices-nbSlices+1:ix*nbSlices,:);
%B2=B(ix*nbSlices-nbSlices+1:ix*nbSlices,:);
Res(ix)=Compute(cell2mat(split_A(ix)),cell2mat(split_B(ix)))
end

Answers (0)

Categories

Find more on Parallel for-Loops (parfor) in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!