]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Spin 'dg-do run' part of 'libgomp.c/declare-variant-3-sm30.c' off into new 'libgomp...
authorThomas Schwinge <thomas@codesourcery.com>
Tue, 21 Nov 2023 18:03:47 +0000 (19:03 +0100)
committerThomas Schwinge <thomas@codesourcery.com>
Thu, 30 Nov 2023 14:42:57 +0000 (15:42 +0100)
Having nvptx offloading configured doesn't imply being able to run nvptx
offloading test cases on the test host.

Also, make 'libgomp.c/declare-variant-3.c' work for all non-offloading and
offloading cases.

Fix-up for commit 59b8ade88774b4dcf1691a8f650cdbb86cc30862
"[libgomp, testsuite, nvptx] Add libgomp.c/declare-variant-3-sm*.c".

libgomp/
* testsuite/libgomp.c/declare-variant-3-sm30.c: Turn 'dg-do run'
into 'dg-do link'.
* testsuite/libgomp.c/declare-variant-3.c: New.
* testsuite/libgomp.c/declare-variant-3.h: Extend.

libgomp/testsuite/libgomp.c/declare-variant-3-sm30.c
libgomp/testsuite/libgomp.c/declare-variant-3.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c/declare-variant-3.h

index a373647bb330a4b6de1e8003699feb35773a5849..d2ffa5637c5ea211741474246f6dad444f62b74d 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-do run { target { offload_target_nvptx } } } */
+/* { dg-do link { target { offload_target_nvptx } } } */
 /* { dg-additional-options -foffload=nvptx-none } */
 /* { dg-additional-options "-foffload=-misa=sm_30 -foffload=-mptx=_" } */
 /* { dg-additional-options "-foffload=-fdump-tree-optimized" } */
diff --git a/libgomp/testsuite/libgomp.c/declare-variant-3.c b/libgomp/testsuite/libgomp.c/declare-variant-3.c
new file mode 100644 (file)
index 0000000..62c1fa7
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-additional-options -DOFFLOAD_DEVICE_NVPTX { target offload_device_nvptx } } */
+/* { dg-additional-options {-fdump-tree-optimized -foffload-options=-fdump-tree-optimized} } */
+
+#include "declare-variant-3.h"
+
+/* { dg-final { scan-tree-dump "= f \\(\\);" "optimized" } }
+   { dg-final { only_for_offload_target amdgcn-amdhsa scan-offload-tree-dump "= f \\(\\);" "optimized" { target offload_target_amdgcn } } }
+   { dg-final { only_for_offload_target nvptx-none scan-offload-tree-dump "= f\[0-9\]+ \\(\\);" "optimized" { target offload_target_nvptx } } } */
index 646e15e53113e849e0ca126fe48539aced4f9b0f..38ee257e42dabb31b81fbc5f892a14c9e0167e60 100644 (file)
@@ -65,10 +65,15 @@ main (void)
   #pragma omp target map(from:v)
   v = f ();
 
+#ifdef OFFLOAD_DEVICE_NVPTX
   if (v == 0)
     __builtin_abort ();
 
   __builtin_printf ("Nvptx accelerator: sm_%d\n", v);
+#else
+  if (v != 0)
+    __builtin_abort ();
+#endif
 
   return 0;
 }