https://gcc.gnu.org/g:8ef0518bce489c4c0c252a0e0c44193c5f7cf777
commit r16-115-g8ef0518bce489c4c0c252a0e0c44193c5f7cf777 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__. Diff: --- 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 +++++++++++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp index a057394ca13f..54f2f708b1ba 100644 --- a/libgomp/testsuite/lib/libgomp.exp +++ b/libgomp/testsuite/lib/libgomp.exp @@ -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) 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 11cb4d280309..d7cb174b9e15 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__)