OpenACC documentation updates.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c / clauses-2.c
blob8dc45cb6287ef13b002625b6a202ce9ffe1cc659
1 /* { dg-do run } */
2 /* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */
4 #include <openacc.h>
5 #include <string.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <stdbool.h>
10 int
11 main (int argc, char **argv)
13 int N = 8;
14 float *a, *b, *c, *d;
15 int i;
17 a = (float *) malloc (N * sizeof (float));
18 b = (float *) malloc (N * sizeof (float));
19 c = (float *) malloc (N * sizeof (float));
21 for (i = 0; i < N; i++)
23 a[i] = 2.0;
24 b[i] = 5.0;
27 d = (float *) acc_malloc (N * sizeof (float));
28 acc_map_data (c, d, N * sizeof (float));
30 #pragma acc parallel copyin (a[0:N]) present_or_create (c[0:N+1]) copyout (b[0:N])
32 int ii;
34 for (ii = 0; ii < N; ii++)
36 c[ii] = a[ii];
37 b[ii] = c[ii];
41 for (i = 0; i < N; i++)
43 if (a[i] != 2.0)
44 abort ();
46 if (b[i] != 2.0)
47 abort ();
50 if (acc_is_present (a, (N * sizeof (float))))
51 abort ();
53 if (acc_is_present (b, (N * sizeof (float))))
54 abort ();
56 if (!acc_is_present (c, (N * sizeof (float))))
57 abort ();
59 d = (float *) acc_deviceptr (c);
61 acc_unmap_data (c);
63 acc_free (d);
65 return 0;
67 /* { dg-shouldfail "libgomp: \[\h+,\d+\] is not mapped" } */