20535, "vasslitvinov", "+ reduction on records: just use '+=' if available", "2022-08-26T21:31:54Z"
Consider the standard plus reduction over a user-defined record:
record R { } var r: R; forall ... with (+ reduce r) {...} writeln(r);
Our plus reduction implementation, i.e., class SumReduceScanOp
in ChapelReduce.chpl, uses:
- operator
+
to determine the accumulation type of the reduction - operator
+=
to actually perform accumulation
This issue proposes to ignore the operator +
, even allow its absence, if operator +=(R,R)
is defined. If so, the accumulation type would be R
and only +=
would be invoked at run time.
To implement this proposal, I suggest simply augmenting chpl_sumTypeIsSame()
in ChapelReduce.chpl to check availability of +=(R,R)
and return true if it is available.