Skip to content

Commit 0e3fddc

Browse files
committed
Changed how Thrust would be used in the build.
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.
1 parent 7af0150 commit 0e3fddc

File tree

7 files changed

+28
-15
lines changed

7 files changed

+28
-15
lines changed

CMakeLists.txt

+2-6
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,8 @@ if( TRACCC_SETUP_THRUST )
176176
add_subdirectory( extern/cccl )
177177
endif()
178178
endif()
179-
# Set up an IMPORTED library on top of the Thrust library/libraries. One that
180-
# the TRACCC/Detray code could depend on publicly.
181-
set( TRACCC_THRUST_OPTIONS "" CACHE STRING
182-
"Extra options for configuring how Thrust should be used" )
183-
mark_as_advanced( TRACCC_THRUST_OPTIONS )
184-
thrust_create_target( traccc::Thrust ${TRACCC_THRUST_OPTIONS} )
179+
add_library( traccc::Thrust INTERFACE IMPORTED )
180+
target_link_libraries( traccc::Thrust INTERFACE Thrust::Thrust )
185181

186182
# Set up rocThrust.
187183
option( TRACCC_SETUP_ROCTHRUST

cmake/traccc-config.cmake.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ endif()
5656

5757
# Set up the traccc::Thrust target.
5858
if ( NOT TARGET traccc::Thrust )
59-
set( TRACCC_THRUST_OPTIONS @TRACCC_THRUST_OPTIONS@ )
60-
thrust_create_target( traccc::Thrust ${TRACCC_THRUST_OPTIONS} )
59+
add_library( traccc::Thrust INTERFACE IMPORTED )
60+
target_link_libraries( traccc::Thrust INTERFACE Thrust::Thrust )
6161
endif()
6262

6363
# Include the file listing all the imported targets and options.

device/common/include/traccc/finding/device/find_tracks.hpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** TRACCC library, part of the ACTS project (R&D line)
22
*
3-
* (c) 2023 CERN for the benefit of the ACTS project
3+
* (c) 2023-2024 CERN for the benefit of the ACTS project
44
*
55
* Mozilla Public License Version 2.0
66
*/
@@ -19,9 +19,6 @@
1919
#include "traccc/finding/finding_config.hpp"
2020
#include "traccc/fitting/kalman_filter/gain_matrix_updater.hpp"
2121

22-
// Thrust include(s)
23-
#include <thrust/binary_search.h>
24-
2522
namespace traccc::device {
2623
template <typename detector_t>
2724
struct find_tracks_payload {

device/common/include/traccc/finding/device/impl/find_tracks.ipp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** TRACCC library, part of the ACTS project (R&D line)
22
*
3-
* (c) 2023 CERN for the benefit of the ACTS project
3+
* (c) 2023-2024 CERN for the benefit of the ACTS project
44
*
55
* Mozilla Public License Version 2.0
66
*/
@@ -21,6 +21,7 @@
2121

2222
// Thrust include(s)
2323
#include <thrust/binary_search.h>
24+
#include <thrust/execution_policy.h>
2425

2526
namespace traccc::device {
2627

device/cuda/CMakeLists.txt

+8-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,14 @@ target_compile_options( traccc_cuda
106106
PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--expt-relaxed-constexpr> )
107107
target_link_libraries( traccc_cuda
108108
PUBLIC traccc::core detray::core vecmem::core covfie::core
109-
PRIVATE CUDA::cudart traccc::Thrust traccc::device_common vecmem::cuda )
109+
PRIVATE CUDA::cudart traccc::device_common vecmem::cuda )
110+
111+
# Set up Thrust specifically for the traccc::cuda library.
112+
thrust_create_target( traccc::cuda_thrust
113+
HOST CPP
114+
DEVICE CUDA )
115+
target_link_libraries( traccc_cuda
116+
PRIVATE traccc::cuda_thrust )
110117

111118
# For CUDA 11 turn on separable compilation. This is necessary for using
112119
# Thrust 2.1.0.

device/sycl/CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,10 @@ traccc_add_library( traccc_sycl sycl TYPE SHARED
5757
target_link_libraries( traccc_sycl
5858
PUBLIC traccc::core detray::core vecmem::core covfie::core
5959
PRIVATE traccc::device_common vecmem::sycl oneDPL )
60+
61+
# Set up Thrust specifically for the traccc::sycl library.
62+
thrust_create_target( traccc::sycl_thrust
63+
HOST CPP
64+
DEVICE CPP )
65+
target_link_libraries( traccc_sycl
66+
PRIVATE traccc::sycl_thrust )

tests/cuda/CMakeLists.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ target_link_libraries(
2323
GTest::gtest
2424
)
2525

26+
# Set up Thrust specifically for the CUDA unit tests.
27+
thrust_create_target( traccc_test_cuda_thrusr
28+
HOST CPP
29+
DEVICE CUDA )
30+
2631
traccc_add_test(
2732
cuda
2833

@@ -48,7 +53,7 @@ traccc_add_test(
4853

4954
LINK_LIBRARIES
5055
CUDA::cudart
51-
traccc::Thrust
56+
traccc_test_cuda_thrusr
5257
GTest::gtest
5358
vecmem::cuda
5459
detray::core

0 commit comments

Comments
 (0)