Polyhedral Compilation Foundations

888.11 seminars, part II




[<< home] [Lecture 1] [Lecture 2] [Lecture 3] [Lecture 4]

Lecture 1: Dependence Polyhedra



Assignment for next week

Note: students will present their solution for the exercices on the whiteboard during the class.


Exercise 1
Write the dependence polyhedra, in the PolyLib representation, for the following program:
for (i = 0; i < N; ++i)
   s[i] = 0;
for (i = 1; i < N + 1; ++i)
   tmp[i] = s[i - 1];

Exercise 2
Write the dependence polyhedra, in the PolyLib representation, for the following program:
for (i = 1; i < N + 1; ++i) {
   s[i] = 0;
   tmp[i] = s[i - 1];
}

Exercise 3
Write the dependence polyhedra, in the PolyLib representation, for the following program:
for (i = 0; i < N; ++i)
  for (j = 0; j < N; ++j)
     s[j] = 0;

Exercise 4
Write the dependence polyhedra, in the PolyLib representation, for the following program:
for (i = 0; i < N; ++i)
  for (j = 0; j < N; ++j)
     s[i][j] = s[i][j] + 1;

Exercise 5
Sketch an algorithm which constructs all dependence polyhedra (hint: one is provided in the slides, study it and check for its correctness). Sketch a proof that it is complete and correct (hint: show all possible cases for a dependence to exist are covered).

Exercise 6 (optional)
Write the dependence polyhedra, in the PolyLib representation, for the following program:
for (i = 0; i < N; ++i)
  for (j = 0; j < N; ++j) {
     s[i][j] = s[i][j] + 1;
     a[i] += s[i][j] / b[j];
  }
for (i = 0; i < N; ++i)
  output += a[i];

Exercise 7 (optional)
Study the precedence order condition as described in the slides (slide 18). There is a small mistake, one case is missing. Which one? (hint: the answer is NOT in my thesis ;-) )



Lecture 2: Dependence Polyhedra, Again



Assignment for next week

Note: students will present their solution for the exercices on the whiteboard during the class.


Exercise 1
Write the dependence polyhedra, in the PolyLib representation, for the following program:
for (i = 0; i < N; ++i)
  for (j = 0; j < N; ++j) {
     s[i][j] = s[i][j] + 1;
     a[i] += s[i][j] / b[j];
  }
for (i = 0; i < N; ++i)
  output += a[i];

Exercise 2
Study the precedence order condition as described in the slides (slide 18). There is a small mistake, one case is missing. Which one? (hint: the answer is NOT in my thesis ;-) )
Exercise 3
Given the program:
for (i = 0; i < N; ++i)
  for (j = 0; j < N; ++j) {
     a[i] += s[i][j] / b[j]; // R
  }
for (i = 0; i < N; ++i)
  output += a[i];            // S
And given the schedule Theta_R = i, Theta_S = i + N. Give two detailed solutions based on construction / emptiness test of polyhedra to check if the transformation is legal.
Exercise 4
Write a general algorithm to check the legality of a given multidimensional transformation.
Exercise 5
We define a dependence as the tuple (dependence polyhedra, source statement, target statement, {RAW|WAR|RAR|WAW}, level). Give at two techniques to check if a dependence is loop carried.
Exercise 6 (optional)
Find a third technique to check if a dependence is loop carried.



Lecture 3: Dependence Polyhedra and program legality



Assignment for next week

Note: students will present their solution for the exercices on the whiteboard during the class.


Exercise 1
Given the program:
for (i = 0; i < N; ++i)
  for (j = 0; j < N; ++j) {
     a[i] += s[i][j] / b[j]; // R
  }
for (i = 0; i < N; ++i)
  output += a[i];            // S
And given the schedule Theta_R = i, Theta_S = i + N. Give two detailed solutions based on construction / emptiness test of polyhedra to check if the transformation is legal.
Exercise 2
Write a general algorithm to check the legality of a given multidimensional transformation.
Exercise 3
We define a dependence as the tuple (dependence polyhedra, source statement, target statement, {RAW|WAR|RAR|WAW}, level). Give two techniques to check if a dependence is loop carried.
Exercise 4 (optional)
Find a third technique to check if a dependence is loop carried.



Lecture 4: Scanning Polyhedra



Assignment for next week

The two papers referenced above must have been read and understood. students will present their solution for the exercices on the whiteboard during the class.


Exercise 1
Write the scanning code, using the lexicographic ordering, for the polyhedron defined by (in PolyLib notation):
##################
#  >=  i  j  N  1
##################
    1  1  0  0  0
    1 -1  0  1  0
    1  0  1  0  0 
    1  0 -1  1  0

Exercise 2
Write the scanning code, using the lexicographic ordering, for the polyhedron defined by (in PolyLib notation):
##################
#  >=  i  j  N  1
##################
    1  1  0  0  0
    1 -1  0  1  0
    1  1  1  0  0 
    1  0 -1  1  0

Exercise 3
Write the scanning code, using the lexicographic ordering, for the polyhedron defined by (in PolyLib notation):
#######################
#  >= c1 c2  i  j  N  1
#######################
    1  0  0  1  0  0  0
    1  0  0 -1  0  1  0
    1  0  0  1  1  0  0 
    1  0  0  0 -1  1  0
    0 -1  0  1  0  0  0 
    0  0 -1  0  1  0  0 

Exercise 4
Write the scanning code, using the lexicographic ordering, for the polyhedron defined by (in PolyLib notation):
##########################
#  >= c1 c2 c3  i  j  N  1
##########################
    1  0  0  0  1  0  0  0
    1  0  0  0 -1  0  1  0
    1  0  0  0  1  1  0  0 
    1  0  0  0  0 -1  1  0
    0 -1  0  0  1  0  0  0 
    0  0 -1  0  0  0  0  1
    0  0  0 -1  0  1  0  0