loop count プラグマは、ループカウントが整数定数であることを示します。このプラグマの構文は次のとおりです。
構文 |
---|
#pragma loop count (n) |
n は整数です。
ループカウントの値はソフトウェアのパイプライン化およびデータ・プリフェッチに使用される手法に影響を与えます。
loop count の使用例 |
---|
void loop_count(int a[], int b[]) { #pragma loop count (10000) for (int i=0; i<1000; i++) // This should enable // software pipelinging for this loop. a[i] = b[i] + 1.2; } |
distribute point プラグマは、ループ分配実行の優先度を示します。このプラグマの構文は次のとおりです。
構文 |
---|
#pragma distribute point |
ループ分配は、大きなループを小さなループに分配することがあります。この手法は、より多くのループにおいてソフトウェアのパイプライン化を有効にします。
プラグマをループの内側に置く場合、分配は宣言子の後で行われ、あらゆるループ運搬の依存性が無視されます。
プラグマをループの前に置く場合、コンパイラーは分配する場所を決定し、データ依存性を監視します。ループの内側に置く場合、複数の distribute プラグマがサポートされます。
ループの内側にこれらのプラグマを置く場合、IF 文の内側に置くことはできません。
distribute point の使用例 |
---|
void dist1(int a[], int b[], int c[], int d[]) { #pragma distribute point // Compiler will automatically decide where to // distribute.Data dependency is observed. for (int i=1; i<1000; i++) { b[i] = a[i] + 1; c[i] = a[i] + b[i]; d[i] = c[i] + 1; } }
void dist2(int a[], int b[], int c[], int d[]) { for (int i=1; i<1000; i++) { b[i] = a[i] + 1; #pragma distribute point // Distribution will start here, // ignoring all loop-carried dependency. c[i] = a[i] + b[i]; d[i] = c[i] + 1; } } |