1 | // RUN: %libomp-compile-and-run |
---|---|
2 | |
3 | #include <stdio.h> |
4 | #include <stdlib.h> |
5 | #include <omp.h> |
6 | |
7 | int main() |
8 | { |
9 | int res; |
10 | res = omp_in_explicit_task(); |
11 | if (res) { |
12 | printf(format: "error: omp_in_explicit_task: serial1 returned %d\n", res); |
13 | return 1; |
14 | } |
15 | #pragma omp parallel num_threads(2) |
16 | { |
17 | int r = omp_in_explicit_task(); |
18 | if (r) { |
19 | printf(format: "error: omp_in_explicit_task: par #%d returned %d\n", |
20 | omp_get_thread_num(), r); |
21 | exit(status: 1); |
22 | } |
23 | #pragma omp task |
24 | { |
25 | int r = omp_in_explicit_task(); |
26 | if (!r) { |
27 | printf(format: "error: omp_in_explicit_task: task1 #%d returned %d\n", |
28 | omp_get_thread_num(), r); |
29 | exit(status: 1); |
30 | } |
31 | } |
32 | #pragma omp task |
33 | { |
34 | int r = omp_in_explicit_task(); |
35 | if (!r) { |
36 | printf(format: "error: omp_in_explicit_task: task2 #%d returned %d\n", |
37 | omp_get_thread_num(), r); |
38 | exit(status: 1); |
39 | } |
40 | } |
41 | } |
42 | res = omp_in_explicit_task(); |
43 | if (res) { |
44 | printf(format: "error: omp_in_explicit_task: serial2 returned %d\n", res); |
45 | return 1; |
46 | } |
47 | printf(format: "passed\n"); |
48 | return 0; |
49 | } |
50 |