[Chapel Merge] Parallelize scan expressions using array temp

Branch: refs/heads/main
Revision: 147a3bbd28786c17de25ad4a76cdb666477416fc
Author: bradcray
Link: Parallelize scan expressions using array temp by bradcray · Pull Request #28928 · chapel-lang/chapel · GitHub
Log Message:
Parallelize scan expressions using array temp (#28928)

[reviewed by @DanilaFe]

This parallelizes scans of expressions that are not simply arrays,
such as promotions and loop expressions. It takes the simple approach of
capturing the expression into an array and then computing a scan on that
array. This has the downside of an extra array's worth of storage, but
the upside of simplicity and turning a currently sequential operation
into a parallel one.

In addition to the code itself, which is reasonably straightforward,
I've updated tests that were generating serialization warnings before,
but are no longer, and added a few tests capturing patterns from #12707.

In implementing this, I found that for expressions can't be invoked by
square bracket expressions, so opened #28929 to capture the issue and
filed a pair of tests here—one demonstrating the problem and the second
checking that forall and square bracket loops work.

I've opened #28930 to capture the potential future work of optimizing
this array temp away.

Resolves #12707

Compare: Comparing 9af754d898c8c76deb7834c9e3d93bc4b9465938...219f295072f8b11fde81508107d55d92626bee67 · chapel-lang/chapel · GitHub

Diff:
M modules/internal/ChapelReduce.chpl
A test/expressions/loop-expr/forExprInvokedWithSquareBrackets.bad
A test/expressions/loop-expr/forExprInvokedWithSquareBrackets.chpl
A test/expressions/loop-expr/forExprInvokedWithSquareBrackets.future
A test/expressions/loop-expr/forExprInvokedWithSquareBrackets.good
A test/expressions/loop-expr/forallExprsInvokedWithSquareBrackets.chpl
A test/expressions/loop-expr/forallExprsInvokedWithSquareBrackets.compopts
A test/expressions/loop-expr/forallExprsInvokedWithSquareBrackets.good
M test/reductions/diten/scan_name_collision.good
A test/scan/scanJagged.chpl
A test/scan/scanJagged.good
A test/scan/scanPromotedCast.chpl
A test/scan/scanPromotedCast.good
M test/unstable/unstableScans.good
https://github.com/chapel-lang/chapel/pull/28928.diff