3 /* Like imperfect3.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
++)
55 for (j
= 0; j
< a2
; j
++)
61 for (k
= 0; k
< a3
; k
++)
100 /* All intervening code at the same depth must be executed the same
102 if (f1count
[0] != f2count
[0]) abort ();
103 if (f1count
[1] != f2count
[1]) abort ();
104 if (f1count
[2] != f2count
[2]) abort ();
105 if (g1count
[0] != f1count
[0]) abort ();
106 if (g2count
[0] != f1count
[0]) abort ();
107 if (g1count
[1] != f1count
[1]) abort ();
108 if (g2count
[1] != f1count
[1]) abort ();
109 if (g1count
[2] != f1count
[2]) abort ();
110 if (g2count
[2] != f1count
[2]) abort ();
112 /* Intervening code must be executed at least as many times as the loop
114 if (f1count
[0] < 3) abort ();
115 if (f1count
[1] < 3 * 4) abort ();
117 /* Intervening code must not be executed more times than the number
118 of logical iterations. */
119 if (f1count
[0] > 3 * 4 * 5) abort ();
120 if (f1count
[1] > 3 * 4 * 5) abort ();
122 /* Check that the innermost loop body is executed exactly the number
123 of logical iterations expected. */
124 if (f1count
[2] != 3 * 4 * 5) abort ();