Questions: Data Dependence Analysis

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

Consider this code fragment: (1) x = a + b; (2) y = x * 2; (3) x = c - d. What type of dependence exists between instruction (2) and instruction (3)?

ATrue dependence: instruction (3) reads a value written by instruction (2)
BAnti-dependence (write-after-read): instruction (2) reads x before instruction (3) writes x
COutput dependence (write-after-write): both instructions write to the same variable
DNo dependence: instructions (2) and (3) use different variables
Question 2 Multiple Choice

A compiler wants to parallelize the loop: for (i=0; i<n; i++) { a[i] = a[i-1] + 1; }. Which statement is correct?

AThe loop can be fully parallelized because each iteration writes to a different array element
BThe loop has a loop-carried true dependence: iteration i reads a[i-1] which was written by iteration i-1
CThe loop has only an anti-dependence, which can be eliminated by renaming
DThe loop can be parallelized after applying register renaming to the array accesses
Question 3 True / False

Anti-dependencies (write-after-read) and output dependencies (write-after-write) can potentially be eliminated by renaming variables or registers, whereas true dependencies (read-after-write) cannot.

TTrue
FFalse
Question 4 True / False

A true dependence between two instructions is a conservative approximation: the compiler may identify a true dependence even when the instructions could safely be reordered.

TTrue
FFalse
Question 5 Short Answer

Explain why anti-dependencies and output dependencies are called 'name dependencies,' and describe one technique compilers use to eliminate them.

Think about your answer, then reveal below.