The flattening transformation is an
algorithm
In mathematics and computer science, an algorithm () is a finite sequence of rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for performing ...
that transforms nested
data parallelism
Data parallelism is parallelization across multiple processors in parallel computing environments. It focuses on distributing the data across different nodes, which operate on the data in parallel. It can be applied on regular data structures lik ...
into flat data parallelism. It was pioneered by Guy Blelloch as part of the
NESL
NESL is a parallel programming language developed at Carnegie Mellon by the SCandAL project and released in 1993. It integrates various ideas from parallel algorithms, functional programming, and array programming languages.
The most important ne ...
programming language. The flattening transformation is also sometimes called vectorization, but is completely unrelated to
automatic vectorization
Automatic vectorization, in parallel computing, is a special case of automatic parallelization, where a computer program is converted from a scalar implementation, which processes a single pair of operands at a time, to a vector implementation, w ...
. 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.
Overview
Flattening works by ''lifting'' functions to operate on arrays instead of on single values. For example, a function
is lifted to a function