]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libgomp/testsuite: Fix hip_header_nvidia check, add workaround to test
authorTobias Burnus <tburnus@baylibre.com>
Thu, 24 Apr 2025 16:26:30 +0000 (18:26 +0200)
committerTobias Burnus <tburnus@baylibre.com>
Thu, 24 Apr 2025 16:26:30 +0000 (18:26 +0200)
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__.

libgomp/testsuite/lib/libgomp.exp
libgomp/testsuite/libgomp.c/interop-hip-nvidia-full.c
libgomp/testsuite/libgomp.c/interop-hipblas-nvidia-full.c
libgomp/testsuite/libgomp.c/interop-hipblas.h

index a057394ca13fe05c755da7665dd5134d6c7bbaa2..54f2f708b1ba0f30d46da5f7dcf4b55e7ba719cf 100644 (file)
@@ -671,7 +671,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)
index 324504feb22884bba7faa0efabf84c332317b125..79af47dc07654532cafdcc11c6f3c3d1d08599fe 100644 (file)
@@ -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
 
index c195d2486f693e27a33cabb8d000997c09a76020..ed428c6c760875ced0e3cc3ac55f35561da96c54 100644 (file)
@@ -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
 
index 11cb4d2803095d22e8fe2d847bdb08b48802f567..d7cb174b9e15a43676efddee59a7727db1627514 100644 (file)
@@ -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__)