chapel
chapel copied to clipboard
Feature request : simplifying intents in forall loops (and friends)
I often find myself doing multiple reductions of the same type in forall loops (eg. multiple accumulators). The way I currently do this is to specify separate reduce intents (as in the commented line in the code below....)
(+ reduce sum1, + reduce sum2)
While this works fine, it would be nice to write this as
(+ reduce sum1,sum2)
or something like that (with a different delimiter, for instance). This could be extended to all intents (suggested by @nspark), instead of just reduce intents.
@bradcray suggested using tuples for this
(in (x,y), + reduce (sum1, sum2))
I'll note that OpenMP allows specifying such common reductions over a list of variables.
This was discussed in chapel-users here.
A possible future ---
var sum1, sum2 = 0;
config const N=100000;
forall ii in 1..N with (+ reduce (sum1,sum2)) {
sum1 += ii;
sum2 += ii*ii;
}
writeln(sum1);
writeln(sum2);