testsuite/libgomp.c/pr30494.c

Go to the documentation of this file.
00001 /* PR middle-end/30494 */
00002 /* { dg-do run } */
00003 
00004 #include <omp.h>
00005 
00006 int errors;
00007 
00008 int
00009 check (int m, int i, int *v, int *w)
00010 {
00011   int j;
00012   int n = omp_get_thread_num ();
00013   for (j = 0; j < m; j++)
00014     if (v[j] != j + n)
00015       #pragma omp atomic
00016     errors += 1;
00017   for (j = 0; j < m * 3 + i; j++)
00018     if (w[j] != j + 10 + n)
00019       #pragma omp atomic
00020     errors += 1;
00021 }
00022 
00023 int
00024 foo (int n, int m)
00025 {
00026   int i;
00027 #pragma omp for
00028   for (i = 0; i < 6; i++)
00029     {
00030       int v[n], w[n * 3 + i], j;
00031       for (j = 0; j < n; j++)
00032     v[j] = j + omp_get_thread_num ();
00033       for (j = 0; j < n * 3 + i; j++)
00034     w[j] = j + 10 + omp_get_thread_num ();
00035       check (m, i, v, w);
00036     }
00037   return 0;
00038 }
00039 
00040 int
00041 bar (int n, int m)
00042 {
00043   int i;
00044 #pragma omp parallel for num_threads (4)
00045   for (i = 0; i < 6; i++)
00046     {
00047       int v[n], w[n * 3 + i], j;
00048       for (j = 0; j < n; j++)
00049     v[j] = j + omp_get_thread_num ();
00050       for (j = 0; j < n * 3 + i; j++)
00051     w[j] = j + 10 + omp_get_thread_num ();
00052       check (m, i, v, w);
00053     }
00054   return 0;
00055 }
00056 
00057 int
00058 main (void)
00059 {
00060 #pragma omp parallel num_threads (3)
00061   foo (128, 128);
00062   bar (256, 256);
00063   return 0;
00064 }

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