Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SYCL Track Finding, main branch (2025.01.09.) #811

Merged
merged 5 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,60 @@
/** 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::ckf_cfield_defdet {

struct make_barcode_sequence;
struct apply_interaction;
struct find_tracks;
struct fill_sort_keys;
struct propagate_to_next_surface;
struct build_tracks;
struct prune_tracks;

struct kernels {
using make_barcode_sequence_kernel_type = make_barcode_sequence;
using apply_interaction_kernel_type = apply_interaction;
using find_tracks_kernel_type = find_tracks;
using fill_sort_keys_kernel_type = fill_sort_keys;
using propagate_to_next_surface_kernel_type = propagate_to_next_surface;
using build_tracks_kernel_type = build_tracks;
using prune_tracks_kernel_type = prune_tracks;
}; // namespace kernels
stephenswat marked this conversation as resolved.
Show resolved Hide resolved

} // namespace kernels::ckf_cfield_defdet

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_cfield_defdet::kernels>(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,60 @@
/** 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::ckf_cfield_teldet {

struct make_barcode_sequence;
struct apply_interaction;
struct find_tracks;
struct fill_sort_keys;
struct propagate_to_next_surface;
struct build_tracks;
struct prune_tracks;

struct kernels {
using make_barcode_sequence_kernel_type = make_barcode_sequence;
using apply_interaction_kernel_type = apply_interaction;
using find_tracks_kernel_type = find_tracks;
using fill_sort_keys_kernel_type = fill_sort_keys;
using propagate_to_next_surface_kernel_type = propagate_to_next_surface;
using build_tracks_kernel_type = build_tracks;
using prune_tracks_kernel_type = prune_tracks;
krasznaa marked this conversation as resolved.
Show resolved Hide resolved
}; // namespace kernels

} // namespace kernels::ckf_cfield_teldet

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_cfield_teldet::kernels>(det, field, measurements, seeds,
m_config, m_mr, m_copy,
details::get_queue(m_queue));
}

} // namespace traccc::sycl
Loading
Loading