parfor slicing variables suggestions
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!