Loop Parallelization Analysis and Optimization for Better Code Quality
70 likes | 89 Views
Understanding data dependence, relevance of loop parallelization, optimizing memory hierarchy, transforming code without altering semantics. Investigation into loop parallelizability and dependence analysis in program transformation.
Loop Parallelization Analysis and Optimization for Better Code Quality
E N D
Presentation Transcript
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
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
Data Dependence • Statement S2 is dependent on S1 iff • 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
Example S1: a = 3.14 S2: b = 5.0 S3: c = a * b * b S1 S2 S3
Example S1: a = 3.14 S2: b = 5.0 S3: c = a * b * b S4: b = a * c S1 S2 S3 S4
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?
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 isthe value of all index variables for outerloop(s) for a particular iteration of innermost loop • Iteration space is set of all possible iteration vectors for a statement