gcc/
[official-gcc.git] / libgomp / testsuite / libgomp.c / target-6.c
blobea35aa465f500a1577b6a4bac6a22be8eae0c6b0
1 #include <omp.h>
2 #include <stdlib.h>
4 int
5 main ()
7 omp_set_dynamic (0);
8 omp_set_nested (1);
9 if (omp_in_parallel ())
10 abort ();
11 #pragma omp parallel num_threads (3)
12 if (omp_get_thread_num () == 2)
14 if (!omp_in_parallel ())
15 abort ();
16 #pragma omp parallel num_threads (3)
17 if (omp_get_thread_num () == 1)
19 if (!omp_in_parallel ()
20 || omp_get_level () != 2
21 || omp_get_ancestor_thread_num (0) != 0
22 || omp_get_ancestor_thread_num (1) != 2
23 || omp_get_ancestor_thread_num (2) != 1
24 || omp_get_ancestor_thread_num (3) != -1)
25 abort ();
26 #pragma omp target if (0)
28 if (omp_in_parallel ()
29 || omp_get_level () != 0
30 || omp_get_ancestor_thread_num (0) != 0
31 || omp_get_ancestor_thread_num (1) != -1)
32 abort ();
33 #pragma omp parallel num_threads (2)
35 if (!omp_in_parallel ()
36 || omp_get_level () != 1
37 || omp_get_ancestor_thread_num (0) != 0
38 || omp_get_ancestor_thread_num (1)
39 != omp_get_thread_num ()
40 || omp_get_ancestor_thread_num (2) != -1)
41 abort ();
44 #pragma omp target if (0)
46 #pragma omp teams thread_limit (2)
48 if (omp_in_parallel ()
49 || omp_get_level () != 0
50 || omp_get_ancestor_thread_num (0) != 0
51 || omp_get_ancestor_thread_num (1) != -1)
52 abort ();
53 #pragma omp parallel num_threads (2)
55 if (!omp_in_parallel ()
56 || omp_get_level () != 1
57 || omp_get_ancestor_thread_num (0) != 0
58 || omp_get_ancestor_thread_num (1)
59 != omp_get_thread_num ()
60 || omp_get_ancestor_thread_num (2) != -1)
61 abort ();
67 return 0;