Definitioncore
Dependence distance vector
Also called distance vector.
The difference between the iteration vectors of the sink and the source of a dependence in a loop nest.
The distance vector of a data dependence in a loop nest is the iteration vector of the sink minus the iteration vector of the source. If the sink depends on the source , the distance is . It says how many iterations of each loop lie between the two accesses. Its first nonzero entry gives the loop that carries the dependence, and the distances of all dependences decide which reorderings of the loops are legal. When the distance is not one fixed vector, compilers keep only its signs, the direction vector.
Definition
Let and have common loops, and let a dependence go from to , where are the parts of the iteration vectors for these loops. The distance vector of this pair of instances is
The distance set of the dependence of one kind is the set of all such vectors,
In the isl notation, this is the set of deltas of the dependence relation: for { S[i, j] -> S[i + 1, j - 1] : ... } the deltas are { [1, -1] }. The dependence is uniform, or has a constant distance, when has one element.
Lexicographic sign. Each distance vector is lexicographically positive or zero, . The source runs first, so on the common loops: either , or at the first index where they differ, . In the first case ; in the second, and . A pair of accesses with is a dependence in the other direction, from to , and its distance is .
The zero vector. means that the source and the sink run in the same iteration. Such a dependence is loop independent, not carried by any loop. It exists only between two different statements, with the source first in the body.
Index values against iteration numbers. The definition uses the values of the loop indices. For a loop with step , these values differ by multiples of . Most texts first normalize each loop to start at 0 or 1 with step 1, and then measure distances in iterations. Say which one a table uses.
When the distance is constant
Let access and access , with integer matrices and of size . A dependence needs .
- If (the two references are uniformly generated), then . If moreover has full column rank, this has at most one solution , so the distance is constant whenever a dependence exists. In one dimension this is the case of the strong SIV test: gives , see practical dependence tests.
- If but has a nonzero kernel, the distances form the solutions of that fit in the bounds: one solution plus the kernel vectors. A loop index that the subscript does not use has every distance within its bounds.
- If , the distance usually changes from one pair to the next.
Examples and non-examples
A constant distance
for i = 1 to n:
for j = 1 to n:
S: A[i][j] = A[i-1][j] + A[i][j-1]
writes . reads it as through the first read, and reads it through the second. So there are two flow dependences, with distances and . There is no anti dependence: each element is read only after it is written. Both distances have nonnegative entries, so the two loops are fully permutable: interchange is legal, and so is tiling. The time function has for both distances, so all points on one line can run at the same time (wavefront parallelism, the hyperplane method).
A distance that changes
for i = 1 to 8:
S1: A[2*i] = B[i]
S2: C[i] = A[i]
writes , and reads it when . The flow dependence has the distances for , so . There is no anti dependence, since would have to read before writes it, which needs . The dependence is not uniform. Its direction vector is .
A subscript that does not use a loop index
for i = 1 to n:
for j = 1 to m:
S: A[i] = A[i-1] + B[i][j]
The read of meets the write of when , for any and . The flow distances are for all with . Each is lexicographically positive, also those with a negative second entry. The output dependence of on itself has the distances for : all writes of one row go to . No single vector describes either set; the direction vectors are and .
Legality with distances
For a unimodular transformation of a perfect nest, the new distance of each dependence is , and is legal if for each nonzero distance. Take from A[i][j] = A[i-1][j+1]:
| transformation | matrix | legal | |
|---|---|---|---|
| interchange | no | ||
| skewing of by | yes | ||
| skewing, then interchange | yes |
Non-examples
- is never the distance of a dependence: its first nonzero entry is negative. If a test finds a solution with , it has found a dependence from to with distance .
- Two references to different arrays that cannot overlap have no dependence, so no distance set; an empty distance set is not the same as the distance .
Related definitions
- Direction vector. The vector of signs of , written with , and ; it summarizes a distance set that has more than one element. See dependence direction vector.
- Level of a dependence. The index of the first nonzero entry of . See loop-carried dependence.
- Reuse vector. The same subtraction on two accesses that both read a location gives a reuse vector, used for locality (Wolf-Lam locality algorithm); it is not a dependence.
- Dependence cone and polyhedron. In the polyhedral model, the exact set of pairs is kept as a polyhedron, and the distances are a projection of it.
References
- Randy Allen and Ken Kennedy, Optimizing Compilers for Modern Architectures, a Dependence-Based Approach, Morgan Kaufmann, 2002 (copyright 2001), Chapter 2 (distance and direction vectors, and the rule that the leftmost nonzero entry of a legal distance vector is positive)
- Michael E. Wolf and Monica S. Lam, A loop transformation theory and an algorithm to maximize parallelism, IEEE Transactions on Parallel and Distributed Systems 2(4), 1991, the representation of dependences by distance vectors, the legality condition for unimodular transformations, and fully permutable loops
- Leslie Lamport, The parallel execution of DO loops, Communications of the ACM 17(2), 1974, the sets of iteration differences of a loop nest and the hyperplane method that uses them
- Michael Wolfe, High Performance Compilers for Parallel Computing, Addison-Wesley, 1996, the chapter on data dependence (distance vectors and direction vectors in loop nests)
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag 0X40N7 Edit this page History Report an error Markdown