The non-continuous direction vector I test - Parallel ... - CiteSeerX

0 downloads 0 Views 118KB Size Report
1 minyi@u-aizu.ac.jp,. 2 [email protected],. 3 [email protected]. Abstract. In this paper, we offer the non-continuous direction vector I test, an ...
The Non-continuous Direction Vector I Test Minyi Guo1, Weng-Long Chang2 and Jiannong Cao3 1 Department of Computer Software, The University of Aizu, Aizu-Wakamatsu City, Fukushima 965-8580, Japan 2

Department of Management Information Southern Taiwan University of Technology, Tainan County, Taiwan 710, R.O.C. 3 Department of Computing Hong Kong Polytechnic University, Hung Hom, Kowloon, Hong Kong 1 E-mail: [email protected], [email protected], [email protected]

Mk, N k and INC k are integers for 1 d k d m and M k , N k and INC k are, respectively,

where

Abstract In this paper, we offer the non-continuous direction

lower bound, upper bound and increment of a general loop

vector I test, an extension of the direction vector I test, to

and P is the number of loop iteration in the general loop and

make sure whether there are integer-valued solutions for one-dimensional

arrays

with

constant

bounds

Terms

(N k  M k )

and

INC k

 1. Famous data dependence

methods include [1-9].

non-one-increment.

Index

P =



Parallelizing

Compilers,

Data

Dependence Analysis.

2. Background

1. Introduction

2.1.

The data dependence problem in general case can be

The Direction Vector I Test Definitions 21, cited from [2, 9], defines an interval

reduced to that of checking whether a system of one linear

equation.

equation with m unknown variables has a simultaneous

Definition 21: Let a1 ,  , a m 1 , a m , L and U be

integer solution, which satisfies the constraints for each

integers. A linear equation (21), a 1 X 1  a 2 X 2  

variable in the system. Assume that a linear equations in a

 a m 1 X m 1  a m X m

system

interval equation.

is

written

as

a1 X 1  a 2 X 2    a m 1 X m 1  a m X m each a

j

(11):

a 0 , where

is an integer for 0 d j d m and each X k is a

[L, U], is referred to as an

In light of [9], the direction vector I test considers a pair of same index variables to justify the movement of the two variables to the right. A pair of same index variables in the

scalar integer variable for 1 d k d m. Suppose that the

equation (21) can be moved to the right if the coefficients of

constraints to each variable in (11) are represented as (12):

the two variables have small enough values to justify the

M k d X k d N k , Xk = Mk + (m-1) * INCk and 1 d m d P,

movement of the two variables to the right.

Proceedings of the 7th International Symposium on Parallel Architectures, Algorithms and Networks (ISPAN’04) 1087-4089/04 $ 20.00 © 2004 IEEE Authorized licensed use limited to: Hong Kong Polytechnic University. Downloaded on March 4, 2009 at 03:21 from IEEE Xplore. Restrictions apply.

either an integer, where Mk d Nk. If m > 0, then the non-continuous

3. The Non-continuous Direction Vector I Test

3.1. Non-continuous Interval-Equation

Definition 30: Let [M, N, INC,

N M +1] represent INC

the non-continuous integer intervals from M to N, i.e., the set

of

all

of

the

non-continuous

integers,

interval

U L +1] is said INC

a1 X 1    a m X m

[L, U, INC,

to be ([M1, N1, INC1,

N1  M 1 +1]; …;[Mm, Nm, INC1

INCm,

Nm  M m +1])-integer solvable if one or more of INC m

the equations in the set which it denotes is ([M1, N1, INC1,

Nm  M m N1  M 1 +1]; …; [Mm, Nm, INCm, +1])INC1 INC m

N M ­ ½  1¾.  ®M  ( P  1) u INC | 1 d P d INC ¯ ¿ Definition 3-1: Let a 0 , a1 ,  , a m 1 , a m be integers.

integer solvable. 

For each k, 1d k d m, let each of Mk and Nk be integer, where Mk d Nk. If m > 0, then the equation,

3.2. Mathematical Preliminaries

a1 X 1   a m X m

equation

a 0 , is said to be ([M1, N1, INC1,

Nm  M m N1  M 1 +1]; …; [Mm, Nm, INCm, +1])INC1 INC m

Definition 3-4: Let S and S ' be sets of non-continuous integers. We define an addition and a substitution operation

integer solvable if there exist integers j1, j2, …, jm, such

on

that

S  S ' {s  s ' | s  S and s ' S '} and S  S ' {s  s ' | s  S and s ' S '} . Note that if S is the

· a1 j1  a 2 j 2    a m 1 j m 1  a m j m

a 0.

· For each k, 1d k d m: jk = Mk+(p-1)uINCk, where p is an integer and 1 d p d

Nk  M k +1.  INC k

integers. A non-continuous interval equation is an equation in the form of a 1 X 1    a m X m

[L, U, INC,

U L +1], which denotes the set of normal equations INC consisting of: a 1 X 1   L, …,  am X m a1 X 1    a m X m

L+(

U L ) u INC = U.  INC

Definition 3-3: Let a 0 , a1 ,  , a m 1 , a m , L and U be integers. For each k, 1d k d m, let each of Mk and Nk be

of

non-continuous

integer

as

non-continuous integer interval [ L, U , INC , and

Definition 3-2: Let a 0 , a1 ,  , a m 1 , a m L and U be

sets

S ' {s1 , s 2 ,  , s n }

,

it

U L  1]  S ' INC n U L 1 [ L  s i , U  s i , INC, INC  1] i

follows:

U L  1] INC

follows

that

[ L, U , INC ,

and

U L  1]  S ' INC  n U L 1 [ L  s i , U  s i , INC, INC  1]. i

[ L, U , INC ,

Lemma 3-1: Let [ L, U , INC ,

Proceedings of the 7th International Symposium on Parallel Architectures, Algorithms and Networks (ISPAN’04) 1087-4089/04 $ 20.00 © 2004 IEEE Authorized licensed use limited to: Hong Kong Polytechnic University. Downloaded on March 4, 2009 at 03:21 from IEEE Xplore. Restrictions apply.

U L  1] be a INC

non-continuous

integer

N M [ M , N , DIF ,  1] DIF

interval. be

Let

also

a

non-continuous integer interval, where M  DIF  N . Let S = {b*y + c*z| y and z are,

respectively,

one

[ M , N , DIF ,

N M  1] DIF

t

element and

y



t d U  L  INC , 0 d t d U  L  INC and t is a

multiple of INC

.

Proof: Omitted due to space limit. 

3.3. Non-continuous Interval-Equation Transformation

in z}.

Let

­ max(| b * DIF |, | c * DIF |) °° if b * c ! 0 ®max(min(| b * DIF |, | c * DIF |), | (b  c) * DIF |) ° °¯ if b * c  0.

First, if two variables are related by a direction vector constraint of "=," they may be replaced by a single variable. Second, terms with zero coefficients may be omitted. Finally, a ">" constraint from one variable to another may be replaced by a constraint in the reverse direction. Taking all of those points into account, we propose Lemma 3-2, which is

(Part I):

extended from Theorem 3 in [9].

U L  1]  S [ L  ( b   c )  INC * ( N  M  DIF )  ( b  c ) * M  c * DIF ,

Lemma 3-2: Let E=[(3-1), (3-2)], where (3-1) is equal to

U  ( b   c )  * ( N  M  DIF )  ( b  c )

U L  1], INC

[ L , U , INC ,

* M  c * DIF , INC , (U  L )  ( N  M  DIF ) * (( b   c )   ( b   c )   1] INC iff t d U  L  INC , 0 d t d U  L  INC t d U  L  INC , 0 d t d U  L  INC and t is a multiple

of INC

n

¦a

m

q

Xq 

q 1

¦ (b Y q

[ L, U , INC ,

(3-2)

is

X q  [ M q , N q , INC q ,

to

for 1 d q d n

U L 1]  S [L  (b   c)  [L,U, INC, INC * ( N  M  DIF)  (b  c) * M  c * DIF,U  (b   c)  * ( N  M  DIF)  (b  c) * M  c * DIF, INC,

equal

Nq  M q INC q

equal

Nq  M q INC q

 1]

Yq and Z q 

and

[ M q , N q , INC q ,

iff

 cq Z q )

and

(Part II):

(U  L)  ( N  M  DIF) * ((b   c)   (b   c)  ) INC 1]

q

q n 1

 1]

and Y q  Z q .

for n  1 d q d m. Let E’=[(3-3), (3-4)], where (3-3) is n

to

¦ aq X q  q 1

m 1

¦ (b Y

q q

q n 1

[ L  (bm  c m )  ( N m  M m  INC m )  (bm  c m ) * M m  c m * INC m , U  (bm  c m )  ( N m  M m  INC m )

 (bm  c m ) * M m

Proceedings of the 7th International Symposium on Parallel Architectures, Algorithms and Networks (ISPAN’04) 1087-4089/04 $ 20.00 © 2004 IEEE Authorized licensed use limited to: Hong Kong Polytechnic University. Downloaded on March 4, 2009 at 03:21 from IEEE Xplore. Restrictions apply.

 cq Z q

 c m * INC m , INC ,

Since t1 d 2, 0 d t1 d 2 and t1 is a multiple of 2, the condition of the movement for the pair of the same index

(U  L)  (Nm  Mm  INCm ) *  m



 m

variable, X1 and X2 is satisfied according to Lemma 3-2.



((b  cm )  (b  cm ) ) INC

Therefore, X1 and X2 are selected to move to the

 1],

right-hand-side of (Ex1-1). Due to Lemma 3-2, a new non-continuous interval equation is obtained (Ex1-2): 0 =

and (3-4) is equal to

X q  [ M q , N q , INC q ,

Nq  Mq INC q

[2, 8, 2, 4]. Because 2 d 0 is false, 0 is not one element in

 1]

the non-continuous integer interval [2, 8, 2, 4]. Thus, the non-continuous direction vector I test concludes that there is no integer-valued solution.

for 1 d q d n, Yq and Z q 

[ M q , N q , INC q ,

Nq  Mq INC q

3.4. Interval-Equation Transformation Using the GCD

 1]

Test

and Y q  Z q for n  1 d q d m  1 .

interval equation have no sufficiently small values to justify the movements of variables to the right, then Lemmas 3-1

Let

tm

If all coefficients for variables in the non-continuous

­if bm * c m ! 0 ° max(| b * INC |, | c * INC |) m m m m °° ® if bm * c m  0. ° max(min(| b * INC |, | c * INC |), m m m m ° °¯ | (bm  c m ) * INC m |)

If t m d U  L  INC , 0 d t m d U  L  INC ,

and t m is a multiple of INC ,

then

E

is

integer

We take an example to show the power of Lemmas 3-1 and 3-2. Consider the normal linear equation (Ex1): X1 - X2 = 0, subject to the constraints X1 and X2: [1, 9, 2, 5] and X1 < X2. First, the non-continuous direction vector I test equation

(Ex1)

equation cannot be moved to the right, Theorem 31 and Lemma 3-3 describe a transformation using the GCD test that enables additional variables to be moved. Theorem 3-1: Let E=[(3-1), (3-2)], and let g = gcd(a1, },

g*ªL/gº is one element of the integer set {L+(m-1)uINC| 1d md

Proof: Omitted due to space limit. 

the

movement. While every variable in a non-continuous interval

an, bn+1, }, bm, cn+1, }, cm). E is integer solvable iff

solvable iff E’ is integer solvable.

transforms

and 32 can not be applied to result in the immediate

into

the

following

non-continuous interval equation (Ex1-1): X1 - X2 = [0, 0, 2, 1]. In light of Lemmas 3-1 and 3-2, because the coefficients

U L +1}. INC

Proof: Omitted due to space limit.  Lemma

3-3:

Let

E=[(3-1),

(3-2)],

and

let

g=gcd ( a ,  , a , b ,  , bm , c n 1 ,  , c m ) . Let 1 n n 1 E’=[(3-5), n

aq

¦gX q 1

(3-6)], m

q



where

bq

¦(gY

q

q n 1



cq g

(3-5)

Zq )

of X1 and X2 are, respectively, 1 and -1, t1 is equal to 2.

Proceedings of the 7th International Symposium on Parallel Architectures, Algorithms and Networks (ISPAN’04) 1087-4089/04 $ 20.00 © 2004 IEEE Authorized licensed use limited to: Hong Kong Polytechnic University. Downloaded on March 4, 2009 at 03:21 from IEEE Xplore. Restrictions apply.

is

equal

L U [ , , g g

to

INC U  L ,  1], g INC

and

X q  [ M q , N q , INC q ,

(3-6)

is

equal

to

integer interval needs a constant time 2(y), where y is a

Nq  M q INC q

constant. Thus, for calculating all new non-continuous

 1]

integer interval, the worst-case time complexity is 2(m) because there are at most m

for 1 d q d n and Yq and Z q  [ M q , N q , INC q ,

Yq  Z q for

bound and the upper bound of the new non-continuous

Nq  M q INC q

2 moves.

If all coefficients in a non-continuous interval equation

 1] and

n  1 d q d m. If L, U and INC are,

have no absolute values of 1, then Lemma 33 employs the GCD test to reduce all coefficients to obtain small enough coefficients to justify the movement of a pair of same index variables to the right. In the worst cases, the non-continuous

respectively, a multiple of g then E is integer solvable iff E’

direction vector I test contains m GCD tests. That study [2]

is integer solvable.

shows that a large percentage of all coefficients have

Proof: Omitted due to space limit. 

absolute values of 1 in one-dimensional array references with linear subscripts in real programs. Therefore, the GCD test is not always applied to reduce all coefficients in the equations

3.5. Time Complexity

inferred from one-dimensional array references with linear A pair of same index variables with small enough

subscripts in real programs because all coefficients in the

coefficients is easily found according to Lemmas 31 and

equations have at least an absolute value of 1. The worst-case

32. In light of Lemmas 31 and 32, it is obvious that the

time complexity to the non-continuous direction vector I test

worst-case time complexity to finding a pair of coefficients

to testing those one-dimensional array references with linear

enough is 2(m), where m is the number of variables in a

subscripts in real programs is immediately derived to be

non-continuous interval equation. The number of looking for

2(m2). The worst-case time complexity of the direction

all pairs of small enough coefficients in a non-continuous

vector I test is also 2(m2) [9]. Therefore, it is inferred that the

interval equation is at most m

non-continuous direction vector I test still remains the

2 times because the number

efficiency of the direction vector I test.

of pairs moved in the non-continuous interval equation is at most m

2

pairs. Thus, the worst-case time complexity to

move all pairs is 2(m2).

4. Experimental Results

We have tested our method and performed experiments

To calculate the new non-continuous integer interval on

on the codes abstracted from two numerical packages: Vector

the right-hand side of a non-continuous interval equation due

Loop and Livermore [10, 11]. 603 pairs of tested

to the movement of the qualified pairs actually is equivalent

one-dimensional array references consisting of the same pair

to apply a single Banerjee-Wolfe inequality. Applying a

of array references with different direction vectors were

single Banerjee-Wolfe inequality to calculate the lower

observed under constant bounds and non-one-increment. The

Proceedings of the 7th International Symposium on Parallel Architectures, Algorithms and Networks (ISPAN’04) 1087-4089/04 $ 20.00 © 2004 IEEE Authorized licensed use limited to: Hong Kong Polytechnic University. Downloaded on March 4, 2009 at 03:21 from IEEE Xplore. Restrictions apply.

proposed

method

is

only

applied

to

test

those

"The I Test," IEEE Transaction on Parallel and Distributed

one-dimensional arrays with subscripts under constant

Systems," Vol. 2, No. 3, July 1991, pp. 342359.

bounds and non-one-increment. It is very clear from Table 1

[3] Weng-Long Chang, Chih-Ping Chu and J. Wu, "A

that the proposed method could properly solve whether there

Multi-dimensional Version of the I Test," Parallel

are definitive results for one-dimensional arrays with

Computing, Vol. 27-13, Sept. 2001, pp. 1783-1799.

subscripts under constant bounds and non-one-increment.

[4] Weng-Long Chang, Chih-Ping Chu and J. Wu, "A Precise Dependence Analysis for Multi-dimensional Arrays Under Specific Dependence Direction," Journal of System

The number of Benchmark

and Software. (Accepted, 2001).

definitive results

[5] Weng-Long Vector Loop

Chang

and

Chih-Ping

Chu.

"The

Generalized Direction Vector I Test," Parallel Computing,

522

Vol. 27-8, July 2001, pp. 1117-1144. [6] Weng-Long Chang and Chih-Ping Chu. “The Infinity Livermore

81

Lambda Test: A Multi-dimensional Version of Banerjee

Table 1. The result is to solve whether there are

Infinity Test,” Parallel Computing, Vol. 26-10, Aug. 2000,

integer-valued solutions for one-dimensional arrays

pp. 1275-1295.

with

[7] Weng-Long Chang, Chih-Ping Chu, and Jesse Wu. "The

subscripts

under

constant

bounds

and

non-one-increment.

Generalized Lambda Test: A Multi-dimensional Version of Banerjee's Algorithm," International Journal of Parallel and

5. Conclusions

Distributed Systems and Networks, Vol. 2, Issue 2, 1999, pp. 69-78.

According to the time complexity analysis, the

[8] Weng-Long Chang and Chih-Ping Chu. "The Extension

proposed method remains the efficiency of the direction

of the I Test," Parallel Computing, Vol. 24, Number 14,

vector I test. Therefore, assume that depending on the

Nov. 1998, pp. 2101-2127.

application domains and environments, the proposed method

[9] Kleanthis Psarris, Xiangyun Kong, David Klappholz.

can be applied independently or together with other famous

"The Direction Vector I test," IEEE Transaction on Parallel

methods to analyze data dependence for linear-subscript

and Distributed Systems, Vol. 4, No. 11, 1993, pp.

array references.

12801290. [10] David Levine, David Callahan and Jack Dongarra, "A

References

comparative study of automatic vectorizing compilers," Parallel Computing 17(1991), pp.1223-1244.

[1] Kleanthis Psarris, David Klappholz, and Xiangyun Kong.

[11] W. Blume and R. Eigenmann. "Performance analysis of

"On the Accuracy of the Banerjee Test," Journal of Parallel

parallelizing compilers on the perfect benchmark s

and Distributed Computing, 12(2), June 1991, pp. 152-158.

programs," IEEE Transaction on Parallel and Distributed

[2] Xiangyun Kong, David Klappholz and Kleanthis Psarris.

Systems, Vol. 3, No. 6 (November 1992), pp. 643656.

£

Proceedings of the 7th International Symposium on Parallel Architectures, Algorithms and Networks (ISPAN’04) 1087-4089/04 $ 20.00 © 2004 IEEE Authorized licensed use limited to: Hong Kong Polytechnic University. Downloaded on March 4, 2009 at 03:21 from IEEE Xplore. Restrictions apply.

Suggest Documents