New Issue: Support scan'ing into an existing array

20205, "ronawho", "Support scan'ing into an existing array", "2022-07-13T11:28:53Z"

Currently, chapel scans always create a new array. Even when storing the result into an existing array, this results in new array creation followed by an assignment into the existing array. e.g.:

var outputArray: [inputArray.domain] inputArray.eltType = 0;
outputArray = + scan inputArray;

Will result in creating a temporary array from the + scan and then assigning that into outputArray. For use-cases (like a few in Arkouda) where you could reuse an existing array this wastes time allocating, faulting-in, and potentially registering a new array.

Here I'm wondering if we could support scan'ing into an existing array through a language or library extension or with a compiler optimization. For the compiler optimization I'm wondering if we can detect the patten and just have the scan use the output array, but it's not really clear to me how this would work.

It's also not really clear to me what language level support would look like. For a library you could imagine passing in the result array to a function. Maybe something like proc exclusiveScan(operator, inputIterable, outputIterable).