Skip to content

Commit e7948f3

Browse files
authored
SYCL Track Finding, main branch (2025.01.09.) (acts-project#811)
* Update the project to oneDPL-2022.7.1. * Introduce a CKF algorithm into traccc::sycl. While also doing some final small fixes in the common track finding code. * Add unit tests for the SYCL CKF algorithm. * Simplified the way unique kernel names are generated with. * Remove the apparently unnecessary memset.
1 parent bdfa3f5 commit e7948f3

14 files changed

+1369
-8
lines changed

device/common/include/traccc/finding/device/impl/build_tracks.ipp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,9 @@ TRACCC_DEVICE inline void build_tracks(const global_index_t globalIndex,
6565
// Resize the candidates with the exact size
6666
cands_per_track.resize(n_cands);
6767

68-
unsigned int i = 0;
69-
7068
// Reversely iterate to fill the track candidates
7169
for (auto it = cands_per_track.rbegin(); it != cands_per_track.rend();
7270
it++) {
73-
i++;
7471

7572
while (L.meas_idx > n_meas &&
7673
L.previous.first !=

device/common/include/traccc/finding/device/impl/find_tracks.ipp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ TRACCC_DEVICE inline void find_tracks(
107107
* this thread.
108108
*/
109109
else {
110-
const auto bcd_id = std::distance(barcodes.begin(), lo);
110+
const vecmem::device_vector<const unsigned int>::size_type bcd_id =
111+
static_cast<
112+
vecmem::device_vector<const unsigned int>::size_type>(
113+
std::distance(barcodes.begin(), lo));
111114

112115
init_meas = lo == barcodes.begin() ? 0u : upper_bounds[bcd_id - 1];
113116
num_meas = upper_bounds[bcd_id] - init_meas;

device/sycl/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# TRACCC library, part of the ACTS project (R&D line)
22
#
3-
# (c) 2021-2024 CERN for the benefit of the ACTS project
3+
# (c) 2021-2025 CERN for the benefit of the ACTS project
44
#
55
# Mozilla Public License Version 2.0
66

@@ -30,6 +30,12 @@ traccc_add_library( traccc_sycl sycl TYPE SHARED
3030
"src/seeding/seeding_algorithm.cpp"
3131
"include/traccc/sycl/seeding/track_params_estimation.hpp"
3232
"src/seeding/track_params_estimation.sycl"
33+
# Track finding algorithm(s).
34+
"include/traccc/sycl/finding/combinatorial_kalman_filter_algorithm.hpp"
35+
"src/finding/combinatorial_kalman_filter_algorithm.cpp"
36+
"src/finding/combinatorial_kalman_filter_algorithm_constant_field_default_detector.sycl"
37+
"src/finding/combinatorial_kalman_filter_algorithm_constant_field_telescope_detector.sycl"
38+
"src/finding/find_tracks.hpp"
3339
# Track fitting algorithm(s).
3440
"include/traccc/sycl/fitting/kalman_fitting_algorithm.hpp"
3541
"src/fitting/kalman_fitting_algorithm.cpp"
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/** TRACCC library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 2024 CERN for the benefit of the ACTS project
4+
*
5+
* Mozilla Public License Version 2.0
6+
*/
7+
8+
#pragma once
9+
10+
// SYCL library include(s).
11+
#include "traccc/sycl/utils/queue_wrapper.hpp"
12+
13+
// Project include(s).
14+
#include "traccc/edm/measurement.hpp"
15+
#include "traccc/edm/track_candidate.hpp"
16+
#include "traccc/edm/track_parameters.hpp"
17+
#include "traccc/finding/finding_config.hpp"
18+
#include "traccc/geometry/detector.hpp"
19+
#include "traccc/utils/algorithm.hpp"
20+
#include "traccc/utils/memory_resource.hpp"
21+
22+
// Detray include(s).
23+
#include <detray/detectors/bfield.hpp>
24+
25+
// VecMem include(s).
26+
#include <vecmem/utils/copy.hpp>
27+
28+
// System include(s).
29+
#include <functional>
30+
31+
namespace traccc::sycl {
32+
33+
/// CKF track finding algorithm
34+
class combinatorial_kalman_filter_algorithm
35+
: public algorithm<track_candidate_container_types::buffer(
36+
const default_detector::view&,
37+
const detray::bfield::const_field_t::view_t&,
38+
const measurement_collection_types::const_view&,
39+
const bound_track_parameters_collection_types::const_view&)>,
40+
public algorithm<track_candidate_container_types::buffer(
41+
const telescope_detector::view&,
42+
const detray::bfield::const_field_t::view_t&,
43+
const measurement_collection_types::const_view&,
44+
const bound_track_parameters_collection_types::const_view&)> {
45+
46+
public:
47+
/// Configuration type
48+
using config_type = finding_config;
49+
/// Output type
50+
using output_type = track_candidate_container_types::buffer;
51+
52+
/// Constructor with the algorithm's configuration
53+
explicit combinatorial_kalman_filter_algorithm(
54+
const config_type& config, const traccc::memory_resource& mr,
55+
vecmem::copy& copy, queue_wrapper queue);
56+
57+
/// Execute the algorithm
58+
///
59+
/// @param det The (default) detector object
60+
/// @param field The (constant) magnetic field object
61+
/// @param measurements All measurements in an event
62+
/// @param seeds All seeds in an event to start the track finding
63+
/// with
64+
///
65+
/// @return A container of the found track candidates
66+
///
67+
output_type operator()(
68+
const default_detector::view& det,
69+
const detray::bfield::const_field_t::view_t& field,
70+
const measurement_collection_types::const_view& measurements,
71+
const bound_track_parameters_collection_types::const_view& seeds)
72+
const override;
73+
74+
/// Execute the algorithm
75+
///
76+
/// @param det The (telescope) detector object
77+
/// @param field The (constant) magnetic field object
78+
/// @param measurements All measurements in an event
79+
/// @param seeds All seeds in an event to start the track finding
80+
/// with
81+
///
82+
/// @return A container of the found track candidates
83+
///
84+
output_type operator()(
85+
const telescope_detector::view& det,
86+
const detray::bfield::const_field_t::view_t& field,
87+
const measurement_collection_types::const_view& measurements,
88+
const bound_track_parameters_collection_types::const_view& seeds)
89+
const override;
90+
91+
private:
92+
/// Algorithm configuration
93+
config_type m_config;
94+
/// Memory resource used by the algorithm
95+
traccc::memory_resource m_mr;
96+
/// Copy object used by the algorithm
97+
std::reference_wrapper<vecmem::copy> m_copy;
98+
/// Queue wrapper
99+
mutable queue_wrapper m_queue;
100+
101+
}; // class combinatorial_kalman_filter_algorithm
102+
103+
} // namespace traccc::sycl
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/** TRACCC library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 2024 CERN for the benefit of the ACTS project
4+
*
5+
* Mozilla Public License Version 2.0
6+
*/
7+
8+
// Local include(s).
9+
#include "traccc/sycl/finding/combinatorial_kalman_filter_algorithm.hpp"
10+
11+
namespace traccc::sycl {
12+
13+
combinatorial_kalman_filter_algorithm::combinatorial_kalman_filter_algorithm(
14+
const config_type& config, const traccc::memory_resource& mr,
15+
vecmem::copy& copy, queue_wrapper queue)
16+
: m_config{config}, m_mr{mr}, m_copy{copy}, m_queue{queue} {}
17+
18+
} // namespace traccc::sycl
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/** TRACCC library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 2024 CERN for the benefit of the ACTS project
4+
*
5+
* Mozilla Public License Version 2.0
6+
*/
7+
8+
// Local include(s).
9+
#include "../utils/get_queue.hpp"
10+
#include "find_tracks.hpp"
11+
#include "traccc/sycl/finding/combinatorial_kalman_filter_algorithm.hpp"
12+
13+
// Detray include(s).
14+
#include <detray/detectors/bfield.hpp>
15+
#include <detray/navigation/navigator.hpp>
16+
#include <detray/propagator/propagator.hpp>
17+
#include <detray/propagator/rk_stepper.hpp>
18+
19+
namespace traccc::sycl {
20+
namespace kernels {
21+
struct ckf_constant_field_default_detector;
22+
} // namespace kernels
23+
24+
combinatorial_kalman_filter_algorithm::output_type
25+
combinatorial_kalman_filter_algorithm::operator()(
26+
const default_detector::view& det,
27+
const detray::bfield::const_field_t::view_t& field,
28+
const measurement_collection_types::const_view& measurements,
29+
const bound_track_parameters_collection_types::const_view& seeds) const {
30+
31+
// Perform the track finding using the templated implementation.
32+
return details::find_tracks<
33+
detray::rk_stepper<detray::bfield::const_field_t::view_t,
34+
default_detector::device::algebra_type,
35+
detray::constrained_step<>>,
36+
detray::navigator<const default_detector::device>,
37+
kernels::ckf_constant_field_default_detector>(
38+
det, field, measurements, seeds, m_config, m_mr, m_copy,
39+
details::get_queue(m_queue));
40+
}
41+
42+
} // namespace traccc::sycl
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/** TRACCC library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 2024 CERN for the benefit of the ACTS project
4+
*
5+
* Mozilla Public License Version 2.0
6+
*/
7+
8+
// Local include(s).
9+
#include "../utils/get_queue.hpp"
10+
#include "find_tracks.hpp"
11+
#include "traccc/sycl/finding/combinatorial_kalman_filter_algorithm.hpp"
12+
13+
// Detray include(s).
14+
#include <detray/detectors/bfield.hpp>
15+
#include <detray/navigation/navigator.hpp>
16+
#include <detray/propagator/propagator.hpp>
17+
#include <detray/propagator/rk_stepper.hpp>
18+
19+
namespace traccc::sycl {
20+
namespace kernels {
21+
struct ckf_constant_field_telescope_detector;
22+
} // namespace kernels
23+
24+
combinatorial_kalman_filter_algorithm::output_type
25+
combinatorial_kalman_filter_algorithm::operator()(
26+
const telescope_detector::view& det,
27+
const detray::bfield::const_field_t::view_t& field,
28+
const measurement_collection_types::const_view& measurements,
29+
const bound_track_parameters_collection_types::const_view& seeds) const {
30+
31+
// Perform the track finding using the templated implementation.
32+
return details::find_tracks<
33+
detray::rk_stepper<detray::bfield::const_field_t::view_t,
34+
telescope_detector::device::algebra_type,
35+
detray::constrained_step<>>,
36+
detray::navigator<const telescope_detector::device>,
37+
kernels::ckf_constant_field_telescope_detector>(
38+
det, field, measurements, seeds, m_config, m_mr, m_copy,
39+
details::get_queue(m_queue));
40+
}
41+
42+
} // namespace traccc::sycl

0 commit comments

Comments
 (0)