Loop Count and Loop Distribution

loop count (n) Directive

The loop count (n) directive indicates the loop count is likely to be n. The syntax for this directive is:

#pragma loop count (n)

where n is an integer constant. The value of loop count affects heuristics used in software pipelining, vectorization and loop-transformations.

Example of loop count (n) Directive

#pragma loop count (10000)

 

for(i=0; i<m; i++)

{

    //swp likely to occur in this loop  

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

}

distribute point Directive

The distribute point directive indicates to the compiler a preference of performing loop distribution. The syntax for this directive is:

#pragma distribute point

Loop distribution may cause large loops be distributed into smaller ones. This may enable software pipelining for more loops. If the directive is placed inside a loop, the distribution is performed after the directive and any loop-carried dependency is ignored. If the directive is placed before a loop, the compiler will determine where to distribute and data dependency is observed. Only one distribute directive is supported when placed inside the loop.

Example of distribute point Directive

#pragma distribute point

 

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

{

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

 

   ...

 

   //Compiler will automatically

   //decide where to distribute.

   //Data dependency is observed.

 

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

 

   ...

 

   d[i]=c[i]+1;

}

 

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

{

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

 

   ...

 

   #pragma distribute point

 

   //Distribution will start here,

   //ignoring all loop-carried dependency. 

 

   sub(a,n);

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

 

   ...

 

   d[i]=c[i]+1;

}