Open jabraham17 opened 2 months ago
@jabraham17 : Is the concept here to warn whenever a loop zip iterates over distributed and non-distributed things where the non-distributed thing is the leader?
Yes
It sounds reasonable to me. It's not the biggest issue IMO for a warning but I think it's reasonable to ask if there is a way for a user to indicate they really meant to do this thing.
This is related in concept to PR #10791 / issue #5657.
In Chapel its possible to think you are writing a distributed parallel loop but end up creating something that runs locally. The following code sample demonstrates this:
Because
d
is not distributed, theforall
is not going to result in distributed execution. This is because the data-parallelforall
loop is driver by the leader iterator ofd
, which is a local domain. This results in a ton of extra communication because in most iterations of the loopelm
is remote and the assignmentelm = i
results in a PUT. There are several ways to avoid this, two simple ones are to changezip(d, A)
tozip(A.domain, A)
or to changeforall (i, elm) in zip(d, A)
toforall (elm, i) in zip(A, d)
.While this is expected Chapel behavior, I think a compiler/linter/static analyzer warning for this case would be good, warning users when a data-parallel loop over a distributed object is not going to result in distributed execution. This would give users an early warning that they may have poor performance due to the extra communication.