Parfor: Converting broadcast variables into temporary variables or sliced variables
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
Matt J
2021년 5월 18일
편집: Matt J
2021년 5월 18일
Temporary variables are not sent to the workers. They are created on the workers (and are destroyed there).
댓글 수: 4
Walter Roberson
2021년 5월 18일
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.
추가 답변 (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!