Skip various cmp-mem-const tests on lp64 hppa*-*-*
[official-gcc.git] / libgomp / testsuite / libgomp.c-c++-common / target-imperfect1.c
blob53bc611ace3a59056c0c1f7cec18b0311f5f396a
1 /* { dg-do run } */
3 /* Like imperfect1.c, but enables offloading. */
5 static int f1count[3], f2count[3];
6 #pragma omp declare target enter (f1count, f2count)
8 #ifndef __cplusplus
9 extern void abort (void);
10 #else
11 extern "C" void abort (void);
12 #endif
14 int f1 (int depth, int iter)
16 #pragma omp atomic
17 f1count[depth]++;
18 return iter;
21 int f2 (int depth, int iter)
23 #pragma omp atomic
24 f2count[depth]++;
25 return iter;
28 void s1 (int a1, int a2, int a3)
30 int i, j, k;
32 #pragma omp target parallel for collapse(3) map(always, tofrom:f1count, f2count)
33 for (i = 0; i < a1; i++)
35 f1 (0, i);
36 for (j = 0; j < a2; j++)
38 f1 (1, j);
39 for (k = 0; k < a3; k++)
41 f1 (2, k);
42 f2 (2, k);
44 f2 (1, j);
46 f2 (0, i);
50 int
51 main (void)
53 f1count[0] = 0;
54 f1count[1] = 0;
55 f1count[2] = 0;
56 f2count[0] = 0;
57 f2count[1] = 0;
58 f2count[2] = 0;
60 s1 (3, 4, 5);
62 /* All intervening code at the same depth must be executed the same
63 number of times. */
64 if (f1count[0] != f2count[0]) abort ();
65 if (f1count[1] != f2count[1]) abort ();
66 if (f1count[2] != f2count[2]) abort ();
68 /* Intervening code must be executed at least as many times as the loop
69 that encloses it. */
70 if (f1count[0] < 3) abort ();
71 if (f1count[1] < 3 * 4) abort ();
73 /* Intervening code must not be executed more times than the number
74 of logical iterations. */
75 if (f1count[0] > 3 * 4 * 5) abort ();
76 if (f1count[1] > 3 * 4 * 5) abort ();
78 /* Check that the innermost loop body is executed exactly the number
79 of logical iterations expected. */
80 if (f1count[2] != 3 * 4 * 5) abort ();