diff --git a/CMakeLists.txt b/CMakeLists.txt index 671f827e9..a9df9e229 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/cmake/traccc-config.cmake.in b/cmake/traccc-config.cmake.in index ef0b9e0ad..84f32b5cf 100644 --- a/cmake/traccc-config.cmake.in +++ b/cmake/traccc-config.cmake.in @@ -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" ) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 6f7a79264..36f91a918 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -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 diff --git a/device/alpaka/CMakeLists.txt b/device/alpaka/CMakeLists.txt index 5d91c14cd..5ed6f087e 100644 --- a/device/alpaka/CMakeLists.txt +++ b/device/alpaka/CMakeLists.txt @@ -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}) diff --git a/device/common/CMakeLists.txt b/device/common/CMakeLists.txt index e9871b1ef..6ef58e5ae 100644 --- a/device/common/CMakeLists.txt +++ b/device/common/CMakeLists.txt @@ -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" @@ -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 ) diff --git a/device/common/include/traccc/device/make_prefix_sum_buffer.hpp b/device/common/include/traccc/device/make_prefix_sum_buffer.hpp index 90eed8533..530bc0841 100644 --- a/device/common/include/traccc/device/make_prefix_sum_buffer.hpp +++ b/device/common/include/traccc/device/make_prefix_sum_buffer.hpp @@ -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& 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{}, + std::variant, + vecmem::data::vector_buffer>{}, + prefix_sum_size_t{0}}; + } + + // Create vector with summation of sizes + vecmem::vector sizes_sum(sizes.size(), + mr.host ? mr.host : &(mr.main)); + std::partial_sum(sizes.begin(), sizes.end(), sizes_sum.begin(), + std::plus()); + const prefix_sum_size_t totalSize = sizes_sum.back(); + + if (mr.host != nullptr) { + // Create buffer and view objects + vecmem::data::vector_buffer sizes_sum_buff( + static_cast(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 sizes_sum_view( + sizes_sum_buff); + + return {sizes_sum_view, std::move(sizes_sum_buff), totalSize}; + } else { + // Create view object + vecmem::data::vector_view sizes_sum_view = + vecmem::get_data(sizes_sum); + + return {sizes_sum_view, std::move(sizes_sum), totalSize}; + } +} } // namespace traccc::device diff --git a/device/common/src/make_prefix_sum_buffer.cpp b/device/common/src/make_prefix_sum_buffer.cpp deleted file mode 100644 index 7daf98012..000000000 --- a/device/common/src/make_prefix_sum_buffer.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/** TRACCC library, part of the ACTS project (R&D line) - * - * (c) 2022 CERN for the benefit of the ACTS project - * - * Mozilla Public License Version 2.0 - */ - -// Local include(s). -#include "traccc/device/make_prefix_sum_buffer.hpp" - -// System include(s). -#include - -namespace traccc::device { - -TRACCC_HOST -prefix_sum_buffer_t make_prefix_sum_buffer( - const std::vector& sizes, vecmem::copy& copy, - const traccc::memory_resource& mr) { - - if (sizes.size() == 0) { - return {{}, {}, 0}; - } - - // Create vector with summation of sizes - vecmem::vector sizes_sum(sizes.size(), - mr.host ? mr.host : &(mr.main)); - std::partial_sum(sizes.begin(), sizes.end(), sizes_sum.begin(), - std::plus()); - const prefix_sum_size_t totalSize = sizes_sum.back(); - - if (mr.host != nullptr) { - // Create buffer and view objects - vecmem::data::vector_buffer sizes_sum_buff( - static_cast(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 sizes_sum_view( - sizes_sum_buff); - - return {sizes_sum_view, std::move(sizes_sum_buff), totalSize}; - } else { - // Create view object - vecmem::data::vector_view sizes_sum_view = - vecmem::get_data(sizes_sum); - - return {sizes_sum_view, std::move(sizes_sum), totalSize}; - } -} - -} // namespace traccc::device diff --git a/device/cuda/CMakeLists.txt b/device/cuda/CMakeLists.txt index cb717746d..beb3e862b 100644 --- a/device/cuda/CMakeLists.txt +++ b/device/cuda/CMakeLists.txt @@ -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. diff --git a/device/kokkos/CMakeLists.txt b/device/kokkos/CMakeLists.txt index dad5f3493..628248eda 100644 --- a/device/kokkos/CMakeLists.txt +++ b/device/kokkos/CMakeLists.txt @@ -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 )