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)
11 extern void abort (void);
13 extern "C" void abort (void);
16 int f1 (int depth
, int iter
)
23 int f2 (int depth
, int iter
)
30 int g1 (int depth
, int iter
)
37 int g2 (int depth
, int iter
)
44 void s1 (int a1
, int a2
, int a3
)
48 #pragma omp target parallel for collapse(3) map(always, tofrom:f1count, f2count, g1count, g2count)
49 for (i
= 0; i
< a1
; i
++)
54 for (j
= 0; j
< a2
; j
++)
59 for (k
= 0; k
< a3
; k
++)
97 /* All intervening code at the same depth must be executed the same
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
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 ();