Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CS 698L Assignment 2 for Semester 2019–2020-I, Assignments of Compilers

Information about an assignment for a computer science course (cs 698l) in the semester 2019–2020-i. The assignment includes four problems with instructions, data dependences, and expected outcomes. Students are required to write code for various loop unrolling, permutations, and tiling, as well as identify data dependences.

Typology: Assignments

2019/2020

Uploaded on 10/13/2020

Muzafarwani28
Muzafarwani28 🇮🇳

4 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 698L Semester 2019–2020-I: Assignment 2
23rd August 2019
Due Your assignment is due by Sep 1 2019 11:59 PM IST.
General Policies
You should do this assignment ALONE.
Do not plagiarize or turn in solutions from other sources. You will be PEN AL IZ ED if caught.
We MAY check your submission(s) with plagiarism checkers.
Submission
Submission will be through Canvas.
Submit a PDF file with name “<roll-no>.pdf”. You are encouraged to use L
A
T
E
X typesetting system
for generating the PDF file.
Submitting your assignments late will mean losing points automatically. You will lose 10% for each
day that you miss, for up to three days.
For late submissions, email your submission to the instructor.
Problem 1 [10 points]
Consider the following code:
for i = 1, N-2
for j = i+1, i+N-2
A(i, i-j) = A(i, i-j-1) - A(i+1, i-j) + A(i-1, i-j-1)
List all flow, anti, and output dependences, if any.
Problem 2 [70 points]
Consider the following code:
int i, j, t;
for (t = 0; t < 1024; t++) {
for (i = 0; i < 1024; i++) {
for (j = 1; j < 2048 - i; j++) {
S(t, i, j);
}
}
}
The data dependences for the loop are given to be (0,1,-1), (0,0,1), and (1,-1,0).
(a) Which loops, if any, are valid to unroll? Why?
1
pf3

Partial preview of the text

Download CS 698L Assignment 2 for Semester 2019–2020-I and more Assignments Compilers in PDF only on Docsity!

CS 698L Semester 2019–2020-I: Assignment 2

rd

August 2019

Due Your assignment is due by Sep 1 2019 11:59 PM IST.

General Policies

  • You should do this assignment ALONE.
  • Do not plagiarize or turn in solutions from other sources. You will be PENALIZED if caught.
  • We MAY check your submission(s) with plagiarism checkers.

Submission

  • Submission will be through Canvas.
  • Submit a PDF file with name “<roll-no>.pdf”. You are encouraged to use LATEX typesetting system for generating the PDF file.
  • Submitting your assignments late will mean losing points automatically. You will lose 10% for each day that you miss, for up to three days.
  • For late submissions, email your submission to the instructor.

Problem 1 [10 points]

Consider the following code:

for i = 1, N- for j = i+1, i+N- A(i, i-j) = A(i, i-j-1) - A(i+1, i-j) + A(i-1, i-j-1)

List all flow, anti, and output dependences, if any.

Problem 2 [70 points]

Consider the following code:

int i, j, t; for (t = 0; t < 1024; t++) { for (i = 0; i < 1024; i++) { for (j = 1; j < 2048 - i; j++) { S(t, i, j); } } }

The data dependences for the loop are given to be (0,1,-1), (0,0,1), and (1,-1,0).

(a) Which loops, if any, are valid to unroll? Why?

(b) What are valid permutations of the loop? Why?

(c) What tiling is valid, if any?

(d) Show valid code for the tji permutation of the loop. For this part and the next one, assume all permutations are valid.

(e) Show a 2-way i-unrolled form (i.e., unroll-jam) for the tij form.

Problem 3 [70 points]

Consider the following code: int i, j, t, k; for (t = 0; t < 1024; t++) { for (i = t; i < 1024; i++) { for (j = t; j < i; j++) { for (k = 1; k < j; k++) { S(t, i, j, k); } } } }

The data dependences for the loop are given to be (1,0,-1,1), (1,-1,0,1), and (0,1,0,-1).

(a) Which loops, if any, are valid to unroll? Why?

(b) What are valid permutations of the loop? Why?

(c) What tiling is valid, if any?

(d) Which loops, if any, are parallel?

(e) Show code for the tikj form of the code. For this part, ignore the above dependences and assume tikj permutation is allowed.

Problem 4 [50 points]

Consider the following code: #define N 1024 double A[N][N]; int t,i,j; for (t = 0; t < N; t++) { for (i = 1; i < N-1; i++) { for (j = 1; j < N-1; j++) { A[i][j] = 0.2*(A[i-1][j] + A[i][j] + A[i+1][j] + A[i][j-1] + A[i][j+1]); } } }

(a) List all data dependences, stating the kind of dependence and the distance vector.