| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */ |
| 3 |
|
| 4 |
#include <openacc.h> |
| 5 |
#include <string.h> |
| 6 |
#include <stdio.h> |
| 7 |
#include <stdlib.h> |
| 8 |
#include <stdbool.h> |
| 9 |
|
| 10 |
int |
| 11 |
main (int argc, char **argv) |
| 12 |
{ |
| 13 |
int N = 8; |
| 14 |
float *a, *b, *c, *d; |
| 15 |
int i; |
| 16 |
|
| 17 |
a = (float *) malloc (N * sizeof (float)); |
| 18 |
b = (float *) malloc (N * sizeof (float)); |
| 19 |
c = (float *) malloc (N * sizeof (float)); |
| 20 |
|
| 21 |
for (i = 0; i < N; i++) |
| 22 |
{ |
| 23 |
a[i] = 2.0; |
| 24 |
b[i] = 5.0; |
| 25 |
} |
| 26 |
|
| 27 |
d = (float *) acc_malloc (N * sizeof (float)); |
| 28 |
acc_map_data (c, d, N * sizeof (float)); |
| 29 |
|
| 30 |
fprintf (stderr, "CheCKpOInT\n"); |
| 31 |
#pragma acc parallel copyin (a[0:N]) present_or_create (c[0:N+1]) copyout (b[0:N]) |
| 32 |
{ |
| 33 |
int ii; |
| 34 |
|
| 35 |
for (ii = 0; ii < N; ii++) |
| 36 |
{ |
| 37 |
c[ii] = a[ii]; |
| 38 |
b[ii] = c[ii]; |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
for (i = 0; i < N; i++) |
| 43 |
{ |
| 44 |
if (a[i] != 2.0) |
| 45 |
abort (); |
| 46 |
|
| 47 |
if (b[i] != 2.0) |
| 48 |
abort (); |
| 49 |
} |
| 50 |
|
| 51 |
if (acc_is_present (a, (N * sizeof (float)))) |
| 52 |
abort (); |
| 53 |
|
| 54 |
if (acc_is_present (b, (N * sizeof (float)))) |
| 55 |
abort (); |
| 56 |
|
| 57 |
if (!acc_is_present (c, (N * sizeof (float)))) |
| 58 |
abort (); |
| 59 |
|
| 60 |
d = (float *) acc_deviceptr (c); |
| 61 |
|
| 62 |
acc_unmap_data (c); |
| 63 |
|
| 64 |
acc_free (d); |
| 65 |
|
| 66 |
return 0; |
| 67 |
} |
| 68 |
|
| 69 |
/* { dg-output "CheCKpOInT(\n|\r\n|\r).*" } */ |
| 70 |
/* { dg-output "Trying to map into device \\\[\[0-9a-fA-FxX\]+..\[0-9a-fA-FxX\]+\\\) object when \\\[\[0-9a-fA-FxX\]+..\[0-9a-fA-FxX\]+\\\) is already mapped" } */ |
| 71 |
/* { dg-shouldfail "" } */ |