1 /* Minimized from for-5.c. */
6 /* Size of array we want to write. */
9 /* Size of extra space before and after. */
10 #define CANARY_SIZE (N * 32)
12 /* Start of array we want to write. */
13 #define BASE (CANARY_SIZE)
15 // Total size to be allocated.
16 #define ALLOC_SIZE (CANARY_SIZE + N + CANARY_SIZE)
18 #pragma omp declare target
20 #pragma omp end declare target
25 /* Use variable step in for loop. */
28 #pragma omp target update to(a)
30 /* Write a[BASE] .. a[BASE + N - 1]. */
31 #pragma omp target simd
32 for (int i
= N
- 1; i
> -1; i
-= s
)
35 #pragma omp target update from(a)
37 for (int i
= 0; i
< ALLOC_SIZE
; i
++)
39 int expected
= (BASE
<= i
&& i
< BASE
+ N
) ? 1 : 0;
43 printf ("Expected %d, got %d at base[%d]\n", expected
, a
[i
], i
- BASE
);