]> git.ipfire.org Git - thirdparty/gcc.git/blob - libgomp/testsuite/libgomp.c/appendix-a/a.15.1.c
[multiple changes]
[thirdparty/gcc.git] / libgomp / testsuite / libgomp.c / appendix-a / a.15.1.c
1 /* { dg-do run } */
2
3 #include <stdio.h>
4
5 void
6 work (int n)
7 {
8 printf ("[%d of %d], nested = %d, n = %d\n", omp_get_thread_num (), omp_get_num_threads(), omp_get_nested (), n);
9 }
10
11 void
12 sub3 (int n)
13 {
14 work (n);
15 #pragma omp barrier
16 work (n);
17 }
18
19 void
20 sub2 (int k)
21 {
22 #pragma omp parallel shared(k)
23 sub3 (k);
24 }
25
26 void
27 sub1 (int n)
28 {
29 int i;
30 #pragma omp parallel private(i) shared(n)
31 {
32 #pragma omp for
33 for (i = 0; i < n; i++)
34 sub2 (i);
35 }
36 }
37 int
38 main ()
39 {
40 sub1 (2);
41 sub2 (15);
42 sub3 (20);
43 return 0;
44 }