Algorithm Search⌘K

Loop transformations

Problems

  • Dependence testing

    Decide whether two array references in a loop nest can touch the same element, an integer programming problem over the iteration space.

    core
  • Induction variable analysis

    Find the variables of a loop that change by a fixed amount each iteration, or are affine in such variables.

    core
  • Affine scheduling

    Find affine functions that map each statement instance to a time point and respect every dependence, to expose parallelism.

    advanced

Algorithms

  • Allen-Kennedy vectorization algorithm

    Distributes a loop nest by the strongly connected components of its dependence graph, level by level, and turns each statement that is on no cycle into a vector statement.

    O(n (r + e)) worst1 languagescore
  • Banerjee test

    Reports independence when the constant of a subscript equation lies outside the real bounds of the equation over the loop bounds.

    O(m k) worst1 languagescore
  • GCD test

    Reports independence when the gcd of the coefficients of a linear subscript equation does not divide its constant term.

    O(m k log C) worst1 languagescore
  • Array dataflow analysis

    Finds for each read of an array element the exact iteration that last wrote it, by parametric integer programming.

    O(s d (P + L)) worst1 languagesadvanced
  • Feautrier scheduling algorithm

    Finds affine schedules with the affine form of Farkas' lemma and linear programming, satisfying as many dependences as possible per dimension.

    O(e L) worst1 languagesadvanced
  • Lamport hyperplane method

    Finds a linear time function such that all iterations on one hyperplane can run in parallel, for loops with uniform dependences.

    O(D k + N k) worst1 languagesadvanced
  • Subscript-wise dependence tests

    Classifies subscript pairs by the number of loop indices they use and applies an exact test to each class, joining results by the delta test.

    O(m^2 k + m log C + 3^k m k) worst1 languagesadvanced
  • Superword-level parallelism vectorization

    Packs isomorphic independent statements of a basic block into SIMD instructions, starting from adjacent memory accesses.

    O(n^3) worst1 languagesadvanced
  • Wolf-Lam locality optimization

    Models temporal and spatial reuse as vector spaces and picks unimodular transformations and tiling that keep the reuse in the innermost loops.

    O(4^k k! k D + 2^k k^3 A^2) worst1 languagesadvanced
  • Pluto algorithm

    Finds affine transformations that allow tiling and parallelism by minimizing a bound on dependence distances with integer linear programming.

    O((s d + e) I) worst1 languagesresearch
  • Polyhedral scanning

    Generates loop nests that visit the integer points of a union of polyhedra in schedule order, by separating and projecting the polyhedra.

    O(s m P^(n+1) L) worst1 languagesresearch

Techniques

  • Loop unrolling

    Replicates the body of a loop k times and divides the trip count by k, which cuts branch overhead and exposes instruction parallelism.

    intro
  • Loop distribution

    Splits a loop into several loops over the same range, each with part of the body, by the strongly connected components of dependences.

    core
  • Loop fusion

    Merges adjacent loops with the same bounds into one loop, which improves reuse of data and lowers loop overhead.

    core
  • Loop interchange

    Swaps two loops of a nest, which can make memory access contiguous or move a parallel loop outward, when dependences allow.

    core
  • Loop tiling

    Splits the iteration space of a nest into blocks that fit in cache and runs each block fully, for data reuse and parallelism.

    core
  • Strip mining

    Splits one loop into an outer loop over strips and an inner loop over a fixed number of iterations, as for vector registers.

    core
  • Vectorization

    Turns loops or statement groups into SIMD instructions that process several data elements at once, when dependences allow.

    core
  • Array privatization

    Gives each iteration or thread its own copy of a scratch array written before read in each iteration, removing false dependences.

    advanced
  • Chains of recurrences

    Represents the values of an induction variable over iterations as a chain of add or multiply recurrences, closed under arithmetic.

    advanced
  • DOACROSS parallelization

    Runs the iterations of a loop with carried dependences in parallel, and delays each sink with post and wait until its source in an earlier iteration is done.

    advanced
  • Loop skewing

    Adds a multiple of an outer index to an inner one, so that dependences point forward in both loops and tiling or interchange becomes legal.

    advanced
  • Unimodular loop transformations

    Models interchange, reversal and skewing as integer matrices of determinant plus or minus 1 on the iteration space, composed by product.

    advanced

Definitions

  • DOALL loop

    A loop that carries no data dependence at its own level, so its iterations may run in any order or in parallel with the same result.

    core
  • Data dependence

    Two accesses to the same location, at least one a write, whose order must be kept; flow, anti and output by which access writes.

    core
  • Dependence direction vector

    The signs of the components of the distance vectors of a dependence, written with less, equal and greater, when exact distances are unknown.

    core
  • Dependence distance vector

    The difference between the iteration vectors of the sink and the source of a dependence in a loop nest.

    core
  • Loop-carried dependence

    A dependence between different iterations of a loop, carried by the outermost loop whose distance component is not zero.

    core

Theorems

  • Legality of loop reordering

    A reordering of loop iterations keeps the meaning if every dependence distance vector remains lexicographically positive after it.

    core

Models

  • Polyhedral model

    Represents a loop nest with affine bounds and accesses as integer points in polyhedra, with affine schedules and access functions.

    advanced