[gcc/devel/omp/gcc-10] openmp: Add test for OMP_TARGET_OFFLOAD=mandatory for cases where it must not fail

Kwok Yeung kcy@gcc.gnu.org
Fri Nov 13 11:53:50 GMT 2020


https://gcc.gnu.org/g:374e0efd4e21b60cc8fb79eed408dd8ca2cee523

commit 374e0efd4e21b60cc8fb79eed408dd8ca2cee523
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Oct 22 09:33:17 2020 +0200

    openmp: Add test for OMP_TARGET_OFFLOAD=mandatory for cases where it must not fail
    
    This is a backport from mainline (commit
    17c5b7e1dc47bab6e6cedbf4b2d88cef3283533e).
    
    2020-10-22  Jakub Jelinek  <jakub@redhat.com>
    
            * testsuite/libgomp.c/target-41.c: New test.

Diff:
---
 libgomp/ChangeLog.omp                   |  7 +++++++
 libgomp/testsuite/libgomp.c/target-41.c | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 6dc9187181c..f62909557a7 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,3 +1,10 @@
+2020-11-11  Kwok Cheung Yeung  <kcy@codesourcery.com>
+
+	Backport from mainline
+	2020-10-22  Jakub Jelinek  <jakub@redhat.com>
+
+	* testsuite/libgomp.c/target-41.c: New test.
+
 2020-11-11  Kwok Cheung Yeung  <kcy@codesourcery.com>
 
 	Backport from mainline
diff --git a/libgomp/testsuite/libgomp.c/target-41.c b/libgomp/testsuite/libgomp.c/target-41.c
new file mode 100644
index 00000000000..d8d756f80e9
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/target-41.c
@@ -0,0 +1,33 @@
+/* { dg-set-target-env-var OMP_TARGET_OFFLOAD "mandatory" } */
+
+#include <omp.h>
+#include <stdlib.h>
+
+int v;
+
+void
+foo (void)
+{
+  v++;
+}
+
+#pragma omp declare target to (v, foo)
+
+int
+main ()
+{
+  /* OMP_TARGET_OFFLOAD=mandatory shouldn't fail for host fallback
+     if it is because the program explicitly asked for the host
+     fallback through if(false) or omp_get_initial_device () as
+     the device.  */
+  #pragma omp target if (v)
+  foo ();
+  #pragma omp target device (omp_get_initial_device ())
+  foo ();
+  omp_set_default_device (omp_get_initial_device ());
+  #pragma omp target
+  foo ();
+  if (v != 3)
+    abort ();
+  return 0;
+}


More information about the Gcc-cvs mailing list