1 // RUN: %libomp-compile-and-run
2 #include <stdio.h>
3 #include "omp_testsuite.h"
4 
5 /*
6  * Test if the compiler supports nested parallelism
7  * By Chunhua Liao, University of Houston
8  * Oct. 2005
9  */
10 int test_omp_nested()
11 {
12   int counter = 0;
13 #ifdef _OPENMP
14   omp_set_nested(1);
15 #endif
16 
17   #pragma omp parallel shared(counter)
18   {
19     #pragma omp critical
20     counter++;
21     #pragma omp parallel
22     {
23       #pragma omp critical
24       counter--;
25     }
26   }
27   return (counter != 0);
28 }
29 
30 int main()
31 {
32   int i;
33   int num_failed=0;
34 
35   for(i = 0; i < REPETITIONS; i++) {
36     if(!test_omp_nested()) {
37       num_failed++;
38     }
39   }
40   return num_failed;
41 }
42