Debian Codegraph @

openmp/runtime/test/parallel/bug63197.c

raw
1 // RUN: %libomp-compile-and-run | FileCheck %s
2
3 #include <omp.h>
4 #include <stdio.h>
5
6 /* This code tests that state pushed for the num_threads clause does not
7 reach the next parallel region. omp_get_max_threads() + 1 can never
8 be chosen as team size for the second parallel and could only be the
9 result of some left-over state from the first parallel.
10 */
11
12 int main(int argc, char *argv[]) {
13 unsigned N = omp_get_max_threads();
14 #pragma omp parallel num_threads(N + 1) if (0)
15 #pragma omp single
16 { printf("BBB %2d\n", omp_get_num_threads()); }
17
18 #pragma omp parallel
19 #pragma omp single
20 {
21 if (omp_get_num_threads() <= N)
22 printf("PASS\n");
23 }
24 return 0;
25 }
26
27 // CHECK: PASS