[Omp] Loop interchnage problem...

Marcel Beemster marcel at ace.nl
Sun Jun 24 00:43:17 PDT 2007


Sidharth.......

Some hints.......

1) Before loop interchange a[1] is also assigned twice....

2) Did you actually print the value of b[1] after the loops.....?

3) I prefer the book by Allen and Kennedy.....

....Marcel....

On Sun, Jun 24, 2007 at 09:51:43AM +0530, sidharth garg wrote:
> hello friends...
> 
> i was trying to do loop interchange in two level nseted loop...there was a
> dependency of (<) dependency for inner loop.....accordin to the book
> "high performnace compilers" by michale wolfe...........there should be no
> problem while interchanging the loop ....but after i interhanged the loop
> the result was diffrent from the original...
> code of loop is:
> 
> for(i=0;i<2;i++)
> {
>   for(j=0;j<2;j++)
>    {
>       a[j+1]=i+j;
>       b[j]=a[j]
>   }
> }
> 
> Executing the code sequentially we have:
> (!st iteration) i=0;j=0
>   a[1]=0;
>   b[0]=a[0]
> 
> (2nd iteration) i=0;j=1
>  a[2]=1
>  b[1]=a[1];  (b[1]=0)
> 
> (3rd iteration) i=1;j=0
>  a[1]=1;
>  b[0]=a[0]
> 
> (4th iteration) i=1;j=1
> i=1;j=1
>  a[2]=2;
>  b[1]=1;
> 
> after interchanging the loops...
> 
> (!st iteration)   j=0;i=0
>   a[1]=0;
>   b[0]=a[0]
> 
> (3rd iteration) j=0;i=1
>  a[1]=1
>  b[0]=a[0];
> 
> (2nd iteration) j=1;i=0
>  a[2]=1
>  b[1]=a[1]; (a[1]=1)   // now for 2nd iteration a[2] got diff value because
> a[1] has been assigned twice due to loop interchange
> 
> (4th iteration) j=1;i=1
>  a[2]=2;
>  b[1]=1;
> 
> 
> now as seen from comparison result of iteration no.2 is not same for both
> the cases......
> Executing sequentialy b[1]=0;
> Execting after loop interchange b[1]=1;
> 
> what i want to ask is that in existence of what kind of dependencies ..loop
> interchange can still be applied without any voilation in the result
> of execution??
> like: loop with dendencies of zero distance can be prefectly  interchnaged
> without any change in result......
> now what are other dependency cases which still does not effect the
> result????
> 
> 
> thanks for patience and reading the whole problem carefully!!!!
> 
> sidharth

> _______________________________________________
> Omp mailing list
> Omp at openmp.org
> http://openmp.org/mailman/listinfo/omp


-- 
Dr. Marcel Beemster, Senior Software Engineer, marcel at ace.nl,www.ace.nl
Associated Compiler Experts bv. Amsterdam, Netherlands. +31 20 6646416.
-----------------------------------------------------------------------
This e-mail and any  files transmitted  with it are  confidential.  Any
technical information contained herein is supplied as-is, and no rights
can be  derived therefrom.  If you have received this message in error,
please notify  the sender by reply  e-mail immediately,  and delete the
message and all copies thereof.




More information about the Omp mailing list