1 // RUN: %libomp-compile-and-run
3 #include "omp_testsuite.h"
6 * This test will hang if the nowait is not working properly
8 * It relies on a one thread skipping to the last single construct to
9 * release the threads in the first three single constructs
14 void wait_for_release_then_increment(int rank
)
16 fprintf(stderr
, "Thread nr %d enters first section"
17 " and waits.\n", rank
);
23 void release_and_increment(int rank
)
25 fprintf(stderr
, "Thread nr %d sets release to 1\n", rank
);
31 int test_omp_single_nowait()
36 #pragma omp parallel num_threads(4)
39 rank
= omp_get_thread_num ();
40 #pragma omp single nowait
42 wait_for_release_then_increment(rank
);
44 #pragma omp single nowait
46 wait_for_release_then_increment(rank
);
48 #pragma omp single nowait
50 wait_for_release_then_increment(rank
);
55 release_and_increment(rank
);
58 // Check to make sure all four singles were executed
60 } /* end of check_single_nowait*/
67 for(i
= 0; i
< REPETITIONS
; i
++) {
68 if(!test_omp_single_nowait()) {