[Instrumentation] Fix a warning
[llvm-project.git] / openmp / runtime / test / parallel / omp_nested.c
blobb5a3fbd6fa8015d523534a5e65e9461a389aa048
1 // RUN: %libomp-compile-and-run
2 #include <stdio.h>
3 #include "omp_testsuite.h"
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()
12 #ifdef _OPENMP
13 if (omp_get_max_threads() > 4)
14 omp_set_num_threads(4);
15 if (omp_get_max_threads() < 2)
16 omp_set_num_threads(2);
17 #endif
19 int counter = 0;
20 #ifdef _OPENMP
21 omp_set_nested(1);
22 omp_set_max_active_levels(omp_get_supported_active_levels());
23 #endif
25 #pragma omp parallel shared(counter)
27 #pragma omp critical
28 counter++;
29 #pragma omp parallel
31 #pragma omp critical
32 counter--;
35 return (counter != 0);
38 int main()
40 int i;
41 int num_failed=0;
43 for(i = 0; i < REPETITIONS; i++) {
44 if(!test_omp_nested()) {
45 num_failed++;
48 return num_failed;