• Tidak ada hasil yang ditemukan

Data Dependence of Scalars

N/A
N/A
Protected

Academic year: 2024

Membagikan "Data Dependence of Scalars"

Copied!
15
0
0

Teks penuh

(1)

Basic Loop Parallelization

Å Data dependences

Å Loop parallelization

Å How to extract data dependence information

(2)

Parallelization Goal

Å

DoAll loops: Loops whose iterations can execute in parallel

Å

Example

for (i = 0; i < n; i++) A[i] = B[i] + C[i]

¿ Statically assign each iteration to a processor

(3)

Data Dependence of Scalars

¿ True dependence

¿ Anti dependence

¿ Output dependence

Å

Data dependence exists from a dynamic instance i to i’ iff

¿ either i or i’ is a write operation

¿ i and i’ refer to the same variable

¿ i executes before i’

(4)

Lack of Data Flow Information

Å Example

(1) x = f()

(2) x = g()

(3) = x

Å Standard data dependences are flow-insensitive

¿ Don’t care if there is no intervening write between a write and a read; (3) is dependent on (1) in the above Å Standard data dependence

¿ Alias analysis

¿ Memory disambiguation

(5)

Data Dependences for Arrays

for (i = 2; i < 5; i++) A[i] = A[i-2] + 1 for (i = 0; i < 3; i++)

A[i] = A[i] + 1

Å

Recognize DOALL loops (intuitively)

¿ Find data dependences in loops

¿ No dependences crossing iteration boundaries

⇒ parallelizable

(6)

Iteration Space

Å

n

-dimensional discrete space for

n

-deep loops

i

j Iteration Space

Program

FOR i = 0 TO 5 FOR j = i TO 7

A[i,j] = A[i,j-1] + 1

(7)

Iteration Space

Å Iteration is represented as coordinates in iteration space

Å Sequential execution order of iteration:

Lexicographic order

Å Iteration is lexicographically less than , iff

] 6 , 1 [ . . . ], 1 , 1 [ ], 7 , 0 [ , . . ], 1 , 0 [ ], 0 , 0 [

i r

i r ′

c c

c

c

i i and i i

i i

t s

c = ′ ′ < ′

∃ . .(

1

, ..

1

) (

1

, ..

1

)

(8)

Distance Vectors

Å Distance vector=[1,1]

Å A loop has a distance vector

if there exists data dependence from a node to a later node and

Å Since

is lexicographically greater than or equal to 0 :

dr

i

j Iteration Space

ir ir′ dr ir ir

′−

= 0

, ≥

id ir r r

dr

FOR (i = 0; i < n; i++) FOR (j = 0; j < n; j++)

A[i,j] = A[i-1,j-1] + 1

(9)

Distance Vectors

Å Distance vector(infinitely large set)

([0,0][0,1],..[0,n])([1,-n],..,[1,0],..[1,n])..([n,-n],..[n,0],..[n,n])

Å Summarized as direction vector (0 or lexicographically positive) ([0,0][0,+][+,-][+,0][+,+])

i

j Iteration Space FOR (i = 0; i < n; i++)

FOR (j = 0; j < n; j++) a = a + a;

(10)

Direction Vectors

Å

Common notations

(0 =),(+ <),(- >),(+/- *)

Å

What can the direction vectors for 3-D loops be like?

[? ? ?]

[0 ? ?]

[0 0 ?]

[0 0 0]

[0 0 ] [0 0 +]

[0 + ?]

[+ ? ?]

[0 ?]

[ ? ?]

(11)

Test for Parallelization

Å Example

for (j = 0; j < n; j++) A[j] = A[j] + 1;

Å Distance Vector: [0]

Å Test for parallelization:

¿ A loop with data dependence is parallelizable if for all = (0)dr drD

(12)

Parallelization of Loops

Å is loop-carried at level i if di is the first non-zero element does not affect the parallelizability of inner loop (= 0: no dependence; ≠ 0: second-order effect)

1

0

FOR (i = 0; i < n; i++) FOR (j = 0; j < n; j++)

A[i,j] = A[i,j-1] + 1

FOR (i = 0; i < n; i++) FOR (j = 0; j < n; j++)

A[i,j] = A[i-1,j] + 1

FOR (i = 0; i < n; i++) FOR (j = 0; j < n; j++)

A[i,j] = A[i-1,j-1] + 1

0 1

1 1

) ,..,

,

(d1 d2 dn dv =

j

j

j i

i

i

(13)

Test for Parallelization

Å The

i

th loop of an

n

-dimensional loop is

parallelizable if there does not exist any level

i

dependences

Å The

i

th loop of an

n

-dimensional loop is

parallelizable for all dependences , either

¿

¿

) .., ,

(d1 dn dv =

0 ) .., ,

(d1 di = 0 )

.., ,

(d1 di1 >

(14)

Improving Parallelizability

Å

Scalar Privatization

float t;

for (i = 0; i < n; i++) { t = A[i];

b[i] = t*t;

}

for (i = 0; i < n; i++) {

float t;

t = A[i];

b[i] = t*t;

}

(15)

Summary

Å

Data Dependence

¿ read/write

¿ same variable

¿ in direction of sequential ordering Å

Representation

¿ iteration space

¿ dependence vectors: distance vectors, direction vectors

Å

Parallelization Testing

Referensi

Dokumen terkait

Therefore, the objective of this research was to find the basic data of the mtDNA D-Loop genetic varieties of Aceh cattle and its association with the Bhutanese, Chinese, and

He also reviews how data unification works with installed data management solutions, allowing businesses to embrace data volume and variety for more productive data

More than that, they have driven changes in what we consider to be data available for analysis, what we view the possible results to be, how we view information itself, and

Complete access to data, information about the data values, and information about the organization of the data is achieved through a technique herein referred to as introspection

All but the very cheapest solar controllers provide basic information on an LCD screen that allows you to see how much power you have generated compared to how much

The combination of data science DS and machine learning ML techniques can improve cybersecurity as machine learning techniques help extract useful information from raw data.. In this

Temperature dependence of these parameters has provided much insight with regard to the operation mechanisms of OFETs, particularly on charge transport in organic semicon- ductors.5,6On

1 Factors that directly determine the demographic impact of conspecific negative density dependence CNDD over the seed-to-seedling transi- tion include a the strength of CNDD and b