testsuite/libgomp.c/pr36802-2.c

Go to the documentation of this file.
00001 /* PR middle-end/36802 */
00002 
00003 extern void abort (void);
00004 
00005 int q;
00006 
00007 int
00008 foo (int k)
00009 {
00010   int i = 6, n = 0;
00011   omp_set_dynamic (0);
00012   omp_set_nested (1);
00013 #pragma omp parallel shared (i) num_threads (3)
00014   {
00015     int l;
00016 
00017     if (omp_get_num_threads () != 3)
00018     #pragma omp atomic
00019       n += 1;
00020     else
00021     #pragma omp for
00022       for (l = 0; l < 3; l++)
00023     if (k)
00024     #pragma omp atomic
00025       q += i;
00026     else
00027     #pragma omp parallel shared (i) num_threads (4)
00028       {
00029         if (omp_get_num_threads () != 4)
00030         #pragma omp atomic
00031           n += 1;
00032         #pragma omp critical
00033           i += 1;
00034       }
00035   }
00036   if (n == 0 && i != 6 + 3 * 4)
00037     abort ();
00038   return 0;
00039 }
00040 
00041 int
00042 main (void)
00043 {
00044   foo (0);
00045   return 0;
00046 }

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