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

source code of openmp/runtime/test/tasking/omp_taskloop_taskwait.c