From 2afb4c05a44790bf325ca0b523088f9ecf9d62c1 Mon Sep 17 00:00:00 2001 From: Attila Krasznahorkay Date: Thu, 16 May 2024 17:42:17 +0200 Subject: [PATCH] Tweaking the rocThrust setup according to my own taste. So that it could be used with our existing ROCm/HIP Docker images as well. --- .github/workflows/builds.yml | 4 ++-- CMakeLists.txt | 7 +++++++ cmake/traccc-config.cmake.in | 3 ++- extern/rocThrust/CMakeLists.txt | 17 ++++++++++++----- extern/rocThrust/rocm-6.1.1.patch | 26 ++++++++++++++++++++++++++ 5 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 extern/rocThrust/rocm-6.1.1.patch diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index f768f479d7..c63384cac2 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -30,8 +30,8 @@ jobs: - name: CPU container: ghcr.io/acts-project/ubuntu2004:v30 options: -DTRACCC_USE_ROOT=FALSE - - name: HIP - container: ghcr.io/acts-project/ubuntu2204_rocm_clang:sha-3a6b0b2 + - name: HIP + container: ghcr.io/acts-project/ubuntu2004_rocm:v42 options: -DTRACCC_BUILD_HIP=TRUE -DTRACCC_SETUP_ROCTHRUST=TRUE - name: CUDA container: ghcr.io/acts-project/ubuntu2004_cuda:v30 diff --git a/CMakeLists.txt b/CMakeLists.txt index f6bab2791f..cb94955199 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,17 +119,24 @@ set( TRACCC_THRUST_OPTIONS "" CACHE STRING mark_as_advanced( TRACCC_THRUST_OPTIONS ) thrust_create_target( traccc::Thrust ${TRACCC_THRUST_OPTIONS} ) +# Set up rocThrust. option( TRACCC_SETUP_ROCTHRUST "Set up the rocThrust target(s) explicitly" FALSE ) option( TRACCC_USE_SYSTEM_ROCTHRUST "Pick up an existing installation of rocThrust from the build environment" ${TRACCC_USE_SYSTEM_LIBS} ) if( TRACCC_SETUP_ROCTHRUST ) + set( ROCM_WARN_TOOLCHAIN_VAR FALSE CACHE BOOL "Don't print ROCm warnings" ) + set( ROCM_ERROR_TOOLCHAIN_VAR FALSE CACHE BOOL "Don't print ROCm errors" ) + mark_as_advanced( ROCM_WARN_TOOLCHAIN_VAR ROCM_ERROR_TOOLCHAIN_VAR ) if( TRACCC_USE_SYSTEM_ROCTHRUST ) find_package( rocThrust REQUIRED ) else() add_subdirectory( extern/rocThrust ) endif() + # Dress up the rocthrust target a little. + target_compile_definitions( rocthrust INTERFACE + THRUST_IGNORE_CUB_VERSION_CHECK ) endif() # Set up TBB. diff --git a/cmake/traccc-config.cmake.in b/cmake/traccc-config.cmake.in index 6bfe85e92f..e546bbd01d 100644 --- a/cmake/traccc-config.cmake.in +++ b/cmake/traccc-config.cmake.in @@ -1,6 +1,6 @@ # TRACCC library, part of the ACTS project (R&D line) # -# (c) 2022-2023 CERN for the benefit of the ACTS project +# (c) 2022-2024 CERN for the benefit of the ACTS project # # Mozilla Public License Version 2.0 @@ -9,6 +9,7 @@ # Remember the options that traccc was built with. set( TRACCC_BUILD_CUDA @TRACCC_BUILD_CUDA@ ) +set( TRACCC_BUILD_HIP @TRACCC_BUILD_HIP@ ) set( TRACCC_BUILD_SYCL @TRACCC_BUILD_SYCL@ ) set( TRACCC_BUILD_FUTHARK @TRACCC_BUILD_FUTHARK@ ) set( TRACCC_BUILD_KOKKOS @TRACCC_BUILD_KOKKOS@ ) diff --git a/extern/rocThrust/CMakeLists.txt b/extern/rocThrust/CMakeLists.txt index 71a9a55491..32ac5cd143 100644 --- a/extern/rocThrust/CMakeLists.txt +++ b/extern/rocThrust/CMakeLists.txt @@ -1,6 +1,6 @@ # TRACCC library, part of the ACTS project (R&D line) # -# (c) 2021-2024 CERN for the benefit of the ACTS project +# (c) 2024 CERN for the benefit of the ACTS project # # Mozilla Public License Version 2.0 @@ -18,16 +18,23 @@ message( STATUS "Building rocThrust as part of the TRACCC project" ) # Declare where to get rocThrust from. set( TRACCC_ROCTHRUST_SOURCE - "GIT_REPOSITORY;https://github.com/ROCm/rocThrust.git;GIT_TAG;rocm-6.1.0" - CACHE STRING "Source for Thrust, when built as part of this project" ) + "URL;https://github.com/ROCm/rocThrust/archive/refs/tags/rocm-6.1.1.tar.gz;URL_MD5;038abf313688c00555fe1efc51e1307b" + CACHE STRING "Source for rocThrust, when built as part of this project" ) +set( TRACCC_ROCTHRUST_PATCH + "PATCH_COMMAND;patch;-p1;<;${CMAKE_CURRENT_SOURCE_DIR}/rocm-6.1.1.patch" + CACHE STRING "Patch for rocThrust, when built as part of this project" ) mark_as_advanced( TRACCC_ROCTHRUST_SOURCE ) -FetchContent_Declare( rocThrust ${TRACCC_ROCTHRUST_SOURCE} ) +FetchContent_Declare( rocThrust + ${TRACCC_ROCTHRUST_SOURCE} + ${TRACCC_ROCTHRUST_PATCH} ) -#Turn off build testing +# Settings for the rocThrust build. if( DEFINED CACHE{BUILD_TESTING} ) set( _buildTestingValue ${BUILD_TESTING} ) endif() set( BUILD_TESTING FALSE CACHE INTERNAL "Forceful setting of BUILD_TESTING" ) +set( HIP_COMPILER "clang" ) +set( HIP_CXX_COMPILER "hipcc" ) # Get it into the current directory. FetchContent_MakeAvailable( rocThrust ) diff --git a/extern/rocThrust/rocm-6.1.1.patch b/extern/rocThrust/rocm-6.1.1.patch new file mode 100644 index 0000000000..7cf6169cf3 --- /dev/null +++ b/extern/rocThrust/rocm-6.1.1.patch @@ -0,0 +1,26 @@ +diff -ur rocThrust-rocm-6.1.1-orig/cmake/Dependencies.cmake rocThrust-rocm-6.1.1-fixed/cmake/Dependencies.cmake +--- rocThrust-rocm-6.1.1-orig/cmake/Dependencies.cmake 2024-02-07 00:12:37.000000000 +0100 ++++ rocThrust-rocm-6.1.1-fixed/cmake/Dependencies.cmake 2024-05-17 09:33:52.423910609 +0200 +@@ -23,7 +23,7 @@ + GIT_REPOSITORY https://github.com/ROCmSoftwarePlatform/rocPRIM.git + GIT_TAG develop + INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps/rocprim +- CMAKE_ARGS -DBUILD_TEST=OFF -DCMAKE_INSTALL_PREFIX= -DCMAKE_PREFIX_PATH=/opt/rocm ++ CMAKE_ARGS -DBUILD_TEST=OFF -DCMAKE_INSTALL_PREFIX= -DCMAKE_PREFIX_PATH=/opt/rocm -DHIP_COMPILER=${HIP_COMPILER} -DHIP_CXX_COMPILER=${HIP_CXX_COMPILER} + LOG_DOWNLOAD TRUE + LOG_CONFIGURE TRUE + LOG_BUILD TRUE +diff -ur rocThrust-rocm-6.1.1-orig/CMakeLists.txt rocThrust-rocm-6.1.1-fixed/CMakeLists.txt +--- rocThrust-rocm-6.1.1-orig/CMakeLists.txt 2024-02-07 00:12:37.000000000 +0100 ++++ rocThrust-rocm-6.1.1-fixed/CMakeLists.txt 2024-05-16 16:52:07.600882025 +0200 +@@ -63,10 +63,6 @@ + # Get dependencies + include(cmake/Dependencies.cmake) + +-# Verify that supported compilers are used +-if (NOT WIN32) +- include(cmake/VerifyCompiler.cmake) +-endif() + # Build options + # Disable -Werror + option(DISABLE_WERROR "Disable building with Werror" ON)