Sale!

# Assignment 8 – Dependencies

\$30.00

Category:
Rate this product

CS314
Assignment 8
Problem 1 – Dependencies
Suppose we have the following program (a sequence of instructions), with each instruction labeled as
S<num:
S1 : a := 4;
S2 : b := 2;
S3 : c := 5;
S4 : read ( d );
S5 : a := b + 3;
S6 : b := a – 3;
S7 : c := d * b ;
S8 : e := a + 6;
S9 : print ( c );
S10 : print ( e );
(a) Give the statement-level dependence graph for the above program. A node in the statement-level
dependence graph represents a statement, an edge represents dependence between the statements
(i.e. the nodes). Label each edge as a true data dependence, an anti data dependence, or an
output data dependence.
(b) Assume that each statement takes 1 cycle to execute. What is the execution time of the sequential code? What is the fastest parallel execution time of the program (i.e. the critical path)?
You may assume that I/O operations (read and print) can be done in parallel.
Problem 2 – Dependence Analysis
Give the source and sink references, the type (whether a dependence is true, anti, or output), and
the distance vectors for all dependences in the following loops.
(a) do i = 3, 100
a(i) = a(i – 1) + a(i + 1) – a(i – 2)
enddo
(b) do i = 2, 100
a(3 * i) = a(3 * i – 3) + a(3 * i + 3)
enddo
(c) do i = 1, 10
a(i) = a(5) + a(i)
enddo
Use aW (i) and aR(i) to annotate the write access to a(i) and the read access to a(i) respectively.
Problem 3 – Loop Parallelization
Given the following nested loop:
1
do i = 2 , 100
do j = 2 , 100
S1 : a (i , j ) = b ( i – 1 , j – 1) + 2
S2 : b (i , j ) = i + j – 1
enddo
enddo
(a) Give the statement-level dependence graph. Show the dependence graph for statement instances
in a part of the iteration space: i = 2 … 5, j = 2 … 5.
(b) In its current form, can any loop be parallelized? If so, which loop(s)? If not, justify your