Add 'libgomp.oacc-c-c++-common/host_data-6.c'
diff mbox series

Message ID 87r21d3ekn.fsf@euler.schwinge.homeip.net
State New
Headers show
Series
  • Add 'libgomp.oacc-c-c++-common/host_data-6.c'
Related show

Commit Message

Thomas Schwinge Dec. 9, 2019, 11:48 a.m. UTC
Hi!

See attached "Add 'libgomp.oacc-c-c++-common/host_data-6.c'", committed
to trunk in r279119.


Grüße
 Thomas

Patch
diff mbox series

From e5247d4a6930ca12fef2d38922cf6dbd9812da22 Mon Sep 17 00:00:00 2001
From: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 9 Dec 2019 11:40:08 +0000
Subject: [PATCH] Add 'libgomp.oacc-c-c++-common/host_data-6.c'

	libgomp/
	* testsuite/libgomp.oacc-c-c++-common/host_data-6.c: New file.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@279119 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog                             |  2 +
 .../libgomp.oacc-c-c++-common/host_data-6.c   | 47 +++++++++++++++++++
 2 files changed, 49 insertions(+)
 create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/host_data-6.c

diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index c5541bcec81..6ef2f24e4d5 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/host_data-6.c: New file.
+
 	* target.c (gomp_exit_data): Use 'gomp_remove_var'.
 
 2019-12-09  Tobias Burnus  <tobias@codesourcery.com>
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/host_data-6.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/host_data-6.c
new file mode 100644
index 00000000000..1cda442b001
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/host_data-6.c
@@ -0,0 +1,47 @@ 
+/* Call 'acc_memcpy_from_device' inside '#pragma acc host_data'.  */
+
+/* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */
+
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include <openacc.h>
+
+int
+main ()
+{
+  const int SIZE = 318;
+  const int c0 = 22;
+  const int c1 = 112;
+
+  char *h = (char *) malloc (SIZE);
+
+  memset (h, c0, SIZE);
+
+#pragma acc data create (h[0:SIZE - 44])
+  {
+#pragma acc update device (h[0:SIZE - 44])
+
+    memset (h, c1, 67);
+
+    void *d = h;
+#pragma acc host_data use_device (d)
+    {
+      acc_memcpy_from_device (h, d, 12);
+    }
+  }
+
+  for (int i = 0; i < SIZE; ++i)
+    {
+      if (i < 12)
+	assert (h[i] == c0);
+      else if (i < 67)
+	assert (h[i] == c1);
+      else
+	assert (h[i] == c0);
+    }
+
+  free (h);
+
+  return 0;
+}
-- 
2.17.1