From 38d117d220ccd49c6b2c3b6733ef4e5675eaf515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ty=C3=A1s=20Aradi?= Date: Thu, 1 Aug 2024 16:05:13 +0200 Subject: [PATCH] Update platform check and add CUDA CMake version check --- Tutorials/CMakeLists.txt | 1 - Tutorials/Reduction/CMakeLists.txt | 13 ++++++++++--- Tutorials/Reduction/benchmark/CMakeLists.txt | 17 +++++++---------- Tutorials/Reduction/example/CMakeLists.txt | 17 +++++++---------- Tutorials/Reduction/test/CMakeLists.txt | 17 +++++++---------- 5 files changed, 31 insertions(+), 34 deletions(-) diff --git a/Tutorials/CMakeLists.txt b/Tutorials/CMakeLists.txt index 290a6c03..14084d7a 100644 --- a/Tutorials/CMakeLists.txt +++ b/Tutorials/CMakeLists.txt @@ -27,4 +27,3 @@ file(RELATIVE_PATH folder_bin ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${folder_bin}) add_subdirectory(reduction) - diff --git a/Tutorials/Reduction/CMakeLists.txt b/Tutorials/Reduction/CMakeLists.txt index a738b33d..3b962754 100644 --- a/Tutorials/Reduction/CMakeLists.txt +++ b/Tutorials/Reduction/CMakeLists.txt @@ -20,10 +20,17 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia") - cmake_minimum_required(VERSION 3.25.2) +if("${GPU_RUNTIME}" STREQUAL "CUDA") + if(${CMAKE_VERSION} VERSION_LESS "3.25.2") + message( + STATUS + "Skipped: Reduction tutorial, because CMake version is too low." + ) + return() + endif() + cmake_minimum_required(VERSION 3.25.2) else() - cmake_minimum_required(VERSION 3.21) + cmake_minimum_required(VERSION 3.21) endif() project(Reduction LANGUAGES CXX) diff --git a/Tutorials/Reduction/benchmark/CMakeLists.txt b/Tutorials/Reduction/benchmark/CMakeLists.txt index 0c3f4606..588fe560 100644 --- a/Tutorials/Reduction/benchmark/CMakeLists.txt +++ b/Tutorials/Reduction/benchmark/CMakeLists.txt @@ -20,19 +20,16 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia") - cmake_minimum_required(VERSION 3.25.2) +if("${GPU_RUNTIME}" STREQUAL "CUDA") + cmake_minimum_required(VERSION 3.25.2) else() - cmake_minimum_required(VERSION 3.21) -endif() - -project(reduction_benchmarks LANGUAGES CXX) - -if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "amd") + cmake_minimum_required(VERSION 3.21) # Add -fPIE flag to compiler. set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() +project(reduction_benchmarks LANGUAGES CXX) + include("${CMAKE_CURRENT_LIST_DIR}/../../../Common/HipPlatform.cmake") select_gpu_language() @@ -63,7 +60,7 @@ set(include_dirs "../../../Common") list(APPEND include_dirs "${PROJECT_SOURCE_DIR}") # For examples targeting NVIDIA, include the HIP header directory. -if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia") +if("${GPU_RUNTIME}" STREQUAL "CUDA") list(APPEND include_dirs "${ROCM_ROOT}/include") endif() @@ -133,7 +130,7 @@ foreach(VER RANGE 0 10) $<$:TBB::tbb> ) - if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia") + if("${GPU_RUNTIME}" STREQUAL "CUDA") set_source_files_properties( ${Sources} PROPERTIES LANGUAGE ${GPU_RUNTIME} diff --git a/Tutorials/Reduction/example/CMakeLists.txt b/Tutorials/Reduction/example/CMakeLists.txt index 3ad6527f..d28fb3e8 100644 --- a/Tutorials/Reduction/example/CMakeLists.txt +++ b/Tutorials/Reduction/example/CMakeLists.txt @@ -20,19 +20,16 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia") - cmake_minimum_required(VERSION 3.25.2) +if("${GPU_RUNTIME}" STREQUAL "CUDA") + cmake_minimum_required(VERSION 3.25.2) else() - cmake_minimum_required(VERSION 3.21) -endif() - -project(reduction_examples LANGUAGES CXX) - -if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "amd") + cmake_minimum_required(VERSION 3.21) # Add -fPIE flag to compiler. set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() +project(reduction_examples LANGUAGES CXX) + include("${CMAKE_CURRENT_LIST_DIR}/../../../Common/HipPlatform.cmake") select_gpu_language() @@ -63,7 +60,7 @@ set(include_dirs "../../../Common") list(APPEND include_dirs "${PROJECT_SOURCE_DIR}") # For examples targeting NVIDIA, include the HIP header directory. -if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia") +if("${GPU_RUNTIME}" STREQUAL "CUDA") list(APPEND include_dirs "${ROCM_ROOT}/include") endif() @@ -102,7 +99,7 @@ foreach(VER RANGE 1 9) set_target_properties(${TargetName} PROPERTIES LINKER_LANGUAGE CXX) - if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia") + if("${GPU_RUNTIME}" STREQUAL "CUDA") set_target_properties(${TargetName} PROPERTIES CUDA_STANDARD 20) endif() diff --git a/Tutorials/Reduction/test/CMakeLists.txt b/Tutorials/Reduction/test/CMakeLists.txt index 622d10f0..2c0340e4 100644 --- a/Tutorials/Reduction/test/CMakeLists.txt +++ b/Tutorials/Reduction/test/CMakeLists.txt @@ -20,19 +20,16 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia") - cmake_minimum_required(VERSION 3.25.2) +if("${GPU_RUNTIME}" STREQUAL "CUDA") + cmake_minimum_required(VERSION 3.25.2) else() - cmake_minimum_required(VERSION 3.21) -endif() - -project(reduction_tests LANGUAGES CXX) - -if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "amd") + cmake_minimum_required(VERSION 3.21) # Add -fPIE flag to compiler. set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() +project(reduction_tests LANGUAGES CXX) + include("${CMAKE_CURRENT_LIST_DIR}/../../../Common/HipPlatform.cmake") select_gpu_language() @@ -63,7 +60,7 @@ set(include_dirs "../../../Common") list(APPEND include_dirs "${PROJECT_SOURCE_DIR}") # For examples targeting NVIDIA, include the HIP header directory. -if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia") +if("${GPU_RUNTIME}" STREQUAL "CUDA") list(APPEND include_dirs "${ROCM_ROOT}/include") endif() @@ -154,7 +151,7 @@ foreach(VER RANGE 1 10) $<$:TBB::tbb> ) - if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia") + if("${GPU_RUNTIME}" STREQUAL "CUDA") set_source_files_properties( ${Sources} PROPERTIES LANGUAGE ${ROCM_EXAMPLES_GPU_LANGUAGE}