testsuite/libgomp.c/appendix-a/a.15.1.c

Go to the documentation of this file.
00001 /* { dg-do run } */
00002 
00003 #include <stdio.h>
00004 
00005 void
00006 work (int n)
00007 {
00008   printf ("[%d of %d], nested = %d, n = %d\n", omp_get_thread_num (), omp_get_num_threads(), omp_get_nested (), n);
00009 }
00010 
00011 void
00012 sub3 (int n)
00013 {
00014   work (n);
00015 #pragma omp barrier
00016   work (n);
00017 }
00018 
00019 void
00020 sub2 (int k)
00021 {
00022 #pragma omp parallel shared(k)
00023   sub3 (k);
00024 }
00025 
00026 void
00027 sub1 (int n)
00028 {
00029   int i;
00030 #pragma omp parallel private(i) shared(n)
00031   {
00032 #pragma omp for
00033     for (i = 0; i < n; i++)
00034       sub2 (i);
00035   }
00036 }
00037 int
00038 main ()
00039 {
00040   sub1 (2);
00041   sub2 (15);
00042   sub3 (20);
00043   return 0;
00044 }

Generated on Fri Apr 5 05:38:10 2013 for Libgomp by  doxygen 1.4.7