diff options
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/HIP/ArchitectureOff/CMakeLists.txt | 14 | ||||
-rw-r--r-- | Tests/HIP/CMakeLists.txt | 5 | ||||
-rw-r--r-- | Tests/HIP/CompileFlags/CMakeLists.txt | 7 | ||||
-rw-r--r-- | Tests/HIP/MathFunctions/CMakeLists.txt | 6 | ||||
-rw-r--r-- | Tests/HIP/TryCompile/CMakeLists.txt | 7 | ||||
-rw-r--r-- | Tests/HIP/WithDefs/CMakeLists.txt | 8 | ||||
-rw-r--r-- | Tests/HIP/WithDefs/main.hip.cpp | 4 |
7 files changed, 40 insertions, 11 deletions
diff --git a/Tests/HIP/ArchitectureOff/CMakeLists.txt b/Tests/HIP/ArchitectureOff/CMakeLists.txt index bccb3b4..18f3a1e 100644 --- a/Tests/HIP/ArchitectureOff/CMakeLists.txt +++ b/Tests/HIP/ArchitectureOff/CMakeLists.txt @@ -2,7 +2,17 @@ cmake_minimum_required(VERSION 3.18) project(HIPArchitecture HIP) # Make sure CMake doesn't pass architectures if HIP_ARCHITECTURES is OFF. -string(APPEND CMAKE_HIP_FLAGS " --offload-arch=gfx908") +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) -set_property(TARGET HIPOnlyArchitectureOff PROPERTY HIP_ARCHITECTURES OFF) +get_property(hip_archs TARGET HIPOnlyArchitectureOff PROPERTY HIP_ARCHITECTURES) +if(NOT hip_archs STREQUAL "OFF") + message(FATAL_ERROR "CMAKE_HIP_ARCHITECTURES did not initialize HIP_ARCHITECTURES") +endif() 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 c808313..a3adb7b 100644 --- a/Tests/HIP/CompileFlags/CMakeLists.txt +++ b/Tests/HIP/CompileFlags/CMakeLists.txt @@ -3,6 +3,11 @@ project(CompileFlags HIP) add_executable(HIPOnlyCompileFlags main.hip) -set_property(TARGET HIPOnlyCompileFlags PROPERTY HIP_ARCHITECTURES gfx803) +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}) target_compile_options(HIPOnlyCompileFlags PRIVATE -DALWAYS_DEFINE) 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 92a834c..1022a58 100644 --- a/Tests/HIP/TryCompile/CMakeLists.txt +++ b/Tests/HIP/TryCompile/CMakeLists.txt @@ -4,7 +4,12 @@ project (TryCompile HIP) #Goal for this example: # Verify try_compile with HIP language works set(CMAKE_HIP_STANDARD 14) -set(CMAKE_HIP_ARCHITECTURES gfx803 gfx900) + +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) try_compile(result "${CMAKE_CURRENT_BINARY_DIR}" diff --git a/Tests/HIP/WithDefs/CMakeLists.txt b/Tests/HIP/WithDefs/CMakeLists.txt index 270f957..5602111 100644 --- a/Tests/HIP/WithDefs/CMakeLists.txt +++ b/Tests/HIP/WithDefs/CMakeLists.txt @@ -2,12 +2,11 @@ cmake_minimum_required(VERSION 3.18) project (WithDefs HIP) -set(CMAKE_HIP_ARCHITECTURES OFF) set(release_compile_defs DEFREL) #Goal for this example: -#build a executable that needs to be passed a complex define through add_definitions -#this verifies we can pass C++ style attributes to hipcc +#Build an executable that needs to be passed a complex define through add_definitions. +#Verify we can pass C++ style attributes to the HIP compiler. add_definitions("-DPACKED_DEFINE=[[gnu::packed]]") add_executable(HIPOnlyWithDefs main.hip.cpp) @@ -17,9 +16,8 @@ target_compile_features(HIPOnlyWithDefs PRIVATE hip_std_17) target_compile_options(HIPOnlyWithDefs PRIVATE - --offload-arch=gfx900 -DFLAG_COMPILE_LANG_$<COMPILE_LANGUAGE> - $<$<HIP_COMPILER_ID:Clang>:-DFLAG_LANG_IS_HIP=$<COMPILE_LANGUAGE:HIP>> # Host-only defines are possible only on NVCC. + -DFLAG_LANG_IS_HIP=$<COMPILE_LANGUAGE:HIP> ) target_compile_definitions(HIPOnlyWithDefs 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; |