| 1 |
/* Verify enter/exit data interoperability between pragmas and |
| 2 |
acc library calls. */ |
| 3 |
|
| 4 |
/* { dg-do run } */ |
| 5 |
|
| 6 |
#include <stdlib.h> |
| 7 |
#include <assert.h> |
| 8 |
#include <openacc.h> |
| 9 |
|
| 10 |
int |
| 11 |
main () |
| 12 |
{ |
| 13 |
int *p = (int *)malloc (sizeof (int)); |
| 14 |
|
| 15 |
/* Test 1: pragma input, library output. */ |
| 16 |
|
| 17 |
#pragma acc enter data copyin (p[0:1]) |
| 18 |
|
| 19 |
#pragma acc parallel present (p[0:1]) num_gangs (1) |
| 20 |
{ |
| 21 |
p[0] = 1; |
| 22 |
} |
| 23 |
|
| 24 |
acc_copyout (p, sizeof (int)); |
| 25 |
|
| 26 |
assert (p[0] == 1); |
| 27 |
|
| 28 |
/* Test 2: library input, pragma output. */ |
| 29 |
|
| 30 |
acc_copyin (p, sizeof (int)); |
| 31 |
|
| 32 |
#pragma acc parallel present (p[0:1]) num_gangs (1) |
| 33 |
{ |
| 34 |
p[0] = 2; |
| 35 |
} |
| 36 |
|
| 37 |
#pragma acc exit data copyout (p[0:1]) |
| 38 |
|
| 39 |
assert (p[0] == 2); |
| 40 |
|
| 41 |
/* Test 3: library input, library output. */ |
| 42 |
|
| 43 |
acc_copyin (p, sizeof (int)); |
| 44 |
|
| 45 |
#pragma acc parallel present (p[0:1]) num_gangs (1) |
| 46 |
{ |
| 47 |
p[0] = 3; |
| 48 |
} |
| 49 |
|
| 50 |
acc_copyout (p, sizeof (int)); |
| 51 |
|
| 52 |
assert (p[0] == 3); |
| 53 |
|
| 54 |
/* Test 4: pragma input, pragma output. */ |
| 55 |
|
| 56 |
#pragma acc enter data copyin (p[0:1]) |
| 57 |
|
| 58 |
#pragma acc parallel present (p[0:1]) num_gangs (1) |
| 59 |
{ |
| 60 |
p[0] = 3; |
| 61 |
} |
| 62 |
|
| 63 |
#pragma acc exit data copyout (p[0:1]) |
| 64 |
|
| 65 |
assert (p[0] == 3); |
| 66 |
|
| 67 |
free (p); |
| 68 |
|
| 69 |
return 0; |
| 70 |
} |