public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-2528] Add 'libgomp.oacc-c-c++-common/async-data-1-{1,2}.c'
@ 2021-07-27  9:19 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2021-07-27  9:19 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:88c40c36db8a52d2c630aa61ee54e33908e9daec

commit r12-2528-g88c40c36db8a52d2c630aa61ee54e33908e9daec
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Tue Jan 9 11:57:00 2018 +0100

    Add 'libgomp.oacc-c-c++-common/async-data-1-{1,2}.c'
    
            libgomp/
            * testsuite/libgomp.oacc-c-c++-common/async-data-1-1.c: New file.
            * testsuite/libgomp.oacc-c-c++-common/async-data-1-2.c: Likewise.
    
    Co-Authored-By: Tom de Vries <tom@codesourcery.com>

Diff:
---
 .../libgomp.oacc-c-c++-common/async-data-1-1.c     |  90 +++++++++++++++++++
 .../libgomp.oacc-c-c++-common/async-data-1-2.c     | 100 +++++++++++++++++++++
 2 files changed, 190 insertions(+)

diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/async-data-1-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/async-data-1-1.c
new file mode 100644
index 00000000000..cd87aec56ff
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/async-data-1-1.c
@@ -0,0 +1,90 @@
+/* Verify back to back 'async' operations, one data mapping.
+
+   Due to one data mapping, this isn't using the libgomp 'cbuf' buffering.
+*/
+
+/* { dg-xfail-run-if "TODO" { openacc_radeon_accel_selected } } */
+
+
+#include <stdlib.h>
+
+
+#define N 128
+
+
+static void
+t1 (void)
+{
+  unsigned int *a;
+  int i;
+  int nbytes;
+
+  nbytes = N * sizeof (unsigned int);
+
+  a = (unsigned int *) malloc (nbytes);
+
+  for (i = 0; i < N; i++)
+    a[i] = 3;
+
+#pragma acc parallel async copy (a[0:N])
+  for (int ii = 0; ii < N; ii++)
+    a[ii] += 1;
+
+#pragma acc parallel async copy (a[0:N])
+  for (int ii = 0; ii < N; ii++)
+    a[ii] += 1;
+
+#pragma acc wait
+
+  for (i = 0; i < N; i++)
+    if (a[i] != 5)
+      abort ();
+}
+
+
+static void
+t2 (void)
+{
+  unsigned int *a;
+  int i;
+  int nbytes;
+
+  nbytes = N * sizeof (unsigned int);
+
+  a = (unsigned int *) malloc (nbytes);
+
+#pragma acc data copyin (a[0:N])
+  {
+    for (i = 0; i < N; i++)
+      a[i] = 3;
+
+#pragma acc update async device (a[0:N])
+#pragma acc parallel async present (a[0:N])
+  for (int ii = 0; ii < N; ii++)
+    a[ii] += 1;
+#pragma acc update async host (a[0:N])
+
+#pragma acc update async device (a[0:N])
+#pragma acc parallel async present (a[0:N])
+  for (int ii = 0; ii < N; ii++)
+    a[ii] += 1;
+#pragma acc update async host (a[0:N])
+
+#pragma acc wait
+  }
+
+  for (i = 0; i < N; i++)
+    if (a[i] != 5)
+      abort ();
+}
+
+
+int
+main (void)
+{
+  t1 ();
+
+  t2 ();
+
+  return 0;
+}
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/async-data-1-2.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/async-data-1-2.c
new file mode 100644
index 00000000000..385237698e2
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/async-data-1-2.c
@@ -0,0 +1,100 @@
+/* Verify back to back 'async' operations, two data mappings.
+
+   Due to two data mappings, this is using the libgomp 'cbuf' buffering.
+*/
+
+/* { dg-xfail-run-if "TODO" { openacc_radeon_accel_selected } } */
+
+
+#include <stdlib.h>
+
+
+#define N 128
+
+
+static void
+t1 (void)
+{
+  unsigned int *a, *b;
+  int i;
+  int nbytes;
+
+  nbytes = N * sizeof (unsigned int);
+
+  a = (unsigned int *) malloc (nbytes);
+  b = (unsigned int *) malloc (nbytes);
+
+  for (i = 0; i < N; i++)
+    b[i] = a[i] = 3;
+
+#pragma acc parallel async copy (a[0:N], b[0:N])
+  for (int ii = 0; ii < N; ii++)
+    b[ii] += (a[ii] += 1);
+
+#pragma acc parallel async copy (a[0:N], b[0:N])
+  for (int ii = 0; ii < N; ii++)
+    b[ii] += (a[ii] += 1);
+
+#pragma acc wait
+
+  for (i = 0; i < N; i++)
+    {
+      if (a[i] != 5)
+	abort ();
+      if (b[i] != 12)
+	abort ();
+    }
+}
+
+
+static void
+t2 (void)
+{
+  unsigned int *a, *b;
+  int i;
+  int nbytes;
+
+  nbytes = N * sizeof (unsigned int);
+
+  a = (unsigned int *) malloc (nbytes);
+  b = (unsigned int *) malloc (nbytes);
+
+#pragma acc data copyin (a[0:N], b[0:N])
+  {
+    for (i = 0; i < N; i++)
+      b[i] = a[i] = 3;
+
+#pragma acc update async device (a[0:N], b[0:N])
+#pragma acc parallel async present (a[0:N], b[0:N])
+  for (int ii = 0; ii < N; ii++)
+    b[ii] += (a[ii] += 1);
+#pragma acc update async host (a[0:N], b[0:N])
+
+#pragma acc update async device (a[0:N], b[0:N])
+#pragma acc parallel async present (a[0:N], b[0:N])
+  for (int ii = 0; ii < N; ii++)
+    b[ii] += (a[ii] += 1);
+#pragma acc update async host (a[0:N], b[0:N])
+
+#pragma acc wait
+  }
+
+  for (i = 0; i < N; i++)
+    {
+      if (a[i] != 5)
+	abort ();
+      if (b[i] != 12)
+	abort ();
+    }
+}
+
+
+int
+main (void)
+{
+  t1 ();
+
+  t2 ();
+
+  return 0;
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-27  9:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-27  9:19 [gcc r12-2528] Add 'libgomp.oacc-c-c++-common/async-data-1-{1,2}.c' Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).