Back to home page

EIC code displayed by LXR

 
 

    


Warning, /acts/Detray/tests/integration_tests/device/sycl/propagator.sycl is written in an unsupported language. File is not indexed.

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 // Project indlude(s)
0010 #include "detray/utils/logging.hpp"
0011 
0012 // Detray test include(s)
0013 #include "detray/test/common/build_toy_detector.hpp"
0014 #include "propagator_sycl_kernel.hpp"
0015 
0016 // Vecmem include(s)
0017 #include <vecmem/memory/host_memory_resource.hpp>
0018 #include <vecmem/memory/sycl/device_memory_resource.hpp>
0019 #include <vecmem/memory/sycl/shared_memory_resource.hpp>
0020 #include <vecmem/utils/sycl/copy.hpp>
0021 
0022 // GTest include
0023 #include <gtest/gtest.h>
0024 
0025 using namespace detray;
0026 
0027 // Simple asynchronous handler function
0028 auto handle_async_error = [](::sycl::exception_list elist) {
0029     for (auto& e : elist) {
0030         try {
0031             std::rethrow_exception(e);
0032         } catch (::sycl::exception& e) {
0033             DETRAY_FATAL_HOST("ASYNC EXCEPTION!!\n");
0034             DETRAY_FATAL_HOST(e.what() << "\n");
0035         }
0036     }
0037 };
0038 class SyclPropConstBFieldMng
0039     : public ::testing::TestWithParam<std::tuple<scalar, scalar, vector3>> {};
0040 
0041 TEST_P(SyclPropConstBFieldMng, propagator) {
0042 
0043     // Creating SYCL queue object
0044     ::sycl::queue q(handle_async_error);
0045     DETRAY_VERBOSE_HOST(
0046         "Running constant bfield propagation on device(mng mem): "
0047         << q.get_device().get_info<::sycl::info::device::name>() << "\n");
0048 
0049     // VecMem memory resource(s)
0050     vecmem::sycl::shared_memory_resource shared_mr;
0051 
0052     // Test configuration
0053     propagator_test_config cfg{};
0054     cfg.track_generator.phi_steps(20u).theta_steps(20u);
0055     cfg.track_generator.p_tot(10.f * unit<scalar>::GeV);
0056     cfg.track_generator.eta_range(-3.f, 3.f);
0057     cfg.propagation.navigation.search_window = {3u, 3u};
0058     // Configuration for non-z-aligned B-fields
0059     cfg.propagation.navigation.intersection.overstep_tolerance =
0060         std::get<0>(GetParam());
0061     cfg.propagation.stepping.step_constraint = std::get<1>(GetParam());
0062 
0063     // Set the magnetic field
0064     const vector3 B = std::get<2>(GetParam());
0065     auto field = create_const_field<scalar>(B);
0066 
0067     // Create the toy geometry
0068     auto [det, names] = build_toy_detector<test_algebra>(shared_mr);
0069 
0070     auto det_view = detray::get_data(det);
0071 
0072     run_propagation_test<bfield::const_bknd_t<scalar>>(&shared_mr, &q, det, cfg,
0073                                                        det_view, field);
0074 }
0075 
0076 class SyclPropConstBFieldCpy
0077     : public ::testing::TestWithParam<std::tuple<scalar, scalar, vector3>> {};
0078 
0079 TEST_P(SyclPropConstBFieldCpy, propagator) {
0080 
0081     // Creating SYCL queue object
0082     ::sycl::queue q(handle_async_error);
0083     DETRAY_VERBOSE_HOST("Running constant bfield propagation on device (cpy): "
0084                         << q.get_device().get_info<::sycl::info::device::name>()
0085                         << "\n");
0086 
0087     // VecMem memory resource(s)
0088     vecmem::host_memory_resource host_mr;
0089     vecmem::sycl::shared_memory_resource shared_mr;
0090     vecmem::sycl::device_memory_resource dev_mr;
0091 
0092     vecmem::sycl::queue_wrapper q_wrapper(&q);
0093     vecmem::sycl::copy sycl_cpy(q_wrapper);
0094 
0095     // Test configuration
0096     propagator_test_config cfg{};
0097     cfg.track_generator.phi_steps(20u).theta_steps(20u);
0098     cfg.track_generator.p_tot(10.f * unit<scalar>::GeV);
0099     cfg.track_generator.eta_range(-3.f, 3.f);
0100     cfg.propagation.navigation.search_window = {3u, 3u};
0101     // Configuration for non-z-aligned B-fields
0102     cfg.propagation.navigation.intersection.overstep_tolerance =
0103         std::get<0>(GetParam());
0104     cfg.propagation.stepping.step_constraint = std::get<1>(GetParam());
0105 
0106     // Set the magnetic field
0107     const vector3 B = std::get<2>(GetParam());
0108     auto field = create_const_field<scalar>(B);
0109 
0110     // Create the toy geometry
0111     auto [det, names] = build_toy_detector<test_algebra>(host_mr);
0112 
0113     auto det_buff = detray::get_buffer(det, dev_mr, sycl_cpy);
0114 
0115     run_propagation_test<bfield::const_bknd_t<scalar>>(
0116         &shared_mr, &q, det, cfg, detray::get_data(det_buff), field);
0117 }
0118 
0119 INSTANTIATE_TEST_SUITE_P(
0120     SyclPropagatorValidation1, SyclPropConstBFieldMng,
0121     ::testing::Values(std::make_tuple(-100.f * unit<scalar>::um,
0122                                       std::numeric_limits<scalar>::max(),
0123                                       vector3{0.f * unit<scalar>::T,
0124                                               0.f * unit<scalar>::T,
0125                                               2.f * unit<scalar>::T})));
0126 
0127 INSTANTIATE_TEST_SUITE_P(SyclPropagatorValidation2, SyclPropConstBFieldMng,
0128                          ::testing::Values(std::make_tuple(
0129                              -800.f * unit<scalar>::um, 5.f * unit<scalar>::mm,
0130                              vector3{0.f * unit<scalar>::T,
0131                                      1.f * unit<scalar>::T,
0132                                      1.f * unit<scalar>::T})));
0133 
0134 INSTANTIATE_TEST_SUITE_P(SyclPropagatorValidation3, SyclPropConstBFieldMng,
0135                          ::testing::Values(std::make_tuple(
0136                              -800.f * unit<scalar>::um, 5.f * unit<scalar>::mm,
0137                              vector3{1.f * unit<scalar>::T,
0138                                      0.f * unit<scalar>::T,
0139                                      1.f * unit<scalar>::T})));
0140 
0141 INSTANTIATE_TEST_SUITE_P(SyclPropagatorValidation4, SyclPropConstBFieldMng,
0142                          ::testing::Values(std::make_tuple(
0143                              -800.f * unit<scalar>::um, 1.f * unit<scalar>::mm,
0144                              vector3{1.f * unit<scalar>::T,
0145                                      1.f * unit<scalar>::T,
0146                                      1.f * unit<scalar>::T})));
0147 
0148 INSTANTIATE_TEST_SUITE_P(
0149     SyclPropagatorValidation5, SyclPropConstBFieldCpy,
0150     ::testing::Values(std::make_tuple(-100.f * unit<scalar>::um,
0151                                       std::numeric_limits<scalar>::max(),
0152                                       vector3{0.f * unit<scalar>::T,
0153                                               0.f * unit<scalar>::T,
0154                                               2.f * unit<scalar>::T})));
0155 
0156 INSTANTIATE_TEST_SUITE_P(SyclPropagatorValidation6, SyclPropConstBFieldCpy,
0157                          ::testing::Values(std::make_tuple(
0158                              -800.f * unit<scalar>::um, 5.f * unit<scalar>::mm,
0159                              vector3{0.f * unit<scalar>::T,
0160                                      1.f * unit<scalar>::T,
0161                                      1.f * unit<scalar>::T})));
0162 
0163 INSTANTIATE_TEST_SUITE_P(SyclPropagatorValidation7, SyclPropConstBFieldCpy,
0164                          ::testing::Values(std::make_tuple(
0165                              -800.f * unit<scalar>::um, 5.f * unit<scalar>::mm,
0166                              vector3{1.f * unit<scalar>::T,
0167                                      0.f * unit<scalar>::T,
0168                                      1.f * unit<scalar>::T})));
0169 
0170 INSTANTIATE_TEST_SUITE_P(SyclPropagatorValidation8, SyclPropConstBFieldCpy,
0171                          ::testing::Values(std::make_tuple(
0172                              -800.f * unit<scalar>::um, 1.f * unit<scalar>::mm,
0173                              vector3{1.f * unit<scalar>::T,
0174                                      1.f * unit<scalar>::T,
0175                                      1.f * unit<scalar>::T})));
0176 
0177 /// This tests the device propagation in an inhomogenepus magnetic field
0178 /*
0179 TEST(SyclPropagatorValidation10, inhomogeneous_bfield_cpy) {
0180 
0181     // Creating SYCL queue object
0182     ::sycl::queue q(handle_async_error);
0183     DETRAY_VERBOSE_HOST("Running inhom bfield propagation on device (cpy): "
0184               << q.get_device().get_info<::sycl::info::device::name>() << "\n");
0185 
0186     // VecMem memory resource(s)
0187     vecmem::host_memory_resource host_mr;
0188     vecmem::sycl::shared_memory_resource shared_mr;
0189     vecmem::sycl::device_memory_resource dev_mr;
0190 
0191     vecmem::sycl::copy sycl_cpy;
0192 
0193     // Test configuration
0194     propagator_test_config cfg{};
0195     cfg.track_generator.phi_steps(10u).theta_steps(10u);
0196     cfg.track_generator.p_tot(10.f * unit<scalar>::GeV);
0197     cfg.track_generator.eta_range(-3.f, 3.f);
0198     cfg.propagation.navigation.search_window = {3u, 3u};
0199 
0200     // Create the toy geometry with inhomogeneous bfield from file
0201     auto [det, names] = build_toy_detector<test_algebra, bfield::inhom_bknd_t>(
0202         shared_mr, toy_cfg);
0203 
0204     auto det_buff = detray::get_buffer<bfield::sycl::inhom_bknd_t>(det,
0205 cfg,dev_mr, sycl_cpy);
0206 
0207     run_propagation_test<bfield::sycl::inhom_bknd_t>(&mng_mr, &q, det, cfg,
0208 detray::get_data(det_buff));
0209 }*/