Flattening transformation

It was pioneered by Guy Blelloch as part of the NESL programming language.

The original flattening algorithm was concerned solely with first-order multidimensional arrays containing primitive types, but was extended to handle higher-order and recursive data types in the work on Data Parallel Haskell.

[2] Flattening works by lifting functions to operate on arrays instead of on single values.

This flag vector is necessary in order to correctly flatten nested parallelism.

For example, it is used in the flattening of prefix sum to segmented scan.

Flattening can increase the asymptotic work and space complexity of the original program, leading to a much less efficient result.

[3] Flattening was originally developed for vector machines such as the Connection Machine, and often produces code that is not a good fit for modern multicore CPUs.

[4] However, the principles underlying its simpler cases can be found in constructs such as the vmap in Google Jax.