chapel
chapel copied to clipboard
[Feature Request]: Warning when a data-parallel loop over something distributed is not distributed
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:
use BlockDist;
use CommDiagnostics;
var d = {1..100};
var A = blockDist.createArray(d, int);
startVerboseComm();
forall (i, elm) in zip(d, A) {
elm = i;
}
stopVerboseComm();
Because d
is not distributed, the forall
is not going to result in distributed execution. This is because the data-parallel forall
loop is driver by the leader iterator of d
, which is a local domain. This results in a ton of extra communication because in most iterations of the loop elm
is remote and the assignment elm = i
results in a PUT. There are several ways to avoid this, two simple ones are to change zip(d, A)
to zip(A.domain, A)
or to change forall (i, elm) in zip(d, A)
to forall (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.