Daily bump.
[official-gcc.git] / libgomp / testsuite / libgomp.c / ordered-4.c
blob8412d4715c31aaac0d19b8f3361848b4f61e6a1c
1 extern
2 #ifdef __cplusplus
3 "C"
4 #endif
5 void abort (void);
7 void
8 foo (int i, char *j)
10 #pragma omp atomic
11 j[i]++;
12 #pragma omp ordered threads
14 int t;
15 #pragma omp atomic read
16 t = j[i];
17 if (t != 3)
18 abort ();
19 if (i > 1)
21 #pragma omp atomic read
22 t = j[i - 1];
23 if (t == 2)
24 abort ();
26 if (i < 127)
28 #pragma omp atomic read
29 t = j[i + 1];
30 if (t == 4)
31 abort ();
34 #pragma omp atomic
35 j[i]++;
38 int
39 main ()
41 int i;
42 char j[128];
43 #pragma omp parallel
45 #pragma omp for
46 for (i = 0; i < 128; i++)
47 j[i] = 0;
48 #pragma omp for ordered schedule(dynamic, 1)
49 for (i = 0; i < 128; i++)
51 #pragma omp atomic
52 j[i]++;
53 #pragma omp ordered threads
55 int t;
56 #pragma omp atomic read
57 t = j[i];
58 if (t != 1)
59 abort ();
60 if (i > 1)
62 #pragma omp atomic read
63 t = j[i - 1];
64 if (t == 0)
65 abort ();
67 if (i < 127)
69 #pragma omp atomic read
70 t = j[i + 1];
71 if (t == 2)
72 abort ();
75 #pragma omp atomic
76 j[i]++;
78 #pragma omp for ordered schedule(static, 1)
79 for (i = 0; i < 128; i++)
80 foo (i, j);
82 return 0;