Add 'libgomp.oacc-c-c++-common/struct-copyout-{1, 2}.c' (was: [PATCH 1/3] OpenACC "exit data" copyout for struct members)

Message ID 873679sd6f.fsf@euler.schwinge.homeip.net
State New
Headers show
Series
  • Add 'libgomp.oacc-c-c++-common/struct-copyout-{1, 2}.c' (was: [PATCH 1/3] OpenACC "exit data" copyout for struct members)
Related show

Commit Message

Thomas Schwinge June 5, 2020, 4:14 p.m.
Hi!

On 2020-06-04T06:40:53-0700, Julian Brown <julian@codesourcery.com> wrote:
> [...] I've added a couple of new testcases to verify the behaviour

> (which fail without the patch).


Thanks.  Given the preparational patches pushed yesterday, these now PASS
already.

>       * testsuite/libgomp.oacc-c-c++-common/struct-copyout-1.c: New test.

>       * testsuite/libgomp.oacc-c-c++-common/struct-copyout-2.c: New test.


Pushed "Add 'libgomp.oacc-c-c++-common/struct-copyout-{1,2}.c'" to master
branch in commit 9643f5bbe237764cbefc975e934d1281f47ee3c2, and
releases/gcc-10 branch in commit
52d737058897eb438099b57234d41330147d0b6f, see attached.


Grüße
 Thomas


-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

Patch

From 52d737058897eb438099b57234d41330147d0b6f Mon Sep 17 00:00:00 2001
From: Julian Brown <julian@codesourcery.com>
Date: Thu, 4 Jun 2020 06:40:53 -0700
Subject: [PATCH] Add 'libgomp.oacc-c-c++-common/struct-copyout-{1,2}.c'

	libgomp/
	* testsuite/libgomp.oacc-c-c++-common/struct-copyout-1.c: New test.
	* testsuite/libgomp.oacc-c-c++-common/struct-copyout-2.c: New test.

Reviewed-by: Thomas Schwinge <thomas@codesourcery.com>
(cherry picked from commit 9643f5bbe237764cbefc975e934d1281f47ee3c2)
---
 .../struct-copyout-1.c                        | 38 ++++++++++++++++
 .../struct-copyout-2.c                        | 44 +++++++++++++++++++
 2 files changed, 82 insertions(+)
 create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/struct-copyout-1.c
 create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/struct-copyout-2.c

diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/struct-copyout-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/struct-copyout-1.c
new file mode 100644
index 000000000000..b86f1c921a98
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/struct-copyout-1.c
@@ -0,0 +1,38 @@ 
+#include <assert.h>
+
+struct str1 {
+  int a;
+  int b;
+};
+
+struct str2 {
+  int c;
+  int d;
+  struct str1 s;
+};
+
+int
+main (int argc, char *argv[])
+{
+  struct str2 t;
+
+  t.c = 1;
+  t.d = 2;
+  t.s.a = 3;
+  t.s.b = 4;
+
+  #pragma acc enter data copyin(t.s)
+
+  #pragma acc serial present(t.s) /* { dg-warning "using vector_length \\(32\\), ignoring 1" "" { target openacc_nvidia_accel_selected } } */
+  {
+    t.s.a = 5;
+    t.s.b = 6;
+  }
+
+  #pragma acc exit data copyout(t.s)
+
+  assert (t.s.a == 5);
+  assert (t.s.b == 6);
+
+  return 0;
+}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/struct-copyout-2.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/struct-copyout-2.c
new file mode 100644
index 000000000000..4dd8a3a7e175
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/struct-copyout-2.c
@@ -0,0 +1,44 @@ 
+#include <assert.h>
+#include <stdlib.h>
+
+struct str1 {
+  int a;
+  int b;
+  int *c;
+};
+
+#define N 1024
+
+int
+main (int argc, char *argv[])
+{
+  struct str1 s;
+
+  s.a = 1;
+  s.b = 2;
+  s.c = (int *) malloc (sizeof (int) * N);
+
+  for (int i = 0; i < N; i++)
+    s.c[i] = i + 10;
+
+  #pragma acc enter data copyin(s.a, s.b, s.c[0:N])
+
+  #pragma acc serial present(s.a, s.b, s.c[0:N]) /* { dg-warning "using vector_length \\(32\\), ignoring 1" "" { target openacc_nvidia_accel_selected } } */
+  {
+    s.a = 3;
+    s.b = 4;
+    for (int i = 0; i < N; i++)
+      s.c[i] = i + 20;
+  }
+
+  #pragma acc exit data copyout(s.a, s.b, s.c[0:N])
+
+  assert (s.a == 3);
+  assert (s.b == 4);
+  for (int i = 0; i < N; i++)
+    assert (s.c[i] == i + 20);
+
+  free (s.c);
+
+  return 0;
+}
-- 
2.26.2