From 8b5dbdcd543c147f043101585d640f23c6192ef0 Mon Sep 17 00:00:00 2001 From: beomki-yeo Date: Mon, 16 Oct 2023 14:33:01 +0200 Subject: [PATCH] Extended fixes and updates --- .github/workflows/builds.yml | 2 +- io/include/detray/io/common/grid_reader.hpp | 4 +-- .../cuda/benchmark_propagator_cuda.cpp | 1 + .../cuda/benchmark_propagator_cuda_kernel.hpp | 2 +- .../common/test_base/propagator_test.hpp | 8 +++--- .../unit_tests/device/cuda/navigator_cuda.cpp | 10 ++++--- .../device/cuda/navigator_cuda_kernel.hpp | 3 ++- .../device/cuda/propagator_cuda.cpp | 7 ++--- tests/unit_tests/device/sycl/propagator.sycl | 26 ++++++++++--------- .../device/sycl/propagator_kernel.sycl | 11 ++++---- tutorials/CMakeLists.txt | 9 +++---- .../src/device/cuda/detector_construction.cpp | 1 + .../src/device/cuda/detector_construction.hpp | 3 ++- tutorials/src/device/cuda/propagation.cpp | 25 ++++++++---------- tutorials/src/device/cuda/propagation.hpp | 23 +++++----------- .../src/device/cuda/propagation_kernel.cu | 4 +-- .../detectors/create_telescope_detector.hpp | 2 +- 17 files changed, 67 insertions(+), 74 deletions(-) diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 46b05ef86d..c64f03ba74 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -57,7 +57,7 @@ jobs: SCALAR_TYPE: ["float", "double"] PLATFORM: - NAME: "HOST" - CONTAINER: "ghcr.io/acts-project/ubuntu2004:v30" + CONTAINER: "ghcr.io/acts-project/ubuntu2004:v43" OPTIONS: -DDETRAY_EIGEN_PLUGIN=ON -DDETRAY_SMATRIX_PLUGIN=ON -DDETRAY_VC_PLUGIN=ON # The system to run on. diff --git a/io/include/detray/io/common/grid_reader.hpp b/io/include/detray/io/common/grid_reader.hpp index 8de59bb617..35cc104f07 100644 --- a/io/include/detray/io/common/grid_reader.hpp +++ b/io/include/detray/io/common/grid_reader.hpp @@ -94,7 +94,7 @@ class grid_reader : public reader_interface { typename binning_ts = types::type_list<>, typename... Ts> static void deserialize(std::queue &bound_ids, std::queue &binning_ids, - Ts &&...data) { + Ts &&... data) { using namespace n_axis; constexpr std::size_t n_bounds_types{types::size}; @@ -152,7 +152,7 @@ class grid_reader : public reader_interface { template == Dim, bool> = true> static void deserialize(std::queue &binning_ids, - Ts &&...data) { + Ts &&... data) { using namespace n_axis; diff --git a/tests/benchmarks/cuda/benchmark_propagator_cuda.cpp b/tests/benchmarks/cuda/benchmark_propagator_cuda.cpp index b1645c0c2d..7b38b8f0b4 100644 --- a/tests/benchmarks/cuda/benchmark_propagator_cuda.cpp +++ b/tests/benchmarks/cuda/benchmark_propagator_cuda.cpp @@ -7,6 +7,7 @@ // Project include(s) #include "benchmark_propagator_cuda_kernel.hpp" +#include "detray/detectors/create_toy_geometry.hpp" #include "detray/simulation/event_generator/track_generators.hpp" // Vecmem include(s) diff --git a/tests/benchmarks/cuda/benchmark_propagator_cuda_kernel.hpp b/tests/benchmarks/cuda/benchmark_propagator_cuda_kernel.hpp index ea332e9339..223ccc0971 100644 --- a/tests/benchmarks/cuda/benchmark_propagator_cuda_kernel.hpp +++ b/tests/benchmarks/cuda/benchmark_propagator_cuda_kernel.hpp @@ -11,7 +11,7 @@ #include "detray/definitions/algebra.hpp" #include "detray/definitions/units.hpp" #include "detray/detectors/bfield.hpp" -#include "detray/detectors/create_toy_geometry.hpp" +#include "detray/detectors/toy_metadata.hpp" #include "detray/propagator/actor_chain.hpp" #include "detray/propagator/actors/aborters.hpp" #include "detray/propagator/actors/parameter_resetter.hpp" diff --git a/tests/common/include/tests/common/test_base/propagator_test.hpp b/tests/common/include/tests/common/test_base/propagator_test.hpp index 5ba29e9666..b1286696a2 100644 --- a/tests/common/include/tests/common/test_base/propagator_test.hpp +++ b/tests/common/include/tests/common/test_base/propagator_test.hpp @@ -11,7 +11,7 @@ #include "detray/definitions/algebra.hpp" #include "detray/definitions/units.hpp" #include "detray/detectors/bfield.hpp" -#include "detray/detectors/create_toy_geometry.hpp" +#include "detray/detectors/toy_metadata.hpp" #include "detray/propagator/actor_chain.hpp" #include "detray/propagator/actors/aborters.hpp" #include "detray/propagator/actors/parameter_resetter.hpp" @@ -44,6 +44,7 @@ using detector_device_t = detector; // These types are identical in host and device code for all bfield types using transform3 = typename detector_host_t::transform3; using vector3_t = typename transform3::vector3; +using point3_t = typename transform3::point3; using matrix_operator = standard_matrix_operator; using track_t = free_track_parameters; using free_matrix = typename track_t::covariance_type; @@ -59,9 +60,6 @@ using constraints_t = constrained_step<>; template using rk_stepper_t = rk_stepper; -// Detector configuration -toy_det_config toy_cfg{}; - // Geomery navigation configurations constexpr unsigned int theta_steps{10u}; constexpr unsigned int phi_steps{10u}; @@ -229,7 +227,7 @@ inline void compare_propagation_results( const vector3_t &device_pos = device_positions[i][j]; auto relative_error = - static_cast(1. / host_pl * (host_pos - device_pos)); + static_cast(1. / host_pl * (host_pos - device_pos)); ASSERT_NEAR(getter::norm(relative_error), 0.f, is_close); } diff --git a/tests/unit_tests/device/cuda/navigator_cuda.cpp b/tests/unit_tests/device/cuda/navigator_cuda.cpp index a9935b394b..78cecd6c99 100644 --- a/tests/unit_tests/device/cuda/navigator_cuda.cpp +++ b/tests/unit_tests/device/cuda/navigator_cuda.cpp @@ -5,13 +5,17 @@ * Mozilla Public License Version 2.0 */ -#include +// Project include(s) +#include "detray/detectors/create_toy_geometry.hpp" +#include "navigator_cuda_kernel.hpp" +// vecmem include(s) #include #include +#include -#include "navigator_cuda_kernel.hpp" -#include "vecmem/utils/cuda/copy.hpp" +// GTest include(s) +#include TEST(navigator_cuda, navigator) { diff --git a/tests/unit_tests/device/cuda/navigator_cuda_kernel.hpp b/tests/unit_tests/device/cuda/navigator_cuda_kernel.hpp index 3602b124f4..8da848f6f0 100644 --- a/tests/unit_tests/device/cuda/navigator_cuda_kernel.hpp +++ b/tests/unit_tests/device/cuda/navigator_cuda_kernel.hpp @@ -10,7 +10,7 @@ // Project include(s) #include "detray/definitions/algebra.hpp" #include "detray/definitions/units.hpp" -#include "detray/detectors/create_toy_geometry.hpp" +#include "detray/detectors/toy_metadata.hpp" #include "detray/propagator/line_stepper.hpp" #include "detray/propagator/navigator.hpp" #include "detray/simulation/event_generator/track_generators.hpp" @@ -18,6 +18,7 @@ using namespace detray; using transform3 = __plugin::transform3; +using point3 = __plugin::point3; // some useful type declarations using detector_host_t = detector; diff --git a/tests/unit_tests/device/cuda/propagator_cuda.cpp b/tests/unit_tests/device/cuda/propagator_cuda.cpp index 30af1eceef..9acf3ddaab 100644 --- a/tests/unit_tests/device/cuda/propagator_cuda.cpp +++ b/tests/unit_tests/device/cuda/propagator_cuda.cpp @@ -7,6 +7,7 @@ // Project include(s) #include "detray/detectors/bfield.hpp" +#include "detray/detectors/create_toy_geometry.hpp" #include "propagator_cuda_kernel.hpp" // Vecmem include(s) @@ -32,7 +33,7 @@ TEST_P(CudaPropConstBFieldMng, propagator) { auto field = bfield::create_const_field(B); // Create the toy geometry - auto [det, names] = create_toy_geometry(mng_mr, toy_cfg); + auto [det, names] = create_toy_geometry(mng_mr); run_propagation_test( &mng_mr, det, detray::get_data(det), std::move(field)); @@ -54,7 +55,7 @@ TEST_P(CudaPropConstBFieldCpy, propagator) { auto field = bfield::create_const_field(B); // Create the toy geometry - auto [det, names] = create_toy_geometry(host_mr, toy_cfg); + auto [det, names] = create_toy_geometry(host_mr); auto det_buff = detray::get_buffer(det, dev_mr, cuda_cpy); @@ -116,7 +117,7 @@ TEST(CudaPropagatorValidation10, inhomogeneous_bfield_cpy) { auto field = bfield::create_inhom_field(); // Create the toy geometry with inhomogeneous bfield from file - auto [det, names] = create_toy_geometry(host_mr, toy_cfg); + auto [det, names] = create_toy_geometry(host_mr); auto det_buff = detray::get_buffer(det, dev_mr, cuda_cpy); diff --git a/tests/unit_tests/device/sycl/propagator.sycl b/tests/unit_tests/device/sycl/propagator.sycl index 05c0bd5bd2..d56a3cb421 100644 --- a/tests/unit_tests/device/sycl/propagator.sycl +++ b/tests/unit_tests/device/sycl/propagator.sycl @@ -6,6 +6,7 @@ */ // Project include(s) +#include "detray/detectors/create_toy_geometry.hpp" #include "propagator_sycl_kernel.hpp" // Vecmem include(s) @@ -43,14 +44,16 @@ TEST_P(SyclPropConstBFieldMng, propagator) { vecmem::sycl::shared_memory_resource shared_mr; // Set the magnetic field - const vector3 B = GetParam(); + const vector3_t B = GetParam(); + auto field = bfield::create_const_field(B); // Create the toy geometry - toy_cfg.bfield_vec(B); - auto [det, names] = create_toy_geometry(shared_mr, toy_cfg); + auto [det, names] = create_toy_geometry(shared_mr); - run_propagation_test( - &shared_mr, &q, det, detray::get_data(det)); + auto det_view = detray::get_data(det); + + run_propagation_test(&shared_mr, &q, det, det_view, + field); } class SyclPropConstBFieldCpy : public ::testing::TestWithParam {}; @@ -71,17 +74,16 @@ TEST_P(SyclPropConstBFieldCpy, propagator) { vecmem::sycl::copy sycl_cpy(q_wrapper); // Set the magnetic field - const vector3 B = GetParam(); + const vector3_t B = GetParam(); + auto field = bfield::create_const_field(B); // Create the toy geometry - toy_cfg.bfield_vec(B); - auto [det, names] = create_toy_geometry(host_mr, toy_cfg); + auto [det, names] = create_toy_geometry(host_mr); - auto det_buff = - detray::get_buffer(det, dev_mr, sycl_cpy); + auto det_buff = detray::get_buffer(det, dev_mr, sycl_cpy); - run_propagation_test(&shared_mr, &q, det, - detray::get_data(det_buff)); + run_propagation_test( + &shared_mr, &q, det, detray::get_data(det_buff), field); } INSTANTIATE_TEST_SUITE_P(SyclPropagatorValidation1, SyclPropConstBFieldMng, diff --git a/tests/unit_tests/device/sycl/propagator_kernel.sycl b/tests/unit_tests/device/sycl/propagator_kernel.sycl index 739c9c781f..1e0f5d0432 100644 --- a/tests/unit_tests/device/sycl/propagator_kernel.sycl +++ b/tests/unit_tests/device/sycl/propagator_kernel.sycl @@ -32,9 +32,9 @@ void propagator_test( reinterpret_cast<::sycl::queue*>(queue.queue()) ->submit([&](::sycl::handler& h) { - h.parallel_for(ndrange, [det_data, tracks_data, candidates_data, - path_lengths_data, positions_data, - jac_transports_data]( + h.parallel_for(ndrange, [det_data, field_data, tracks_data, + candidates_data, path_lengths_data, + positions_data, jac_transports_data]( ::sycl::nd_item<1> item) { detector_device_t dev_det(det_data); @@ -43,7 +43,8 @@ void propagator_test( candidates(candidates_data); vecmem::jagged_device_vector path_lengths( path_lengths_data); - vecmem::jagged_device_vector positions(positions_data); + vecmem::jagged_device_vector positions( + positions_data); vecmem::jagged_device_vector jac_transports( jac_transports_data); @@ -93,7 +94,7 @@ void propagator_test( } /// Explicit instantiation for a constant magnetic field -template void propagator_test( +template void propagator_test( detector_host_t::view_type, covfie::field_view, vecmem::data::vector_view&, vecmem::data::jagged_vector_view>&, diff --git a/tutorials/CMakeLists.txt b/tutorials/CMakeLists.txt index 9a7e2df0d9..83731b4d4e 100644 --- a/tutorials/CMakeLists.txt +++ b/tutorials/CMakeLists.txt @@ -11,12 +11,9 @@ include( detray-compiler-options-cpp ) file( GLOB _detray_tutorial_headers RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "include/detray/tutorials/*.hpp" ) -add_library( detray_tutorial INTERFACE "${_detray_tutorial_headers}" ) -add_library( detray::tutorial ALIAS detray_tutorial ) -target_include_directories( detray_tutorial - INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include" ) -target_link_libraries( detray_tutorial INTERFACE - vecmem::core detray::core ) + +detray_add_library( detray_tutorial tutorial ${_detray_tutorial_headers}) +target_link_libraries( detray_tutorial INTERFACE vecmem::core detray::core ) unset( _detray_tutorial_headers ) # Include all of the code-holding sub-directories. diff --git a/tutorials/src/device/cuda/detector_construction.cpp b/tutorials/src/device/cuda/detector_construction.cpp index 481af92a7b..23324e1bcb 100644 --- a/tutorials/src/device/cuda/detector_construction.cpp +++ b/tutorials/src/device/cuda/detector_construction.cpp @@ -9,6 +9,7 @@ #include "detector_construction.hpp" #include "detray/detectors/bfield.hpp" +#include "detray/detectors/create_toy_geometry.hpp" // Vecmem include(s) #include diff --git a/tutorials/src/device/cuda/detector_construction.hpp b/tutorials/src/device/cuda/detector_construction.hpp index 7a4304d2ec..23a1992178 100644 --- a/tutorials/src/device/cuda/detector_construction.hpp +++ b/tutorials/src/device/cuda/detector_construction.hpp @@ -8,8 +8,9 @@ #pragma once // Project include(s). +#include "detray/core/detector.hpp" #include "detray/definitions/units.hpp" -#include "detray/detectors/create_toy_geometry.hpp" +#include "detray/detectors/toy_metadata.hpp" #include "detray/tutorial/types.hpp" namespace detray::tutorial { diff --git a/tutorials/src/device/cuda/propagation.cpp b/tutorials/src/device/cuda/propagation.cpp index 0ab090dab5..5fa882c068 100644 --- a/tutorials/src/device/cuda/propagation.cpp +++ b/tutorials/src/device/cuda/propagation.cpp @@ -8,6 +8,7 @@ // Project include(s) #include "propagation.hpp" +#include "detray/detectors/create_toy_geometry.hpp" #include "detray/simulation/event_generator/track_generators.hpp" // Vecmem include(s) @@ -16,23 +17,23 @@ #include "vecmem/utils/cuda/copy.hpp" +// System + /// Prepare the data and move it to device int main() { // VecMem memory resource(s) vecmem::cuda::managed_memory_resource mng_mr; - // Set the magnetic field + // Create the bfield + const auto B = + detray::tutorial::vector3{0. * detray::unit::T, + 0. * detray::unit::T, + 2. * detray::unit::T}; - // Define the name of the input file: use detray unittest data in this case - const std::string field_file = !std::getenv("DETRAY_BFIELD_FILE") - ? "" - : std::getenv("DETRAY_BFIELD_FILE"); - detray::tutorial::field_host_t bfield = - detray::io::read_bfield(field_file); + detray::tutorial::field_t bfield = detray::bfield::create_const_field(B); // Create the toy geometry - detray::toy_det_config toy_cfg{}; - auto [det, names] = detray::create_toy_geometry(mng_mr, toy_cfg); + auto [det, names] = detray::create_toy_geometry(mng_mr); // Create the vector of initial track parameters vecmem::vector> @@ -61,10 +62,6 @@ int main() { auto det_data = detray::get_data(det); auto tracks_data = detray::get_data(tracks); - // Get the device bfield - detray::tutorial::field_device_t device_field(bfield); - detray::tutorial::field_device_t::view_t device_field_view(device_field); - // Create navigator candidates buffer vecmem::copy copy; //< Helper object for performing memory copies. auto candidates_buffer = @@ -72,6 +69,6 @@ int main() { copy.setup(candidates_buffer); // Run the propagator test for GPU device - detray::tutorial::propagation(det_data, device_field_view, tracks_data, + detray::tutorial::propagation(det_data, bfield, tracks_data, candidates_buffer); } diff --git a/tutorials/src/device/cuda/propagation.hpp b/tutorials/src/device/cuda/propagation.hpp index 452175abbd..6c8e1c07f2 100644 --- a/tutorials/src/device/cuda/propagation.hpp +++ b/tutorials/src/device/cuda/propagation.hpp @@ -8,9 +8,10 @@ #pragma once // Project include(s). +#include "detray/core/detector.hpp" #include "detray/definitions/units.hpp" #include "detray/detectors/bfield.hpp" -#include "detray/detectors/create_toy_geometry.hpp" +#include "detray/detectors/toy_metadata.hpp" #include "detray/propagator/actor_chain.hpp" #include "detray/propagator/actors/aborters.hpp" #include "detray/propagator/actors/parameter_resetter.hpp" @@ -22,9 +23,6 @@ #include "detray/tracks/tracks.hpp" #include "detray/tutorial/types.hpp" -// Covfie include(s) -#include - namespace detray::tutorial { // Detector @@ -36,18 +34,9 @@ using detector_device_t = using navigator_t = navigator; using intersection_t = navigator_t::intersection_type; -// Magnetic field types -using inhom_cuda_bknd_t = covfie::backend::affine< - covfie::backend::nearest_neighbour>>>>; -using field_host_t = covfie::field; -using field_device_t = covfie::field; - -// Stepper (only running device propagation, so need the device field type) -using stepper_t = - rk_stepper; +// Stepper +using field_t = detray::bfield::const_field_t; +using stepper_t = rk_stepper; // Actors using actor_chain_t = @@ -62,7 +51,7 @@ using propagator_t = propagator; /// Propagation tutorial function void propagation( typename detector_host_t::view_type det_data, - covfie::field_view field_data, + typename field_t::view_t field_data, const vecmem::data::vector_view< free_track_parameters> tracks_data, diff --git a/tutorials/src/device/cuda/propagation_kernel.cu b/tutorials/src/device/cuda/propagation_kernel.cu index 832eff174b..d832925c13 100644 --- a/tutorials/src/device/cuda/propagation_kernel.cu +++ b/tutorials/src/device/cuda/propagation_kernel.cu @@ -17,7 +17,7 @@ inline constexpr detray::scalar path_limit{2.f * /// Kernel that runs the entire propagation loop __global__ void propagation_kernel( typename detray::tutorial::detector_host_t::view_type det_data, - covfie::field_view field_data, + typename detray::tutorial::field_t::view_t field_data, const vecmem::data::vector_view< detray::free_track_parameters> tracks_data, @@ -67,7 +67,7 @@ __global__ void propagation_kernel( void propagation( typename detray::tutorial::detector_host_t::view_type det_data, - covfie::field_view field_data, + typename detray::tutorial::field_t::view_t field_data, const vecmem::data::vector_view< detray::free_track_parameters> tracks_data, diff --git a/utils/include/detray/detectors/create_telescope_detector.hpp b/utils/include/detray/detectors/create_telescope_detector.hpp index 94bd799dae..76f824011b 100644 --- a/utils/include/detray/detectors/create_telescope_detector.hpp +++ b/utils/include/detray/detectors/create_telescope_detector.hpp @@ -45,7 +45,7 @@ struct tel_det_config { template < typename... Args, std::enable_if_t<(std::is_same_v || ...), bool> = true> - tel_det_config(Args &&...args) : m_mask(0u, std::forward(args)...) {} + tel_det_config(Args &&... args) : m_mask(0u, std::forward(args)...) {} /// Mask of the test surfaces mask m_mask;