aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2019-12-09 12:40:27 +0100
committerThomas Schwinge <tschwinge@gcc.gnu.org>2019-12-09 12:40:27 +0100
commit6effebe10be2c53472db9eb573cdeeac312036c1 (patch)
treef4ddce59c1413df157987a5b47d5f25652150591
parent7d02047320b1d47e4ab82d96dcb88dfe410e9be0 (diff)
downloadgcc-6effebe10be2c53472db9eb573cdeeac312036c1.zip
gcc-6effebe10be2c53472db9eb573cdeeac312036c1.tar.gz
gcc-6effebe10be2c53472db9eb573cdeeac312036c1.tar.bz2
Add 'libgomp.oacc-c-c++-common/map-data-1.c'
libgomp/ * testsuite/libgomp.oacc-c-c++-common/map-data-1.c: New file. From-SVN: r279121
-rw-r--r--libgomp/ChangeLog2
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/map-data-1.c53
2 files changed, 55 insertions, 0 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index aac3b18..51a00a3 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,5 +1,7 @@
2019-12-09 Thomas Schwinge <thomas@codesourcery.com>
+ * testsuite/libgomp.oacc-c-c++-common/map-data-1.c: New file.
+
PR libgomp/92854
* testsuite/libgomp.oacc-c-c++-common/pr92854-1.c: New file.
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/map-data-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/map-data-1.c
new file mode 100644
index 0000000..d0781dd
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/map-data-1.c
@@ -0,0 +1,53 @@
+/* Verify that 'acc_map_data' does not copy data to, and 'acc_unmap_data' does
+ not copy data from the device. */
+
+/* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */
+
+#include <stdlib.h>
+#include <string.h>
+#include <openacc.h>
+
+int
+main ()
+{
+ const int c0 = 9;
+ const int c1 = 40;
+ const int c2 = 47;
+
+ const size_t N = 256;
+
+ unsigned char *h = (unsigned char *) malloc (N);
+
+ void *d = acc_malloc (N);
+
+ memset (h, c0, N); // H <- c0
+ acc_memcpy_to_device (d, h, N); // D <- H = c0
+
+ memset (h, c1, N); // H <- c1
+ acc_map_data (h, d, N);
+ for (size_t i = 0; i < N; ++i)
+ if (h[i] != c1)
+ abort ();
+
+ acc_memcpy_from_device (h, d, N); // H <- D = c0
+ for (size_t i = 0; i < N; ++i)
+ if (h[i] != c0)
+ abort ();
+
+ memset (h, c2, N); // H <- c2
+ acc_unmap_data (h);
+ for (size_t i = 0; i < N; ++i)
+ if (h[i] != c2)
+ abort ();
+
+ acc_memcpy_from_device (h, d, N); // H <- D = c0
+ for (size_t i = 0; i < N; ++i)
+ if (h[i] != c0)
+ abort ();
+
+ acc_free (d);
+
+ free (h);
+
+ return 0;
+}