ループカウントとループ分配

loop count (n) ディレクティブ

loop count (n) ディレクティブはループカウントが n になるように指定します。このディレクティブの構文は次のとおりです:

#pragma loop count (n)

n は整数定数です。loop count の値はソフトウェアのパイプライン化、ベクトル化およびループ変換に使用される手法に影響を与えます。

loop count (n) ディレクティブの例

#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 ディレクティブ

distribute point ディレクティブはループ分配の実行優先度をコンパイラに指示します。このディレクティブの構文は次のとおりです:

#pragma distribute point

ループ分配は、大きなループを小さなループに分配することがあります。これは、より多くのループにおいてソフトウェアのパイプライン化を有効にします。ディレクティブをループの内側に置く場合、分配はディレクティブの後で行われ、あらゆるループキャリーの依存性が無視されます。ディレクティブをループの前に置く場合、コンパイラは分配する場所を決定し、データ依存性を監視します。1 つの distribute ディレクティブのみが、ループの内側に置かれる際にサポートされます。

distribute point ディレクティブの例

#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;

}