Skip to content

Commit

Permalink
SYCL Track Finding, main branch (2025.01.09.) (#811)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
krasznaa authored Jan 10, 2025
1 parent bdfa3f5 commit e7948f3
Show file tree
Hide file tree
Showing 14 changed files with 1,369 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,9 @@ TRACCC_DEVICE inline void build_tracks(const global_index_t globalIndex,
// Resize the candidates with the exact size
cands_per_track.resize(n_cands);

unsigned int i = 0;

// Reversely iterate to fill the track candidates
for (auto it = cands_per_track.rbegin(); it != cands_per_track.rend();
it++) {
i++;

while (L.meas_idx > n_meas &&
L.previous.first !=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ TRACCC_DEVICE inline void find_tracks(
* this thread.
*/
else {
const auto bcd_id = std::distance(barcodes.begin(), lo);
const vecmem::device_vector<const unsigned int>::size_type bcd_id =
static_cast<
vecmem::device_vector<const unsigned int>::size_type>(
std::distance(barcodes.begin(), lo));

init_meas = lo == barcodes.begin() ? 0u : upper_bounds[bcd_id - 1];
num_meas = upper_bounds[bcd_id] - init_meas;
Expand Down
8 changes: 7 additions & 1 deletion device/sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TRACCC library, part of the ACTS project (R&D line)
#
# (c) 2021-2024 CERN for the benefit of the ACTS project
# (c) 2021-2025 CERN for the benefit of the ACTS project
#
# Mozilla Public License Version 2.0

Expand Down Expand Up @@ -30,6 +30,12 @@ traccc_add_library( traccc_sycl sycl TYPE SHARED
"src/seeding/seeding_algorithm.cpp"
"include/traccc/sycl/seeding/track_params_estimation.hpp"
"src/seeding/track_params_estimation.sycl"
# Track finding algorithm(s).
"include/traccc/sycl/finding/combinatorial_kalman_filter_algorithm.hpp"
"src/finding/combinatorial_kalman_filter_algorithm.cpp"
"src/finding/combinatorial_kalman_filter_algorithm_constant_field_default_detector.sycl"
"src/finding/combinatorial_kalman_filter_algorithm_constant_field_telescope_detector.sycl"
"src/finding/find_tracks.hpp"
# Track fitting algorithm(s).
"include/traccc/sycl/fitting/kalman_fitting_algorithm.hpp"
"src/fitting/kalman_fitting_algorithm.cpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

// SYCL library include(s).
#include "traccc/sycl/utils/queue_wrapper.hpp"

// Project include(s).
#include "traccc/edm/measurement.hpp"
#include "traccc/edm/track_candidate.hpp"
#include "traccc/edm/track_parameters.hpp"
#include "traccc/finding/finding_config.hpp"
#include "traccc/geometry/detector.hpp"
#include "traccc/utils/algorithm.hpp"
#include "traccc/utils/memory_resource.hpp"

// Detray include(s).
#include <detray/detectors/bfield.hpp>

// VecMem include(s).
#include <vecmem/utils/copy.hpp>

// System include(s).
#include <functional>

namespace traccc::sycl {

/// CKF track finding algorithm
class combinatorial_kalman_filter_algorithm
: public algorithm<track_candidate_container_types::buffer(
const default_detector::view&,
const detray::bfield::const_field_t::view_t&,
const measurement_collection_types::const_view&,
const bound_track_parameters_collection_types::const_view&)>,
public algorithm<track_candidate_container_types::buffer(
const telescope_detector::view&,
const detray::bfield::const_field_t::view_t&,
const measurement_collection_types::const_view&,
const bound_track_parameters_collection_types::const_view&)> {

public:
/// Configuration type
using config_type = finding_config;
/// Output type
using output_type = track_candidate_container_types::buffer;

/// Constructor with the algorithm's configuration
explicit combinatorial_kalman_filter_algorithm(
const config_type& config, const traccc::memory_resource& mr,
vecmem::copy& copy, queue_wrapper queue);

/// Execute the algorithm
///
/// @param det The (default) detector object
/// @param field The (constant) magnetic field object
/// @param measurements All measurements in an event
/// @param seeds All seeds in an event to start the track finding
/// with
///
/// @return A container of the found track candidates
///
output_type operator()(
const default_detector::view& det,
const detray::bfield::const_field_t::view_t& field,
const measurement_collection_types::const_view& measurements,
const bound_track_parameters_collection_types::const_view& seeds)
const override;

/// Execute the algorithm
///
/// @param det The (telescope) detector object
/// @param field The (constant) magnetic field object
/// @param measurements All measurements in an event
/// @param seeds All seeds in an event to start the track finding
/// with
///
/// @return A container of the found track candidates
///
output_type operator()(
const telescope_detector::view& det,
const detray::bfield::const_field_t::view_t& field,
const measurement_collection_types::const_view& measurements,
const bound_track_parameters_collection_types::const_view& seeds)
const override;

private:
/// Algorithm configuration
config_type m_config;
/// Memory resource used by the algorithm
traccc::memory_resource m_mr;
/// Copy object used by the algorithm
std::reference_wrapper<vecmem::copy> m_copy;
/// Queue wrapper
mutable queue_wrapper m_queue;

}; // class combinatorial_kalman_filter_algorithm

} // namespace traccc::sycl
18 changes: 18 additions & 0 deletions device/sycl/src/finding/combinatorial_kalman_filter_algorithm.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

// Local include(s).
#include "traccc/sycl/finding/combinatorial_kalman_filter_algorithm.hpp"

namespace traccc::sycl {

combinatorial_kalman_filter_algorithm::combinatorial_kalman_filter_algorithm(
const config_type& config, const traccc::memory_resource& mr,
vecmem::copy& copy, queue_wrapper queue)
: m_config{config}, m_mr{mr}, m_copy{copy}, m_queue{queue} {}

} // namespace traccc::sycl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

// Local include(s).
#include "../utils/get_queue.hpp"
#include "find_tracks.hpp"
#include "traccc/sycl/finding/combinatorial_kalman_filter_algorithm.hpp"

// Detray include(s).
#include <detray/detectors/bfield.hpp>
#include <detray/navigation/navigator.hpp>
#include <detray/propagator/propagator.hpp>
#include <detray/propagator/rk_stepper.hpp>

namespace traccc::sycl {
namespace kernels {
struct ckf_constant_field_default_detector;
} // namespace kernels

combinatorial_kalman_filter_algorithm::output_type
combinatorial_kalman_filter_algorithm::operator()(
const default_detector::view& det,
const detray::bfield::const_field_t::view_t& field,
const measurement_collection_types::const_view& measurements,
const bound_track_parameters_collection_types::const_view& seeds) const {

// Perform the track finding using the templated implementation.
return details::find_tracks<
detray::rk_stepper<detray::bfield::const_field_t::view_t,
default_detector::device::algebra_type,
detray::constrained_step<>>,
detray::navigator<const default_detector::device>,
kernels::ckf_constant_field_default_detector>(
det, field, measurements, seeds, m_config, m_mr, m_copy,
details::get_queue(m_queue));
}

} // namespace traccc::sycl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

// Local include(s).
#include "../utils/get_queue.hpp"
#include "find_tracks.hpp"
#include "traccc/sycl/finding/combinatorial_kalman_filter_algorithm.hpp"

// Detray include(s).
#include <detray/detectors/bfield.hpp>
#include <detray/navigation/navigator.hpp>
#include <detray/propagator/propagator.hpp>
#include <detray/propagator/rk_stepper.hpp>

namespace traccc::sycl {
namespace kernels {
struct ckf_constant_field_telescope_detector;
} // namespace kernels

combinatorial_kalman_filter_algorithm::output_type
combinatorial_kalman_filter_algorithm::operator()(
const telescope_detector::view& det,
const detray::bfield::const_field_t::view_t& field,
const measurement_collection_types::const_view& measurements,
const bound_track_parameters_collection_types::const_view& seeds) const {

// Perform the track finding using the templated implementation.
return details::find_tracks<
detray::rk_stepper<detray::bfield::const_field_t::view_t,
telescope_detector::device::algebra_type,
detray::constrained_step<>>,
detray::navigator<const telescope_detector::device>,
kernels::ckf_constant_field_telescope_detector>(
det, field, measurements, seeds, m_config, m_mr, m_copy,
details::get_queue(m_queue));
}

} // namespace traccc::sycl
Loading

0 comments on commit e7948f3

Please sign in to comment.