PR target/35485
[official-gcc.git] / libgomp / testsuite / libgomp.c / pr30494.c
blobec6828e440681ec3a14c14530615cc86ea1abd97
1 /* PR middle-end/30494 */
2 /* { dg-do run } */
4 #include <omp.h>
6 int errors;
8 int
9 check (int m, int i, int *v, int *w)
11 int j;
12 int n = omp_get_thread_num ();
13 for (j = 0; j < m; j++)
14 if (v[j] != j + n)
15 #pragma omp atomic
16 errors += 1;
17 for (j = 0; j < m * 3 + i; j++)
18 if (w[j] != j + 10 + n)
19 #pragma omp atomic
20 errors += 1;
23 int
24 foo (int n, int m)
26 int i;
27 #pragma omp for
28 for (i = 0; i < 6; i++)
30 int v[n], w[n * 3 + i], j;
31 for (j = 0; j < n; j++)
32 v[j] = j + omp_get_thread_num ();
33 for (j = 0; j < n * 3 + i; j++)
34 w[j] = j + 10 + omp_get_thread_num ();
35 check (m, i, v, w);
37 return 0;
40 int
41 bar (int n, int m)
43 int i;
44 #pragma omp parallel for num_threads (4)
45 for (i = 0; i < 6; i++)
47 int v[n], w[n * 3 + i], j;
48 for (j = 0; j < n; j++)
49 v[j] = j + omp_get_thread_num ();
50 for (j = 0; j < n * 3 + i; j++)
51 w[j] = j + 10 + omp_get_thread_num ();
52 check (m, i, v, w);
54 return 0;
57 int
58 main (void)
60 #pragma omp parallel num_threads (3)
61 foo (128, 128);
62 bar (256, 256);
63 return 0;