aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Burnus <tburnus@baylibre.com>2025-04-24 18:26:30 +0200
committerTobias Burnus <tburnus@baylibre.com>2025-04-24 18:26:30 +0200
commit8ef0518bce489c4c0c252a0e0c44193c5f7cf777 (patch)
tree76736eb1b015ba2724b1beff4665301f05e373e1
parent2fb6ddd45872f04306375572c281ec65ee59c761 (diff)
downloadgcc-8ef0518bce489c4c0c252a0e0c44193c5f7cf777.zip
gcc-8ef0518bce489c4c0c252a0e0c44193c5f7cf777.tar.gz
gcc-8ef0518bce489c4c0c252a0e0c44193c5f7cf777.tar.bz2
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__.
-rw-r--r--libgomp/testsuite/lib/libgomp.exp2
-rw-r--r--libgomp/testsuite/libgomp.c/interop-hip-nvidia-full.c2
-rw-r--r--libgomp/testsuite/libgomp.c/interop-hipblas-nvidia-full.c2
-rw-r--r--libgomp/testsuite/libgomp.c/interop-hipblas.h14
4 files changed, 16 insertions, 4 deletions
diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index a057394..54f2f708 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 324504f..79af47d 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 c195d24..ed428c6 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 11cb4d2..d7cb174 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__)