summaryrefslogtreecommitdiff
path: root/openmp/runtime/test/tasking/omp_taskloop_taskwait.c
blob: 6cb226461c8ebeff97faf032f90f186560a1a309 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// RUN: %libomp-compile-and-run
#include <stdio.h>
#include <omp.h>
int main()
{
  enum {ITERS = 500};
  enum {SIZE = 5};
  int err = 0;
  #pragma omp parallel num_threads(2) reduction(+:err)
  {
    int r = 0;
    int i;
    #pragma omp taskloop grainsize(SIZE) shared(r) nogroup
    for(i=0; i<ITERS; i++) {
      #pragma omp atomic
        ++r;
    }
    #pragma omp taskwait
    printf("%d\n", r);
    if (r != ITERS)
      err++;
  } // end of parallel
  if (err != 0) {
    printf("failed, err = %d\n", err);
    return 1;
  } else {
    printf("passed\n");
    return 0;
  }
}