PARFOR slicing of user-defined objects
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Matt J
el 1 de Mzo. de 2019
Comentada: Matt J
el 4 de Mzo. de 2019
I have a user-defined class with its own overloaded subsref and subsasgn methods to define indexing expressions like A(:,:,i). My question is, how would parfor treat a loop like the following with respect to slicing,
parfor i=1:N
x(:,i)=some_function( A(:,:,i) );
end
Will my object A be sliced as a normal numeric array would, and if so how is my overloaded subsref/subsasgn method involved in this process? Will parfor execute my subsref method when it tries to extract a chunk A(:,:,m:n) to send to the workers?
0 comentarios
Respuesta aceptada
Edric Ellis
el 4 de Mzo. de 2019
The parfor machinery decides whether a variable reference is "sliced" or not by examining the form of indexing used, paying no regard to the type of the variable. So, in your example, A will indeed be sliced. Your indexing overloads will be called on the client as part of the slicing operation, and also on the workers. The parfor machinery will send contiguous blocks of A of size MxNxp to the workers in groups known as "intervals" (with an interval size p), and then on the workers, these blocks will be further indexed to create the MxNx1 slices.
Más respuestas (0)
Ver también
Categorías
Más información sobre Parallel for-Loops (parfor) en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!