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

Michael Christ, James Demmel, Nicholas Knight, Thomas Scanlon, Katherine Yelick

Introduction

Algorithms have two costs: computation (e.g., arithmetic) and communication, i.e., moving data between levels of a memory hierarchy or between processors over a network. Communication costs (measured in time or energy per operation) already greatly exceed computation costs, and the gap is growing over time following technological trends [FOSC, ComputerPerformanceNRC]. Thus it is important to design algorithms that minimize communication, and if possible attain communication lower bounds. In this work, we measure communication cost in terms of the number of words moved (a bandwidth cost), and will not discuss other factors like per-message latency, congestion, or costs associated with noncontiguous data. Our goal here is to establish new lower bounds on the communication cost of a much broader class of algorithms than possible before, and when possible describe how to attain these lower bounds.

Communication lower bounds have been a subject of research for a long time. Hong and Kung [hongkung] used an approach called pebbling to establish lower bounds for Θ(N3)\Theta(N^{3}) matrix multiplication and other algorithms. Irony, Tiskin and Toledo [ITT04] proved the result for Θ(N3)\Theta(N^{3}) matrix multiplication in a different, geometric way, and extended the results both to the parallel case and the case of using redundant copies of the data. In [BallardDemmelHoltzSchwartz11] this geometric approach was further generalized to include any algorithm that “geometrically resembled” matrix multiplication in a sense to be made clear later, but included most direct linear algebra algorithms (dense or sparse, sequential or parallel), and some graph algorithms as well. Of course lower bounds alone are not algorithms, so a great deal of additional work has gone into developing algorithms that attain these lower bounds, resulting in many faster algorithms as well as remaining open problems (we discuss attainability in Section LABEL:sec:attain).

Our geometric approach, following [ITT04, BallardDemmelHoltzSchwartz11], works as follows. We have a set Z\mathcal{Z} of arithmetic operations to perform, and the amount of data available locally, i.e., without any communication, is MM words. For example, MM could be the cache size. Suppose we can upper bound the number of (useful) arithmetic operations that we can perform with just this data; call this bound FF. Letting ∣⋅∣|\cdot| denote the cardinality of a set, if the total number of arithmetic operations that we need to perform is ∣Z∣|\mathcal{Z}| (e.g., ∣Z∣=N3|\mathcal{Z}|=N^{3} multiply-adds in the case of dense matrix multiplication on one processor), then we need to refill the cache at least ∣Z∣/F|\mathcal{Z}|/F times in order to perform all the operations. Since refilling the cache has a communication cost of moving O(M)O(M) words (e.g., writing at most MM words from cache back to slow memory, and reading at most MM new words into cache from slow memory), the total communication cost is Ω(M⋅∣Z∣/F)\Omega(M\cdot|\mathcal{Z}|/F) words moved. This argument is formalized in Section 4.

The most challenging part of this argument is determining FF. Our approach, described in more detail in Sections 2–3, builds on the work in [ITT04, BallardDemmelHoltzSchwartz11]; in those papers, the algorithm is modeled geometrically using the iteration space of the loop nest, as sketched in the following example.

Our approach is based on a major generalization of [LW49] in [BCCT10] that lets us geometrically model a much larger class of algorithms with an arbitrary number of loops and array expressions involving affine functions of indices.

formalizes the argument that an upper bound on FF yields a lower bound on communication of the form Ω(M⋅∣Z∣/F)\Omega(M\cdot|\mathcal{Z}|/F). Some technical assumptions are required for this to work. Using the same approach as in [BallardDemmelHoltzSchwartz11], we need to eliminate the possibility that an algorithm could do an unbounded amount of work on a fixed amount of data without requiring any communication. We also describe how the bound applies to communication in a variety of computer architectures (sequential, parallel, heterogeneous, etc.).

summarizes our results, and outlines the contents of Part 2 of this paper. Part 2 will discuss how to compute lower bounds more efficiently and will include more cases where optimal algorithms are possible, including a discussion of loop dependencies.

This completes the outline of the paper. We note that it is possible to omit the detailed proofs in Sections 3 and 5 on a first reading; the rest of the paper is self-contained.

To conclude this introduction, we apply our theory to two examples (revisited later), and show how to derive communication-optimal sequential algorithms.

yielding the well-known blocked algorithm where the innermost three loops multiply M1/2M^{1/2}–by–M1/2M^{1/2} blocks of AA and BB and update a block of CC. We note that to have all three blocks fit in fast memory simultaneously, they would have to be slightly smaller than M1/2M^{1/2}–by–M1/2M^{1/2} by a constant factor. We will address this constant factor and others, which are important in practice, in Part 2 of this work (see Section LABEL:sec:conclusions). △\triangle

Other examples appearing later include matrix-vector multiplication, tensor contractions, the direct NN–body algorithm, database join, and computing matrix powers AkA^{k}.

Geometric Model

We begin by reviewing the geometric model of matrix multiplication introduced in [ITT04], describe how it was extended to more general linear algebra algorithms in [BallardDemmelHoltzSchwartz11], and finally show how to generalize it to the class of programs considered in this work.

We want a bound F≥∣E∣F\geq|E|, where E⊆ZE\subseteq\mathcal{Z} is any set of lattice points I\mathcal{I} representing operations that can be performed just using data available in fast memory of size MM. Let EAE_{A}, EBE_{B} and ECE_{C} be projections of EE onto faces of the cube representing all the required operands A(i1,i3)A(i_{1},i_{3}), B(i3,i2)B(i_{3},i_{2}) and C(i1,i2)C(i_{1},i_{2}), resp., needed to perform the operations represented by EE. A special case of [LW49, Theorem 2] gives us the desired bound on EE:

Finally, since the entries represented by EA,EB,ECE_{A},\allowbreak E_{B},\allowbreak E_{C} fit in fast memory by assumption (i.e., ∣EA∣,∣EB∣,∣EC∣≤M|E_{A}|,\allowbreak|E_{B}|,\allowbreak|E_{C}|\leq M), this yields the desired bound F≥∣E∣F\geq|E|:

Irony et al. [ITT04] applied this approach to obtain a lower bound for matrix multiplication. Ballard et al. [BallardDemmelHoltzSchwartz11] extended this approach to programs of the form

and picked the iteration space Z\mathcal{Z}, arrays A,B,CA,B,C, and binary operations +i1,i2+_{i_{1},i_{2}} and ∗i1,i2,i3\ast_{i_{1},i_{2},i_{3}} to represent many (dense or sparse) linear algebra algorithms. To make this generalization, Ballard et al. made several observations, which also apply to our case, below.

An instance of the geometric model is an abstract representation of an algorithm, taking the form

(We will be more concrete about what it means to ‘access a variable’ when we introduce our execution model in Section 4.)

Assuming that all variables are accessed in each iteration rules out certain optimizations, or requires us not to count certain inner loop iterations in our lower bound. For example, consider Boolean matrix multiplication, where the inner loop body is C(i1,i2)=C(i1,i2)∨(A(i1,i3)∧B(i3,i2))C(i_{1},i_{2})=C(i_{1},i_{2})\vee(A(i_{1},i_{3})\wedge B(i_{3},i_{2})). As long as A(i1,i3)∧B(i3,i2)A(i_{1},i_{3})\wedge B(i_{3},i_{2}) is false, C(i1,i2)C(i_{1},i_{2}) does not need to be accessed. So we need either to exclude such optimizations, or not count such loop iterations. And once C(i1,i2)C(i_{1},i_{2}) is true, its value cannot change, and no more values of A(i1,i3)A(i_{1},i_{3}) and B(i3,i2)B(i_{3},i_{2}) need to be accessed; if this optimization is performed, then these loop iterations would not occur and not be counted in the lower bound. In general, if there are data-dependent branches in the inner loop (e.g., ‘flip a coin…’), we may not know to which subset Z\mathcal{Z} of all the loop iterations our model applies until the code has executed. We refer to a later example (database join) and [BallardDemmelHoltzSchwartz11, Section 3.2.1] for more examples and discussion of this assumption.

Following the approach for matrix multiplication, we need to bound ∣E∣|E| where EE is a nonempty finite subset of Z\mathcal{Z}. To execute EE, we need array entries A1(ϕ1(E)),…,Am(ϕm(E))A_{1}(\phi_{1}(E)),\ldots,\allowbreak A_{m}(\phi_{m}(E)). Analogous to the analysis of matrix multiplication, we need to bound ∣E∣|E| in terms of the number of array entries needed: ∣ϕj(E)∣|\phi_{j}(E)| entries of AjA_{j}, for j={1,…,m}j=\{{1,\ldots,m}\}.

Suppose there were nonnegative constants s1,…,sms_{1},\ldots,s_{m} such that for any such EE,

i.e., a generalization of Theorem 2.1. Then just as with matrix multiplication, if the number of entries of each array were bounded by ∣ϕj(E)∣≤M|\phi_{j}(E)|\leq M, we could bound

The next section shows how to determine the constants s1,…,sms_{1},\ldots,s_{m} such that inequality (2.3) holds. To give some rough intuition for the result, consider again the special case of Theorem 2.1, where ∣E∣|E| can be interpreted as a volume, and each ∣ϕj(E)∣|\phi_{j}(E)| as an area. Thus one can think of ∣E∣|E| as having units of, say, meters3{\rm meters}^{3}, and ∣ϕj(E)∣|\phi_{j}(E)| as having units of meters2{\rm meters}^{2}. Thus, for ∏j=13∣ϕj(E)∣sj\prod_{j=1}^{3}|\phi_{j}(E)|^{s_{j}} to have units of meters3{\rm meters}^{3}, we would expect the sjs_{j} to satisfy 3=2s1+2s2+2s33=2s_{1}+2s_{2}+2s_{3}. But if EE were a lower dimensional subset, lying say in a plane, then ∣E∣|E| would have units meters2{\rm meters}^{2} and we would get a different constraint on the sjs_{j}. This intuition is formalized in Theorem 3.2 below.

Upper bounds from HBL theory

As discussed above, we aim to establish an upper bound of the form (2.3) for ∣E∣|E|, for any finite set EE of loop iterations. In this section we formulate and prove Theorem 3.2, which states that such a bound is valid if and only if the exponents s1,…,sms_{1},\ldots,s_{m} satisfy a certain finite set of linear constraints, specified in (3.1) below.

The following theorem provides bounds which are fundamental to our application.

Conversely, if (3.2) holds for s∈ms\in^{m}, then ss satisfies (3.1).

Note that if s∈[0,∞)ms\in[0,\infty)^{m} satisfies (3.1) or (3.2), then any t∈[0,∞)mt\in[0,\infty)^{m} where each tj≥sjt_{j}\geq s_{j} does too. This is obvious for (3.1); in the case of (3.2), since EE is nonempty and finite, then for each jj, 1≤∣ϕj(E)∣<∞1\leq|\phi_{j}(E)|<\infty, so ∣ϕj(E)∣sj≤∣ϕj(E)∣tj|\phi_{j}(E)|^{s_{j}}\leq|\phi_{j}(E)|^{t_{j}}.

The following result demonstrates there is no loss of generality restricting s∈ms\in^{m}, rather than in [0,∞)m[0,\infty)^{m}, in Theorem 3.2.

Whenever (3.1) or (3.2) holds for some s∈[0,∞)ms\in[0,\infty)^{m}, it holds for t∈mt\in^{m} where tj=min⁡(sj,1)t_{j}=\min(s_{j},1) for j∈{1,…,m}j\in\{{1,\ldots,m}\}.

2 Generalizations

We will use the terminology HBL datum to refer to either of two types of structures; the first is defined as follows:

An Abelian group HBL datum is a 33–tuple

where GG and each GjG_{j} are finitely generated Abelian groups, GG is torsion-free, each ϕj ⁣:G→Gj\phi_{j}\colon G\to G_{j} is a group homomorphism, and the notation on the left-hand side always implies that j∈{1,2,…,m}j\in\{{1,2,\ldots,m}\}.

Consider an Abelian group HBL datum (G,(Gj),(ϕj))({G,({G_{j}}),({\phi_{j}})}) and s∈ms\in^{m}. Suppose that

Conversely, if (3.5) holds for s∈ms\in^{m}, then ss satisfies (3.8).

[BCCT10, Theorem 2.4] treats the more general situation in which GG is not required to be torsion-free, and establishes the conclusion (3.4) in the weaker form

where the constant C<∞C<\infty depends only on GG and {ϕ1,…,ϕm}\{{\phi_{1},\ldots,\phi_{m}}\}. The constant C=1C=1 established here is optimal. Indeed, consider any single x∈Gx\in G, and for each jj define fjf_{j} to be 1ϕj(x)1_{\phi_{j}(x)}, the indicator function for ϕj(x)\phi_{j}(x). Then both sides of the inequalities in (3.4) are equal to 11. In Remark 3.11, we will show that the constant CC is bounded above by the number of torsion elements of GG.

Necessity of (3.3) follows from an argument given in [BCCT10, Theorem 2.4].

On the other hand, for j∈{1,…,m}j\in\{{1,\ldots,m}\},

where AjA_{j} is a finite constant which depends on ϕj\phi_{j}, on the structure of HjH_{j}, and on the choice of {ei}\{{e_{i}}\}, but not on NN. Indeed, it follows from the definition of rank that for each jj it is possible to permute the indices ii so that for each i>rank⁡(ϕj(H))i>\operatorname{rank}({\phi_{j}(H)}) there exist integers kik_{i} and κi,l\kappa_{i,l} such that

The upper bound (3.7) follows from these relations.

where A<∞A<\infty is independent of NN. By letting NN tend to infinity, we conclude that rank⁡(H)≤∑j=1msjrank⁡(ϕj(H))\operatorname{rank}({H})\leq{\sum_{j=1}^{m}s_{j}\operatorname{rank}({\phi_{j}(H)})}, as was to be shown. ∎

We show sufficiency in Theorem 3.6 in its full generality is a consequence of the special case in which all of the groups GjG_{j} are torsion-free.

We are assuming validity of Theorem 3.6 in the torsion-free case. Its conclusion asserts that

Combining these inequalities gives the conclusion of Theorem 3.6. ∎

Our second generalization of Theorem 3.2 is as follows.

Consider a vector space HBL datum (V,(Vj),(ϕj))({V,({V_{j}}),({\phi_{j}})}) and s∈ms\in^{m}. Suppose that

Thus the conclusion (3.4) of Theorem 3.6 is satisfied. ∎

Consider (G,(Gj),(ϕj))({G,({G_{j}}),({\phi_{j}})}), an HBL datum with torsion, and s∈ms\in^{m}. If (3.3) holds, then (3.6) holds with C=∣T(G)∣C=|T(G)|. In particular,

Conversely, if (3.11) holds for s∈ms\in^{m}, then ss satisfies (3.3).

The first inequality is an application of Theorem 3.6. Summation with respect to t∈T(G)t\in T(G) gives the required bound.

The factor ∣T(G)∣|T(G)| cannot be improved if the groups GjG_{j} are torsion free, or more generally if T(G)T(G) is contained in the intersection of the kernels of all the homomorphisms ϕj\phi_{j}; this is seen by considering E=T(G)E=T(G).

3 The polytope 𝒫𝒫\mathcal{P}

The constraints (3.3) and (3.8) are encoded by convex polytopes in m^{m}.

For any Abelian group HBL datum (G,(Gj),(ϕj))({G,({G_{j}}),({\phi_{j}})}), we denote the set of all s∈ms\in^{m} which satisfy (3.3) by P(G,(Gj),(ϕj))\mathcal{P}({G,({G_{j}}),({\phi_{j}})}). For any vector space HBL datum (V,(Vj),(ϕj))({V,({V_{j}}),({\phi_{j}})}), we denote the set of all s∈ms\in^{m} which satisfy (3.8) by P(V,(Vj),(ϕj))\mathcal{P}({V,({V_{j}}),({\phi_{j}})}).

In the course of proving Theorem 3.6 above, we established the following result.

Now we prove Proposition 3.3, i.e., that there was no loss of generality in assuming each sj≤1s_{j}\leq 1.

Proposition 3.3 concerns the case of Theorem 3.2, but in the course of its proof we will show that this result also applies to Theorems 3.6 and 3.10.

We first show the result concerning (3.1), by considering instead the set of inequalities (3.8). Suppose that a vector space HBL datum (V,(Vj),(ϕj))({V,({V_{j}}),({\phi_{j}})}) and s∈[0,∞)ms\in[0,\infty)^{m} satisfy (3.8), and suppose that sk≥1s_{k}\geq 1 for some kk. Define t∈[0,∞)mt\in[0,\infty)^{m} by tj=sjt_{j}=s_{j} for j≠kj\neq k, and tk=1t_{k}=1. Pick any subspace W≤VW\leq V; let W′≔W∩ker⁡(ϕk)W^{\prime}\coloneqq W\cap\operatorname{ker}({\phi_{k}}) and let UU be a supplement of W′W^{\prime} in WW, i.e., W=U+W′W=U+W^{\prime} and dim⁡(W)=dim⁡(U)+dim⁡(W′)\operatorname{dim}({W})=\operatorname{dim}({U})+\operatorname{dim}({W^{\prime}}). Since dim⁡(ϕk(U))=dim⁡(U)\operatorname{dim}({\phi_{k}(U)})=\operatorname{dim}({U}),

since ss satisfies (3.8) and dim⁡(ϕk(W′))=0\operatorname{dim}({\phi_{k}(W^{\prime})})=0, by (3.8) applied to W′W^{\prime},

Next, we show the result concerning (3.2). Consider the following more general situation. Let X,X1,…,XmX,X_{1},\ldots,X_{m} be sets and ϕj ⁣:X→Xj\phi_{j}\colon X\to X_{j} be functions for j∈{1,…,m}j\in\{{1,\ldots,m}\}. Let s∈[0,∞)ms\in[0,\infty)^{m} with some sk≥1s_{k}\geq 1, and suppose that ∣E∣≤∏j=1m∣ϕj(E)∣sj|E|\leq\prod_{j=1}^{m}|\phi_{j}(E)|^{s_{j}} for any finite nonempty subset E⊆XE\subseteq X. Fix one such set EE. For each y∈ϕk(E)y\in\phi_{k}(E), let Ey=ϕk−1(y)∩EE_{y}=\phi_{k}^{-1}(y)\cap E, the preimage of yy under \phi_{k}\big{|}_{E}; thus ∣ϕk(Ey)∣=1|\phi_{k}(E_{y})|=1. By assumption, ∣Ey∣≤∏j=1m∣ϕj(Ey)∣sj|E_{y}|\leq\prod_{j=1}^{m}|\phi_{j}(E_{y})|^{s_{j}}, so it follows that

Since EE can be written as the union of disjoint sets ⋃y∈ϕk(E)Ey\bigcup_{y\in\phi_{k}(E)}E_{y}, we obtain

We claim that this result can be generalized to \eqrefBL\eqref{BL} and \eqrefBLfield\eqref{BLfield}, based on a comment in [BCCT10, Section 8] that it generalizes in the weaker case of (3.6). ∎

To prove Theorem 3.10, we show in Section 3.4 that if (3.9) holds at each extreme point ss of P\mathcal{P}, then it holds for all s∈Ps\in\mathcal{P}. Then in Section 3.5, we show that when ss is an extreme point of P\mathcal{P}, the hypothesis (3.8) can be restated in a special form. Finally in Section 3.7 we prove Theorem 3.10 (with restated hypothesis) when ss is any extreme point of P\mathcal{P}, thus proving the theorem for all s∈Ps\in\mathcal{P}.

4 Interpolation between extreme points of 𝒫𝒫\mathcal{P}

One multilinear extension of the Riesz-Thörin theorem states the following (see, e.g., [bennettsharpley]).

Suppose that p0=(pj,0),p1=(pj,1)∈[1,∞]mp_{0}=({p_{j,0}}),p_{1}=({p_{j,1}})\in[1,\infty]^{m}. Suppose that there exist A0,A1∈[0,∞)A_{0},A_{1}\in[0,\infty) such that

For each θ∈(0,1)\theta\in(0,1) define exponents pj,θp_{j,\theta} by

Here ∥fj∥p=∥fj∥Lp(Xj,Aj,μj)\|f_{j}\|_{p}=\|f_{j}\|_{L^{p}(X_{j},\mathcal{A}_{j},\mu_{j})}.

In the context of Theorem 3.10 with vector space HBL datum (V,(Vj),(ϕj))({V,({V_{j}}),({\phi_{j}})}), we consider the multilinear map

representing the left-hand side in (3.9).

If (3.9) holds for every extreme point of P\mathcal{P}, then it holds for every s∈Ps\in\mathcal{P}.

5 Critical subspaces and extreme points

Assume a fixed vector space HBL datum (V,(Vj),(ϕj))({V,({V_{j}}),({\phi_{j}})}), and let P\mathcal{P} continue to denote the set of all s∈ms\in^{m} which satisfy (3.8).

Consider any s∈ms\in^{m}. A subspace W≤VW\leq V satisfying dim⁡(W)=∑j=1msjdim⁡(ϕj(W))\operatorname{dim}({W})=\sum_{j=1}^{m}s_{j}\operatorname{dim}({\phi_{j}(W)}) is said to be a critical subspace; one satisfying dim⁡(W)≤∑j=1msjdim⁡(ϕj(W))\operatorname{dim}({W})\leq\sum_{j=1}^{m}s_{j}\operatorname{dim}({\phi_{j}(W)}) is said to be subcritical; and a subspace satisfying dim⁡(W)>∑j=1msjdim⁡(ϕj(W))\operatorname{dim}({W})>\sum_{j=1}^{m}s_{j}\operatorname{dim}({\phi_{j}(W)}) is said to be supercritical. WW is said to be strictly subcritical if dim⁡(W)<∑j=1msjdim⁡(ϕj(W))\operatorname{dim}({W})<\sum_{j=1}^{m}s_{j}\operatorname{dim}({\phi_{j}(W)}).

In this language, the conditions (3.8) assert that that every subspace WW of VV, including {0}\{{0}\} and VV itself, is subcritical; equivalently, there are no supercritical subspaces. When more than one mm–tuple ss is under discussion, we sometimes say that WW is critical, subcritical, supercritical or strictly subcritical with respect to ss.

The goal of Section 3.5 is to establish the following:

Let ss be an extreme point of P\mathcal{P}. Then some subspace {0}<W<V\{{0}\}<W<V is critical with respect to ss, or s∈{0,1}ms\in\{{0,1}\}^{m}.

Note that these two possibilities are not mutually exclusive.

If ss is an extreme point of P\mathcal{P}, and if ii is an index for which si∉{0,1}s_{i}\notin\{{0,1}\}, then dim⁡(ϕi(V))≠0\operatorname{dim}({\phi_{i}(V)})\neq 0.

Suppose dim⁡(ϕi(V))=0\operatorname{dim}({\phi_{i}(V)})=0. If t∈mt\in^{m} satisfies tj=sjt_{j}=s_{j} for all j≠ij\neq i, then ∑j=1mtjdim⁡(ϕj(W))=∑j=1msjdim⁡(ϕj(W))\sum_{j=1}^{m}t_{j}\operatorname{dim}({\phi_{j}(W)})=\sum_{j=1}^{m}s_{j}\operatorname{dim}({\phi_{j}(W)}) for all subspaces W≤VW\leq V, so t∈Pt\in\mathcal{P} as well. If si∉{0,1}s_{i}\notin\{{0,1}\}, then this contradicts the assumption that ss is an extreme point of P\mathcal{P}. ∎

Let ss be an extreme point of P\mathcal{P}. Suppose that no subspace {0}<W≤V\{{0}\}<W\leq V is critical with respect to ss. Then s∈{0,1}ms\in\{{0,1}\}^{m}.

Suppose to the contrary that for some index ii, si∉{0,1}s_{i}\notin\{{0,1}\}. If t∈mt\in^{m} satisfies tj=sjt_{j}=s_{j} for all j≠ij\neq i and if tit_{i} is sufficiently close to sis_{i}, then t∈Pt\in\mathcal{P}. This again contradicts the assumption that ss is an extreme point. ∎

Let ss be an extreme point of P\mathcal{P}. Suppose that there exists no subspace {0}<W<V\{{0}\}<W<V which is critical with respect to ss. Then there exists at most one index ii for which si∉{0,1}s_{i}\notin\{{0,1}\}.

Whenever ∣ε∣|\varepsilon| is sufficiently small, t∈mt\in^{m}. Moreover, VV remains subcritical with respect to tt. If ∣ε∣|\varepsilon| is sufficiently small, then every subspace {0}<W<V\{{0}\}<W<V remains strictly subcritical with respect to tt, because the set of all parameters (dim⁡(W),dim⁡(ϕ1(W)),…,dim⁡(ϕm(W)))({\operatorname{dim}({W}),\operatorname{dim}({\phi_{1}(W)}),\ldots,\operatorname{dim}({\phi_{m}(W)})}) which arise, is finite. Thus t∈Pt\in\mathcal{P} for all sufficiently small ∣ε∣|\varepsilon|. Therefore ss is not an extreme point of P\mathcal{P}. ∎

Let s∈ms\in^{m}. Suppose that VV is critical with respect to ss. Suppose that there exists exactly one index i∈{1,2,…,m}i\in\{{1,2,\ldots,m}\} for which si∉{0,1}s_{i}\notin\{{0,1}\}. Then VV has a subspace which is supercritical with respect to ss.

By Lemma 3.19, dim⁡(ϕi(V))>0\operatorname{dim}({\phi_{i}(V)})>0. Let KK be the set of all indices kk for which sk=1s_{k}=1. The hypothesis that VV is critical means that

Since si>0s_{i}>0 and dim⁡(ϕi(V))>0\operatorname{dim}({\phi_{i}(V)})>0,

Consider the subspace W≤VW\leq V defined by

this intersection is interpreted to be W=VW=V if the index set KK is empty. WW necessarily has positive dimension. Indeed, WW is the kernel of the map ψ ⁣:V→⨁k∈Kϕk(V)\psi\colon V\to\bigoplus_{k\in K}\phi_{k}(V), defined by ψ(x)=(ϕk(x):k∈K)\psi(x)=({\phi_{k}(x):k\in K}), where ⨁\bigoplus denotes the direct sum of vector spaces. The image of ψ\psi is isomorphic to some subspace of ⨁k∈Kϕk(V)\bigoplus_{k\in K}\phi_{k}(V), a vector space whose dimension ∑k∈Kdim⁡(ϕk(V))\sum_{k\in K}\operatorname{dim}({\phi_{k}(V)}) is strictly less than dim⁡(V)\operatorname{dim}({V}). Therefore ker⁡(ψ)=W\operatorname{ker}({\psi})=W has dimension greater than or equal to dim⁡(V)−∑k∈Kdim⁡(ϕk(V))>0\operatorname{dim}({V})-\sum_{k\in K}\operatorname{dim}({\phi_{k}(V)})>0. Since ϕk(W)={0}\phi_{k}(W)=\{{0}\} for all k∈Kk\in K,

Since si<1s_{i}<1 and dim⁡(W)>0\operatorname{dim}({W})>0, sidim⁡(ϕi(W))s_{i}\operatorname{dim}({\phi_{i}(W)}) is strictly less than dim⁡(W)\operatorname{dim}({W}), whence WW is supercritical. ∎

Suppose that there exists no critical subspace {0}<W<V\{{0}\}<W<V. By Lemma 3.20, either sj∈{0,1}ms_{j}\in\{{0,1}\}^{m} — in which case the proof is complete — or VV is critical. By Lemma 3.21, there can be at most one index ii for which si∉{0,1}s_{i}\notin\{{0,1}\}. By Lemma 3.22, for critical VV, the existence of one single such index ii implies the presence of some supercritical subspace, contradicting the main hypothesis of Proposition 3.18. Thus again, s∈{0,1}ms\in\{{0,1}\}^{m}. ∎

6 Factorization of HBL data

Let (V,(Vj),(ϕj))({V,({V_{j}}),({\phi_{j}})}) be a vector space HBL datum. To any subspace W≤VW\leq V can be associated two HBL data:

Given the vector space HBL datum (V,(Vj),(ϕj))({V,({V_{j}}),({\phi_{j}})}), for any subspace W≤VW\leq V,

Consider any subspace U≤VU\leq V and some s∈ms\in^{m} such that both s\in\mathcal{P}({W,({V_{j}}),({\phi_{j}\big{|}_{W}})}) and s∈P(V/W,(Vj/ϕj(W)),([ϕj]))s\in\mathcal{P}({V/W,({V_{j}/\phi_{j}(W)}),({[\phi_{j}]})}). Then

The last inequality is a consequence of the inclusions ϕj(U∩W)⊆ϕj(U)∩ϕj(W)\phi_{j}(U\cap W)\subseteq\phi_{j}(U)\cap\phi_{j}(W). The last equality is the relation dim⁡(A)+dim⁡(B)=dim⁡(A+B)+dim⁡(A∩B)\operatorname{dim}({A})+\operatorname{dim}({B})=\operatorname{dim}({A+B})+\operatorname{dim}({A\cap B}), which holds for any subspaces A,BA,B of a vector space. Thus UU is subcritical. ∎

Given the vector space HBL datum (V,(Vj),(ϕj))({V,({V_{j}}),({\phi_{j}})}), let s∈P(V,(Vj),(ϕj))s\in\mathcal{P}({V,({V_{j}}),({\phi_{j}})}). Let W≤VW\leq V be a subspace which is critical with respect to ss. Then

With Lemma 3.24 in hand, it remains to show that P(V,(Vj),(ϕj))\mathcal{P}({V,({V_{j}}),({\phi_{j}})}) is contained in the intersection of the other two polytopes.

Any subspace U≤WU\leq W is also a subspace of VV. UU is subcritical with respect to ss when regarded as a subspace of WW, if and only if UU is subcritical when regarded as a subspace of VV. So s\in\mathcal{P}({W,({V_{j}}),({\phi_{j}\big{|}_{W}})}).

Now consider any subspace of U/W≤W/VU/W\leq W/V; we have W≤U≤VW\leq U\leq V and dim⁡(U/W)=dim⁡(U)−dim⁡(W)\operatorname{dim}({U/W})=\operatorname{dim}({U})-\operatorname{dim}({W}). Moreover,

Therefore since dim⁡(W)=∑j=1msjdim⁡(ϕj(W))\operatorname{dim}({W})=\sum_{j=1}^{m}s_{j}\operatorname{dim}({\phi_{j}(W)}),

by the subcriticality of UU, which holds because s∈P(V,(Vj),(ϕj))s\in\mathcal{P}({V,({V_{j}}),({\phi_{j}})}). Thus any U/W≤V/WU/W\leq V/W is subcritical with respect to ss, so s∈P(V/W,(Vj/ϕj(W)),([ϕj]))s\in\mathcal{P}({V/W,({V_{j}/\phi_{j}(W)}),({[\phi_{j}]})}) as well. ∎

7 Proof of Theorem 3.10

Recall we are given the vector space HBL datum (V,(Vj),(ϕj))({V,({V_{j}}),({\phi_{j}})}); we prove Theorem 3.10 by induction on the dimension of the ambient vector space VV. If dim⁡(V)=0\operatorname{dim}({V})=0 then VV has a single element, and the result (3.9) is trivial.

To establish the inductive step, consider any extreme point ss of P\mathcal{P}. According to Proposition 3.18, there are two cases which must be analyzed. We begin with the case in which there exists a critical subspace {0}<W<V\{{0}\}<W<V, which we prove in the following lemma. We assume that Theorem 3.10 holds for all HBL data for which the ambient vector space has strictly smaller dimension than is the case for the given datum.

Let (V,(Vj),(ϕj))({V,({V_{j}}),({\phi_{j}})}) be a vector space HBL datum, and let s∈P(V,(Vj),(ϕj))s\in\mathcal{P}(V,({V_{j}}),({\phi_{j}})). Suppose that subspace {0}<W<V\{{0}\}<W<V is critical with respect to ss. Then (3.9) holds for this ss.

Consider any inequality in (3.9). We may assume that none of the exponents equal zero. For if sk=0s_{k}=0, then fk(ϕk(x))≤∥fk∥1/skf_{k}(\phi_{k}(x))\leq\|f_{k}\|_{1/s_{k}} for all xx, and therefore

If ∥fk∥1/sk=0\|f_{k}\|_{1/s_{k}}=0, then (3.9) holds with both sides . Otherwise we divide by ∥fk∥1/sk\|f_{k}\|_{1/s_{k}} to conclude that s∈P(V,(Vj),(ϕj))s\in\mathcal{P}({V,({V_{j}}),({\phi_{j}})}) if and only if (sj)j≠k({s_{j}})_{j\neq k} belongs to the polytope associated to the HBL datum (V,(Vj)j≠k,(ϕj)j≠k)({V,({V_{j}})_{j\neq k},({\phi_{j}})_{j\neq k}}). Thus the index kk can be eliminated. This reduction can be repeated to remove all indices which equal zero.

Let Wj≔ϕj(W)W_{j}\coloneqq\phi_{j}(W). By Lemma 3.25, s\in\mathcal{P}({W,({W_{j}}),({\phi_{j}\big{|}_{W}})}). Therefore by the inductive hypothesis, one of the inequalities in (3.9) is

Define Fj ⁣:Vj/Wj→[0,∞)F_{j}\colon V_{j}/W_{j}\to[0,\infty) to be the function

This quantity is a function of the coset x+Wjx+W_{j} alone, rather than of xx itself, because for any z∈Wjz\in W_{j},

by virtue of the substitution y+z↦yy+z\mapsto y. Moreover,

To prove this, choose one element x∈Vjx\in V_{j} for each coset x+Wj∈Vj/Wjx+W_{j}\in V_{j}/W_{j}. Denoting by XX the set of all these representatives,

because the map X×Wj∋(x,y)↦x+y∈VjX\times W_{j}\ni(x,y)\mapsto x+y\in V_{j} is a bijection.

The inductive bound (3.14) can be equivalently written in the more general form

for any y∈Vy\in V, by applying (3.14) to (f^j)({\hat{f}_{j}}) where f^j(z)=fj(z+ϕj(y))\hat{f}_{j}(z)=f_{j}(z+\phi_{j}(y)).

Denote by Y⊆VY\subseteq V a set of representatives of the cosets y+W∈V/Wy+W\in V/W, and identify V/WV/W with YY. Then

This is a set of inequalities of exactly the form (3.9), with (V,(Vj),(ϕj))({V,({V_{j}}),({\phi_{j}})}) replaced by (V/W,(Vj/Wj),([ϕj]))({V/W,({V_{j}/W_{j}}),({[\phi_{j}]})}). By Lemma 3.25, s∈P(V/W,(Vj/Wj),([ϕj]))s\in\mathcal{P}({V/W,({V_{j}/W_{j}}),({[\phi_{j}]})}), and since dim⁡(V/W)<dim⁡(V)\operatorname{dim}({V/W})<\operatorname{dim}({V}), we conclude directly from the inductive hypothesis that (3.17) holds, concluding the proof of Lemma 3.26. ∎

According to Proposition 3.18, in order to complete the proof of Theorem 3.10, it remains only to analyze the case where the extreme point s∈{0,1}ms\in\{{0,1}\}^{m}. Let K={k:sk=1}K=\{{k:s_{k}=1}\}. Consider W=⋂k∈Kker⁡(ϕk)W=\bigcap_{k\in K}\operatorname{ker}({\phi_{k}}). Since WW is subcritical by hypothesis,

so dim⁡(W)=0\operatorname{dim}({W})=0, that is, W={0}W=\{{0}\}. Therefore the map x↦(ϕk(x))k∈Kx\mapsto({\phi_{k}(x)})_{k\in K} from VV to the Cartesian product ∏k∈KVk\prod_{k\in K}V_{k} is injective.

since si=0s_{i}=0 for all i∉Ki\notin K. Thus it suffices to prove that

This is a special case of the following result.

Define Φ ⁣:V→∏k∈KVk\Phi\colon V\to\prod_{k\in K}V_{k} by Φ(x)=(ϕk(x))k∈K\Phi(x)=({\phi_{k}(x)})_{k\in K}. The hypothesis ⋂k∈Kker⁡(ϕk)={0}\bigcap_{k\in K}\operatorname{ker}({\phi_{k}})=\{{0}\} is equivalent to Φ\Phi being injective. The product ∏k∈K∥fk∥1\prod_{k\in K}\|f_{k}\|_{1} can be expanded as the sum of products

where the sum is taken over all y=(yk)k∈Ky=({y_{k}})_{k\in K} belonging to the Cartesian product ∏k∈KVk\prod_{k\in K}V_{k}. The quantity of interest,

is likewise a sum of such products. Each term of the latter sum appears as a term of the former sum, and by virtue of the injectivity of Φ\Phi, appears only once. Since all summands are nonnegative, the former sum is greater than or equal to the latter. Therefore

Having shown sufficiency for extreme points of P\mathcal{P}, we apply Lemma 3.16 to conclude sufficiency for all s∈Ps\in\mathcal{P}.

Communication lower bounds from Theorem 3.2

In addition to the concrete execution model and the geometric model, we use pseudocode in our examples. At a high level, these three different algorithm representations are related as follows:

A concrete execution is a sequence of instructions executed by the machine, according to the model detailed in Section 4.1. The concrete execution, unlike either the geometric model or pseudocode, contains explicit data movement operations between slow and fast memory.

The geometric model (Definition 2.2), is the most abstract, and is the foundation of the bounds in Section 3. Each instance (2.2) of the geometric model corresponds to a set of concrete executions, as detailed in Section 4.2.

The rest of this section is organized as follows. Section 4.1 describes the concrete execution model mentioned above, and Section 4.2 relates the concrete execution model to the geometric model. Section 4.3 states and proves the main communication lower bound result of this paper, Theorem 4.1. Section 4.4 presents a number of examples showing why the assumptions of Theorem 4.1 are in fact necessary to obtain a lower bound. Section 4.5 looks at one of these assumptions in more detail (“no loop splitting”), and shows that loop splitting can only improve (reduce) the lower bound. Finally, Section 4.6 discusses generalizations of the lower bound result to other machine models.

The hypothetical machine in our execution model has a two-level memory hierarchy: a slow memory of unbounded capacity and a fast memory that can store MM words (all data in our model have one-word width). Data movement between slow and fast memory is explicitly managed by software instructions (unlike a hardware cache), and data is copiedWe will use the word ‘copied’ but our analysis does not require that a copy remains, e.g., exclusive caches. at a one-word granularity (we will discuss spatial locality in Part 2 of this work). Every storage location in slow and fast memory (including the array elements Aj(ϕj(I))A_{j}(\phi_{j}(\mathcal{I}))) has a unique memory address, called a variable; since the slow and fast memory address spaces (variable sets) are disjoint, we will distinguish between slow memory variables and fast memory variables. When a fast memory variable represents a copy of a slow memory variable vv, we refer to vv as a cached slow memory variable; in this case, we assume we can always identify the corresponding fast memory variable given vv, even if the copy is relocated to another fast memory location.

We define a sequential execution E=(e1,e2,…,en)E=({e_{1},e_{2},\ldots,e_{n}}) as a sequence of statements eie_{i} of the following types:

read(v)read(v): allocates a location in fast memory and copies variable vv from slow to fast memory.

write(v)write(v): copies variable vv from fast to slow memory and deallocates the location in fast memory.

compute({v1,…,vn})compute(\{{v_{1},\ldots,v_{n}}\}) is a statement accessing variables v1,…,vnv_{1},\ldots,v_{n}.

allocate(v)allocate(v) introduces variable vv in fast memory.

free(v)free(v) removes variable vv from fast memory.

A sequential execution defines a total order on the statements, and thereby a natural notion of when one statement succeeds or precedes another. We say that a Read or Allocate statement and a subsequent Write or Free statement are paired if the same variable vv appears as an operand in both and there are no intervening Reads, Allocates, Writes, or Frees of vv. A sequential execution is considered to be well formed if and only if

operands to Read (resp., Write) statements are uncached (resp., cached) slow memory variables,

operands to Allocate statements are uncached slow memory variables or fast memory variablesIf a fast memory variable vv in an allocate(v)allocate(v) statement already stores a cached slow memory variable, then we assume the system will first relocate the cached variable to an available location within fast memory),

operands to Free statements are cached slow memory variables or fast memory variables,

every Read, Allocate, Write, and Free statement is paired, and

every Compute statement involving variable vv interposes between paired Read/Allocate and Write/Free statements of vv, i.e., each operand vv in a Compute statements resides in fast memory before and after the statement.

Essentially, fast memory variables must be allocated and deallocated, either implicitly (Read/Write) or explicitly (Allocate/Free), while slow memory variables cannot be allocated/deallocated. Given the finite capacity of fast memory, we need an additional assumption to ensure the memory operations are well-defined. Given a well-formed sequential execution E=(e1,…,en)E=({e_{1},\ldots,e_{n}}), we define footprinti(E)footprint_{i}(E) to be the fast memory usage after executing statement eie_{i} in the program, i.e.,

Then EE is said to be MM–fit (for fast memory size MM) if max⁡ifootprinti(E)≤M\max_{i}footprint_{i}(E)\leq M.

It is of practical interest to permit variables to reside in fast memory before and after the execution, e.g., to handle parallel code as described in the next paragraph; however, this violates our notion of well-formedness. Rather than redefine well-formedness to account for this possibility, we take a simpler approach: given an execution that is well formed except for the II (‘input’) and OO (‘output’) variables which reside in fast memory before and after the execution, we insert up to MM Reads and MM Writes at the beginning and end of the execution so that all memory statements are paired, and then later reduce the lower bound (on Reads/Writes) by I+O≤2MI+O\leq 2M.

Although we will establish our bounds first for a sequential execution, they also apply to parallel executions as explained in Section 4.6. We define a parallel execution as a set of PP sequential executions, {E1,E2,…,EP}\{{E_{1},E_{2},\ldots,E_{P}}\}. In our parallel model, the global (‘slow’) memory for each processor is a subset of the union of the local (‘fast’) memories of the other processors. That is, for a given processor, each of its slow memory variables is really a fast memory variable for some other processor, and each of its fast memory variables is a slow memory variable for every other processor, unless it corresponds to a cached slow memory variable, in which case it is invisible to the other processors. (We could remove this last assumption by extending our model to distinguish between copies of a slow memory variable.) A parallel execution is well formed or (additionally) {M1,…,MP}\{{M_{1},\ldots,M_{P}}\}–fit if each of its serial executions EiE_{i} is well formed or (additionally) MiM_{i}–fit. Since well-formedness assumes no variables begin and end execution in fast/local memory, it seems impossible for there to be any nontrivial well-formed parallel execution. As mentioned above, we can always allow for a sequential execution with this property by inserting up to I+O≤2MI+O\leq 2M Reads/Writes, and later reducing the lower bound by this amount; we insert Reads/Writes in this manner to each sequential execution EiE_{i} in a parallel execution.

2 Relation to the geometric model

Recall from Section 2 our geometric model (2.2):

Given an execution, we assume we can discern the expression Aj(ϕj(I))A_{j}(\phi_{j}(\mathcal{I})) from any variable which represents an array variable in the geometric model. The execution may contain additional variables that act as surrogates (or copies) of the variables specified in the program text. As an extreme example, an execution could use an array Aj′A^{\prime}_{j} as a surrogate for the array AjA_{j} in the computations, and then later set AjA_{j} to Aj′A^{\prime}_{j}. In such examples, one can always associate each surrogate variable with the ‘master’ copy, and there is no loss of generality in our analysis to assume all variables are in fact the master copies.

We say a legal sequential execution of an instance of the geometric model is a sequential execution whose subsequence of Compute statements can be partitioned into contiguous chunks in one-to-one correspondence with Z\mathcal{Z}, and furthermore all mm array variables Aj(ϕj(I))A_{j}(\phi_{j}(\mathcal{I})) appear as operands in the chunk corresponding to I\mathcal{I}. Given a possibly overlapping partition Z=⋃i=1PZi\mathcal{Z}=\bigcup_{i=1}^{P}\mathcal{Z}_{i}, a legal parallel execution is a parallel execution {E1,…,Ep}\{{E_{1},\ldots,E_{p}}\} where each sequential execution EiE_{i} is legal with respect to loop iterations I∈Zi\mathcal{I}\in\mathcal{Z}_{i}. Legality restricts the set of possible concrete executions we consider (for a given instance of the geometric model), and in general is a necessary requirement for the lower bound to hold for all concrete executions. For example, transforming the classical algorithm for matrix multiplication into Strassen’s algorithm (which can move asymptotically less data) is illegal, since it exploits the distributive property to interleave computations, and any resulting execution cannot be partitioned contiguously according to the original iteration space Z\mathcal{Z}. As another example, legality prevents loop splitting, an optimization which can invalidate the lower bound as discussed in Section 4.5.

We note that there are no assumptions about preserving dependencies in the original program or necessarily computing the correct answer. Restricting the set of executions further to ones that are correct may make the lower bound unattainable, but does not invalidate the bound.

3 Derivation of Communication Lower Bound

Now we present the more formal derivation of the communication lower bound, which was sketched in Section 2. The approach used here was introduced in [ITT04] and generalized in [BallardDemmelHoltzSchwartz11]. Here we generalize it again to deal with the more complicated algorithms considered in this paper.

Given an MM–fit legal sequential execution E=(e1,…,en)E=({e_{1},\ldots,e_{n}}), we proceed as follows:

Break EE into MM–Read/Write segments of consecutive statements, where each segment (except possibly the last one) contains exactly MM Reads and/or Writes. Each segment (except the last) ends with the MthM^{\text{th}} Read/Write and the next segment starts with whatever statement follows. The last segment may have statements other than Reads/Writes at the end to complete the execution. (We will simply refer to these as Read/Write segments when MM is clear from context.)

Independently, break EE into Compute segments of consecutive statements so that the Compute statements within a segment correspond to the same iteration I\mathcal{I}. (It will not matter that this does not uniquely define the first and last statements of a Compute segment.) Our assumption of a legal execution guarantees that there is one Compute segment per iteration I\mathcal{I}. We associate each Compute segment with the (unique) Read/Write segment that contains the Compute segment’s first Compute statement.

Using the limited availability of data in any one Read/Write segment, we will use Theorem 3.2 to establish an upper bound FF on the number of complete Compute segments that can be executed during one Read/Write segment (see below). This is an upper bound on the number of complete loop iterations that can be executed.

Now, we can bound below the number of complete Read/Write segments by ⌊∣Z∣/(F+1)⌋\lfloor|\mathcal{Z}|/(F+1)\rfloor. We add 11 to FF to account for Compute segments that overlap two (or more) Read/Write segments. We need the floor function because the last Read/Write segment may not contain MM Reads/Writes. (Since we are doing asymptotic analysis, ∣Z∣|\mathcal{Z}| can often be replaced by the total number of Compute statements.)

Finally we bound below the total number of Reads/Writes by the lower bound on the number of complete Read/Write segments times the number of Reads/Writes per such segment, minus the number of Reads/Writes we inserted to account for variables residing in fast memory before/after the execution:

where we have applied our asymptotic assumption F=Ω(M)=ω(1)F=\Omega(M)=\omega(1).

To determine an upper bound FF, we will use Theorem 3.2 to bound the amount of (useful) computation that can be done given only O(M)O(M) array variables. First, we discuss how to ensure that only a fixed number of array variables is available during a single Read/Write segment.

Given an MM–fit legal sequential execution, consider any MM–Read/Write segment. There are at most MM array variables in fast memory when the segment starts, at most MM array variables are read/written during the segment, and at most MM array variables remain in fast memory when the segment ends. If there are no Allocates of array variables, or if there are no Frees of array variables, then at most 2M2M distinct array variables appear in the segment (at most MM may already reside in fast memory, and at most MM more can be read or allocated). More generally, if there are no paired Allocate/Free statements of array variables, then at most 3M3M array variables appear in the segment (at most MM already reside in fast memory, at most MM can be read, and at most MM can be allocated). However, if we allow array variables to be allocated and subsequently freed, then it is possible to have an unbounded number of array variables contributing to computation in the same segment; this can occur in practice and we give concrete examples in the following section. Thus, we need an additional assumption in order to obtain a lower bound that is valid for all executions.

We will assume that the execution contains no paired Allocate/Free statements of array variables. However, we note that of these paired statements, we only need to avoid the ones where both statements occur within a given Read/Write segment; e.g., one could remove the preceding assumption by proving that at least MM Read/Write statements (of variables besides vv) interpose every paired Allocate/Free of an array variable vv. (This weaker assumption is equivalent to an assumption in [BallardDemmelHoltzSchwartz11, Section 2] that there are no ‘R2/D2 operands.’)

The communication lower bound is now a straightforward application of Theorem 3.2.

When ∣Z∣=Θ(F)|\mathcal{Z}|=\Theta(F), i.e., the problem (iteration space) is not sufficiently large, the lower bound becomes Ω(M)−O(M)\Omega(M)-O(M), so the subtractive O(M)O(M) term may dominate and lead to zero communication; this is increasingly likely as the ratio ∣Z∣/F|\mathcal{Z}|/F goes to zero. The parallel case also demonstrates this behavior in the ‘strong scaling’ limit, when the problem is decomposed to the point that each processor’s working set fits in their local memory (see Section 4.6). In the regime ∣Z∣=O(F)|\mathcal{Z}|=O(F), a memory-independent lower bound [BDHLS12] provides more insight than the bound above. Let WW be the (unknown) number of Reads/Writes performed, and let II and OO be the numbers of input/output variables residing in fast memory before/after execution. Then

4 Examples

We give four examples to demonstrate why our assumptions in Theorem 4.1 are necessary. Then, we discuss how one can sometimes deal with the presence of imperfectly nested loops, paired Allocate/Free statements, and an infeasible linear program to compute a useful lower bound; we give an example of this approach.

The following simple modification of matrix multiplication demonstrates how paired Allocate/Frees can invalidate our lower bound.

Suppose we know the arrays do not alias each other. Clearly CC only depends on the data when i3=Ni_{3}=N, but we need to do all N3N^{3} multiplications to compute tt correctly. But the same analysis from Section 3 applies to these loops as to matrix multiplication, suggesting a sequential communication lower bound of Ω(N3/M1/2)\Omega(N^{3}/M^{1/2}). However, it is clearly possible to execute all N3N^{3} iterations moving only O(N3/M+N2)O(N^{3}/M+N^{2}) words, by hoisting the (unblocked) i3i_{3} loop outside and blocking the i1i_{1} and i2i_{2} loops by M/2M/2, doing (M/2)2(M/2)^{2} multiplications in a Read/Write segment using M/2M/2 entries each of A(⋅,i3)A(\cdot,i_{3}) and B(i3,⋅)B(i_{3},\cdot), and (over)writing the values C(i1,i2)C(i_{1},i_{2}) to a single location in fast memory, which is repeatedly Allocated and Freed. Only when i3=Ni_{3}=N would C(i1,i2)C(i_{1},i_{2}) actually be written to slow memory. So in this case there are a total of N3−N2N^{3}-N^{2} paired Allocates/Frees, corresponding to the overwritten C(i1,i2)C(i_{1},i_{2}) operands. △\triangle

This example also demonstrates how paired Allocate/Frees can invalidate our lower bound. Consider the following code:

Again, suppose we know that the arrays do not alias each other. Toward a lower bound, we ignore the initialization of AA (first loop nest) and only look at the second loop nest, a matrix multiplication. However, by computing entries of AA on-the-fly from I\mathcal{I} and discarding them (i.e., Allocating/Freeing them), one can beat the lower bound of Ω(N3/M1/2)\Omega(N^{3}/M^{1/2}) words for matrix multiplication. That is, by hoisting the (unblocked) i2i_{2} loop outside and blocking the i1i_{1} and i3i_{3} loops by M/2M/2, and finally writing each A(i1,i3)A(i_{1},i_{3}) to slow memory when i2=Ni_{2}=N, we can instead move O(N3/M+N2)O(N^{3}/M+N^{2}) words. So, there are N3−N2N^{3}-N^{2} possible paired Allocate/Frees. △\triangle

This example demonstrates how infeasibility of the linear constraints (3.1) of Theorem 3.2 can invalidate our lower bound. Consider the following code:

While infeasibility may be sufficient for there to be an unbounded number of array variables in a Read/Write segment, the previous two examples show that it is not necessary, since their linear programs are feasible. We will be more concrete about this relationship between infeasibility and unbounded data reuse in Part 2. △\triangle

This example demonstrates how an execution which interleaves the inner loop bodies (an illegal execution) can invalidate our lower bound; see also Section 4.5. We will see in Section 4.5 that the lower bound for each split loop is no larger than the lower bound for the original loop. Consider splitting the two lines of the inner loop body in the Complicated Code example (see Section 1) into two disjoint loop nests (each over I∈{1,…,N}6\mathcal{I}\in\{{1,\ldots,N}\}^{6}). We assume func1\text{func}_{1} and func2\text{func}_{2} do not modify their arguments, and that the arrays do not alias — the two lines share only read accesses to one array, A3A_{3}, so correctness is preserved. As will be seen later by using Theorem LABEL:thm6.1, the resulting two loop nests have lower bounds Ω(N6/M3/2)\Omega(N^{6}/M^{3/2}) and Ω(N6/M2)\Omega(N^{6}/M^{2}), resp., both better than the Ω(N6/M8/7)\Omega(N^{6}/M^{8/7}) of the original, and both these lower bounds are attainable. △\triangle

Theorem 4.1 is enough for many direct linear algebra computations such as (dense or sparse) LULU decomposition, which do not have paired Allocate/Frees, but not all algorithms for the QRQR decomposition or eigenvalue problems, which can potentially have large numbers of paired Allocates/Frees (see [BallardDemmelHoltzSchwartz11]). We can often deal with interleaving iterations, paired Allocates/Frees, and infeasibility of (3.1) by imposing Reads and Writes [BallardDemmelHoltzSchwartz11, Section 3.4]: we modify the algorithm to add (“impose”) Reads and Writes of array variables which are allocated/freed or repeatedly overwritten, apply the lower bound from Theorem 4.1, and then subtract the number of imposed Reads and Writes to get the final lower bound. (Note that we have already used a similar technique, above, to allow an execution to begin/end with a nonzero fast memory footprint.) We give an example of this approach (see also [BallardDemmelHoltzSchwartz11, Corollary 5.1]).

Consider computing B=AkB=A^{k} using the following code, shown (for simplicity) for odd kk and initially B=AB=A:

This example also illustrates that our results will only be of interest for sufficiently large problems, certainly where the floor function in the lower bound (4.1) is at least 11. △\triangle

The above approach covers many but not all algorithms of interest. We refer to reader to [BallardDemmelHoltzSchwartz11, Sections 3.4 and 5] for more examples of imposing Reads and Writes, and [BallardDemmelHoltzSchwartz11, Section 4] on orthogonal matrix factorizations for an important class of algorithms where a subtler analysis is required to deal with paired Allocates/Frees.

Imposing Reads and Writes may fundamentally alter the program, so the lower bound obtained for the modified code need not apply to the original code. In the example above, one could reorderFor simplicity, and without reducing data movement, this code performs (k−1)N2(k-1)N^{2} additional ++ operations. the original code to

5 Loop Splitting Can Only Help

Here we show that loop splitting can only reduce (improve) the communication lower bound expressed in Theorem 4.1. More formally, we state this as the following.

While loop splitting appears to always be worth attempting, in practice data dependencies limit our ability to perform this optimization; we will discuss the practical aspects of loop splitting further in Part 2 of this work.

6 Generalizing the machine model

Earlier we said the reader could think of a sequential algorithm where the fast memory consists of a cache of MM words, and slow memory is the main memory. In fact, the result can be extended to the following situations:

If a sequential machine has a memory hierarchy, i.e., multiple levels of cache (most do), where data may only move between adjacent levels, and arithmetic done only on the “top” level, then it is of interest to bound the data transferred between every pair of adjacent levels, say ii and i+1i+1, where ii is higher (faster and closer to the arithmetic unit) than i+1i+1. In this case we apply our model with MM representing the total memory available in levels 1 through ii, typically an increasing function of ii.

One may also ask what value of MM to use for each processor. Suppose that each processor has MmaxM_{\text{max}} words of fast memory, and that the total problem size of all the array entries accessed is MarrayM_{\text{array}}. So if each processor gets an equal share of the data we use M=Marray/P≤MmaxM=M_{\text{array}}/P\leq M_{\text{max}}. But the lower bound may still apply, and be smaller, if MM is larger than Marray/PM_{\text{array}}/P (but at most MmaxM_{\text{max}}). In some cases algorithms are known that attain these smaller lower bounds (e.g., matrix multiplication in [2.5D_EuroPar]), i.e., replicating data can reduce communication.

In Section 7.3, we discuss attainability of these parallel lower bounds, and reducing communication by replicating data.

The simplest possible hierarchical machine is the sequential one with multiple levels of memory discussed above. But real parallel machines are similar: each processor has its own memory organized in a hierarchy. So just as we applied our lower bound to measure memory traffic between levels ii and i+1i+1 of cache on a sequential machine, we can similarly analyze the memory hierarchy on each processor in a parallel machine.

Finally, people are building heterogeneous parallel machines, where the various processors, memories, and interconnects can have different speeds or sizes. Since minimizing the total running time means minimizing the time when the last processor finishes, it may no longer make sense to assign an equal fraction ∣Z∣/P|\mathcal{Z}|/P of the work and equal subset of memory MM to each processor. Since our lower bounds apply to each processor independently, they can be used to formulate an optimization problem that will give the optimal amount of work to assign to each processor [Hetero_SPAA11].

(Un)decidability of the communication lower bound

In Section 3, we proved Theorem 3.2, which tells us that the exponents s∈ms\in^{m} satisfy the inequalities (3.1), i.e.,

The proof of Theorem 5.1 is built upon several smaller results.

Generate a list of all nonempty subsets of VV having at most dim⁡(V)\operatorname{dim}({V}) elements. Test each subset for linear independence, and discard all which fail to be independent. Output a list of those which remain. ∎

We do not require this list to be free of redundancies.

To the given family of inequalities, adjoin the 2m2m inequalities sj≥0s_{j}\geq 0 and −sj≥−1-s_{j}\geq-1. P\mathcal{P} is the convex polytope defined by all inequalities in the resulting enlarged family. Express these inequalities as ⟨s,vα⟩≥cα\langle s,v_{\alpha}\rangle\geq c_{\alpha} for all α∈A\alpha\in A, where AA is a finite nonempty index set.

Create a list of all subsets B⊂AB\subset A with cardinality equal to mm. There are finitely many such sets, since AA itself is finite. Delete each one for which {vβ:β∈B}\{{v_{\beta}:\beta\in B}\} is not linearly independent. For each subset BB not deleted, compute the unique solution τ\tau of the system of equations ⟨τ,vβ⟩=cβ\langle\tau,v_{\beta}\rangle=c_{\beta} for all β∈B\beta\in B. Include τ\tau in the list of all extreme points, if and only if τ\tau satisfies ⟨τ,vα⟩≥cα\langle\tau,v_{\alpha}\rangle\geq c_{\alpha} for all α∈A∖B\alpha\in A\setminus B. ∎

There exists an algorithm which takes as input a vector space HBL datum (V,(Vj),(ϕj))({V,({V_{j}}),({\phi_{j}})}), an element t∈mt\in^{m}, and a subspace {0}<W<V\{{0}\}<W<V which is critical with respect to tt, and determines whether t∈P(V,(Vj),(ϕj))t\in\mathcal{P}({V,({V_{j}}),({\phi_{j}})}).

Theorem 5.1 and Proposition 5.5 will be proved inductively in tandem, according to the following induction scheme. The proof of Theorem 5.1 for HBL data in which VV has dimension nn, will rely on Proposition 5.5 for HBL data in which VV has dimension nn. The proof of Proposition 5.5 for HBL data in which VV has dimension nn and there are mm subspaces VjV_{j}, will rely on Proposition 5.5 for HBL data in which VV has dimension strictly less than nn, on Theorem 5.1 for HBL data in which VV has dimension strictly less than nn, and also on Theorem 5.1 for HBL data in which VV has dimension nn and the number of subspaces VjV_{j} is strictly less than mm. Thus there is no circularity in the reasoning.

Let (V,(Vj),(ϕj))({V,({V_{j}}),({\phi_{j}})}) and t,Wt,W be given. Following Notation 3.23, consider the two HBL data ({W,({\phi_{j}(W)}),({\phi_{j}\big{|}_{W}})}) and (V/W,(Vj/ϕj(W)),([ϕj]))({V/W,({V_{j}/\phi_{j}(W)}),({[\phi_{j}]})}), where [ϕj] ⁣:V/W→Vj/ϕj(W)[\phi_{j}]\colon V/W\to V_{j}/\phi_{j}(W) are the quotient maps. From a basis for VV, bases for VjV_{j}, a basis for WW, and corresponding matrix representations of ϕj\phi_{j}, it is possible to compute the dimensions of, and bases for, V/WV/W and Vj/ϕj(W)V_{j}/\phi_{j}(W), via row operations on matrices. According to Lemma 3.25, t∈P(V,(Vj),(ϕj))t\in\mathcal{P}({V,({V_{j}}),({\phi_{j}})}) if and only if t\in\mathcal{P}({W,({\phi_{j}(W)}),({\phi_{j}\big{|}_{W}})})\cap\mathcal{P}({V/W,({V_{j}/\phi_{j}(W)}),({[\phi_{j}]})}).

Because 0<W<V0<W<V, both W,V/WW,V/W have dimensions strictly less than the dimension of VV. Therefore by Theorem 5.1 and the induction scheme, there exists an algorithm which computes both a finite list of inequalities characterizing \mathcal{P}({W,({\phi_{j}(W)}),({\phi_{j}\big{|}_{W}})}), and a finite list of inequalities characterizing P(V/W,(Vj/ϕj(W)),([ϕj]))\mathcal{P}({V/W,({V_{j}/\phi_{j}(W)}),({[\phi_{j}]})}). Testing each of these inequalities on tt determines whether tt belongs to these two polytopes, hence whether tt belongs to P(V,(Vj),(ϕj))\mathcal{P}({V,({V_{j}}),({\phi_{j}})}). ∎

Let HBL datum (V,(Vj),(ϕj))({V,({V_{j}}),({\phi_{j}})}) be given. Let i∈{1,2,…,m}i\in\{{1,2,\ldots,m}\}. Let s∈ms\in^{m} and suppose that si=1s_{i}=1. Let V′={x∈V:ϕi(x)=0}V^{\prime}=\{{x\in V:\phi_{i}(x)=0}\} be the nullspace of ϕi\phi_{i}. Define s^∈m−1\widehat{s}\in^{m-1} to be (s1,…,sm)(s_{1},\ldots,s_{m}) with the ithi^{\text{th}} coordinate deleted. Then s∈P(V,(Vj),(ϕj))s\in\mathcal{P}({V,({V_{j}}),({\phi_{j}})}) if and only if \widehat{s}\in\mathcal{P}({V^{\prime},({V_{j}})_{j\neq i},({\phi_{j}\big{|}_{V^{\prime}}})_{j\neq i}}).

For any subspace W≤V′W\leq V^{\prime}, since dim⁡(ϕi(W))=0\operatorname{dim}({\phi_{i}(W)})=0,

So if s∈P(V,(Vj),(ϕj))s\in\mathcal{P}({V,({V_{j}}),({\phi_{j}})}) then \widehat{s}\in\mathcal{P}({V^{\prime},({V_{j}})_{j\neq i},({\phi_{j}\big{|}_{V^{\prime}}})_{j\neq i}}).

Conversely, suppose that \widehat{s}\in\mathcal{P}({V^{\prime},({V_{j}})_{j\neq i},({\phi_{j}\big{|}_{V^{\prime}}})_{j\neq i}}). Let WW be any subspace of VV. Write W=W′′+(W∩V′)W=W^{\prime\prime}+(W\cap V^{\prime}) where the subspace W′′≤VW^{\prime\prime}\leq V is a supplement to W∩V′W\cap V^{\prime} in WW, so that dim⁡(W)=dim⁡(W′′)+dim⁡(W∩V′)\operatorname{dim}({W})=\operatorname{dim}({W^{\prime\prime}})+\operatorname{dim}({W\cap V^{\prime}}). Then

dim⁡(ϕi(W′′))=dim⁡(W′′)\operatorname{dim}({\phi_{i}(W^{\prime\prime})})=\operatorname{dim}({W^{\prime\prime}}) because ϕi\phi_{i} is injective on W′′W^{\prime\prime}. So s∈P(V,(Vj),(ϕj))s\in\mathcal{P}({V,({V_{j}}),({\phi_{j}})}). ∎

To prepare for the proof of Theorem 5.1, let P(V,(Vj),(ϕj))\mathcal{P}({V,({V_{j}}),({\phi_{j}})}) be given. Let (W1,W2,W3,…)({W_{1},W_{2},W_{3},\ldots}) be the list of subspaces of VV produced by the algorithm of Lemma 5.3. Let N≥1N\geq 1. To each index α∈{1,2,…,N}\alpha\in\{{1,2,\ldots,N}\} is associated a linear inequality ∑j=1msjdim⁡(ϕj(Wα))≥dim⁡(Wα)\sum_{j=1}^{m}s_{j}\operatorname{dim}({\phi_{j}(W_{\alpha})})\geq\operatorname{dim}({W_{\alpha}}) for elements s∈ms\in^{m}, which we encode by an (m+1)(m+1)–tuple (v(Wα),c(Wα))({v(W_{\alpha}),c(W_{\alpha})}); the inequality is ⟨s,v(Wα)⟩≥c(Wα)\langle s,v(W_{\alpha})\rangle\geq c(W_{\alpha}). Define PN⊆m\mathcal{P}_{N}\subseteq^{m} to be the polytope defined by this set of inequalities.

Moreover, there exists a positive integer NN such that PM=P(V,(Vj),(ϕj))\mathcal{P}_{M}=\mathcal{P}({V,({V_{j}}),({\phi_{j}})}) for all M≥NM\geq N.

The inclusion holds for every NN, because the set of inequalities defining PN\mathcal{P}_{N} is a subset of the set defining P(V,(Vj),(ϕj))\mathcal{P}({V,({V_{j}}),({\phi_{j}})}).

P(V,(Vj),(ϕj))\mathcal{P}({V,({V_{j}}),({\phi_{j}})}) is specified by some finite set of inequalities, each specified by some subspace of VV. Choose one such subspace for each of these inequalities. Since (Wα)({W_{\alpha}}) is a list of all subspaces of VV, there exists MM such that each of these chosen subspaces belongs to (Wα:α≤M)({W_{\alpha}:\alpha\leq M}). ∎

Let m≥2m\geq 2. If ss is an extreme point of PN\mathcal{P}_{N}, then either sj∈{0,1}s_{j}\in\{{0,1}\} for some j∈{1,2,…,m}j\in\{{1,2,\ldots,m}\}, or there exists α∈{1,2,…,N}\alpha\in\{{1,2,\ldots,N}\} for which WαW_{\alpha} is critical with respect to ss and 0<dim⁡(Wα)<dim⁡(V)0<\operatorname{dim}({W_{\alpha}})<\operatorname{dim}({V}).

For any extreme point ss, equality must hold in at least mm genuinely distinct inequalities among those defining PN\mathcal{P}_{N}. These inequalities are of three kinds: ⟨s,v(Wα)⟩≥c(Wα)\langle s,v(W_{\alpha})\rangle\geq c(W_{\alpha}) for α∈{1,2,…,N}\alpha\in\{{1,2,\ldots,N}\}, sj≥0s_{j}\geq 0, and −sj≥−1-s_{j}\geq-1, with j∈{1,2,…,m}j\in\{{1,2,\ldots,m}\}. If Wβ={0}W_{\beta}=\{{0}\} then WβW_{\beta} specifies the tautologous inequality ∑jsj⋅0=0\sum_{j}s_{j}\cdot 0=0, so that index β\beta can be disregarded.

If none of the coordinates sjs_{j} are equal to or 11, there must exist β\beta such that equality holds in at least two distinct inequalities ⟨s,v(Wβ)⟩≥c(Wβ)\langle s,v(W_{\beta})\rangle\geq c(W_{\beta}) associated to subspaces WαW_{\alpha} among those which are used to define PN\mathcal{P}_{N}. We have already discarded the subspace {0}\{{0}\}, so there must exist β\beta such that WβW_{\beta} and VV specify distinct inequalities. Thus 0<dim⁡(Wβ)<dim⁡(V)0<\operatorname{dim}({W_{\beta}})<\operatorname{dim}({V}). ∎

Suppose that m≥2m\geq 2. Let (V,(Vj),(ϕj))({V,({V_{j}}),({\phi_{j}})}) be given. Let N=0N=0. Recursively apply the following procedure.

Replace NN by N+1N+1. Consider PN\mathcal{P}_{N}. Apply Lemma 5.4 to obtain a list of all extreme points τ\tau of PN\mathcal{P}_{N}, and for each such τ\tau which belongs to (0,1)m(0,1)^{m}, a nonzero proper subspace W(τ)≤VW(\tau)\leq V which is critical with respect to τ\tau.

Examine each of these extreme points τ\tau, to determine whether τ∈P(V,(Vj),(ϕj))\tau\in\mathcal{P}({V,({V_{j}}),({\phi_{j}})}). There are three cases. Firstly, if τ∈(0,1)m\tau\in(0,1)^{m}, then Proposition 5.5 may be invoked, using the critical subspace W(τ)W(\tau), to determine whether τ∈P\tau\in\mathcal{P}.

Secondly, if some component τi\tau_{i} of τ\tau equals 11, let V′V^{\prime} be the nullspace of ϕi\phi_{i}. Set

According to Lemma 5.6, τ∈P\tau\in\mathcal{P} if and only if τ^=(τj)j≠i∈P′\widehat{\tau}=({\tau_{j}})_{j\neq i}\in\mathcal{P}^{\prime}. This polytope P′\mathcal{P}^{\prime} can be computed by the induction hypothesis, since the number of indices jj has been reduced by one.

Finally, if some component τi\tau_{i} of τ\tau equals , then because the term sidim⁡(ϕi(W))=0s_{i}\operatorname{dim}({\phi_{i}(W)})=0 contributes nothing to sums ∑j=1msjdim⁡(ϕj(W))\sum_{j=1}^{m}s_{j}\operatorname{dim}({\phi_{j}(W)}), τ∈P\tau\in\mathcal{P} if and only if τ^\widehat{\tau} belongs to P(V,(Vj)j≠i,(ϕj)j≠i)\mathcal{P}({V,({V_{j}})_{j\neq i},({\phi_{j}})_{j\neq i}}). To determine whether τ^\widehat{\tau} belongs to this polytope requires again only an application of the induction hypothesis.

If every extreme point τ\tau of PN\mathcal{P}_{N} belongs to P\mathcal{P}, then because PN\mathcal{P}_{N} is the convex hull of its extreme points, PN⊆P\mathcal{P}_{N}\subseteq\mathcal{P}. The converse inclusion holds for every NN, so in this case PN=P\mathcal{P}_{N}=\mathcal{P}. The algorithm halts, and returns the conclusion that P=PN\mathcal{P}=\mathcal{P}_{N}, along with information already computed: a list of the inequalities specified by all the subspaces W1,…,WNW_{1},\ldots,W_{N}, and a list of extreme points of PN=P\mathcal{P}_{N}=\mathcal{P}.

On the other hand, if at least one extreme point of PN\mathcal{P}_{N} fails to belong to P\mathcal{P}, then PN≠P\mathcal{P}_{N}\neq\mathcal{P}. Then increment NN by one, and repeat the above steps.

Lemma 5.7 guarantees that this procedure will halt after finitely many steps. ∎

2 On Computation of the Constraints Defining 𝒫𝒫\mathcal{P}

There exists an effective algorithm for computing the set of constraints (3.1) defining P\mathcal{P} if and only if there exists an effective algorithm to decide whether a system of polynomial equations with rational coefficients has a rational solution.

For a natural number dd and ring RR, we write Md(R)M_{d}({R}) to denote the ring of dd–by–dd matrices with entries from RR. (Note that elsewhere in this work we also use the notation Rm×nR^{m\times n} to denote the set of mm–by–nn matrices with entries from RR.) We identify Md(R)M_{d}({R}) with the endomorphism ring of the RR–module RdR^{d} and thus may write elements of Md(R)M_{d}({R}) as RR–linear maps rather than as matrices. Via the usual coordinates, we may identify Md(R)M_{d}({R}) with Rd2R^{d^{2}}. We write R[x1,…,xq]R[x_{1},\ldots,x_{q}] to denote the ring of polynomials over RR in variables x1,…,xqx_{1},\ldots,x_{q}.

With the next lemma, we use a standard trick of replacing composite terms with single applications of the basic operations to put a general Diophantine set in a standard form (see, e.g., [Vak]).

uα+β−uαuβu_{\alpha+\beta}-u_{\alpha}u_{\beta} for (α+β)∈D(\alpha+\beta)\in\mathcal{D}, α≠0\alpha\neq{\mathbf{0}} and β≠0\beta\neq{\mathbf{0}}.

Let S′S^{\prime} be the set containing TT and the polynomials ∑α∈Dcαuα\sum_{\alpha\in\mathcal{D}}c_{\alpha}u_{\alpha} for which ∑α∈Dcαxα∈S\sum_{\alpha\in\mathcal{D}}c_{\alpha}x^{\alpha}\in S.

For the remainder of this argument, we call a set enjoying the properties identified for S′S^{\prime} (namely that each polynomial is either affine or of the form uαuβ−uγu_{\alpha}u_{\beta}-u_{\gamma}) a basic set.

and the kk polynomials expressing multiplicative relations in SS as

Note that by scaling, we may assume that all of the coefficients λi,j\lambda_{i,j} are integers.

The map f1f_{1} is constant taking the value (u;v)↦(u0,0,…,0)(u;v)\mapsto(u_{0},0,\ldots,0).

The map f2f_{2} is constant taking the value (u;v)↦(v0,0,…,0)(u;v)\mapsto(v_{0},0,\ldots,0).

The map f3f_{3} is constant taking the value (u;v)↦(u0,…,uq;0,…,0)(u;v)\mapsto(u_{0},\ldots,u_{q};0,\ldots,0).

The map f4f_{4} is constant taking the value (u;v)↦(v0,…,vq;0,…,0)(u;v)\mapsto(v_{0},\ldots,v_{q};0,\ldots,0).

The map f4+jf_{4+j} (for 0<j≤q0<j\leq q) is constant taking the value (u;v)↦(u0−v0,uj−vj,0,…,0)(u;v)\mapsto(u_{0}-v_{0},u_{j}-v_{j},0,\ldots,0).

The map f4+q+jf_{4+q+j} (for 0<j≤k0<j\leq k) is constant taking the value (u;v)↦(ui1,j+v0,ui3,j+vi2,j,0,…,0)(u;v)\mapsto(u_{i_{1,j}}+v_{0},u_{i_{3,j}}+v_{i_{2,j}},0,\ldots,0).

The map f4+q+k+jf_{4+q+k+j} (for 0<j≤t0<j\leq t) takes a=(p1q1,…,ptqt)a=(\frac{p_{1}}{q_{1}},\ldots,\frac{p_{t}}{q_{t}}) (written in lowest terms) to the linear map (u;v)↦(pju0−qjuj,0,…,0)(u;v)\mapsto(p_{j}u_{0}-q_{j}u_{j},0,\ldots,0).

Visibly, dim⁡(V)=2=ρ\operatorname{dim}({V})=2=\rho.

For 0<j≤k0<j\leq k we have ci3,j=ci1,jci2,jc_{i_{3,j}}=c_{i_{1,j}}c_{i_{2,j}}, the general element of f4+q+j(a)(V)f_{4+q+j}(a)(V) has the form (αci1,j+β,αci3,j+βci2,j,0,…,0)=(αci1,j+β,αci1,jci2,j+βci2,j,0,…,0)=(αci1,j+β)(1,ci2,j,0,…,0)(\alpha c_{i_{1,j}}+\beta,\alpha c_{i_{3,j}}+\beta c_{i_{2,j}},0,\ldots,0)=(\alpha c_{i_{1,j}}+\beta,\alpha c_{i_{1,j}}c_{i_{2,j}}+\beta c_{i_{2,j}},0,\ldots,0)=(\alpha c_{i_{1,j}}+\beta)(1,c_{i_{2,j}},0,\ldots,0) so we have that ρ4+q+j=dim⁡(f4+q+j(a)(V))=1\rho_{4+q+j}=\operatorname{dim}({f_{4+q+j}(a)(V)})=1.

For 0<j≤t0<j\leq t, the general element of f4+q+k+j(a)(V)f_{4+q+k+j}(a)(V) has the form (pjα−qjαaj,0,…,0)=0(p_{j}\alpha-q_{j}\alpha a_{j},0,\ldots,0)={\mathbf{0}}. That is, ρ4+q+k+j=dim⁡(f4+q+k+j(a)(V))=0\rho_{4+q+k+j}=\operatorname{dim}({f_{4+q+k+j}(a)(V)})=0.

The following is an implementation of row reduction. Let the elements d=(d0,…,dq;d0′,…,dq′)d=(d_{0},\ldots,d_{q};d_{0}^{\prime},\ldots,d_{q}^{\prime}) and e=(e0,…,eq;e0′,…,eq′)e=(e_{0},\ldots,e_{q};e_{0}^{\prime},\ldots,e_{q}^{\prime}) be a basis for VV. Since dim⁡(f1(a)(V))=1\operatorname{dim}({f_{1}(a)(V)})=1, at the cost of reversing dd and ee and multiplying by a scalar, we may assume that d0=1d_{0}=1. Since dim⁡(f3(a)(V))=1\operatorname{dim}({f_{3}(a)(V)})=1, we may find a scalar γ\gamma for which (γd0,…,γdq)=(e0,…,eq)(\gamma d_{0},\ldots,\gamma d_{q})=(e_{0},\ldots,e_{q}). Set g~≔e−γd\widetilde{g}\coloneqq e-\gamma d. Write g~=(0,…,0,g~0,…,g~q)\widetilde{g}=(0,\ldots,0,\widetilde{g}_{0},\ldots,\widetilde{g}_{q}). Since g~\widetilde{g} is linearly independent from ee and dim⁡(f4(a)(V))=1\operatorname{dim}({f_{4}(a)(V)})=1, we see that there is some scalar δ\delta for which (δg~0,…,δg~q)=(d0′,…,dq′)(\delta\widetilde{g}_{0},\ldots,\delta\widetilde{g}_{q})=(d_{0}^{\prime},\ldots,d_{q}^{\prime}). Set h≔d−δg~h\coloneqq d-\delta\widetilde{g}. Using the fact that dim⁡(f2(a)(V))=1\operatorname{dim}({f_{2}(a)(V)})=1 we see that g~0≠0\widetilde{g}_{0}\neq 0. Set g≔g~0−1g~g\coloneqq\widetilde{g}_{0}^{-1}\widetilde{g}. ∎

For 0≤j≤q0\leq j\leq q we have gj=hjg_{j}=h_{j}.

The image of αh+βg\alpha h+\beta g under f4+q+k+j(a)f_{4+q+k+j}(a) is (pjα−qjαhj,0,…,0)(p_{j}\alpha-q_{j}\alpha h_{j},0,\ldots,0) where aj=pjqja_{j}=\frac{p_{j}}{q_{j}} in lowest terms. Since dim⁡(f4+q+k+j(a)(V))=0\operatorname{dim}({f_{4+q+k+j}(a)(V)})=0, we have qjhj=pjq_{j}h_{j}=p_{j}. That is, hj=ajh_{j}=a_{j}. ∎

For any F∈SF\in S, we have F(h1,…,hq)=0F(h_{1},\ldots,h_{q})=0.

Recall in Section 5.2, we hoped to answer the following (possibly undecidable) question.

If such an HH exists, we know the linear constraint r≤∑j=1msjrjr\leq\sum_{j=1}^{m}s_{j}r_{j} is one of the conditions (3.1), which define the polytope P\mathcal{P} of feasible solutions (s1,…,sm)(s_{1},\ldots,s_{m}). We now ask the related question,

There is an effective algorithm (the cylindrical algebraic decomposition [CAD]) to decide whether a system of real polynomial equations (e.g., that in Remark 5.12) has a real solution. ∎

In other words, it is Tarski-decidable to write down a communication lower bound, but it may be strictly smaller than the best lower bound implied by Theorem 3.2, and obtained by the approach in Section 5.1.

Easily computable communication lower bounds

There are variety of other situations in which we can effectively compute the communication lower bound, without applying the approach in Section 5.1. These are summarized in Section LABEL:sec:conclusions, and will appear in detail in Part 2 of this paper.

So in the remainder of this section, we assume that the group homomorphisms ϕ1,…,ϕm\phi_{1},\ldots,\phi_{m} are distinct and nontrivial. The arrays AjA_{j} however, may overlap in memory addresses; this possibility does not affect our asymptotic lower bound, given our assumption from Section 4 that mm is a constant, negligible compared to MM.

2 Trivial Cases

There are a few trivial cases where no work is required to find the communication lower bound: when the homomorphisms’ kernels have a nontrivial intersection, and when at least one homomorphism is an injection. These cover the cases where d=1d=1 or m=1m=1. (When m=0m=0 there are no arrays, and when d=0d=0 there are no loops, cases we ignore.)

If d>0d>0 and s∈ms\in^{m} satisfies (3.1), then ∑j=1msj≥1\sum_{j=1}^{m}s_{j}\geq 1.

If not, then any nontrivial subgroup is supercritical with respect to ss. ∎

The following result, a companion to Theorem 3.2, gives a simpler necessary and sufficient condition for there to exist some exponent ss which satisfies (3.2).

There exists s∈ms\in^{m} for which (3.2) holds if and only if

If ⋂jker⁡(ϕj)={0}\bigcap_{j}\operatorname{ker}({\phi_{j}})=\{{0}\}, then Lemma 3.27 asserts that (3.2) holds with all sjs_{j} equal to 11. Conversely, if H=⋂jker⁡(ϕj)H=\bigcap_{j}\operatorname{ker}({\phi_{j}}) is nontrivial, then for any finite nonempty subset E⊂HE\subset H, ϕj(E)={0}\phi_{j}(E)=\{{0}\} for every index jj, so ∣ϕj(E)∣=1|\phi_{j}(E)|=1. Thus the inequality (3.2) fails to hold for any E⊂HE\subset H of cardinality ≥2\geq 2. ∎

If m=1m=1 or d=1d=1, then either we fall into this case, or that of Section 6.2.2.

2.2 Injective Case

If one of the array references is an injection, then each loop iteration will require (at least) one unique operand, so at most MM iterations are possible with MM operands in cache. This observation is confirmed by the following lemma.

We see that s≔ek∈Ps\coloneqq e_{k}\in\mathcal{P} by rewriting (3.1) as

As anticipated, the argument in Section 4 gives a lower bound Ω(M⋅∣Z∣/F)=Ω(∣Z∣)\Omega(M\cdot|\mathcal{Z}|/F)=\Omega(|\mathcal{Z}|), that is, no (asymptotic) data reuse is possible.

3 Product Case

all of which simply choose subsets of the loop indices i1,i2,i3i_{1},i_{2},i_{3}. Similarly, for other linear algebra algorithms, tensor contractions, direct NN–body simulations, and other examples discussed below, the ϕj\phi_{j} simply choose subsets of loop indices. In this case, one can straightforwardly write down a simple linear program for the optimal exponents of Theorem 3.2. We present this result as Theorem 6.6 below (this is a special case, with a simpler proof, of the more general result in [BCCT10, Proposition 7.1]). Using Theorem 6.6 we also give a number of concrete examples, some known (e.g., linear algebra) and some new.

Necessity follows from the fact that the constraints (6.2) are a subset of (3.1).

To show sufficiency, we rewrite hypothesis (6.2) as

We can generalize this to the case where the ϕj\phi_{j} do not choose subsets SjS_{j} of the indices i1,…,idi_{1},\ldots,i_{d}, but rather subsets of suitable independent linear combinations of the indices, for example subsets of {i1,i1+i2,i3−2i1}\{{i_{1},i_{1}+i_{2},i_{3}-2i_{1}}\} instead of subsets of {i1,i2,i3}\{{i_{1},i_{2},i_{3}}\}. We will discuss recognizing the product case in more general array references in Part 2 of this paper.

We continue the example from Section 6.2.2, with ϕy(i1,i2)=(i1)\phi_{y}(i_{1},i_{2})=(i_{1}), ϕA(i1,i2)=(i1,i2)\phi_{A}(i_{1},i_{2})=(i_{1},i_{2}), and ϕx(i1,i2)=(i2)\phi_{x}(i_{1},i_{2})=(i_{2}), or

The (simplest) code that accumulates the force on each particle (body) due to all NN particles is

We get ϕF(i1,i2)=(i1)\phi_{F}(i_{1},i_{2})=(i_{1}), ϕP1(i1,i2)=(i1)\phi_{P_{1}}(i_{1},i_{2})=(i_{1}), and ϕP2(i1,i2)=(i2)\phi_{P_{2}}(i_{1},i_{2})=(i_{2}), or

which represents a generic “nested loop” database join algorithm of the sets of tuples RR and SS with ∣R∣=N1|R|=N_{1} and ∣S∣=N2|S|=N_{2}. We have a data-dependent branch in the inner loop, so we split the iteration space Z≕Ztrue+Zfalse\mathcal{Z}\eqqcolon\mathcal{Z}_{\text{true}}+\mathcal{Z}_{\text{false}} depending on the value of the predicate (we still assume that the predicate is evaluated for every (i1,i2)(i_{1},i_{2})). This gives

an increasing function of α∈\alpha\in (using the fact that (M+1)/M=Θ(1)(M+1)/M=\Theta(1)). When α\alpha is close enough to zero, we have the ‘best’ lower bound Ω(N1N2/M)\Omega(N_{1}N_{2}/M), and when α\alpha is close enough to 1, we have Ω(αN1N2)\Omega(\alpha N_{1}N_{2}), the size of the output, a lower bound for any computation. △\triangle

We outlined this result already in part 2/5 of this example (see Section 1). We have ϕA(i1,i2,i3)=(i1,i3)\phi_{A}(i_{1},i_{2},i_{3})=(i_{1},i_{3}), ϕB(i1,i2,i3)=(i3,i2)\phi_{B}(i_{1},i_{2},i_{3})=(i_{3},i_{2}), and ϕC(i1,i2,i3)=(i1,i2)\phi_{C}(i_{1},i_{2},i_{3})=(i_{1},i_{2}), or

We already outlined this example in part 1/4 (see Section 1). The code given in part 1/4 leads to

We continue this example from part 2/4 (above), with ϕA\phi_{A}, ϕB\phi_{B} and ϕC\phi_{C} as given there. So we have