https://gcc.gnu.org/g:c9731fdbe4b323f563ee07b05a9a2ff153708aee

commit c9731fdbe4b323f563ee07b05a9a2ff153708aee
Author: Tobias Burnus <tbur...@baylibre.com>
Date:   Thu Apr 24 18:26:30 2025 +0200

    libgomp/testsuite: Fix hip_header_nvidia check, add workaround to test
    
    This is all about using the AMD's HIP header files with
    __HIP_PLATFORM_NVIDIA__ defined, i.e. HIP with Nvidia/CUDA; in that case,
    HIP is a thin layer on top of CUDA.
    
    First, the check_effective_target_gomp_hip_header_nvidia check failed;
    to fix it, -Wno-deprecated-declarations was added - and likewise to the
    two affected testcases that actually used the HIP headers on Nvidia.
    
    Doing so, the HIP tested was successful but the HIP-BLAS one showed two
    issues:
    
    * One seems to be related to include search paths as the HIP header uses
      #include "library_types.h" to include that CUDA header. Seemingly, it
      tried to included (again) the HIP header hip/library_types.h, not the
      CUDA one. I guess, some tweaking of -isystem vs. -I could have
      prevented this, but the simpler workaround was to just explicitly
      include the CUDA one before the HIP header files.
    
    * Once done, everything compiled but linking failed as the association
      between three HIP-BLAS functions and their CUDA-BLAS ones did not
      work. Solution: Just add three #define for mapping them.
    
    libgomp/ChangeLog:
    
            * testsuite/lib/libgomp.exp
            (check_effective_target_gomp_hip_header_nvidia): Compile with
            "-Wno-deprecated-declarations".
            * testsuite/libgomp.c/interop-hip-nvidia-full.c: Likewise.
            * testsuite/libgomp.c/interop-hipblas-nvidia-full.c: Likewise.
            * testsuite/libgomp.c/interop-hipblas.h: Add workarounds
            when using the HIP headers with __HIP_PLATFORM_NVIDIA__.
    
    (cherry picked from commit 8ef0518bce489c4c0c252a0e0c44193c5f7cf777)

Diff:
---
 libgomp/ChangeLog.omp                                     | 13 +++++++++++++
 libgomp/testsuite/lib/libgomp.exp                         |  2 +-
 libgomp/testsuite/libgomp.c/interop-hip-nvidia-full.c     |  2 +-
 libgomp/testsuite/libgomp.c/interop-hipblas-nvidia-full.c |  2 +-
 libgomp/testsuite/libgomp.c/interop-hipblas.h             | 14 +++++++++++++-
 5 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 053e25302afe..bf1fe1b1bdd1 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,3 +1,16 @@
+2025-04-24  Tobias Burnus  <tbur...@baylibre.com>
+
+       Backported from master:
+       2025-04-24  Tobias Burnus  <tbur...@baylibre.com>
+
+       * testsuite/lib/libgomp.exp
+       (check_effective_target_gomp_hip_header_nvidia): Compile with
+       "-Wno-deprecated-declarations".
+       * testsuite/libgomp.c/interop-hip-nvidia-full.c: Likewise.
+       * testsuite/libgomp.c/interop-hipblas-nvidia-full.c: Likewise.
+       * testsuite/libgomp.c/interop-hipblas.h: Add workarounds
+       when using the HIP headers with __HIP_PLATFORM_NVIDIA__.
+
 2025-04-24  Tobias Burnus  <tbur...@baylibre.com>
 
        Backported from master:
diff --git a/libgomp/testsuite/lib/libgomp.exp 
b/libgomp/testsuite/lib/libgomp.exp
index 742045a46690..8c92c24df980 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -673,7 +673,7 @@ int main() {
     if (r != hipSuccess)
        return 1;
     return 0;
-} }]
+} } "-Wno-deprecated-declarations"]
 }
 
 # Return 1 if the Fortran hipfort module is available (no link check)
diff --git a/libgomp/testsuite/libgomp.c/interop-hip-nvidia-full.c 
b/libgomp/testsuite/libgomp.c/interop-hip-nvidia-full.c
index 324504feb228..79af47dc0765 100644
--- a/libgomp/testsuite/libgomp.c/interop-hip-nvidia-full.c
+++ b/libgomp/testsuite/libgomp.c/interop-hip-nvidia-full.c
@@ -1,7 +1,7 @@
 /* { dg-require-effective-target openacc_cudart } */
 /* { dg-require-effective-target openacc_cuda } */
 /* { dg-require-effective-target gomp_hip_header_nvidia } */
-/* { dg-additional-options "-lcuda -lcudart" } */
+/* { dg-additional-options "-lcuda -lcudart -Wno-deprecated-declarations" } */
 
 #define __HIP_PLATFORM_NVIDIA__ 1
 
diff --git a/libgomp/testsuite/libgomp.c/interop-hipblas-nvidia-full.c 
b/libgomp/testsuite/libgomp.c/interop-hipblas-nvidia-full.c
index c195d2486f69..ed428c6c7608 100644
--- a/libgomp/testsuite/libgomp.c/interop-hipblas-nvidia-full.c
+++ b/libgomp/testsuite/libgomp.c/interop-hipblas-nvidia-full.c
@@ -1,6 +1,6 @@
 /* { dg-require-effective-target openacc_cublas } */
 /* { dg-require-effective-target gomp_hip_header_nvidia } */
-/* { dg-additional-options "-lcublas" } */
+/* { dg-additional-options "-lcublas -Wno-deprecated-declarations" } */
 
 #define __HIP_PLATFORM_NVIDIA__ 1
 
diff --git a/libgomp/testsuite/libgomp.c/interop-hipblas.h 
b/libgomp/testsuite/libgomp.c/interop-hipblas.h
index 8b7e118a7aa3..c24d95d41267 100644
--- a/libgomp/testsuite/libgomp.c/interop-hipblas.h
+++ b/libgomp/testsuite/libgomp.c/interop-hipblas.h
@@ -24,7 +24,19 @@ Based on the interop example in OpenMP's example document  */
 #include "../libgomp.c-c++-common/on_device_arch.h"
 
 
-#if __has_include(<hipblas/hipblas.h>) && !defined(USE_HIP_FALLBACK_HEADER)
+#if __has_include(<hipblas/hipblas.h>) && (__has_include(<library_types.h>) || 
!defined(__HIP_PLATFORM_NVIDIA__)) && !defined(USE_HIP_FALLBACK_HEADER)
+  #ifdef __HIP_PLATFORM_NVIDIA__
+    /* There seems to be an issue with hip/library_types.h including
+       CUDA's "library_types.h". Include CUDA's one explicitly here.
+       Could possibly worked around by using -isystem vs. -I.  */
+    #include <library_types.h>
+
+    /* For some reasons, the following symbols do not seem to get
+       mapped from HIP to CUDA, causing link errors.  */
+    #define hipblasSetStream cublasSetStream_v2
+    #define hipblasDaxpy cublasDaxpy_v2
+    #define hipblasCreate cublasCreate_v2
+  #endif
   #include <hipblas/hipblas.h>
 
 #elif defined(__HIP_PLATFORM_AMD__)

Reply via email to