Digitized by the Internet Archive in 2013 http://archive.org/details/datadependencein837bane u> » ~r Report No. UIUCDCS-R-76-837 73 J NSF-0CA-MCS73-07980 A03-000025 ) 2- DATA DEPENDENCE IN ORDINARY PROGRAMS by UTPAL BANERJEE November 1976 DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN URBANA, ILLINOIS The Library of the University 01 Illinois * Urbana-Charn w Report No. UIUCDCS-R-76-837 DATA DEPENDENCE IN ORDINARY PROGRAMS by UTPAL BANERJEE November 1976 Department of Computer Science University of Illinois at Urbana-Champaign Urbana, Illinois 61801 This work was supported in part by the National Science Foundation under Grant No. US NSF-MCS73-07980 A03 and was submitted in partial fulfillment of the requirements for the degree of Master of Science in Computer Science, November 1976. Ill ACKNOWLEDGMENT I would like to thank my thesis advisor, Professor David Kuck, for his valuable advice, my wife, Aloka, for her infinite patience, and my colleague, Michael Wolfe, for his great help in debugging the PL/ 1 program in the thesis. IV TABLE OF CONTENTS Page 1. . INTRODUCTION 1 2. PRELIMINARIES 3 2.1 Definitions 3 2.2 Lemma 3 2.3 Lemma 4 2.4 Definitions 5 2.5 Definitions 5 3. THE MAIN RESULT 7 3.1 Theorem 10 3.2 Example 14 3.3 Example 18 3.4 Remarks 21 3.5 Extensions 24 4. THE LINEAR CASE 27 4.1 Theorem 27 4.2 Example : 30 4.3 Theorem 31 4.4 Example 35 4.5 Remarks 37 LIST OF REFERENCES 38 APPENDIX 39 m s no e 1. INTRODUCTION In recent times much effort has been spent in the search for narallelism in existing nrop-rams. Here, the con- cent of data dependence plays a very special role. T he ai or this thesis is to study conditions under which there i dependence between two assignment statements inside an TV_f re loon in a language like Fortran. In our basic model, we deal with array variables coming from a one-dimensional array and let the subscripts be arbitrary polynomials In the index var- iables. Generalization to multi-dimensional arrays noses no additional problems. In section 2 we establish our notation and e-ive some useful definitions and lemmas. Our main result (Theorem 3.1) alonr with some examples, remarks, and possible extensions is riven in section 3. Finally, section * is devoted to a detailed study of the very important special case where the subscripts are linear functions. So far, no work has been done in the non-linear case, not even in the linear case with more than two index variables. Cohagan [1] and Towle ([5], ch. 5) have considered the linear case when the number of variables is restricted to one or two. Towle rives a very large set of necessary conditions in the two-variable case, and a complicated program based on that set. Prom the nractical noint of view, it would be extremely difficult to extend his oroP-ram to the linear case of three or more var- iables. And It can not be extended to the non-linear case at all. 2 The necessary conditions we have obtained are valid in thl general non-linear case with an arbitrary number of index variable: . They are also shown to be sufficient in a snecial linear case (Theorem *J . 3 ) that occurs frequently in nractice. Five a short and simnle nrorram (based on those conditions) that wor for the reneral linear case with any number of variables, (See the Anoendix.) And this oropxam can be easilv extended to the non-linear case with onlv minor modifications. f "ore comments on the results of Ooharan and ,p owle are civen at the end o r section >\ . 2. PRELIMINARIES 2.1 Definitions Let r denote a real number. (1) We define Lr I to be the greatest integer not greater than r. For example, [3 J = 3, 1.3. 9J = 3, and L-3.9J = -4. (2) The positive nart r and the negative part r~" of r are ^ivon by r + = (!r| + r)/2 and r" = (Irl - r)/2. The basic nronerties of r and r~ are summarized .1 n the followinp tv/o lemmas. 2 . 2 Lemma For any real number r, (1) r + _> 0, r~ _> 0; (2) if r _> then r = r and r" = 0; (3) if r <_ then r = -r~ and r + = 0; (4) r = r + - r"; (5) (-r) + = r*, (-r)" = r + ; (6) (r + ) + = r + , (r + )~ = 0, (r~) + = r", (r - ) - = Proof. The proof follows directly from the deflnltior . 2.3 Lemma Let r,s,z denote real numbers. Tf r i <_ z <_ s then + -r s < rz < r s . + In oarticular, -r <_ r <_ r . Proof. If r >_ 0, then <_ rz <_ rs and r = r + , f" = 0, so that + -r s < rz < r s. and so that If r <_ 0, then rs < rz < + r = -r , r = 0, + -r s < rz < r s. Q . E . D ^hese two lemmas will be frenuently used without always beinn; exnlicitly mentioned. 2.4 Definitions Let y denote a vector (y,, Vp,,.., y ) where y, , y ni .... y are all integer variables. 1 d ' m (1) For any positive integer L we define a vector y by Li y L (2) A product term (or simply, a term ) in y 1s an expression of the form l l l 2 £ m • 1 ' y 2 ,y m where £ , L.,,,. I are non-negative integer constants. 1 d m If for some r, £ > then we say that the term contains the » r J variable y . The degree of the term is the . non-negative in- ' r ■ teger (I. + l„ + ... + i ). (The term with degree is the 12 171 constant 1. ) (3) A polynomial in y is a finite sum of the form y a k P k (v")> where for each k, a R is an integer constant K and P. (7) a nroduct term in y. The degree of this noly- K. nomial is the largest of the degrees of all the product terms P k (y) such that a k * 0. 2.5 Definitions An assignment statement S is a statement of the form 6 Z = R, where 7. Is a scalar or array var^ -1 formed arithmatic expression. Z is cai: e output variable of S and is denoted by OUT(S). Any variable occurrlr r is an input variable of S, and the set of all input var- iables of S is denoted by IN(S). If S and S« are two assignment statements such that S is executed before r, ?i then we write Sj < ^ ? . Finally, we have the followinr convention. Any sum of the form *T ( ) where 1s the empty set, or of the m form V ( ) where M >m, is identically enual to 0. I k=M 3. THE MAIN RESULT We turn now to the problem of data dependence. Con- sider a program segment of the following type: DO 5 I 1 a 0, n 1 DO 5 Ip ■ 0, n 2 DO 5 I = 0, n s 1 (T) s 2 (T) s N (D 5 CONTINUE, where n>, n„,..., n are positive integers, T = (I-., I?'*'** * ^» and S , S ,..., S„ are assignment statements. Take any two statements S and S (1 < n, q < N). Let X(f(T)) denote d q — — a variable of S and X(g(T)) a variable of S , where X is P <1 a one-dimensional array and f, g are integer valued functions (such that the variables are well defined). Three different types of dependence of X(g(I)) on X(f(I)) may arise corresponding to the following three possib- ilities : % (1) x(f(T)) ■ OIJT(S ), X(pr(i)) e II (2) X(f(T)) e IN(S ), X(r(D) = OUT-L (a + c~ k,E < a k + C Lk> W> ''J for some positive integer L such that Tm+1 if p_ a Proof Assume that X(f(I)) A X(p;(I)). Then there must exist two values 11 and i « (i , i 2 ,..., i m ) .1 vJ-ij J 2 * • • • * ^m of I such that (1) S p (i) < S (J), and (2) f(i) = K (J). Now (1) implies that there exists a positive integer L such that m if p > q; W i r = J r , 1 < r < L * 1 (if L > 1); and (5) i L - ,1 L " - 1 (if L £ m )- Usinp; the exoressions for f and p; we pet from (2) that (6) 3 - a = ^ a k P k (i) " I b k P k ( < 1} • keE kcE This implies condition (A) of the theorem. In order to derive condition (B) we oroceed as follows. hynotl I \ V T) " ^,, + I e Lk V keF 12 Mence, (6) can be written as (7) 3 or as - « = -y l + 1 1\ v*> - c L k yv ] keF (8) 6 - a = -y L + £ [a k P k (D - C Lk P k (J L )] keE LI + ^ [a k P k (i) " °T,k W 1 keF. L2 + > ^ \ (i) " C Lk W 3 :eE L3 Now three cases arise. Case (i) 1 1 ' 2'** 3 1 , J 2 » ' ' Let k e E . Then P k U) is a function of . , i T , alone and p . (T T ) is a function of ' L-l k L j T n alone. Therefore, (4) imnlies that lj™" A. P k (1) " W' lence, _ _ a k P k (i) " C Lk W (a k - C Lk } W 13 < (a k - c LR ) p k ( n L ) fe y Lemma 2.3, since < P k (,1 L ) £ p k ^ n L ) - Case (ii) Let k e E-p. We can write P k (T) . Q R (I) R k (I L ), where (I) is a product term in I containing none of j -t > It.u.i.j I , and R. (I T ) is a power of I T . L' L+l m' k L r L Since \(i) = Q k ( J~L ; ' We get a k V T > = a k Q k (i) R k (i L ) = a k VV W 1 a k Q k (T L ) R k U L - 1) by Lemnma 2.3, since < VT L > W * Vl 5 V 3 L" ^ W i (a k " C LK ,+ W' slnce ° i W i v H ■ case (iii) Let k e E, ,. We have a k p k (1) " c Lk \ { h> i a k P k<"L> + °Zk P k (E L>- since < P k (D, P k (J L ) £ V"^' = (a k + <=Zk> W- The second part of condition (B) now follows fron (8) if we use the inequalities in all three cases. To ret the first part, multiply (8) by -1 and oroceed as before. This completes the proof of the theorem. O.F..D For any Riven polynomial functions f and g, we must first find the constants y T . c T , and the sets E T , , L' Lk LI' E T p, E_ » before we can test for data dependence. Consider the followinr examoles. 3.2 Examnle Consider the following program: 15 DO 5 I 1 - 0, n x DO 5 I = o, n. S d : X(a + a 2 l ? ) = R S : X(3 + b 1 i l + b^i^) = r 2 5 CONTINUE. Suppose that we want to test for dependence of the output variable of S on the output variable of S . n p Here n = 2, and f(I) and p(T) are polynomials in J of decrees 1 and 2 respectively. We can take E = {1, 2, 3, 4, c ^} and P 1 (T) = l lf P 2 (D = i 2 , P 3 CT) = ij > V X) = l 1 l 2 > V T) = x 2 Then a n = a = a,, = a,- = b = b n = b r = 0. There are three 13 4 b 2 3 5 oossible values of L: 1, 2, 3. Case (i) Since Let L = 1. Then I = I = (^ - 1, I ) b 1 I 1 + b 4 I x I 2 = b 1 + b 1 d 1 - 1) + b 4 i 2 .+ b i( (I 1 - di 2 , 16 we F,et Yt = b i » c n = b i» c io = h n> 1 1» 11 12 H C 13 = °» C l>\ = b H» C l^ = °* Also, E ia = 0, E 12 = (1, 3), E - {2, H, 5). case (11) Let L = 2. Then I. = I 2 = (I lf I 2 - 1). Since b 1 T 1 + b,!^ ■ < b i + V 1 ! + Vl (I 2 " 1) ' we eet Y 2 = 0, c 21 = b x + b i|} c 22 = 0, c 23 ~ ' °24 ~ 4' C 2S Als o, E 21 = (1, 3}, E 22 = (2, 4, 5>, E 23 = 0, Case (ill) Let L = 3. Then I L = I = (I I ). V, T e have Y 3 = °' C 31 = b l* ° 32 = °' c 33 ~ °' °3^ ~ b ^ a °35 ~ ° Also, E 31 = {1, 2, 3, 4, 5>, E 32 = , E 33 = 17 Corresponding to the three values 1, 2, 3 of L, the inequalities in condition (D) of Theorem 3.1 take the following three forms: (1) (L = 1) b~ - b, n, - a" n^ - b^ n -\ n 2 < B - a <_ - b + b~ n + a« rip + b^ run,,, (2) (L = 2) -(b 1 + b^) n 1 - a" (n - 1) - b 2| n 1 (n 2 - 1) < 3 - a <_ (b-j^ + b i4 )~n 1 + a ? (n 2 - 1) + b^ n.(n 2 - 1), (3) (L = 3) -b. n, - a ? n 2 - b^ n i n p < 6 - a < b, n, + a,, n~ + b7 ri.n~ — 11 2. 2. 4 12 Now sunoose that the variable X(3 + b I, + b^I-Ip) of statement S is dependent on the variable X(a + a I ) q f 2 2 of statement S . Then, (3 - a) must be divisible by the n;cd oT a~, b , b i( . Tf p < q, then one of (1), ' , ' • hold. Tf n > o, then one of (1) and (2) mm 3.3 Example Consider the followinr nrofram serment: DO 5 T 1 = 0, n 1 DO 5 I 2 - 0, n 2 S x : Z = X(p, - I* + 5lJ + 2I 1 I 2^ S 2 : X(« + I 1 - 3I 2 ) = R 5 CONTINUE Suppose that we want to test for dependence of the inout var- iable of S. on the output variable of S . 1 2 Here, m=2, p=2, q = 1 , f(I) = a + I 1 - 3I 2 , and «, P 7 (I) = IJI 2 , Pg(l) = I 1 I|, P g (l) = I|. Then, a, - 1, a g - -3, a 3 a i4 a 5 ^f, " a 7 ~ a 3 ~ °s a,, = a = a., = a r . = a,- = b 3 = ~ lj b 6 = 5 » b 8 = 2 ' b l = b 2 = b 4 = b 5 = b 7 = b 9 = °' Since p > q, there are only two possible values of L: 1, 2 Case (i) Let L = 1. Then I L - I. = (I- L - 1, I 2 ). Since - I? + 51? + !I,I 1 "~1 --1 = - [(I-l - 1) + l] 2 + 5[(I 1 - 1) + I] 3 + 2[(I 1 - 1) + 1]I 2 = i\ + 13(I 1 - 1) + 14(I 1 - l) 2 + 2I 2 + 5(I X - I) 3 + 2(1.. - 1)1* we n;et Tn = ^> On = 13, c, Q = 14, "11 J l6 = 2, c, A = 5, c lR = 2, 13 18 c 12 c l4 c 17 c 19 0. Also, K,, = 0, I ! 12 = (1, 3, 6), E 13 = {2, fc, 5, y, B, Case (ii) since Let L = 2. Then T. = T. = (I_, I- -1). L C id 2 1 2 = " J l + 5I 1 + 2I 1 [(I 2 " 1} + 1] .2 *1 = 21, - i, + 'a^ip - D + 51J + 2i 1 d 2 i) 2 , we ret Yp > ^21 ^2^ — c oh = ^» G o^ = 5, c o 2, 2^ 26 28 c 22 c 25 C 27 °29 °* A lso, E = (1, 3, 6), E 22 = {2, A, 5, 7, 8, 9>, E 23 = 0. Corresponding to the two values of L, the inequalities in condition (R) of Theorem 3.1 take the followinp two forms: (1) (L = 1) (2) 2 c 3 n l " 5n l 2 2n,n - 3n^ < 6 - a < -4, (L = 2) 3 + n 1 - 9n ? + 9n 2 - 5n? - 2n_ L n 2 - 3n^ < - a <_ n,, If the input variable of S. is dependent on the out- put variable of S ? , then by Theorem 3.1 either (1) or (2) must hold. 21 3.^1 Remarks (1) The conditions of Theorem 3.1 are not sufficient for data dependence in general. We show this by an example. Let m = 1, n 1 = 2, f(I) = 2I 1 , g(T)- H - 3I X . Since d Then 1 we can take E = {1} and P,(I) a = 0, a x = 2, (5-4, b 1 = = T. - 3. Let n > q. Then L = 1. Clearly, y 1 = -3, c n = -3, E 1n 0, E 10 (!}, E 13 = 0. 11 12 Condition (R) of Theorem 3.1 becomes x or, (a l + C ll )+(n l " 1) - 3 ~ a - " Y l + (a l " C ll^ ^ n l~ "^ 3-0 < ^ < 3 + 5 which is true. Condition (A) is also satisfied. However, two values i, , ,j of I can not be found such that and < 1 1 < ^ < 2 21., = H - 33 ± 22 Therefore, the variable '/.( <\ - 31.) dependent on the variable /.(?!) (2) Suppose for a moment that 1 ,..., i and .},,..., ' denote real variables, and define a real valued function P(i lf .... i m , .1^..., J m ) = V Ea k P y (T) - b k %(!)]. keE For a riven value of L, v/e consider a subset - P the Li 2n-dimensional Kuclidean space, defined by < i , ,1 < n ( 1 < r < m) , and the conditions ( ; , (5) in the proof o^ Theorem 3.1. Since D, is connact and connected and F is continuous, the image set F(D T ) is a finite closed interval. (T,ee Dieudonne' [2], m heorems 3.17.10 and 3.19.8.) Condition (B) of Theorem 3.1 is necessary and sufficient for (ft - a.) to lie in the interval F(D T ), i.e. for the existence of a "real" noint in D T at which the value of F is (B - a). (3) Suppose that condition (B) of Theorem 3.1 is satisfied for at least one value of L. Let L n be the largest value of L for which it is satisfied, and suppose that L~ <_ m. Then, there will be no data dependence if the index variables I,, T ,..., I are kept fixed at any set of permissible values . ( l \) The whole idea behind Theorem 3.1 is to ret the sharpest 23 possible bounds for (p - a) that can be directly obtained using the nroperties of the different terms in f(T) and g(T). Let us comnare the second inequality in condition (B) against two other inequalities that can be derived much more easily. From (6) in the Droof of Theorem 3.1, we get - « < ]T Ca* + b k ) P k (n). keK Let m = 1, f(I) ■ a + I,, and g(T) = 8 + -I-. Then, this will i^ive 3 - a < n. . But the second inequality in condition (B) gives - a <_ - 1 for L = 1 and B - a < for L = 2. From equation (7) in the nroof, we get 8 " n i " Y L + I (a k + c Zk> P k (n L ). keE The second inequality in condition (B) is clearly better than this. Because, for any two real numbers a and c we have (a - c) < (a -c) X (P(£-,..., *,»Tr\ ) ) 25 where a is defined below: aU,,..., *, JD ) = £\l\ ~ LB k ) k=l with '(UB k+1 - LB k+1 + 1) ... (UB ND - LB ND + 1) if k .< ND - 1 if K = ND. Thus Theoren 3.1 can be applied to multi dimensional arrays after they have been transformed this way. (3) Theorem 3.1 can be extended so that the statements S and S are not required to be within the same loon. n q Let us illustrate this bv the following examnle: DO 5 I 1 = 0, n. DO 5 I t = 0, n 1 S CONTINUE DO 7 I t+1 = 0, n t+ S q DO 7 I = 0. n 7 CONTINUE 26 Here, f Is a function of I,,..., I alone and r '-a function of I^.t,.... I alone. Equation (6) In the proof t + 1 ' m Theorem 3.1 holds, where 1 and j are now any two arl Ltn values of I. We ret the condition -X ( <\ + b k> p k ( "' i b - ° - T u t. + b k> p k (n_) keE keE which replaces condition (R). 27 4. THE LINEAR CASE In this section we assume that both f(T) and p 5 (T) are polynomials in I of degree 1. This is the most important special case that one encounters in practice. Our first theorem here is the linear version of Theorem 3.1. 4.1 Theorem Let m f(T) = « + y a k I k and m „(i) - u ♦ y b k i k where «, 3, the a's, and the b f s are all integer constants If X(f(I)) A X(g(T)), then (A) (8 - a) is divisible by the ";cd of all the a. ' s and the b. 's, 1 < k < m if this o;cd is not zero: k ' — — > ' and (B) L-l m -b L . y (a k - b k ) n R - (a" + b L ) (n L - 1)- (a!~ + b, )n, k k k y l k=?L+l < 8 - a L-l - - b L + fa k " b k )+n k + (a lt " b L ) + (n L - 1 ) + £ (a* ♦ bj)n, = 1 k=L+l for some oositive integer L such that L < m + 1 i r D < fl 2fl n if p > q . (For L = rn + 1, we define a, = b. = n, = 0.) Proof We will use the notation of section 3. Since d ■ 1, We can take and Case (i) 'hen = { 1 , 2 , . . . , rn } P k (I) = T k , 1 < k < m, Let 1 < L < m. Ej. - {1, 2,..., L - 1}, F, L2 = (L), E T _ = {L + 1, L + 2, . . . , m}. (If L = 1 then E T , * 0f. IP L = m then E T - = #. ) We have I keF m I L-l b k P k (I) b, I, k k m Zb, I, . + b T I T + V k k| l l ; K=l k=Wl b. I. k k - \ + £ m k k=l b, I. + b T (I r - 1) + V b. L k k L L / k k k=l+L 29 = b L + y \ W keE 'herefore, and \ ' \ c T1 = b, , k e E 'Lk k .*> case (ii) m hen Let L « m + 1. E L1 = E and E L2 = E L3 = 0. .Since I T = I, we q, then at least one of (1) - (3) must hold. A computer program that tests for data dependence usinr the conditions of Theorem 4.1 is riven in the Appendix. The example in Remark 3.4 (1) shows that the conditions of Theorem 4.1 are not sufficient in the peneral linear case. Fortunately, they are sufficient in a special linear case that occurs frequently in actual nroprams. This is shown by Theorem 4.3 4.3 Theorem Let m f(I) = a + t £ u k I k k=l m and r(D = 3 + tV v k I k , k=l where ct, 8, t are integer constants, t > 0, and u, , v, e {-1, 0, 1 • }, 1 _< k _< m. Then, X(f(D) 4X(g(!)) if and only if (A) t divides ( 8 - a) , and (B) L-l m Y (u k " v k r \ " {u l + v r/ (n L - 1} - ^ (u k + v k )n i k=l k=L+l u < (3 - a)/t L-l m < -v, + I (Ul " V\ + K " v l/ (n L- 1} + + 7 " k=l I for some positive integer L such that L < m+1 if n < n m if p > a (For L = n + 1, We define u T = v T = n, = 0.) ' L L Jj Proof Since the 'only if nart follows directly fron ^heorem 4.1, we need prove only the 'if part. Assume that the conditions (A) and (13) hold. Let (0 - cx)/t + v, > 0. (The negative case can be handled in an exactly similar way.) The second inequality in (B) imnlies that <_ (3 - ot)/t + V! L-l m 1 £ (u k- V +n k + (U L - V L ) + (n L " 1} + X ^ + ^ )rV k=l k = L+l Therefore, we can write m (1) (P - a)/t + v L = I v k=l where if (2) < h R <_ (K k " v k )+n k (u - v T ) (n T _ i) Cu * + V k )n k 1 < k <_ L - 1 L - -w if k = L if L + 1 < k < m. 33 Now, in order to show that X(f(I)) A X(g(I)), it will suffice if we can find two values i = (i n i ) 1' ■ rn and J = (J , . . . , ,1 ) of T such that (3) S (i) < S (j) v p o q and ('0 f(i) g(T). Substituting for f and g in (4) we get m m a + t r u k i k = B + t y v k J k m or Z [ - M i _ v, ,1, ] = (B - a)/t. k k k' k k^ k=l By virtue of (1), this is equivalent to m (5) I [ Vk " Vk ] + ^L 1 ! " V L ( ' 1 L " 1)]= I V k=l k^L k=l We will find i and J such that (5) and (3) are both satisfied. This will be done by picking suitable solutions to the individual equations (6) Vk - V k = h k ; 1 - k - m ' k * L; u T i- v, (j - 1) = h T (if L < m). We give below a table that lists these solutions. For any given k, detailed values of u, and v are considered only when k r h. j* 0. If h, = 0, then we always take the trivial solution. Remember that the range of h is given by (2). Range of k U k v k Ranpe of h k Equation Solution he •>k l1) 1 0 1); < i L < J L - 1 < n L - 1, (if L < m); < 1 k» J k - n k» L + x I k i m (if L K m )« 35 This means that i and j satisfy (3) and (4). Therefore, X(f(T)) A X(g(T)). Q.E.D Let us illustrate the application of Theorem 4.3 by an example. 4.4 Example Consider the following; program segment: DO 5 I 1 = 0, 10 DO 5 I ? = 0, 5 DO 5 I 3 = 0, 9 S x : X(13 + 6l 1 - 61 ) = R 1 Spt X(l + 61 - 6l 2 + 61 ') = R 2 5 CONTINUE. And suppose that we want to test for dependence of the output variable of S ? on the output variable of S, . Here we have m = 3, n i = 10 > n 2 = 5, n„ = 9, p = 1, q = 2, f(T) = 13 + 6I 1 - 6I 3 g(I) = 1 + 6l 1 - 6lp + 61-,. 36 f(T) and g(T) have the forms needed for a - 13, p - 1, t = 6, u 1 =1, u 2 = 0, u^ = -1, v x =1, v 2 = -1, v^ = 1. t divides (fl - a). And for L = 1, the inequalities in condition (13) of Theorem J l . 3 become " V l " ^ U l + V l^ ^ n l 1) - (u~ + v 2 )n 2 - (u~ + v^)n^ < (3 - «)/t <_ - v 1 + (u 1 - v^) (n 1 1) + (u 2 + v~)n 2 + (u_ + v ^)ru or, -28 < -2 < k which is true. Therefore, by Theorem H . 3 the outnut variable X(l + 61 - 6lp + 61-,) of statement S ? is denendent on the outnut variable X(13 + 61, - 6l_) of statement S, . Indeed, taking i = (0, 0, 0) and .1 = (1, 0, 1) , we see that S, (i) < S (.1) 1 o 2 and f(D = g(J). 37 4 . 5 Remarks We g-ive now some comments on the results of Cohap;an [1] and Towle ([51, ch. 5). Theorem 1 of Cohafran can be derived from Theorem 4.1. His Theorem. 2 and Lemmas 2.1, 2.2 follow immediately from well known results in the theory of Diophantine Equations. (See Mordell [4], ch. 5, Sec. 1.) Now consider Towle. Parts (1) and (3) of his Theorems 5.3 and 5.4 can be derived from our Theorem 4.1. However, part (2) of each of these two theorems is false. (Take n, = 10, p = 20, q = 4, a, = 1, b 2 = 2. Since 20 + = 4 + 2*8, there is data dependence. But (d - q)/(b - a, ) = 16 > n ) . His theorems 5.5 and 5.6 are contained in the nroof of our Theorem 3.1. Towle uses a theorem of I 7 an([3], Th . 10) on the inconsistency of a system of linear equations to derive a set of necessary conditions for data dependence. These con- ditions should be equivalent to the inequalities in (B) of Theorem 4.1, since both sets are (separately) necessary and sufficient for the existence of real solutions. However, these conditions are rather imnractical. Because, they are difficult to derive, and even in the two variable case with L = 1, there are 29 of these conditions for the sinple pair of inequalities in (B) of Theorem 4.1. (See Towle [5], Appendix B. ) 38 LIST OF RRPERENC [1] Coha^an, W.L., "Vector Ontimization for the A.': r ;", Proceedings of the Seventh Annual Princeton Conference on Information Sciences and Systems, 1973, nn. 169-174. [2] Dieudonne', J., "Foundations of Modern Analysis", Academic Press, .'Jew York, 1969. [3] Fan, K., "On Systems of Linear Inequalities", Anna. of Mathematics Studies, NO. 38, nn. 99-156, Princeton University Press, 1956. [4] Mordell, L.J., "Dionhantine Equations", Academic Press, New York, 1969. [5] Towle, R., "Control and Data Dependence for Program Transformations", Ph.D. Thesis, Denartment of Comnuter Science, University of Illinois at Urbana-Chamnaipn, Report 788, March - 1976. 39 APPENDIX Here we reive a PL/I program that tests for data dependence usinp: the conditions of Theorem ^.1. The innut to the program consists of the values of W, ALPHA, A, BETA, B, N, P, Q where M = m; ALPHA = a ; A is an array of size M with A(K) = a,, 1 < k < M; BETA = 3; B is an array of size M + 1 with B(K) = b. , 1 < k < M, B(M + 1) = 0; N is an array of size M with M(K) = n, , 1 < k < M; P - p, Q - q. The gcd of the set (A(l),..., A(M), B(l),..., B(M)} is comnuted and condition (A) of Theorem '4.1 is tested. If it holds then the program goes on to test condition (B). ((A) i i it is referred to as the GCD Test , and (B) as the Minimax Test .) Mote that condition (B) can be written as -PSI(M,L, -A, -B, N) < BETA - ALPHA + B(L)< PSI(M, L, A, B, M), where L-l PSI(M, L, A, B, M) + y-j (A(K) - B(K)) N(K) + ((A(L)) - B(L)) + (M(L) - 1) + £ ((A(K)) + + (-B(K) ) + )N(K) . k=L+l Since PS] Ls always non negative of the two inequalities in the condition, d< of [BETA - ALPHA + B(L)]. The number of tines the fimctJ I Is comoutod (and then used in a comparison) ls at mo^t N ♦ 1, The similarity between the conditions o? Theor' .1 and ^ . 1 shows that this prop-ram can be extended to the non lin' case without too much difficulty. The only orobl<- that we must know the sets BL , , ^ T p> Ej ^ and the interers y. , c. . and incornorate then into the program. PROCEDURE OPTIONS (MAIN); 41 PSI ; PROCEDURE (M.L.A,B,N) RETURNS (FIXED BIN (31)): PLUS : PROCEDURE (R) RETURNS (FIXED BIN (31)); DCL R FIXED EIN (31) ; IF R>0 THEN R ETURN (R) ; It SB F.ETUKN (0) ; END PLUS^; DCL_XM. L. A(*), B(*). N(»), K, SUM) FIXED BIN(31); 3TJH = ~^~ DO K = \ TO L-1 ; SUM = SUM + PLUS (A (K) - B (K) ) *N (K) ; rl^L<=M THEN SUM = SUM ♦ PLUS (PLUS (A (L) ) - B (L) ) * (N (L)- 1) ; DO K = L+1 TO H; SUM = SUM ♦ (PLUS (A (K) ) ♦ PLUS (-B (K) ) ) *N (K) ; END: „ PUTSKIP LI3T~f • PSI=', SUM) ; RETURN (SUM) ; END PSI; HCL (M, L r ALPHA, BETA, P, Q) FIXED BIN131) ; DCL \K. DIF, GCD, X, 3, UB) FIXED BIN(31); DCL DEPENDENT BIT (1) ; _9JL ENDFILE ( SYSIN) S TOP; DO V'HILE (' 1'B) ; GET LIST (M) ; BEGIN; DCL (A(M), B(M*1), N(H)J FIXED BIN(JI); GET LIST (ALPHA, A, BETA- B, N, P, Q) ; PUT SKIP(3) DATA (M, ALPHA, A, BETA, B, N, P, Q) ; GCD = AM); /* COMPUTE THE GCD OF ELEMENTS OF A S B */ DO K = 1 TO M-1 ; X = AJK+1) ; DO WHILE (X -.= 0) ; R = MOD(GCD, X) ; GCD = X; X = F; EWj END; DO K = 1 TO M; DO WHILE (X -i= 0) ; R = MOD (GCD, X) ; GCD = X; X = R: END; END; PUT SKIP DATA (GCD) ; /* GCD HAS BEEN COMPUTED */ D I F = BETA - ALP H A ;' IF GCD -.= S MOD (DIF, GCD) -»= THEN PUT SKIP LIST (•NOT DEPENDENT BY THE GCD TEST 1 ); ELSE DO: IF P < C THEN UB = M+1; ELSE OB = ft; DEPENDENT = • O'B; DO L = 1 TO UB WHILE (-DEPENDENT) ; K = DIF ♦ B(L)j I'F (K>0"6"K <= PSI (M,L,A,B, N) ) | (K<0 S K >= -PSI (M,L,-A,-3,N) ) | (K=0) THEN CO; DEPENDENT = • 1 • B; PU T SKIP LI S T ('PROBABLY DE PEN DENT' .' 1=' . L) ; I END; IIP DDT; END; END * IF -DEPENDENT THEN PUT SKIP LIST ('NOT DEPENDENT BY THE MNIMAX TEST'J_; "END; ■" END; BIBLIOGRAPHIC DATA SHEET 1. Report No. UIUCDCS-R-76-837 itle and Subtitle DATA DEPENDENCE IN ORDINARY PROGRAMS 3. Recipient's Accession No. 5. Report Date November 1976 6. Author(s) Utpal Baner.iee 8- Performing Organization Rept. No - UIUCDCS-R-76-837 '. Performing Organization Name and Address University of Illinois at Urbana-Champaign Department of Computer Science Urbana, Illinois 61801 10. Project/Task/Work Unit No. 11. Contract/Grant No. 2. Sponsoring Organization Name and Address National Science Foundation Washington, D. C. 13. Type of Report & Period Covered Master's Thesis 14. 5. Supplementary Notes 6. Abstracts Certain conditions have been obtained under which there is no dependence between two assignment statements inside an IF-free loop in a language like FORTRAN. The number of index variables is arbitrary, and the array subscripts are assumed to be general polynomials in the index variables. 7. Key Words and Document Analysis. 17a. Descriptors Assignment statements Data dependence Input variables Output variables 'b. Identifiers/Open-Ended Terms fc. COSATI Field/Group |J. Availability Statement Release Unlimited 19. Security Class (This Report) UNCI ASSIFIED curitv Class (Thi 20. Security Class (This Page UNCLASSIFIED 21. No. of Pages 45 22. Price 3RM NTIS-3S ( 10-70) USCOMM-DC 403Z9-P7 1 • - ^ % M UNWERal 51(1 MIltRno I Intirm! rtport / XINO»*-Cmt!*H» 3 0112 088403149