This is an archive of the discontinued LLVM Phabricator instance.

[Polly] Compute and print the loop carried dependency distance
ClosedPublic

Authored by jdoerfert on Aug 20 2014, 10:07 AM.

Diff Detail

Event Timeline

jdoerfert updated this revision to Diff 12705.Aug 20 2014, 10:07 AM
jdoerfert retitled this revision from to [Polly] Compute and print the loop carried dependency distance.
jdoerfert added reviewers: grosser, sebpop, simbuerg.
jdoerfert updated this object.
jdoerfert added subscribers: Restricted Project, Unknown Object (MLST).
jdoerfert updated this revision to Diff 13415.Sep 8 2014, 12:44 PM

Rebase patch and show unit tests result in phabricator

sebpop added inline comments.Sep 12 2014, 1:08 PM
lib/Analysis/Dependences.cpp
521

What happens when the isl_set_free function returns a non-zero error?

test/Isl/Ast/dependence_distance_parametric.ll
5

j++)

test/Isl/Ast/dependence_distance_varying.ll
4

I am not sure I understand what "((N - 1) % 2) + 1" means: for a given N, say 100, this expression is equal to 2,

for (int i = 0; i < N; i++)
  A[i] = A[N - i] + 1;

and the dependence distance in this loop is not constant:

  • A[1] is written at iteration i=1 and is read at iteration i=99 -> distance 98
  • A[2] is written at iteration i=2 and is read at iteration i=98 -> distance 96
  • etc.
test/Isl/Ast/dependence_distance_varying_in_outer_loop.ll
6

Is the distance carried by the inner loop equal to 1?

Say we fix the outer loop j to iteration 5, then in the inner loop

  • first iteration i=5, A[2] is written and A[5] is read,
  • third iteration i=8, A[5] is written and A[5] is read.

I think that the dependence distance is not constant in this case.

8

for j < 3, A[i - 3] is a negative access function.

test/Isl/Ast/dependence_distance_varying_multiple.ll
5

The difference between A[i] and A[100 - 2*i] is not constant.

This loop does not carry a constant dependence distance of 1, 2, or 5.

Answers

lib/Analysis/Dependences.cpp
521

isl "guarantees" (with the __isl_null annotation) that we get a nullptr back.

Apperently ppl don't like my shortcut, I can change that.

test/Isl/Ast/dependence_distance_parametric.ll
5

thx

test/Isl/Ast/dependence_distance_varying.ll
4

We compute the minimal dependence distance, everything else seems not really useful? Am I wrong here?

test/Isl/Ast/dependence_distance_varying_in_outer_loop.ll
6

Again, 1 is the minimal dependence distance

8

That is totally fine for a subset of possible pointers A.
What is the problem with negative access functions?

test/Isl/Ast/dependence_distance_varying_multiple.ll
5

Should again be the minimal dep. distance.

sebpop added inline comments.Sep 12 2014, 4:49 PM
test/Isl/Ast/dependence_distance_varying_multiple.ll
5

Ok, so then let's print:

#pragma minimal dependence distance

that is different than what books call "dependence distance", that's why I got confused.

jdoerfert added inline comments.Sep 12 2014, 5:01 PM
test/Isl/Ast/dependence_distance_varying_multiple.ll
5

True, will do.

jdoerfert updated this revision to Diff 13676.Sep 13 2014, 9:58 AM

Addressed review concerns

@sebpop Is it good to go like this?

sebpop edited edge metadata.Sep 13 2014, 10:32 AM

LGTM with those changes.
Let's also wait for Tobi's ok before commit.

include/polly/CodeGen/IslAst.h
55

MinimalDependenceDistance

72

the minimal dependence distance

73

MinimalDependenceDistance

132

Get the minimal dependence distance or nullptr.

134

getMinimalDependenceDistance

include/polly/Dependences.h
95

MinDistancePtr If not nullptr, the minimal dependence distance will be returned at the address of that pointer

lib/Analysis/Dependences.cpp
490

MinDistancePtr

527

Please add a comment above this stmt to explain that we take the min of the distance polyhedron.

jdoerfert closed this revision.Sep 13 2014, 10:44 AM
jdoerfert updated this revision to Diff 13677.

Closed by commit rL217729 (authored by @jdoerfert).