File indexing completed on 2026-05-27 07:24:17
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "detray/test/common/bfield.hpp"
0011 #include "detray/test/common/build_toy_detector.hpp"
0012 #include "propagator_cuda_kernel.hpp"
0013
0014
0015 #include <vecmem/memory/cuda/device_memory_resource.hpp>
0016 #include <vecmem/memory/cuda/managed_memory_resource.hpp>
0017 #include <vecmem/memory/host_memory_resource.hpp>
0018 #include <vecmem/utils/cuda/copy.hpp>
0019
0020
0021 #include <gtest/gtest.h>
0022
0023 using namespace detray;
0024
0025 class CudaPropConstBFieldMng
0026 : public ::testing::TestWithParam<std::tuple<float, float, vector3>> {};
0027
0028
0029 TEST_P(CudaPropConstBFieldMng, propagator) {
0030
0031 vecmem::cuda::managed_memory_resource mng_mr;
0032
0033
0034 propagator_test_config cfg{};
0035 cfg.track_generator.phi_steps(20).theta_steps(20);
0036 cfg.track_generator.p_tot(10.f * unit<scalar>::GeV);
0037 cfg.track_generator.eta_range(-3.f, 3.f);
0038 cfg.propagation.navigation.search_window = {3u, 3u};
0039
0040 cfg.propagation.navigation.intersection.overstep_tolerance =
0041 std::get<0>(GetParam());
0042 cfg.propagation.stepping.step_constraint = std::get<1>(GetParam());
0043
0044
0045 const vector3 B = std::get<2>(GetParam());
0046 auto field = create_const_field<scalar>(B);
0047
0048
0049 auto [det, names] = build_toy_detector<test_algebra>(mng_mr);
0050
0051 run_propagation_test<bfield::const_bknd_t<scalar>>(
0052 &mng_mr, det, cfg, detray::get_data(det), std::move(field));
0053 }
0054
0055 class CudaPropConstBFieldCpy
0056 : public ::testing::TestWithParam<std::tuple<float, float, vector3>> {};
0057
0058
0059 TEST_P(CudaPropConstBFieldCpy, propagator) {
0060
0061 vecmem::host_memory_resource host_mr;
0062 vecmem::cuda::managed_memory_resource mng_mr;
0063 vecmem::cuda::device_memory_resource dev_mr;
0064
0065 vecmem::cuda::copy cuda_cpy;
0066
0067
0068 propagator_test_config cfg{};
0069 cfg.track_generator.phi_steps(20u).theta_steps(20u);
0070 cfg.track_generator.p_tot(10.f * unit<scalar>::GeV);
0071 cfg.track_generator.eta_range(-3.f, 3.f);
0072 cfg.propagation.navigation.search_window = {3u, 3u};
0073
0074 cfg.propagation.navigation.intersection.overstep_tolerance =
0075 std::get<0>(GetParam());
0076 cfg.propagation.stepping.step_constraint = std::get<1>(GetParam());
0077
0078
0079 const vector3 B = std::get<2>(GetParam());
0080 auto field = create_const_field<scalar>(B);
0081
0082
0083 auto [det, names] = build_toy_detector<test_algebra>(host_mr);
0084
0085 auto det_buff = detray::get_buffer(det, dev_mr, cuda_cpy);
0086
0087 run_propagation_test<bfield::const_bknd_t<scalar>>(
0088 &mng_mr, det, cfg, detray::get_data(det_buff), std::move(field));
0089 }
0090
0091 INSTANTIATE_TEST_SUITE_P(
0092 CudaPropagatorValidation1, CudaPropConstBFieldMng,
0093 ::testing::Values(std::make_tuple(-100.f * unit<float>::um,
0094 std::numeric_limits<float>::max(),
0095 vector3{0.f * unit<scalar>::T,
0096 0.f * unit<scalar>::T,
0097 2.f * unit<scalar>::T})));
0098
0099 INSTANTIATE_TEST_SUITE_P(
0100 CudaPropagatorValidation2, CudaPropConstBFieldMng,
0101 ::testing::Values(std::make_tuple(-400.f * unit<float>::um,
0102 std::numeric_limits<float>::max(),
0103 vector3{0.f * unit<scalar>::T,
0104 1.f * unit<scalar>::T,
0105 1.f * unit<scalar>::T})));
0106
0107 INSTANTIATE_TEST_SUITE_P(
0108 CudaPropagatorValidation3, CudaPropConstBFieldMng,
0109 ::testing::Values(std::make_tuple(-400.f * unit<float>::um,
0110 std::numeric_limits<float>::max(),
0111 vector3{1.f * unit<scalar>::T,
0112 0.f * unit<scalar>::T,
0113 1.f * unit<scalar>::T})));
0114
0115 INSTANTIATE_TEST_SUITE_P(
0116 CudaPropagatorValidation4, CudaPropConstBFieldMng,
0117 ::testing::Values(std::make_tuple(-600.f * unit<float>::um,
0118 std::numeric_limits<float>::max(),
0119 vector3{1.f * unit<scalar>::T,
0120 1.f * unit<scalar>::T,
0121 1.f * unit<scalar>::T})));
0122
0123 INSTANTIATE_TEST_SUITE_P(
0124 CudaPropagatorValidation5, CudaPropConstBFieldCpy,
0125 ::testing::Values(std::make_tuple(-100.f * unit<float>::um,
0126 std::numeric_limits<float>::max(),
0127 vector3{0.f * unit<scalar>::T,
0128 0.f * unit<scalar>::T,
0129 2.f * unit<scalar>::T})));
0130
0131 INSTANTIATE_TEST_SUITE_P(
0132 CudaPropagatorValidation6, CudaPropConstBFieldCpy,
0133 ::testing::Values(std::make_tuple(-400.f * unit<float>::um,
0134 std::numeric_limits<float>::max(),
0135 vector3{0.f * unit<scalar>::T,
0136 1.f * unit<scalar>::T,
0137 1.f * unit<scalar>::T})));
0138
0139 INSTANTIATE_TEST_SUITE_P(
0140 CudaPropagatorValidation7, CudaPropConstBFieldCpy,
0141 ::testing::Values(std::make_tuple(-400.f * unit<float>::um,
0142 std::numeric_limits<float>::max(),
0143 vector3{1.f * unit<scalar>::T,
0144 0.f * unit<scalar>::T,
0145 1.f * unit<scalar>::T})));
0146
0147 INSTANTIATE_TEST_SUITE_P(
0148 CudaPropagatorValidation8, CudaPropConstBFieldCpy,
0149 ::testing::Values(std::make_tuple(-600.f * unit<float>::um,
0150 std::numeric_limits<float>::max(),
0151 vector3{1.f * unit<scalar>::T,
0152 1.f * unit<scalar>::T,
0153 1.f * unit<scalar>::T})));
0154
0155
0156 TEST(CudaPropagatorValidation9, inhomogeneous_bfield_cpy) {
0157
0158 vecmem::host_memory_resource host_mr;
0159 vecmem::cuda::managed_memory_resource mng_mr;
0160 vecmem::cuda::device_memory_resource dev_mr;
0161
0162 vecmem::cuda::copy cuda_cpy;
0163
0164
0165 propagator_test_config cfg{};
0166 cfg.track_generator.phi_steps(10u).theta_steps(10u);
0167 cfg.track_generator.p_tot(10.f * unit<scalar>::GeV);
0168 cfg.track_generator.eta_range(-3.f, 3.f);
0169 cfg.propagation.navigation.search_window = {3u, 3u};
0170
0171
0172 auto field = create_inhom_field<scalar>();
0173
0174
0175 auto [det, names] = build_toy_detector<test_algebra>(host_mr);
0176
0177 auto det_buff = detray::get_buffer(det, dev_mr, cuda_cpy);
0178
0179 run_propagation_test<bfield::cuda::inhom_bknd_t<scalar>>(
0180 &mng_mr, det, cfg, detray::get_data(det_buff), std::move(field));
0181 }