Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Thrust from the core and common libraries #815

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ if( TRACCC_SETUP_THRUST )
add_subdirectory( extern/cccl )
endif()
endif()
add_library( traccc::Thrust INTERFACE IMPORTED )
target_link_libraries( traccc::Thrust INTERFACE Thrust::Thrust )

# Set up rocThrust.
option( TRACCC_SETUP_ROCTHRUST
Expand Down
6 changes: 0 additions & 6 deletions cmake/traccc-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ if( TRACCC_BUILD_EXAMPLES )
endif()
endif()

# Set up the traccc::Thrust target.
if ( NOT TARGET traccc::Thrust )
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.
include( "${traccc_CMAKE_DIR}/traccc-config-targets.cmake" )

Expand Down
2 changes: 1 addition & 1 deletion core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ traccc_add_library( traccc_core core TYPE SHARED
"include/traccc/ambiguity_resolution/greedy_ambiguity_resolution_algorithm.hpp"
"src/ambiguity_resolution/greedy_ambiguity_resolution_algorithm.cpp" )
target_link_libraries( traccc_core
PUBLIC Eigen3::Eigen vecmem::core detray::core detray::detectors traccc::Thrust
PUBLIC Eigen3::Eigen vecmem::core detray::core detray::detectors
traccc::algebra )

# Prevent Eigen from getting confused when building code for a
Expand Down
6 changes: 6 additions & 0 deletions device/alpaka/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ if(alpaka_ACC_GPU_CUDA_ENABLE)
thrust_create_target( traccc::cuda_thrust
HOST CPP
DEVICE CUDA )
target_link_libraries(traccc::cuda_thrust INTERFACE CUDA::cudart)
list(APPEND PRIVATE_LIBRARIES traccc::cuda_thrust)
else()
thrust_create_target (traccc::alpaka_thrust
HOST CPP
DEVICE CPP )
list(APPEND PRIVATE_LIBRARIES traccc::alpaka_thrust)
endif()

target_link_libraries(traccc_alpaka PUBLIC ${PUBLIC_LIBRARIES} PRIVATE ${PRIVATE_LIBRARIES})
5 changes: 2 additions & 3 deletions device/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
include( traccc-compiler-options-cpp )

# Declare the traccc::device_common library.
traccc_add_library( traccc_device_common device_common TYPE SHARED
traccc_add_library( traccc_device_common device_common TYPE INTERFACE
# General function(s).
"include/traccc/device/fill_prefix_sum.hpp"
"include/traccc/device/impl/fill_prefix_sum.ipp"
"include/traccc/device/make_prefix_sum_buffer.hpp"
"src/make_prefix_sum_buffer.cpp"
# General algorithm(s).
"include/traccc/device/container_h2d_copy_alg.hpp"
"include/traccc/device/impl/container_h2d_copy_alg.ipp"
Expand Down Expand Up @@ -80,4 +79,4 @@ traccc_add_library( traccc_device_common device_common TYPE SHARED
"include/traccc/fitting/device/impl/fill_sort_keys.ipp"
)
target_link_libraries( traccc_device_common
PUBLIC traccc::Thrust traccc::core vecmem::core )
INTERFACE traccc::core vecmem::core )
37 changes: 35 additions & 2 deletions device/common/include/traccc/device/make_prefix_sum_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,41 @@ using prefix_sum_buffer_t = prefix_sum_buffer;
/// the view elements, and the total summation of the size vector
///
TRACCC_HOST
prefix_sum_buffer_t make_prefix_sum_buffer(
inline prefix_sum_buffer_t make_prefix_sum_buffer(
const std::vector<prefix_sum_size_t>& sizes, vecmem::copy& copy,
const traccc::memory_resource& mr);
const traccc::memory_resource& mr) {

if (sizes.size() == 0) {
return prefix_sum_buffer_t{
vecmem::data::vector_view<prefix_sum_size_t>{},
std::variant<vecmem::vector<prefix_sum_size_t>,
vecmem::data::vector_buffer<prefix_sum_size_t>>{},
prefix_sum_size_t{0}};
}

// Create vector with summation of sizes
vecmem::vector<prefix_sum_size_t> sizes_sum(sizes.size(),
mr.host ? mr.host : &(mr.main));
std::partial_sum(sizes.begin(), sizes.end(), sizes_sum.begin(),
std::plus<prefix_sum_size_t>());
const prefix_sum_size_t totalSize = sizes_sum.back();

if (mr.host != nullptr) {
// Create buffer and view objects
vecmem::data::vector_buffer<prefix_sum_size_t> sizes_sum_buff(
static_cast<unsigned int>(sizes_sum.size()), mr.main);
copy.setup(sizes_sum_buff)->ignore();
(copy)(vecmem::get_data(sizes_sum), sizes_sum_buff)->wait();
vecmem::data::vector_view<prefix_sum_size_t> sizes_sum_view(
sizes_sum_buff);

return {sizes_sum_view, std::move(sizes_sum_buff), totalSize};
} else {
// Create view object
vecmem::data::vector_view<prefix_sum_size_t> sizes_sum_view =
vecmem::get_data(sizes_sum);

return {sizes_sum_view, std::move(sizes_sum), totalSize};
}
}
} // namespace traccc::device
51 changes: 0 additions & 51 deletions device/common/src/make_prefix_sum_buffer.cpp

This file was deleted.

4 changes: 2 additions & 2 deletions device/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ target_link_libraries( traccc_cuda
thrust_create_target( traccc::cuda_thrust
HOST CPP
DEVICE CUDA )
target_link_libraries( traccc_cuda
PRIVATE traccc::cuda_thrust )
target_link_libraries( traccc::cuda_thrust INTERFACE CUDA::cudart )
target_link_libraries( traccc_cuda PUBLIC traccc::cuda_thrust )

# For CUDA 11 turn on separable compilation. This is necessary for using
# Thrust 2.1.0.
Expand Down
6 changes: 5 additions & 1 deletion device/kokkos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ traccc_add_library( traccc_kokkos kokkos TYPE SHARED
"src/seeding/spacepoint_binning.cpp"
)

thrust_create_target (traccc::kokkos_thrust
HOST CPP
DEVICE CPP )

target_link_libraries( traccc_kokkos
PUBLIC traccc::core vecmem::core Kokkos::kokkos
PUBLIC traccc::core vecmem::core Kokkos::kokkos traccc::kokkos_thrust
PRIVATE traccc::device_common )
Loading