diff options
author | Brad King <brad.king@kitware.com> | 2023-09-18 19:46:39 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-09-21 19:34:37 (GMT) |
commit | 18158bf81ccb5269afcfa53cd671cf7f56dc70b5 (patch) | |
tree | c7877ec383af7831f4feb431ceb7dbe7d048d368 /Tests/HIP | |
parent | 127b6fa06bf53ad9f31d041a7d11434ca2856c8e (diff) | |
download | CMake-18158bf81ccb5269afcfa53cd671cf7f56dc70b5.zip CMake-18158bf81ccb5269afcfa53cd671cf7f56dc70b5.tar.gz CMake-18158bf81ccb5269afcfa53cd671cf7f56dc70b5.tar.bz2 |
HIP: Add support for NVIDIA GPUs
Add support for using the CUDA Toolkit's NVCC to compile HIP code.
Fixes: #25143
Diffstat (limited to 'Tests/HIP')
-rw-r--r-- | Tests/HIP/ArchitectureOff/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/HIP/CMakeLists.txt | 5 | ||||
-rw-r--r-- | Tests/HIP/CompileFlags/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/HIP/MathFunctions/CMakeLists.txt | 6 | ||||
-rw-r--r-- | Tests/HIP/TryCompile/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/HIP/WithDefs/main.hip.cpp | 4 |
6 files changed, 19 insertions, 2 deletions
diff --git a/Tests/HIP/ArchitectureOff/CMakeLists.txt b/Tests/HIP/ArchitectureOff/CMakeLists.txt index 9d0bf05..18f3a1e 100644 --- a/Tests/HIP/ArchitectureOff/CMakeLists.txt +++ b/Tests/HIP/ArchitectureOff/CMakeLists.txt @@ -7,6 +7,8 @@ set(CMAKE_HIP_ARCHITECTURES OFF) # Pass our own architecture flags instead. if(CMAKE_HIP_PLATFORM STREQUAL "amd") string(APPEND CMAKE_HIP_FLAGS " --offload-arch=gfx908") +elseif(CMAKE_HIP_PLATFORM STREQUAL "nvidia") + string(APPEND CMAKE_HIP_FLAGS " -arch=sm_52") endif() add_executable(HIPOnlyArchitectureOff main.hip) diff --git a/Tests/HIP/CMakeLists.txt b/Tests/HIP/CMakeLists.txt index 9499be8..26d7459 100644 --- a/Tests/HIP/CMakeLists.txt +++ b/Tests/HIP/CMakeLists.txt @@ -9,7 +9,10 @@ add_hip_test_macro(HIP.CompileFlags HIPOnlyCompileFlags) add_hip_test_macro(HIP.EnableStandard HIPEnableStandard) add_hip_test_macro(HIP.InferHipLang1 HIPInferHipLang1) add_hip_test_macro(HIP.InferHipLang2 HIPInferHipLang2) -add_hip_test_macro(HIP.MathFunctions HIPOnlyMathFunctions) +if(CMake_TEST_HIP STREQUAL "amd") + # The NVIDIA CUDA compiler cannot handle device lambda markup. + add_hip_test_macro(HIP.MathFunctions HIPOnlyMathFunctions) +endif() add_hip_test_macro(HIP.MixedLanguage HIPMixedLanguage) add_hip_test_macro(HIP.TryCompile HIPOnlyTryCompile) add_hip_test_macro(HIP.WithDefs HIPOnlyWithDefs) diff --git a/Tests/HIP/CompileFlags/CMakeLists.txt b/Tests/HIP/CompileFlags/CMakeLists.txt index 46a94a3..a3adb7b 100644 --- a/Tests/HIP/CompileFlags/CMakeLists.txt +++ b/Tests/HIP/CompileFlags/CMakeLists.txt @@ -5,6 +5,8 @@ add_executable(HIPOnlyCompileFlags main.hip) if(CMAKE_HIP_PLATFORM STREQUAL "amd") set(hip_archs gfx803) +elseif(CMAKE_HIP_PLATFORM STREQUAL "nvidia") + set(hip_archs 52) endif() set_property(TARGET HIPOnlyCompileFlags PROPERTY HIP_ARCHITECTURES ${hip_archs}) diff --git a/Tests/HIP/MathFunctions/CMakeLists.txt b/Tests/HIP/MathFunctions/CMakeLists.txt index 81e3ddb..7e768e8 100644 --- a/Tests/HIP/MathFunctions/CMakeLists.txt +++ b/Tests/HIP/MathFunctions/CMakeLists.txt @@ -14,5 +14,9 @@ project(MathFunctions HIP) # that hip needs that inject support for __half support # add_executable(HIPOnlyMathFunctions main.hip) -target_compile_options(HIPOnlyMathFunctions PRIVATE -Werror) +if(CMAKE_HIP_COMPILER_ID STREQUAL "NVIDIA") + target_compile_options(HIPOnlyMathFunctions PRIVATE "SHELL:-Werror all-warnings") +elseif(CMAKE_HIP_COMPILER_ID STREQUAL "Clang") + target_compile_options(HIPOnlyMathFunctions PRIVATE "-Werror") +endif() target_compile_features(HIPOnlyMathFunctions PRIVATE hip_std_14) diff --git a/Tests/HIP/TryCompile/CMakeLists.txt b/Tests/HIP/TryCompile/CMakeLists.txt index c98e59c..1022a58 100644 --- a/Tests/HIP/TryCompile/CMakeLists.txt +++ b/Tests/HIP/TryCompile/CMakeLists.txt @@ -7,6 +7,8 @@ set(CMAKE_HIP_STANDARD 14) if(CMAKE_HIP_PLATFORM STREQUAL "amd") set(CMAKE_HIP_ARCHITECTURES gfx803 gfx900) +elseif(CMAKE_HIP_PLATFORM STREQUAL "nvidia") + set(CMAKE_HIP_ARCHITECTURES 52) endif() set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) diff --git a/Tests/HIP/WithDefs/main.hip.cpp b/Tests/HIP/WithDefs/main.hip.cpp index a8f2d18..b69fa02 100644 --- a/Tests/HIP/WithDefs/main.hip.cpp +++ b/Tests/HIP/WithDefs/main.hip.cpp @@ -51,6 +51,10 @@ static __global__ void DetermineIfValidHIPDevice() # undef PACKED_DEFINE # define PACKED_DEFINE #endif +#ifdef __NVCC__ +# undef PACKED_DEFINE +# define PACKED_DEFINE +#endif struct PACKED_DEFINE result_type { bool valid; |