[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / openmp / runtime / test / api / omp_in_parallel.c
blob5e9e635fa155822402df756ba5ec168fbeade55f
1 // RUN: %libomp-compile-and-run
2 #include <stdio.h>
3 #include "omp_testsuite.h"
5 /*
6 * Checks that false is returned when called from serial region
7 * and true is returned when called within parallel region.
8 */
9 int test_omp_in_parallel()
11 int serial;
12 int isparallel;
14 serial = 1;
15 isparallel = 0;
16 serial = omp_in_parallel();
18 #pragma omp parallel
20 #pragma omp single
22 isparallel = omp_in_parallel();
25 return (!(serial) && isparallel);
28 int main()
30 int i;
31 int num_failed=0;
33 // the test requires more than 1 thread to pass
34 omp_set_dynamic(0); // disable dynamic adjustment of threads
35 if (omp_get_max_threads() == 1)
36 omp_set_num_threads(2); // set 2 threads if no HW resources available
38 for(i = 0; i < REPETITIONS; i++) {
39 if(!test_omp_in_parallel()) {
40 num_failed++;
43 return num_failed;