overhead communication in Parfor
Mostrar comentarios más antiguos
I would like to use parfor to speed up my code but it does not work well. I think it may be due to a warning: Variable "x" is indexed, but not sliced, in a parlor loop. This might result in unnecessary communication.
My code looks similar to the following,
X = cell{128*64,1};
parfor ii = 1:64
y = function(X(ii:ii*128))
end
Respuesta aceptada
Más respuestas (1)
Sean de Wolski
el 29 de Jun. de 2015
0 votos
Since your matrix is not that big, one approach would be to replicate it to be a 64x128 where each column is the values you want transmitted to that worker. Then you could have the parfor loop run over columns of this array passing off one column at a time x(:,ii) and this will result in a sliced matrix.
If you have access to the R2015b Prerelease, there might also be something in there you find useful.
4 comentarios
Chao Song
el 29 de Jun. de 2015
Chao Song
el 29 de Jun. de 2015
Sean de Wolski
el 30 de Jun. de 2015
This document helps explain classification of variables, basically, you can only have the loop iterator and a constant, not a dynamic range (like ii:ii*128).
My same thought above should work on a cell rather than an mxn matrix since cells can be sliced by the same rules as a numeric matrix. I'll try to provide a small example tomorrow.
Chao Song
el 30 de Jun. de 2015
Categorías
Más información sobre Parallel for-Loops (parfor) en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!