tall array within a parfor?
7 views (last 30 days)
Consider the following scenario:
ds = datastore(...);
dst = tall(ds);
% warning here: dst is a broadcast variable. This might result in unnecessary communication overhead.
chunk = gather(dst(:, idx));
Given the fact that dst is a tall array, why MATLAB warns about overhead? In fact, due to the lazy nature of tall arrays, above parfor is quite memory friendly.
So, what's the reason of the warning in case of tall arrays (pleast note I'm aware of communication overhead issue in case of other data types)?
Matt J on 6 Apr 2022
Edited: Matt J on 6 Apr 2022
You've generated idx in a way that doesn't have a simple dependence on the loop variable. This warning is not present if you are simply parfor-looping over the columns.
chunk = gather( dst(:, i) );
Because of whatever you're doing, the variable is not sliced. Because it is not sliced, you may have overhead due to two or more parpool workers trying to access the same memory at the same time. If you had been writing into the tall array, you would have to be even more careful. Parallel write operations into the same memory location can have unpredictable effects.