次の方法で共有


nowait

ディレクティブ内の暗黙のバリアをオーバーライドします。

nowait

解説

nowait は次のディレクティブに適用されます。

詳細については、「2.4.1 for のコンストラクト」、「2.4.2 sections のコンストラクト」、および「2.4.3 single コンストラクト」を参照してください。

使用例

// omp_nowait.cpp
// compile with: /openmp /c
#include <stdio.h>

#define SIZE 5

void test(int *a, int *b, int *c, int size) 
{
    int i;
    #pragma omp parallel
    {
        #pragma omp for nowait
        for (i = 0; i < size; i++)
            b[i] = a[i] * a[i];
  
        #pragma omp for nowait
        for (i = 0; i < size; i++)
            c[i] = a[i]/2;
    }
}

int main( ) 
{
    int a[SIZE], b[SIZE], c[SIZE];
    int i;

    for (i=0; i<SIZE; i++)
        a[i] = i;
   
    test(a,b,c, SIZE);

    for (i=0; i<SIZE; i++)
        printf_s("%d, %d, %d\n", a[i], b[i], c[i]);
}

0, 0, 0
1, 1, 0
2, 4, 1
3, 9, 1
4, 16, 2

参照

概念

OpenMP 句