Using broadcasting array variable values as indexes
3 ビュー (過去 30 日間)
古いコメントを表示
Farbod Tavakkoli
2019 年 10 月 18 日
編集済み: Walter Roberson
2019 年 10 月 18 日
I am using parallel tool for running my code. Actually there is no major error and the code runs but I have some minor error such as "The entire array or structure 'AccelerationY' is a broadcast variable. This might result in unnecessary communication overhead". I have the same error in my code in four different places which I have indicated below with # in bold.
My first question is how can I solve this problem in my code. Second, does it really hurt the runtime of the code?. Because my code has a very high runtime.
I appreciate your kind help in advance,
carnum = data{1,1};
AccelerationY = data{1,2};
coordinationx = data{1,3};
coordinationy = data{1,4};
velocity = data{1,5};
parfor j=1:car
x{j}=[];
y{j}=[];
speed{j}=[];
AccX{j}=[];
AccY{j}=[];
z_gyro{j}=[];
f=find(carnum == j);
for a=f
x{j} = [x{j},coordinationx(a,1)]; %#here for coordinationx
y{j} = [y{j},coordinationy(a,1)]; %#here for coordinationy
AccY{j} = [AccY{j},AccelerationY(a,1)]; %#here for AccelerationY
rr= velocity(a,1)/3.6; %#here for Velocity
speed{j} =[speed{j},rr];
end
end
0 件のコメント
採用された回答
Walter Roberson
2019 年 10 月 18 日
In that code you cannot eliminate the broadcast variables.
If the arrays are large then there could potentially be a fair overhead in copying them into each worker.
You can, however, rewrite the entire code without parfor, by using a series of accumarray() or splitapply() calls, or you could switch to table representation and use table operations.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Other Formats についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!