Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dependence Analysis Important and difficult

Similar presentations


Presentation on theme: "Dependence Analysis Important and difficult"— Presentation transcript:

1 Dependence Analysis Important and difficult
Parallelize Optimize memory hierarchy Loop --- and non-loops ? Application to program transformation Should yield “better” code Should NOT alter code semantics atof( ) - converts the "character string" pointed to by nptr to a double and returns its value atol( ) - converts the "character string" pointed to by str to a long and returns its value atoi( ) - converts the "character string" pointed to by str to an int

2 Which Loop(s) Parallelizable ?
1) Do I = 1, n A[I] = 5 * B[I] + A[I] Enddo 2) Do I = 1, n A[I-1] = 5 * B[I] + A[I] Enddo 3) Do I = 1, n temp = 5 * B[I] A[I] = temp Enddo 4) Do I = 1, n A[I+1] = 5 * B[I] + A[I] Enddo

3 Data Dependence Statement S2 is dependent on S1 iff Dependence “types”
S2 follows S1 in execution S2, S1 access same memory location, M One of S2 or S1 write to M Dependence “types” True (or flow) -- S2 reads M set by S1 Anti- -- S2 writes M read by S1 Output -- S1 and S2 write M Dependence Graph

4 Example S1: a = 3.14 S2: b = 5.0 S3: c = a * b * b S1 S2 S3

5 Example S1: a = 3.14 S1 S2 S2: b = 5.0 S3: c = a * b * b S4: b = a * c

6 Program Order, Dependence
Sequential order of imperative programs is too restrictive Partial order of dependences needed to ensure “correctness” Reordering transformations should not violate dependence Can we always determine dependence?

7 Dependence in Loops Parameterize stmts by loop iterations
Loop nesting level: number of surrounding loops + 1 Iteration number: value of iteration (index) variable Iteration vector, I, of loop is the value of all index variables for outer loop(s) for a particular iteration of innermost loop Iteration space is set of all possible iteration vectors for a statement


Download ppt "Dependence Analysis Important and difficult"

Similar presentations


Ads by Google