summaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-61.c
diff options
context:
space:
mode:
Diffstat (limited to 'libgomp/testsuite/libgomp.oacc-c-c++-common/lib-61.c')
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/lib-61.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-61.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-61.c
new file mode 100644
index 00000000000..ce66ced28e8
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-61.c
@@ -0,0 +1,70 @@
+/* { dg-do run } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */
+
+#include <string.h>
+#include <stdlib.h>
+#include <openacc.h>
+
+int
+main (int argc, char **argv)
+{
+ const int N = 256;
+ int i;
+ unsigned char *h[N];
+ void *d[N];
+
+ for (i = 0; i < N; i++)
+ {
+ int j;
+ unsigned char *p;
+
+ h[i] = (unsigned char *) malloc (N);
+
+ p = h[i];
+
+ for (j = 0; j < N; j++)
+ {
+ p[j] = i;
+ }
+
+ d[i] = acc_malloc (N);
+
+ acc_memcpy_to_device (d[i], h[i], N);
+
+ for (j = 0; j < N; j++)
+ {
+ if (acc_is_present (h[i] + j, 1) != 0)
+ abort ();
+ }
+ }
+
+ for (i = 0; i < N; i++)
+ {
+ int j;
+ unsigned char *p;
+
+ memset (h[i], 0, N);
+
+ acc_memcpy_from_device (h[i], d[i], N);
+
+ p = h[i];
+
+ for (j = 0; j < N; j++)
+ {
+ if (p[j] != i)
+ abort ();
+ }
+
+ for (j = 0; j < N; j++)
+ {
+ if (acc_is_present (h[i] + j, 1) != 0)
+ abort ();
+ }
+
+ acc_free (d[i]);
+
+ free (h[i]);
+ }
+
+ return 0;
+}