Parfor: Converting broadcast variables into temporary variables or sliced variables
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Brandon
el 18 de Mayo de 2021
Comentada: Walter Roberson
el 18 de Mayo de 2021
Is there a difference in efficiency if I just assign a broadcast varible to a temporary variable inside a parfor loop vs re-writing it as a sliced variable that is indexed the same as the main index of the parfor loop? Matlab does not categorize it as a broadcast variable either way, but I'm not sure if the temporary variable method still avoids sending more data than is necesary to workers.
0 comentarios
Respuesta aceptada
Matt J
el 18 de Mayo de 2021
Editada: Matt J
el 18 de Mayo de 2021
Temporary variables are not sent to the workers. They are created on the workers (and are destroyed there).
4 comentarios
Walter Roberson
el 18 de Mayo de 2021
Yes, the broadcast variable will (probably) be sent. MATLAB does some static flow analysis, but you cannot count on it being advanced enough to be able to reason that ih>0 will always be true.
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!