parfor slicing variables suggestions
2 views (last 30 days)
Show older comments
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
0 Comments
Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!