Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion device/alpaka/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ traccc_add_alpaka_library( traccc_alpaka alpaka TYPE SHARED
# Track finding algorithm(s).
"include/traccc/alpaka/finding/combinatorial_kalman_filter_algorithm.hpp"
"src/finding/combinatorial_kalman_filter_algorithm.cpp"
"src/finding/combinatorial_kalman_filter.hpp"
# Track fitting algorithm(s).
"include/traccc/alpaka/fitting/kalman_fitting_algorithm.hpp"
"src/fitting/kalman_fitting_algorithm.cpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,79 +1,187 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2025 CERN for the benefit of the ACTS project
* (c) 2025-2026 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

// Local include(s).
#include "traccc/alpaka/utils/queue.hpp"
#include "traccc/alpaka/utils/algorithm_base.hpp"

// Project include(s).
#include "traccc/bfield/magnetic_field.hpp"
#include "traccc/edm/measurement_collection.hpp"
#include "traccc/edm/track_container.hpp"
#include "traccc/edm/track_parameters.hpp"
#include "traccc/finding/finding_config.hpp"
#include "traccc/geometry/detector.hpp"
#include "traccc/geometry/detector_buffer.hpp"
#include "traccc/utils/algorithm.hpp"
#include "traccc/utils/memory_resource.hpp"
#include "traccc/utils/messaging.hpp"

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

// System include(s).
#include <functional>
#include "traccc/finding/device/combinatorial_kalman_filter_algorithm.hpp"

namespace traccc::alpaka {

/// CKF track finding algorithm
/// CKF track finding algorithm using Alpaka
class combinatorial_kalman_filter_algorithm
: public algorithm<edm::track_container<default_algebra>::buffer(
const detector_buffer&, const magnetic_field&,
const edm::measurement_collection<default_algebra>::const_view&,
const bound_track_parameters_collection_types::const_view&)>,
public messaging {
: public device::combinatorial_kalman_filter_algorithm,
public alpaka::algorithm_base {

public:
/// Configuration type
using config_type = finding_config;

/// Constructor with the algorithm's configuration
explicit combinatorial_kalman_filter_algorithm(
const config_type& config, const traccc::memory_resource& mr,
vecmem::copy& copy, queue& q,
combinatorial_kalman_filter_algorithm(
const finding_config& config, const traccc::memory_resource& mr,
vecmem::copy& copy, alpaka::queue& queue,
std::unique_ptr<const Logger> logger = getDummyLogger().clone());

/// Execute the algorithm
private:
/// @name Function(s) inherited from
/// @c traccc::device::combinatorial_kalman_filter_algorithm
/// @{

/// Function meant to perform sanity checks on the input data
///
/// @param det The detector object
/// @param bfield The magnetic field object
/// @param measurements All measurements in an event
/// @param seeds All seeds in an event to start the track finding
/// with
/// @return @c true if the input data is valid, @c false otherwise
///
/// @return A container of the found track candidates
bool input_is_valid(
const edm::measurement_collection<default_algebra>::const_view&
measurements) const override;

/// Function building the measurement ranges buffer
///
output_type operator()(
const detector_buffer& det, const magnetic_field& bfield,
/// @param det The detector object
/// @param n_measurements The number of measurements in the event
/// @param measurements All measurements in an event
/// @return The measurement ranges buffer
///
vecmem::data::vector_buffer<
edm::measurement_collection<default_algebra>::const_view::size_type>
build_measurement_ranges_buffer(
const detector_buffer& det,
const edm::measurement_collection<
default_algebra>::const_view::size_type n_measurements,
const edm::measurement_collection<default_algebra>::const_view&
measurements,
const bound_track_parameters_collection_types::const_view& seeds)
measurements) const override;

/// Material interaction application kernel launcher
///
/// @param n_threads The number of threads to launch the kernel with
/// @param config The track finding configuration
/// @param det The detector object
/// @param payload The payload for the kernel
///
void apply_interaction_kernel(
unsigned int n_threads, const finding_config& config,
const detector_buffer& det,
const device::apply_interaction_payload& payload) const override;

/// Track finding kernel launcher
///
/// @param n_threads The number of threads to launch the kernel with
/// @param config The track finding configuration
/// @param det The detector object
/// @param payload The payload for the kernel
///
void find_tracks_kernel(
unsigned int n_threads, const finding_config& config,
const detector_buffer& det,
const device::find_tracks_payload& payload) const override;

/// Launch the kernel sorting the parameters before duplicate removal
///
/// @param n_threads The number of threads to launch the kernel with
/// @param payload The payload for the kernel
///
void fill_finding_duplicate_removal_sort_keys_kernel(
unsigned int n_threads,
const device::fill_finding_duplicate_removal_sort_keys_payload& payload)
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;
/// Alpaka queue
std::reference_wrapper<queue> m_queue;
/// Sort the parameter IDs according to the last measurement index
///
/// @param link_last_measurement The last measurement index per link
/// @param param_ids The parameter IDs to sort
///
void sort_param_ids_by_last_measurement(
vecmem::data::vector_view<unsigned int>& link_last_measurement,
vecmem::data::vector_view<unsigned int>& param_ids) const override;

/// Duplicate removal kernel launcher
///
/// @param n_threads The number of threads to launch the kernel with
/// @param config The track finding configuration
/// @param payload The payload for the kernel
///
void remove_duplicates_kernel(
unsigned int n_threads, const finding_config& config,
const device::remove_duplicates_payload& payload) const override;

/// Launch the @c fill_finding_propagation_sort_keys kernel
///
/// @param n_threads The number of threads to launch the kernel with
/// @param payload The payload for the kernel
///
void fill_finding_propagation_sort_keys_kernel(
unsigned int n_threads,
const device::fill_finding_propagation_sort_keys_payload& payload)
const override;

/// Sort the parameter IDs according to a custom set of keys
///
/// @param keys The sort keys
/// @param param_ids The parameter IDs to sort
///
void sort_param_ids_by_keys(
vecmem::data::vector_view<device::sort_key>& keys,
vecmem::data::vector_view<unsigned int>& param_ids) const override;

/// Launch the @c propagate_to_next_surface kernel
///
/// @param n_threads The number of threads to launch the kernel with
/// @param config The track finding configuration
/// @param det The detector object
/// @param bfield The magnetic field object
/// @param payload The payload for the kernel
///
void propagate_to_next_surface_kernel(
unsigned int n_threads, const finding_config& config,
const detector_buffer& det, const magnetic_field& bfield,
const device::propagate_to_next_surface_payload& payload)
const override;

/// Launch the @c gather_best_tips_per_measurement kernel
///
/// @param n_threads The number of threads to launch the kernel with
/// @param payload The payload for the kernel
///
void gather_best_tips_per_measurement_kernel(
unsigned int n_threads,
const device::gather_best_tips_per_measurement_payload<default_algebra>&
payload) const override;

/// Launch the @c gather_measurement_votes kernel
///
/// @param n_threads The number of threads to launch the kernel with
/// @param payload The payload for the kernel
///
void gather_measurement_votes_kernel(
unsigned int n_threads,
const device::gather_measurement_votes_payload& payload) const override;

/// Launch the @c update_tip_length_buffer kernel
///
/// @param n_threads The number of threads to launch the kernel with
/// @param payload The payload for the kernel
///
void update_tip_length_buffer_kernel(
unsigned int n_threads,
const device::update_tip_length_buffer_payload& payload) const override;

/// Launch the @c build_tracks kernel
///
/// @param n_threads The number of threads to launch the kernel with
/// @param run_mbf_smoother Whether the MBF smoother was run
/// @param payload The payload for the kernel
///
void build_tracks_kernel(
unsigned int n_threads, bool run_mbf_smoother,
const device::build_tracks_payload& payload) const override;

/// @}

}; // class combinatorial_kalman_filter_algorithm

Expand Down
Loading
Loading