Polyhedral Compilation Foundations

888.11 seminars, part III




[<< home] [Lab 1] [Lab 2] [Lab 3]

Lab 1: Computing the data set



Assignment for next week

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


Exercise 1

You must first install iscc, that you can find in the Barvinok package.

For the following code, write the ISCC program in order to:

  1. Represent the iteration domain of the statement.
  2. Represent the data space of the program, for each array.
  3. Count the number of points in the iteration domain.
  4. Count the number of points in the data space.
  5. Generate code to scan the iteration domain.
  6. Generate code to scan the data space of the array A.

for (i = 0; i < N; ++i)
  for (j = 0; j < N; ++j)
    for (k = 0; k < N; ++k)
      C[i][j] += A[i][k] * B[k][j];




Lab 2: Tiling and other transformations with ISCC



Assignment for next week

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


Exercise 1

Write an algorithm that creates automatically the (sequence of) transformations, in the form of a scattering function, to tile a loop nest of a given depth. The algorithm takes as an input (1) the number of loops d in a perfectly nested, permutable loop nest; (2) a tile size (scalar) s; and (3) a scattering function that maps some input space into a 2d+1 output space.



Exercise 2

Apply the algorithm of the previous exercise to compute the tiling transformation for matrix-multiply, where the input scattering permutes the loops i and k.

for (i = 0; i < N; ++i)
  for (j = 0; j < N; ++j)
    for (k = 0; k < N; ++k)
      C[i][j] += A[i][k] * B[k][j];




Lab 3: Communication generation



Assignment for next week

Note: students will present their solution for the exercises on the computer during the class.


Exercise 1

Write the algorithm(s) to automatically create and place communications from main memory to a local buffer, for a program that is perfectly nested and contains only permutable loops. The program has to be tiled by your algorithm, and the communications must be at the granularity of a tile (that is, all elements required by a tile are copied before a tile executes).

Your algorithm must:



Exercise 2

Apply the algorithm of the previous exercise to tile and compute communications for matrix-multiply.

for (i = 0; i < N; ++i)
  for (j = 0; j < N; ++j)
    for (k = 0; k < N; ++k)
      C[i][j] += A[i][k] * B[k][j];


Exercise 3

Apply the algorithm of the previous exercise to tile and compute communications for jacobi-1d. A pre-transformation is required to make tiling legal: { s1[t,i] -> [t,2t+i,0]; s2[t,i] -> [t, 2t+i+1, 1]}.

for (t = 0; t < tsteps; t++)
  {
    for (i = 1; i < n - 1; i++)
	B[i] = 0.33333 * (A[i-1] + A[i] + A[i + 1]);
    for (i = 1; i < n - 1; i++)
	A[i] = B[i];
  }