]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add 'libgomp.oacc-c-c++-common/async-data-1-{1,2}.c'
authorThomas Schwinge <thomas@codesourcery.com>
Tue, 9 Jan 2018 10:57:00 +0000 (11:57 +0100)
committerThomas Schwinge <thomas@codesourcery.com>
Tue, 27 Jul 2021 09:16:26 +0000 (11:16 +0200)
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>
libgomp/testsuite/libgomp.oacc-c-c++-common/async-data-1-1.c [new file with mode: 0644]
libgomp/testsuite/libgomp.oacc-c-c++-common/async-data-1-2.c [new file with mode: 0644]

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 (file)
index 0000000..cd87aec
--- /dev/null
@@ -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 (file)
index 0000000..3852376
--- /dev/null
@@ -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;
+}