testsuite/libgomp.c/pr26943-2.c

Go to the documentation of this file.
00001 /* PR c++/26943 */
00002 /* { dg-do run } */
00003 
00004 extern int omp_set_dynamic (int);
00005 extern void abort (void);
00006 
00007 int a = 8, b = 12, c = 16, d = 20, j = 0;
00008 char e[10] = "a", f[10] = "b", g[10] = "c", h[10] = "d";
00009 
00010 int
00011 main (void)
00012 {
00013   int i;
00014   omp_set_dynamic (0);
00015 #pragma omp parallel for shared (a, e) firstprivate (b, f) \
00016              lastprivate (c, g) private (d, h) \
00017              schedule (static, 1) num_threads (4) \
00018              reduction (+:j)
00019   for (i = 0; i < 4; i++)
00020     {
00021       if (a != 8 || b != 12 || e[0] != 'a' || f[0] != 'b')
00022     j++;
00023 #pragma omp barrier /* { dg-warning "may not be closely nested" } */
00024 #pragma omp atomic
00025       a += i;
00026       b += i;
00027       c = i;
00028       d = i;
00029 #pragma omp atomic
00030       e[0] += i;
00031       f[0] += i;
00032       g[0] = 'g' + i;
00033       h[0] = 'h' + i;
00034 #pragma omp barrier /* { dg-warning "may not be closely nested" } */
00035       if (a != 8 + 6 || b != 12 + i || c != i || d != i)
00036     j += 8;
00037       if (e[0] != 'a' + 6 || f[0] != 'b' + i || g[0] != 'g' + i)
00038     j += 64;
00039       if (h[0] != 'h' + i)
00040     j += 512;
00041     }
00042   if (j || a != 8 + 6 || b != 12 || c != 3 || d != 20)
00043     abort ();
00044   if (e[0] != 'a' + 6 || f[0] != 'b' || g[0] != 'g' + 3 || h[0] != 'd')
00045     abort ();
00046   return 0;
00047 }

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