xref: /llvm-project/openmp/runtime/test/barrier/llvm-issue-80664.c (revision 0e0bee26e7f33c065eebef9a674b2f19bb156414)
1 // RUN: %libomp-compile
2 // RUN: env OMP_WAIT_POLICY=passive \
3 // RUN:     KMP_FORKJOIN_BARRIER_PATTERN='linear,linear' %libomp-run
4 // RUN: env OMP_WAIT_POLICY=passive \
5 // RUN:     KMP_FORKJOIN_BARRIER_PATTERN='tree,tree' %libomp-run
6 // RUN: env OMP_WAIT_POLICY=passive \
7 // RUN:     KMP_FORKJOIN_BARRIER_PATTERN='hyper,hyper' %libomp-run
8 // RUN: env OMP_WAIT_POLICY=passive \
9 // RUN:     KMP_FORKJOIN_BARRIER_PATTERN='dist,dist' %libomp-run
10 //
11 // LLVM ISSUE 80664: https://github.com/llvm/llvm-project/issues/80664
12 //
13 // Distributed barrier + OMP_WAIT_POLICY=passive hangs in library termination
14 // Reason: the resume logic in __kmp_free_team() was faulty and, when checking
15 // for sleep status, didn't look at correct location for distributed barrier.
16 
17 #include <stdio.h>
18 #include <stdlib.h>
19 
20 int a = 0;
21 
test_omp_barrier()22 void test_omp_barrier() {
23 #pragma omp parallel
24   {
25 #pragma omp task
26     {
27 #pragma omp atomic
28       a++;
29     }
30   }
31 }
32 
main()33 int main() {
34   test_omp_barrier();
35   printf("a = %d\n", a);
36   return EXIT_SUCCESS;
37 }
38