Definitioncore
Dependence direction vector
Also called 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.
The direction vector of a data dependence in a loop nest gives, for each common loop, the sign of the distance between the sink and the source iterations. It is the summary that compilers keep when the distance is not one fixed vector, which is common: a dependence can hold between many pairs of iterations at many distances. The direction vector still tells which loop carries the dependence and which loop permutations are legal. It cannot decide transformations that need the size of a distance, such as skewing.
Definition
Notation
This page uses Wolfe's notation with the symbols , and . Each symbol compares the source index with the sink index:
| symbol on this page | meaning | sign of | Aho, Lam, Sethi and Ullman |
|---|---|---|---|
So "" means that the sink runs in a later iteration of loop . The two notations run in opposite visual directions: goes with . Unions of symbols are also used: for , for , for , and for all three.
Direction vector of a pair and of a dependence
Let be a dependence with common loops, and . Its direction vector is with , or as , or .
The direction vectors of the dependence form the set , which has at most elements. A vector with union symbols, such as , stands for the set of all plain vectors it contains, here , and .
The legal shape
Every distance vector satisfies (see distance vector). So every direction vector of a dependence has one of two shapes:
- the leftmost entry that is not is : the dependence is carried at the level of that entry;
- all entries are : the dependence is loop independent, and the source statement comes before the sink statement in the body.
A vector whose leftmost non- entry is cannot belong to a dependence from to . When a test finds solutions with such a vector, they belong to the dependence from to , whose direction vector has each entry reversed.
Direction vectors as constraints
A dependence test can take a direction vector as an extra constraint: it adds , or for each level and asks if a solution remains. Testing first, and refining one into , and only when the test does not rule out the coarser vector, finds the set with far fewer tests than all vectors in the usual case. The Banerjee test and the practical tests work this way.
Examples and non-examples
A recurrence read in reverse
for i = 1 to n:
S: A[i] = A[i+1] + 1
The write of and the read of touch the same element when . In the pair (write, read), the read iteration is smaller, so the sign is : this is not a flow dependence from the write to the read. Reversed, it is an anti dependence from the read to the write , with direction and distance . The value read is the old value of .
Directions of a dependence with many distances
for i = 1 to 3:
for j = 1 to 3:
S: X[i+j] = X[i+j-1] + 1
The flow distances are , and , so the flow direction vectors are , and . The output distances and give , and the anti distance gives .
Interchange
Loop interchange of two loops swaps the two entries of each direction vector. It is legal if each swapped vector still has the legal shape. In the example above, becomes , which is not legal, so the interchange is illegal. The vectors , and swap to , and , all legal. So in a two-deep nest, interchange is legal exactly when no dependence has the direction vector .
What a direction vector cannot tell
The dependence has the direction vector , and so does . Skewing the inner loop by the outer one, , maps them to and . The first becomes , the second stays . So the same direction vector can need a different skew factor, and only the distances say which one. Skewing by maps both to vectors with a nonnegative second entry: and .
Non-examples
- is not the direction vector of any dependence. It is the reverse of .
- is not the direction vector of a dependence of a statement on itself, because an instance does not depend on itself. It is the direction vector of a loop-independent dependence between two different statements.
Related definitions
- Distance vector. The exact difference ; the direction vector is its sign. See dependence distance vector.
- Level. The position of the leftmost when all earlier entries are . See loop-carried dependence.
- Legality. A loop permutation is legal if it maps each direction vector of each dependence to a vector of the legal shape; this is a special case of the legality theorem. For general unimodular transformations the test needs distances, or a direction vector with enough information to bound the signs of .
- Loop reversal. Running loop backward swaps and at position in every vector.
References
- Michael Wolfe, High Performance Compilers for Parallel Computing, Addison-Wesley, 1996, the chapter on data dependence (direction vectors with the symbols less, equal and greater, and their use for interchange)
- Randy Allen and Ken Kennedy, Optimizing Compilers for Modern Architectures, a Dependence-Based Approach, Morgan Kaufmann, 2002 (copyright 2001), Chapter 2 (direction vectors and the rule that the leftmost non-equal entry of the direction vector of a dependence is less) and Chapter 3 (direction vectors computed by the dependence tests)
- David J. Kuck, Robert H. Kuhn, David A. Padua, Bruce Leasure and Michael Wolfe, Dependence graphs and compiler optimizations, POPL 1981, pp. 207 to 218 (dependence graphs with direction information on the arcs, and the transformations they allow)
- Alfred V. Aho, Monica S. Lam, Ravi Sethi and Jeffrey D. Ullman, Compilers, Principles, Techniques, and Tools, second edition, Addison-Wesley, 2007, Chapter 11 (Section 11.6 on array data-dependence analysis, where signs of distances are written with plus, zero and minus)
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 CQ8RHA Edit this page History Report an error Markdown