Skip various cmp-mem-const tests on lp64 hppa*-*-*
[official-gcc.git] / libgomp / testsuite / libgomp.c-c++-common / target-imperfect2.c
blobbc2901a517e686ec30efeb6fd4e65129d9f682ad
1 /* { dg-do run } */
3 /* Like imperfect2.c, but enables offloading. */
5 static int f1count[3], f2count[3];
6 static int g1count[3], g2count[3];
7 #pragma omp declare target enter (f1count, f2count)
8 #pragma omp declare target enter (g1count, g2count)
10 #ifndef __cplusplus
11 extern void abort (void);
12 #else
13 extern "C" void abort (void);
14 #endif
16 int f1 (int depth, int iter)
18 #pragma omp atomic
19 f1count[depth]++;
20 return iter;
23 int f2 (int depth, int iter)
25 #pragma omp atomic
26 f2count[depth]++;
27 return iter;
30 int g1 (int depth, int iter)
32 #pragma omp atomic
33 g1count[depth]++;
34 return iter;
37 int g2 (int depth, int iter)
39 #pragma omp atomic
40 g2count[depth]++;
41 return iter;
44 void s1 (int a1, int a2, int a3)
46 int i, j, k;
48 #pragma omp target parallel for collapse(3) map(always, tofrom:f1count, f2count, g1count, g2count)
49 for (i = 0; i < a1; i++)
51 f1 (0, i);
53 g1 (0, i);
54 for (j = 0; j < a2; j++)
56 f1 (1, j);
58 g1 (1, j);
59 for (k = 0; k < a3; k++)
61 f1 (2, k);
63 g1 (2, k);
64 g2 (2, k);
66 f2 (2, k);
68 g2 (1, j);
70 f2 (1, j);
72 g2 (0, i);
74 f2 (0, i);
78 int
79 main (void)
81 f1count[0] = 0;
82 f1count[1] = 0;
83 f1count[2] = 0;
84 f2count[0] = 0;
85 f2count[1] = 0;
86 f2count[2] = 0;
88 g1count[0] = 0;
89 g1count[1] = 0;
90 g1count[2] = 0;
91 g2count[0] = 0;
92 g2count[1] = 0;
93 g2count[2] = 0;
95 s1 (3, 4, 5);
97 /* All intervening code at the same depth must be executed the same
98 number of times. */
99 if (f1count[0] != f2count[0]) abort ();
100 if (f1count[1] != f2count[1]) abort ();
101 if (f1count[2] != f2count[2]) abort ();
102 if (g1count[0] != f1count[0]) abort ();
103 if (g2count[0] != f1count[0]) abort ();
104 if (g1count[1] != f1count[1]) abort ();
105 if (g2count[1] != f1count[1]) abort ();
106 if (g1count[2] != f1count[2]) abort ();
107 if (g2count[2] != f1count[2]) abort ();
109 /* Intervening code must be executed at least as many times as the loop
110 that encloses it. */
111 if (f1count[0] < 3) abort ();
112 if (f1count[1] < 3 * 4) abort ();
114 /* Intervening code must not be executed more times than the number
115 of logical iterations. */
116 if (f1count[0] > 3 * 4 * 5) abort ();
117 if (f1count[1] > 3 * 4 * 5) abort ();
119 /* Check that the innermost loop body is executed exactly the number
120 of logical iterations expected. */
121 if (f1count[2] != 3 * 4 * 5) abort ();