testsuite/libgomp.c/pr39154.c

Go to the documentation of this file.
00001 /* PR middle-end/39154 */
00002 /* { dg-do compile } */
00003 /* { dg-options "-O2 -std=gnu99" } */
00004 
00005 extern void abort (void);
00006 
00007 int n = 20;
00008 
00009 int
00010 main (void)
00011 {
00012   int a[n], b[n][n];
00013 
00014 #pragma omp parallel for
00015     for (int i = 0; i < n; i++)
00016       {
00017     a[i] = i + 1;
00018 #pragma omp parallel for
00019     for (int j = 0; j < n; j++)
00020       b[i][j] = a[i];
00021       }
00022 
00023   for (int i = 0; i < n; i++)
00024     {
00025       for (int j = 0; j < n; j++)
00026     if (b[i][j] != i + 1)
00027       abort ();
00028       if (a[i] != i + 1)
00029     abort ();
00030     }
00031 
00032 #pragma omp parallel for shared (n, a, b)
00033     for (int i = 0; i < n; i++)
00034       {
00035     a[i] = i + 3;
00036 #pragma omp parallel for
00037     for (int j = 0; j < n; j++)
00038       b[i][j] = a[i];
00039       }
00040 
00041   for (int i = 0; i < n; i++)
00042     {
00043       for (int j = 0; j < n; j++)
00044     if (b[i][j] != i + 3)
00045       abort ();
00046       if (a[i] != i + 3)
00047     abort ();
00048     }
00049 
00050 #pragma omp parallel for
00051     for (int i = 0; i < n; i++)
00052       {
00053     a[i] = i + 5;
00054 #pragma omp parallel for shared (n, a, b)
00055     for (int j = 0; j < n; j++)
00056       b[i][j] = a[i];
00057       }
00058 
00059   for (int i = 0; i < n; i++)
00060     {
00061       for (int j = 0; j < n; j++)
00062     if (b[i][j] != i + 5)
00063       abort ();
00064       if (a[i] != i + 5)
00065     abort ();
00066     }
00067 
00068 #pragma omp parallel for shared (n, a, b)
00069     for (int i = 0; i < n; i++)
00070       {
00071     a[i] = i + 7;
00072 #pragma omp parallel for shared (n, a, b)
00073     for (int j = 0; j < n; j++)
00074       b[i][j] = a[i];
00075       }
00076 
00077   for (int i = 0; i < n; i++)
00078     {
00079       for (int j = 0; j < n; j++)
00080     if (b[i][j] != i + 7)
00081       abort ();
00082       if (a[i] != i + 7)
00083     abort ();
00084     }
00085 
00086 #pragma omp parallel for private (a, b)
00087     for (int i = 0; i < n; i++)
00088       {
00089     a[i] = i + 1;
00090 #pragma omp parallel for
00091     for (int j = 0; j < n; j++)
00092       b[i][j] = a[i];
00093       }
00094 
00095 #pragma omp parallel for private (a, b)
00096     for (int i = 0; i < n; i++)
00097       {
00098     a[i] = i + 1;
00099 #pragma omp parallel for private (b)
00100     for (int j = 0; j < n; j++)
00101       b[i][j] = a[i];
00102       }
00103 
00104   return 0;
00105 }

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