1 // RUN: %libomp-compile && env KMP_AFFINITY=compact %libomp-run
2 // REQUIRES: openmp-4.0
3 
4 #include <stdio.h>
5 #include <stdint.h>
6 #include <omp.h>
7 #include "omp_testsuite.h"
8 
9 int test_nested_affinity_bug() {
10   int a = 0;
11   omp_set_nested(1);
12   #pragma omp parallel num_threads(2) shared(a)
13   {
14     #pragma omp parallel num_threads(2) shared(a) proc_bind(close)
15     {
16       #pragma omp atomic
17       a++;
18     }
19   }
20   return 1;
21 }
22 
23 int main() {
24   int i;
25   int num_failed = 0;
26 
27   for (i = 0; i < REPETITIONS; i++) {
28     if (!test_nested_affinity_bug()) {
29       num_failed++;
30     }
31   }
32   return num_failed;
33 }
34