Communication lower bounds and optimal algorithms for programs that reference arrays - Part 1

Michael Christ, James Demmel, Nicholas Knight, Thomas Scanlon, Katherine A. YelickarXiv 2013

Abstract

Data movement (communication) between memory levels or processors is the primary bottleneck in modern computing, often exceeding the costs of arithmetic operations in terms of both time and energy. This paper introduces a generalized mathematical framework based on Hölder-Brascamp-Lieb (HBL) theory to calculate the absolute minimum data movement required for any algorithm characterized by nested loops and affine array accesses. The framework not only establishes theoretical communication lower bounds but also provides a methodology for deriving optimal loop tiling strategies to achieve these limits.

Introduction

In algorithm design, costs are divided into computation (arithmetic) and communication (data movement). As hardware evolves, communication costs are increasing significantly faster than computation costs, making data-movement optimization critical. While communication lower bounds were previously established for specific algorithms like matrix multiplication using the Loomis-Whitney inequality, these methods were not easily generalized. This research addresses the need for a universal communication lower bound for a broader class of programs—specifically those with nested loops where array indices are affine combinations of loop variables (e.g., $A[i, j]$, $B[i+2j, k-1]$).

Methods

The authors bridge theoretical mathematics and compiler optimization through several key techniques:

  1. Geometric Modeling of Execution: Nested loop execution is modeled as a multi-dimensional grid of points within an integer lattice ($\mathbb{Z}^d$). Each array access is represented as a homomorphism mapping a point in the loop iteration space to a specific memory address.
Geometric representation of loop iterations and array accesses as projections onto faces of a lattice cube.
  1. Hölder-Brascamp-Lieb (HBL) Theory: To determine the maximum work possible with a fixed cache size ($M$), the authors employ HBL inequalities. This generalization of the Loomis-Whitney inequality bounds the "volume" of loop iterations executable given the "area" of array projections available in fast memory.
  2. Linear Programming: Array access patterns are translated into linear constraints. Solving this linear program yields a critical exponent, $s_{HBL}$. The maximum number of loop iterations performable with $M$ words of cache is bounded by $O(M^{s_{HBL}})$.
  3. Execution Model: By partitioning program execution into segments fitting into fast memory, the $s_{HBL}$ exponent is used to prove a universal communication lower bound of $\Omega(|Z| / M^{s_{HBL}-1})$, where $|Z|$ represents the total loop iterations.

Key Insights

  • Algebraic Structure and Communication: Minimum data movement is fundamentally dictated by the algebraic structure of array subscripts, not just hardware characteristics.
  • The $s_{HBL}$ Exponent: This exponent, calculated from array indices, determines data reuse potential. If $s_{HBL} = 1$, no asymptotic reuse is possible (e.g., Matrix-Vector multiplication). If $s_{HBL} > 1$, loop tiling can be used to save bandwidth.
  • Duality in Algorithm Design: For algorithms where array indices are subsets of loop variables, the dual of the linear program used for the lower bound directly provides the optimal tile sizes.
  • Decidability and Hilbert's Tenth Problem: While computing general constraints is equivalent to Hilbert's Tenth Problem over rationals, the authors prove that finding the actual lower bound remains a decidable problem.

Key Results

The framework establishes a universal bound of $\Omega(|Z| / M^{s_{HBL}-1})$ applicable to both sequential and parallel architectures. The authors proved the decidability of computing this bound (Theorem 5.1) and successfully derived optimal algorithms for:

  • Matrix-Vector Multiplication: $\Omega(N^2)$ bound (no reuse).
  • N-Body Simulations & Database Joins: $\Omega(N^2/M)$ bound and the corresponding 2D tiling strategy.
  • Matrix Multiplication: Recovered the classic $\Omega(N^3/M^{1/2})$ bound and 3D block sizes.
  • Tensor Contractions: Generalized the matrix multiplication bounds to arbitrary dimensions.

Limitations and Future Work

The current model assumes loop iterations can be executed in any order, potentially ignoring data dependencies that might make the theoretical bound unattainable. Additionally, the general algorithm for computing the lower bound is computationally inefficient. Future work (Part 2) aims to address these by incorporating inter-iteration dependencies, improving linear program efficiency, and refining constant factors for practical compiler application.

Summary updated

BibTeX
@misc{christ2013communication,
  author = {Michael Christ and James Demmel and Nicholas Knight and Thomas Scanlon and Katherine A. Yelick},
  title = {{Communication lower bounds and optimal algorithms for programs that reference arrays - Part 1}},
  year = {2013},
  url = {https://openreview.net/forum?id=bqvrntnXFG},
}
Figure