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_hip_kernel.hpp"
0013
0014
0015 #include <vecmem/memory/hip/device_memory_resource.hpp>
0016 #include <vecmem/memory/hip/managed_memory_resource.hpp>
0017 #include <vecmem/memory/host_memory_resource.hpp>
0018 #include <vecmem/utils/hip/copy.hpp>
0019
0020
0021 #include <gtest/gtest.h>
0022
0023 using namespace detray;
0024
0025 class HipPropConstBFieldMng
0026 : public ::testing::TestWithParam<std::tuple<float, float, vector3>> {};
0027
0028
0029 TEST_P(HipPropConstBFieldMng, propagator) {
0030
0031 vecmem::hip::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 HipPropConstBFieldCpy
0056 : public ::testing::TestWithParam<std::tuple<float, float, vector3>> {};
0057
0058
0059 TEST_P(HipPropConstBFieldCpy, propagator) {
0060
0061 vecmem::host_memory_resource host_mr;
0062 vecmem::hip::managed_memory_resource mng_mr;
0063 vecmem::hip::device_memory_resource dev_mr;
0064
0065 vecmem::hip::copy hip_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, hip_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 HipPropagatorValidation1, HipPropConstBFieldMng,
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 HipPropagatorValidation2, HipPropConstBFieldMng,
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 HipPropagatorValidation3, HipPropConstBFieldMng,
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 HIpPropagatorValidation4, HipPropConstBFieldMng,
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 HipPropagatorValidation5, HipPropConstBFieldCpy,
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 HIpPropagatorValidation6, HipPropConstBFieldCpy,
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 HipPropagatorValidation7, HipPropConstBFieldCpy,
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 HipPropagatorValidation8, HipPropConstBFieldCpy,
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
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185