Committed asr16-497-g94e63410474a36. It turned out that the interop HIP/CUDA testcases could FAIL in the following less common case: The CUDA or HIP runtime is installed but the default device is not an Nvidia or AMD device, respectively. With the commit, the 'dg-do run' is downgraded to a 'dg-do link' if the default device is not the expected GPU type. Note that the cuBLAS/hipBLAS tests do not need this as they already have a runtime test for the GPU type and iterate all devices (including the host), using a fallback if the vendor lib is not supported for a device. Thanks to Sandra for reporting the issue! Tobias
commit 94e63410474a36655e1800387eabd73a6f930048
Author: Tobias Burnus <tbur...@baylibre.com>
Date:   Fri May 9 10:57:44 2025 +0200

    libgomp.{c,fortran}/interop-{hip,cuda}: Fix dg-run target selection
    
    While the tests checked whether the CUDA/HIP runtime is available
    before processing them, the execution was then done unconditionally,
    leading to FAIL when the default device was the host (or the wrong
    offload device).
    
    Now the test is only executed ('run') when the default device is an
    Nvidia or AMD GPU (depending on the test case, cf. the test file name).
    Otherwise, only a 'link' test is done. (Except when the effective-target
    check cannot find the runtime lib - then the test is skipped [as before].)
    
    Note: The cublas/hipblas tests use variant functions and iterate over
    all devices, such that the cublas or hipblas, respectively, is only
    called when the active device is an AMD or Nvidia device, respectively,
    while for the host and other device types the fallback is called.
    
    libgomp/ChangeLog:
    
            * testsuite/libgomp.c/interop-cuda-full.c: Use 'link' instead
            of 'run' when the default device is "! offload_device_nvptx".
            * testsuite/libgomp.c/interop-cuda-libonly.c: Likewise.
            * testsuite/libgomp.c/interop-hip-nvidia-full.c: Likewise.
            * testsuite/libgomp.c/interop-hip-nvidia-no-headers.c: Likewise.
            * testsuite/libgomp.c/interop-hip-nvidia-no-hip-header.c: Likewise.
            * testsuite/libgomp.fortran/interop-hip-nvidia-full.F90: Likewise.
            * testsuite/libgomp.fortran/interop-hip-nvidia-no-module.F90: Likewise.
            * testsuite/libgomp.c/interop-hip-amd-full.c: Use 'link' instead
            of 'run' when the default device is "! offload_device_gcn".
            * testsuite/libgomp.c/interop-hip-amd-no-hip-header.c: Likewise.
            * testsuite/libgomp.fortran/interop-hip-amd-full.F90: Likewise.
            * testsuite/libgomp.fortran/interop-hip-amd-no-module.F90: Likewise.
---
 libgomp/testsuite/libgomp.c/interop-cuda-full.c                    | 3 +++
 libgomp/testsuite/libgomp.c/interop-cuda-libonly.c                 | 3 +++
 libgomp/testsuite/libgomp.c/interop-hip-amd-full.c                 | 3 +++
 libgomp/testsuite/libgomp.c/interop-hip-amd-no-hip-header.c        | 3 +++
 libgomp/testsuite/libgomp.c/interop-hip-nvidia-full.c              | 3 +++
 libgomp/testsuite/libgomp.c/interop-hip-nvidia-no-headers.c        | 3 +++
 libgomp/testsuite/libgomp.c/interop-hip-nvidia-no-hip-header.c     | 3 +++
 libgomp/testsuite/libgomp.fortran/interop-hip-amd-full.F90         | 3 +++
 libgomp/testsuite/libgomp.fortran/interop-hip-amd-no-module.F90    | 3 +++
 libgomp/testsuite/libgomp.fortran/interop-hip-nvidia-full.F90      | 3 +++
 libgomp/testsuite/libgomp.fortran/interop-hip-nvidia-no-module.F90 | 3 +++
 11 files changed, 33 insertions(+)

diff --git a/libgomp/testsuite/libgomp.c/interop-cuda-full.c b/libgomp/testsuite/libgomp.c/interop-cuda-full.c
index 38aa6b130bb..c48a934978d 100644
--- a/libgomp/testsuite/libgomp.c/interop-cuda-full.c
+++ b/libgomp/testsuite/libgomp.c/interop-cuda-full.c
@@ -1,3 +1,6 @@
+/* { dg-do run { target { offload_device_nvptx } } } */
+/* { dg-do link { target { ! offload_device_nvptx } } } */
+
 /* { dg-require-effective-target openacc_cuda } */
 /* { dg-require-effective-target openacc_cudart } */
 /* { dg-additional-options "-lcuda -lcudart" } */
diff --git a/libgomp/testsuite/libgomp.c/interop-cuda-libonly.c b/libgomp/testsuite/libgomp.c/interop-cuda-libonly.c
index 17cbb159183..bc257a24ee8 100644
--- a/libgomp/testsuite/libgomp.c/interop-cuda-libonly.c
+++ b/libgomp/testsuite/libgomp.c/interop-cuda-libonly.c
@@ -1,3 +1,6 @@
+/* { dg-do run { target { offload_device_nvptx } } } */
+/* { dg-do link { target { ! offload_device_nvptx } } } */
+
 /* { dg-require-effective-target openacc_libcudart } */
 /* { dg-require-effective-target openacc_libcuda } */
 /* { dg-additional-options "-lcuda -lcudart" } */
diff --git a/libgomp/testsuite/libgomp.c/interop-hip-amd-full.c b/libgomp/testsuite/libgomp.c/interop-hip-amd-full.c
index d7725fc8e34..bd44f442210 100644
--- a/libgomp/testsuite/libgomp.c/interop-hip-amd-full.c
+++ b/libgomp/testsuite/libgomp.c/interop-hip-amd-full.c
@@ -1,3 +1,6 @@
+/* { dg-do run { target { offload_device_gcn } } } */
+/* { dg-do link { target { ! offload_device_gcn } } } */
+
 /* { dg-require-effective-target gomp_hip_header_amd } */
 /* { dg-require-effective-target gomp_libamdhip64 } */
 /* { dg-additional-options "-lamdhip64" } */
diff --git a/libgomp/testsuite/libgomp.c/interop-hip-amd-no-hip-header.c b/libgomp/testsuite/libgomp.c/interop-hip-amd-no-hip-header.c
index 25845379fcc..91ad987631f 100644
--- a/libgomp/testsuite/libgomp.c/interop-hip-amd-no-hip-header.c
+++ b/libgomp/testsuite/libgomp.c/interop-hip-amd-no-hip-header.c
@@ -1,3 +1,6 @@
+/* { dg-do run { target { offload_device_gcn } } } */
+/* { dg-do link { target { ! offload_device_gcn } } } */
+
 /* { dg-require-effective-target gomp_libamdhip64 } */
 /* { dg-additional-options "-lamdhip64" } */
 
diff --git a/libgomp/testsuite/libgomp.c/interop-hip-nvidia-full.c b/libgomp/testsuite/libgomp.c/interop-hip-nvidia-full.c
index 79af47dc076..d5dc236fcd8 100644
--- a/libgomp/testsuite/libgomp.c/interop-hip-nvidia-full.c
+++ b/libgomp/testsuite/libgomp.c/interop-hip-nvidia-full.c
@@ -1,3 +1,6 @@
+/* { dg-do run { target { offload_device_nvptx } } } */
+/* { dg-do link { target { ! offload_device_nvptx } } } */
+
 /* { dg-require-effective-target openacc_cudart } */
 /* { dg-require-effective-target openacc_cuda } */
 /* { dg-require-effective-target gomp_hip_header_nvidia } */
diff --git a/libgomp/testsuite/libgomp.c/interop-hip-nvidia-no-headers.c b/libgomp/testsuite/libgomp.c/interop-hip-nvidia-no-headers.c
index 4586398ff00..7cff2cb80af 100644
--- a/libgomp/testsuite/libgomp.c/interop-hip-nvidia-no-headers.c
+++ b/libgomp/testsuite/libgomp.c/interop-hip-nvidia-no-headers.c
@@ -1,3 +1,6 @@
+/* { dg-do run { target { offload_device_nvptx } } } */
+/* { dg-do link { target { ! offload_device_nvptx } } } */
+
 /* { dg-require-effective-target openacc_libcudart } */
 /* { dg-require-effective-target openacc_libcuda } */
 /* { dg-additional-options "-lcuda -lcudart" } */
diff --git a/libgomp/testsuite/libgomp.c/interop-hip-nvidia-no-hip-header.c b/libgomp/testsuite/libgomp.c/interop-hip-nvidia-no-hip-header.c
index 41869848fc5..7b7dc746397 100644
--- a/libgomp/testsuite/libgomp.c/interop-hip-nvidia-no-hip-header.c
+++ b/libgomp/testsuite/libgomp.c/interop-hip-nvidia-no-hip-header.c
@@ -1,3 +1,6 @@
+/* { dg-do run { target { offload_device_nvptx } } } */
+/* { dg-do link { target { ! offload_device_nvptx } } } */
+
 /* { dg-require-effective-target openacc_cudart } */
 /* { dg-require-effective-target openacc_cuda } */
 /* { dg-additional-options "-lcuda -lcudart" } */
diff --git a/libgomp/testsuite/libgomp.fortran/interop-hip-amd-full.F90 b/libgomp/testsuite/libgomp.fortran/interop-hip-amd-full.F90
index bbd49ddd010..eb2f4373de9 100644
--- a/libgomp/testsuite/libgomp.fortran/interop-hip-amd-full.F90
+++ b/libgomp/testsuite/libgomp.fortran/interop-hip-amd-full.F90
@@ -1,3 +1,6 @@
+! { dg-do run { target { offload_device_gcn } } }
+! { dg-do link { target { ! offload_device_gcn } } }
+
 ! { dg-require-effective-target gomp_hipfort_module }
 ! { dg-require-effective-target gomp_libamdhip64 }
 ! { dg-additional-options "-lamdhip64" }
diff --git a/libgomp/testsuite/libgomp.fortran/interop-hip-amd-no-module.F90 b/libgomp/testsuite/libgomp.fortran/interop-hip-amd-no-module.F90
index 0afec831841..0ebbe8063e3 100644
--- a/libgomp/testsuite/libgomp.fortran/interop-hip-amd-no-module.F90
+++ b/libgomp/testsuite/libgomp.fortran/interop-hip-amd-no-module.F90
@@ -1,3 +1,6 @@
+! { dg-do run { target { offload_device_gcn } } }
+! { dg-do link { target { ! offload_device_gcn } } }
+
 ! { dg-require-effective-target gomp_libamdhip64 }
 ! { dg-additional-options "-lamdhip64" }
 
diff --git a/libgomp/testsuite/libgomp.fortran/interop-hip-nvidia-full.F90 b/libgomp/testsuite/libgomp.fortran/interop-hip-nvidia-full.F90
index cef592f4926..d29a689de89 100644
--- a/libgomp/testsuite/libgomp.fortran/interop-hip-nvidia-full.F90
+++ b/libgomp/testsuite/libgomp.fortran/interop-hip-nvidia-full.F90
@@ -1,3 +1,6 @@
+! { dg-do run { target { offload_device_nvptx } } }
+! { dg-do link { target { ! offload_device_nvptx } } }
+
 ! { dg-require-effective-target gomp_hipfort_module }
 ! { dg-require-effective-target openacc_cudart }
 ! { dg-require-effective-target openacc_cuda }
diff --git a/libgomp/testsuite/libgomp.fortran/interop-hip-nvidia-no-module.F90 b/libgomp/testsuite/libgomp.fortran/interop-hip-nvidia-no-module.F90
index c1ef29d7008..20636103b73 100644
--- a/libgomp/testsuite/libgomp.fortran/interop-hip-nvidia-no-module.F90
+++ b/libgomp/testsuite/libgomp.fortran/interop-hip-nvidia-no-module.F90
@@ -1,3 +1,6 @@
+! { dg-do run { target { offload_device_nvptx } } }
+! { dg-do link { target { ! offload_device_nvptx } } }
+
 ! { dg-require-effective-target openacc_libcudart }
 ! { dg-require-effective-target openacc_libcuda }
 ! { dg-additional-options "-lcuda -lcudart" }

Reply via email to