parfor slicing variables suggestions
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!