| 1 |
/* Test present data clauses in acc offloaded regions when the |
| 2 |
subarray inside the present clause does not have the same base |
| 3 |
offset value as the subarray in the enclosing acc data or acc enter |
| 4 |
data variable. */ |
| 5 |
|
| 6 |
#include <assert.h> |
| 7 |
|
| 8 |
void |
| 9 |
offset (int *data, int n) |
| 10 |
{ |
| 11 |
int i; |
| 12 |
|
| 13 |
#pragma acc parallel loop present (data[0:n]) |
| 14 |
for (i = 0; i < n; i++) |
| 15 |
data[i] = n; |
| 16 |
} |
| 17 |
|
| 18 |
int |
| 19 |
main () |
| 20 |
{ |
| 21 |
const int n = 30; |
| 22 |
int data[n], i; |
| 23 |
|
| 24 |
for (i = 0; i < n; i++) |
| 25 |
data[i] = -1; |
| 26 |
|
| 27 |
#pragma acc data copy(data[0:n]) |
| 28 |
{ |
| 29 |
offset (data + 10, 10); |
| 30 |
} |
| 31 |
|
| 32 |
for (i = 0; i < n; i++) |
| 33 |
{ |
| 34 |
if (i < 10 || i >= 20) |
| 35 |
assert (data[i] == -1); |
| 36 |
else |
| 37 |
assert (data[i] == 10); |
| 38 |
} |
| 39 |
|
| 40 |
return 0; |
| 41 |
} |