270 likes | 481 Views
Data Dependence Test. 2006. 5. 15 2006-21165 김용주. Introduction. What is data dependence? independent dependent Why is it important?. for i = 1 to 10 do a[i] = a[i+10]+3 endfor. for i = 1 to 10 do a[i] = a[i+1]+3 endfor. Difficult of dependence test. Problem definition
E N D
Data Dependence Test 2006. 5. 15 2006-21165 김용주
Introduction • What is data dependence? independent dependent • Why is it important? for i = 1 to 10 do a[i] = a[i+10]+3 endfor for i = 1 to 10 do a[i] = a[i+1]+3 endfor
Difficult of dependence test • Problem definition for i1 L1 to U1 do for i2 = L2(i1) to U2(i1) do … for in = Ln(i1,…in-1) to Un(i1,. . . ,in-1) do … x[f1(i1,…,in)] …[fn(i1,…,in)] = … … = x[g1(i1,…,in)] …[gn(i1,…,in)] … endfor endfor … end for The two reference are dependence iff there exist integer i1,…in i’1,…,i’n s.t. f1(i1,…,in) = g1(i’1,…,i’n), … , fn(i1,…,in) = gn(I’1,…,I’n) L1 ≤ i1, I’1 ≤ U1 … Ln(i1,…in-1) ≤ in, i’n ≤ Un(I1,…,in-1) It’s Integer programming!!
Integer programming • IP is known to be NP-Complete The most efficient algorithm are order O(nO(n)) • Subscript expression in real program is usually simple • There are several tests for special case. • Some tests prove only independent
Dependence tests • GCD test • Extended GCD test • SIV test • Single variable per constraint test • Acyclic test • Simple Loop Residue test • Fourier-Motzkin test • Omega test • Delta test • Power test • Constraint-Matrix test
GCD test • Condition for i1 L1 to U1 do for i2 = L2(i1) to U2(i1) do … for in = Ln(i1,…in-1) to Un(i1,. . . ,in-1) do … … x[a0+a1*i1+…+an*in] … … x[b0+b1*i1+…+bn*in] … … endfor endfor … end for
GCD test If, for at least one subscript position a0 + aj*ij = b0 +bj*i’j gcd( sep(aj,bj,j)) not divide (aj– bj) where sep(a,b,j) is defined by sep(a,b,j) = {a-b} if direction j is = {a,b} otherwise then two references are independent
for i =1 to 4 b[i] = a[3*i-5] + 2 a[2*i+1] = 1.0/2 endfor gcd(3-2) | (-5-1+3-2) -> dependence gcd(3,2) | (-5-1+3-2) -> dependence for i =1 to 4 b[i] = a[4*i] + 2 a[2*i+1] = 1.0/2 endfor gcd(4,2) | (-1 + 4 -2) -> independence GCD test - example
Extended GCD test • Extended GCD is extended to multi-demensional array. • It is not exact, but it allows us to transform our problem into a simpler and smaller form. • Matrix-multiplication is used.
SIV test(strong SIV) • Condition if it has the form<a*i+b1, a*i’+b2> (it is called strong SIV) • Dependence exist if 1. a=0 and b1=b2, or 2. (b1-b2)/a ≤ U-L
SIV test(strong SIV) - example for i = 1 to 15 a[3i+45] = a[3i] + c endfor (b1-b2)/a = 45/3 = 15 U – L = 14 15 > 14 -> independence for i = 1 to 15 a[3i+15] = a[3i] + c endfor (b1-b2)/a = 15/3 = 5 U – L = 14 5 < 14 -> dependence
SIV test(weak SIV) • Condition if it has the form<a1*i+b1, a2*i’+b2> (it is called weak SIV)
SIV test(weak-zero SIV) • If a1 = 0 or a2 = 0 then, it is called a weak-zero SIV subscript. • Dependence equation: i = (b2 – b1) / a1 (where a2 = 0) If i is an integer and within the loop bounds, it is dependence.
SIV test(weak-cross SIV) • If a1 = -a2 then, it is called a weak-cross SIV subscript. • Dependence equation: i = (b2 – b1) / 2a1 If i is an integer and within the loop bounds, it is dependence.
Single variable per constraint test • Condition Every Constraint is of the formLi ≤ ti ≤ Ui • If after go through all the constraints, Li ≥Ui , then it is independent. Otherwise, it is dependent
Single variable per constraint test (ex) 1 ≤ i ≤ 10 1 ≤ j ≤ 10 11 ≤ j+10 ≤ 20 10 ≤ i+9 ≤ 19 L > U ∴ independence for i = 1 to 10 for j = 1 to 10 a[i][j] = a[j+10][i+9] endfor endfor
Acyclic test • Condition at least one constraint has more than one variable. • Scheme 1. Express constraint as ai*ti ≤ … + aj*tj 2. Drag a graph if ai > 0 and aj > 0 then i to j if ai > 0 and aj < 0 then i to -j if ai < 0 and aj < 0 then -i to -j if ai < 0 and aj > 0 then -i to j If there is no cycle, there exist a node i s.t. there are no edge entering node i
Acyclic test 3. All constraint involving ti are of form ai,1ti ≤ f1(t) ai,2ti ≤ f2(t) … ai,nti ≤ fn(t) where f(t) is a linear 4. Setting ti to Li (if initial node is –ti then ti, set ti to Ui) Continue until we reach a contradiction, or until no variables are left. If all the variable are eliminated, then the system is dependent
Acyclic test - example t2 can be set L2 (=1) t1 can be set. Set t1 toL1 = 1 ∴ There are no contradiction => dependent 1 ≤ t1,t2 ≤ 10 1 ≤ t3 ≤ 4 t2 ≤ t1 t1 ≤ t3 + 4 1 ≤ t1 ≤ 10 1 ≤ t3 ≤ 4 1 ≤ t1 t1 ≤ t3 + 4 0 ≤ t3 ≤ 4 t3 ≥ -3
Simple Loop Residue Test • Condition The graph has a cycle. All constraints are of the form ti ≤ tj + c • Directed arc with value c from ti to tj (When ti < c, make n0 node, and direct arc with value c from ti to n0) (When ati ≤ atj + c, change c and divide by a) • Check every cycle in the graph • If any cycle has a negative value, the system is independent.
Simple Loop Residue Test-example 1 ≤ t1, t2 ≤ 10 0 ≤ t3 ≤ 4 t2 ≤ t1 2t1 ≤ 2t3 – 7 => t1 ≤ t3 - 4 t0 4 -1 -1 -4 +4 = -1 ⇒ independent 0 10 t1 t3 -4 -1 10 0 t2
Fourier Motzkin Test • Condition It is exact at some special condition. • Scheme 1. Eliminate variables one by one (reduction) 2. For such a variable, find lower, upper bound 3. Eliminate the variable, by safely combine If there is contradiction, then the system is independent.
Fourier Motzkin Test-example(1/2) x + y ≥ 16 (1) 4x + 7y ≤ 28 (2) 3x-7y ≤ 20 (3) 2x-3y ≥ -9 (4) rearrange x ≥ 16-y x ≤ 7 - (7/4) y x ≤ 10 + (7/2) y x ≥ -9/2 + (3/2) y 16-y ≤ x ≤ 7 - (7/4) y 16-y ≤ x ≤ 10 + (7/2) y -9/2 + (3/2) y ≤ x ≤ 7 - (7/4) y -9/2 + (3/2) y ≤ x ≤ 10 + (7/2) y 16-y ≤ 7 - (7/4) y 16-y ≤ 10 + (7/2) y -9/2 + (3/2) y ≤ 7 - (7/4) y -9/2 + (3/2) y ≤ 10 + (7/2) y eliminate x
Fourier Motzkin Test-example(2/2) y ≤ -36 y ≥ 4/3 y ≤ 46/13 y ≥ -29/4 4/3 ≤ y ≤ -36 4/3 ≤ y ≤ 46/13 -29/4 ≤ y ≤ -36 -29/4 ≤ y ≤ 46/13 eliminate y 4/3 ≤ -36 4/3 ≤ 46/13 -29/4 ≤ -36 -29/4 ≤ 46/13 4/3 ≤ -36 and -29/4 ≤ -36 is contradiction ⇒ independent
Omega test • For arbitrary set of linear equalities and inequalities. • based on an extension of Fourier-Motzkin test • Average time complexity is Fast in practice • Exact Test
Wrap • Important problem • Difficult problem • Many kinds of dependence test