Nonlinear and Symbolic Data Dependence Testing Presented by Chen-Yong Cher William Blume, Rudolf Eigenmann
Background 80s-90s Benerjee, Omega 80s-90s Benerjee, Omega Can’t handle symbolic and non-linear expr Can’t handle symbolic and non-linear expr Example: Example: i 3, i 2, c*i where c not a known constant i 3, i 2, c*i where c not a known constant Often arise after compiler transformations Often arise after compiler transformations Range Test (1998) Range Test (1998) Check if certain symbolic inequalities hold Check if certain symbolic inequalities hold
Range Test – high level view Disproves Dependences Disproves Dependences No dependence if from iteration i to i+1 No dependence if from iteration i to i+1 Range (i) not overlap Range(i+1) Range (i) not overlap Range(i+1) No overlap if No overlap if max(range(i)) < min(range(i+1)) max(range(i)) < min(range(i+1)) Key: able to evaluate inqualities symbolically Key: able to evaluate inqualities symbolically
Examples 0 2n4n 0 2n n 3n4n5n6n 0 n2n f(*,*) g(*,*) f(0,*)f(1,*)f(2,*)g(0,*)g(1,*)g(2,*) f(0,1)f(1,1)g(0,1)g(1,1) Case 1 : Disprove independence by Theorem 1 Case 2 : Disprove by Theorem 2 or Theorem 3 Case 3 : Reduced to case 1 or 2 through permutation Array subscript for i for j A[f(i,j)] = … = A[g(i,j)]
Theorem 1 If f j max (i 1, … i j ) < g j min (i 1,…,i j ) for all (i 1,…,i j ) € R j, then there’s no dependence 0 f(i1,…,ij) g(i1,…,ij) max min
Theorem 2 If g j min (i 1,…,i j ) is monotonically non-decreasing for i j and If f j max (i 1, … i j ) < g j min (i 1,…,i j +stride j ) for all (i 1,…,i j ) € R j, and lower j <= i j <= upper j – stride j then there’s no dependence Note: Need to apply for f->g and g->f
Theorem 3 If g j min (i 1,…,i j ) is monotonically non-increasing for i j and If f j max (i 1, … i j ) < g j min (i 1,…,i j -stride j ) for all (i 1,…,i j ) € R j, and Lower j + stride j <= i j <= upper j then there’s no dependence Note: Need to apply for f->g and g->f
Permuting Loops for Testing For Case 3, all 3 theorems fail For Case 3, all 3 theorems fail Permute loops to reduce to case 1 or 2 Permute loops to reduce to case 1 or 2 Does not try all possible permutations Does not try all possible permutations Tries to move loop inwards Tries to move loop inwards Make range continuous Make range continuous
Algorithm Refer to paper Refer to paperpaper
Generalizing the Range Test Multidimentional arrays Multidimentional arrays Negetive strides Negetive strides Loop-variant variables Loop-variant variables Not perfectly nested loops Not perfectly nested loops
Symbolic Range Propagation Collect and propagate symbolic ranges Collect and propagate symbolic ranges 2 parts 2 parts Range propagation algorithm Range propagation algorithm Symbolic expression comparison facility Symbolic expression comparison facility Example code segment Example code segment If (a<100) THEN {BODY (know a < 100)} Else if (a < 200) THEN { know a < 200) } {merge point, know a < 100}
Conclusions Identify parallel loops effectively Identify parallel loops effectively Handle non-linear, symbolic expressions Handle non-linear, symbolic expressions The only dependence test in Polaris The only dependence test in Polaris Parallelize Perfect as well as hand-written Parallelize Perfect as well as hand-written Acceptable execution time w/ memoization Acceptable execution time w/ memoization