dependency test in loops n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Dependency Test in Loops PowerPoint Presentation
Download Presentation
Dependency Test in Loops

Loading in 2 Seconds...

play fullscreen
1 / 9

Dependency Test in Loops - PowerPoint PPT Presentation


  • 95 Views
  • Uploaded on

Dependency Test in Loops. By Amala Gandhi. Data Dependence. Three types of data dependence: Flow (True) dependence : read-after-write int a, b, c; a = c * 10; b = 2 * a + c ; Anti Dependency: write-after-read int a, b, c; a = b* 4+ c; c = b + 40;

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Dependency Test in Loops' - dooley


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
data dependence
Data Dependence
  • Three types of data dependence:
  • Flow (True) dependence : read-after-write

int a, b, c;

a = c * 10;

b = 2 * a + c;

  • Anti Dependency: write-after-read

inta, b, c;

a = b* 4+ c;

c = b + 40;

  • Output Dependence: write-after-write

inta, b, c;

a = b *c ;

a = b + c + 10;

dependency in loops
Dependency in Loops
  • Two main types of dependency in loops

Loop Independent : Dependence in same iteration

for (i= 2; i<= 4; i++){

a[i] = b[i] + c[i];

d[i] = a[i];

}

Loop Carried : Dependence over the iteration

for (i= 2 ; i< = 4; i++) {

a[i] = b[i] + c[i];

d[i] = a[i-1];

}

loop dependency analysis
Loop Dependency Analysis
  • With automatic parallelization, the compiler detects loops that can be safely and efficiently executed in parallel
  • Automatic parallelization, kind of optimization
    • Shorter execution time
    • Adds the parallel compiler directives
  • To know whether two usages of an array access the same memory location, compiler needs to perform certain dependency tests
greatest common divisor test
Greatest Common Divisor Test
  • A Linear Diophantine equation

a1*x1 + a2*x2 +...+ an*xn = c

  • Above equation has a solution if , the greatest common divisor of a1,a2,..an can divide the c i.e. the result of the division is an integer.
  • Example:

15*x +6*y -9*z = 12

gcdof 15, 6 and 9 is 3

3can divide 12

Hence the equation has a solution.

  • If equation has a solution , means has dependency ,else no dependency
gcd test contd
GCD Test contd.

Code Snippet:

for (i= 1; i< N; i++)

{

a[2* i] = .. ;

.. = a[3* i- 5];

}

Equation formation:

2x = 3y - 5

i.e. 2x – 3y = -5

GCD(2,3) = 1, divides 5

Has a dependency

  • If there was no dependency, then compiler can directly go forward for applying the parallelization technique.
gcd test limitation
GCD Test Limitation
  • GCD ignores bounds

for (i= 1; i< 10; i++) {

a[i] = b[i] + c[i];

d[i] = a[i-100];

}

  • For above example, GCD test shows that there is dependence, but actually it has ignored bounds.
  • GCD test also does not provide distance or direction information
  • To overcome this limitation, GCD test is combined with Banerjee test
  • Many such tests are present, different compilers may use different loop dependency test
take aways
Take Aways
  • Terminologies used in Data Dependence and Loop Dependence Analysis
  • Concept of tests used in Loop Dependence Analysis with the help of GCD test