Skip to content

Commit

Permalink
Changed how Thrust would be used in the build.
Browse files Browse the repository at this point in the history
Instead of setting up a single traccc::Thrust target that would
take care of everything related to Thrust, the code rather
sets up traccc::Thrust in a way that allows very little access
in traccc::core to Thrust.

Instead, traccc::cuda and traccc::sycl (and also traccc_test_cuda)
privately link against Thrust in specific ways. So that the
appropriate "device headers" would get included everywhere.
  • Loading branch information
krasznaa committed Nov 16, 2024
1 parent 9475d39 commit 2bacf76
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 15 deletions.
8 changes: 2 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,8 @@ if( TRACCC_SETUP_THRUST )
add_subdirectory( extern/cccl )
endif()
endif()
# Set up an IMPORTED library on top of the Thrust library/libraries. One that
# the TRACCC/Detray code could depend on publicly.
set( TRACCC_THRUST_OPTIONS "" CACHE STRING
"Extra options for configuring how Thrust should be used" )
mark_as_advanced( TRACCC_THRUST_OPTIONS )
thrust_create_target( traccc::Thrust ${TRACCC_THRUST_OPTIONS} )
add_library( traccc::Thrust INTERFACE IMPORTED )
target_link_libraries( traccc::Thrust INTERFACE Thrust::Thrust )

# Set up rocThrust.
option( TRACCC_SETUP_ROCTHRUST
Expand Down
4 changes: 2 additions & 2 deletions cmake/traccc-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ endif()

# Set up the traccc::Thrust target.
if ( NOT TARGET traccc::Thrust )
set( TRACCC_THRUST_OPTIONS @TRACCC_THRUST_OPTIONS@ )
thrust_create_target( traccc::Thrust ${TRACCC_THRUST_OPTIONS} )
add_library( traccc::Thrust INTERFACE IMPORTED )
target_link_libraries( traccc::Thrust INTERFACE Thrust::Thrust )
endif()

# Include the file listing all the imported targets and options.
Expand Down
5 changes: 1 addition & 4 deletions device/common/include/traccc/finding/device/find_tracks.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2023 CERN for the benefit of the ACTS project
* (c) 2023-2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/
Expand All @@ -19,9 +19,6 @@
#include "traccc/finding/finding_config.hpp"
#include "traccc/fitting/kalman_filter/gain_matrix_updater.hpp"

// Thrust include(s)
#include <thrust/binary_search.h>

namespace traccc::device {
template <typename detector_t>
struct find_tracks_payload {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2023 CERN for the benefit of the ACTS project
* (c) 2023-2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/
Expand All @@ -21,6 +21,7 @@

// Thrust include(s)
#include <thrust/binary_search.h>
#include <thrust/execution_policy.h>

namespace traccc::device {

Expand Down
9 changes: 8 additions & 1 deletion device/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,14 @@ target_compile_options( traccc_cuda
PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--expt-relaxed-constexpr> )
target_link_libraries( traccc_cuda
PUBLIC traccc::core detray::core vecmem::core covfie::core
PRIVATE CUDA::cudart traccc::Thrust traccc::device_common vecmem::cuda )
PRIVATE CUDA::cudart traccc::device_common vecmem::cuda )

# Set up Thrust specifically for the traccc::cuda library.
thrust_create_target( traccc::cuda_thrust
HOST CPP
DEVICE CUDA )
target_link_libraries( traccc_cuda
PRIVATE traccc::cuda_thrust )

# For CUDA 11 turn on separable compilation. This is necessary for using
# Thrust 2.1.0.
Expand Down
7 changes: 7 additions & 0 deletions device/sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,10 @@ traccc_add_library( traccc_sycl sycl TYPE SHARED
target_link_libraries( traccc_sycl
PUBLIC traccc::core detray::core vecmem::core covfie::core
PRIVATE traccc::device_common vecmem::sycl oneDPL )

# Set up Thrust specifically for the traccc::sycl library.
thrust_create_target( traccc::sycl_thrust
HOST CPP
DEVICE CPP )
target_link_libraries( traccc_sycl
PRIVATE traccc::sycl_thrust )
7 changes: 6 additions & 1 deletion tests/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ target_link_libraries(
GTest::gtest
)

# Set up Thrust specifically for the CUDA unit tests.
thrust_create_target( traccc_test_cuda_thrust
HOST CPP
DEVICE CUDA )

traccc_add_test(
cuda

Expand All @@ -48,7 +53,7 @@ traccc_add_test(

LINK_LIBRARIES
CUDA::cudart
traccc::Thrust
traccc_test_cuda_thrust
GTest::gtest
vecmem::cuda
detray::core
Expand Down

0 comments on commit 2bacf76

Please sign in to comment.