- The broadcast variable is a variable that does not change inside a loop. At the start of a parfor loop, MATLAB sends the values of any broadcast variables to all the workers. The usage of large/many broadcast variables can cause significant communication between a client and its associated workers, and in turn increases overhead. You can learn more about these variables by going through the following documentation: https://www.mathworks.com/help/parallel-computing/broadcast-variable.html
- This issue arises when the loop body accesses multiple rows and columns of a matrix using the loop variable. Refer to this MATLAB Answer for more clarity upon when this issue is encountered: https://www.mathworks.com/matlabcentral/answers/419074-parfor-loop-the-entire-array-or-structure-h-is-a-broadcast-variable-this-might-result-in-unnecess
- Please note that this is a warning and not an error. There are a few ways through which you can reduce the communication overhead such as creating temporary variables within the loop body. Have a look at this MATLAB Answer which demonstrates a way to resolve the issue: https://www.mathworks.com/matlabcentral/answers/1700170-parfor-unnecessary-communication-overhead
How can I solve the unneccesary communication overhead problem caused by the broadcast variable error?
4 次查看(过去 30 天)
显示 更早的评论
%% Errror description Even though I tried to solve it by assigning variable Y to a temporary variable, it didn't work?
%% The entire array or structure Y-temp is broadcast variable. This might result in unneccesary comunicaiton overhead?
for k=0:1:(M-1)
z_plane_path(k+1)=A*W^(-k);
end
ChirpZ_outY(1:M)=0;
Y_temp=Y(:,1);
parfor k=0:M-1
sum1=0;
for n=0:N-1
sum1=sum1+(Y_temp(n+1)*z_plane_path(k+1)^(-n));
end
ChirpZ_outY(k+1)=sum1;
end
DFT_SS_Eq_out=ChirpZ_outY/N*2;
disp(i);
end
0 个评论
回答(1 个)
Shubham
2024-9-18
编辑:Shubham
2024-9-18
Hey Alexi,
I understand that you are facing the following error: "The entire array or structure Y-temp is broadcast variable. This might result in unneccesary comunicaiton overhead" through your above code snippet.
I hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!