Skip to content

Commit

Permalink
Common sense cleanup in the device track finding.
Browse files Browse the repository at this point in the history
Introduced the globalIndex_t typedef for the unsigned int
type. Switched all track finding functions to using it
instead of std::size_t.

Removed all unnecessary templating from functions that
were never updated after the track finding configuration
became a simple standalone struct.

Removed some unnecessary const declarations from the
payload structs, and added some extra const declarations
in some of the function bodies.
  • Loading branch information
krasznaa committed Jan 7, 2025
1 parent dab51f1 commit 63dd4e5
Show file tree
Hide file tree
Showing 15 changed files with 167 additions and 114 deletions.
16 changes: 16 additions & 0 deletions device/common/include/traccc/device/globalIndex.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* traccc library, part of the ACTS project (R&D line)
*
* (c) 2025 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

namespace traccc::device {

/// Type for passing "global indices" to device functions
using globalIndex_t = unsigned int;

} // namespace traccc::device
25 changes: 17 additions & 8 deletions device/common/include/traccc/finding/device/apply_interaction.hpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2023 CERN for the benefit of the ACTS project
* (c) 2023-2025 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

// Local include(s).
#include "traccc/device/globalIndex.hpp"

// Project include(s).
#include "detray/navigation/navigator.hpp"
#include "detray/propagator/actors/pointwise_material_interactor.hpp"
#include "traccc/definitions/qualifiers.hpp"
#include "traccc/edm/track_parameters.hpp"
#include "traccc/finding/finding_config.hpp"
#include "traccc/utils/particle.hpp"

// VecMem include(s).
#include <vecmem/containers/data/vector_view.hpp>

namespace traccc::device {

/// (Event Data) Payload for the @c traccc::device::apply_interaction function
template <typename detector_t>
struct apply_interaction_payload {
/**
Expand All @@ -25,7 +31,7 @@ struct apply_interaction_payload {
/**
* @brief Total number of input parameters (including non-live ones)
*/
const int n_params;
unsigned int n_params;

/**
* @brief View object to the vector of bound track parameters
Expand All @@ -39,16 +45,19 @@ struct apply_interaction_payload {
vecmem::data::vector_view<const unsigned int> params_liveness_view;
};

/// Function applying the Pre material interaction to tracks spawned by bound
/// track parameters
/// Function applying the material interaction to tracks spawned described by
/// bound track parameters
///
/// @param[in] globalIndex The index of the current thread
/// @param[in] cfg Track finding config object
/// @param[inout] payload The function call payload
///
template <typename detector_t>
TRACCC_DEVICE inline void apply_interaction(
std::size_t globalIndex, const finding_config& cfg,
globalIndex_t globalIndex, const finding_config& cfg,
const apply_interaction_payload<detector_t>& payload);

} // namespace traccc::device

// Include the implementation.
#include "./impl/apply_interaction.ipp"
19 changes: 15 additions & 4 deletions device/common/include/traccc/finding/device/build_tracks.hpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2023 CERN for the benefit of the ACTS project
* (c) 2023-2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

// Local include(s).
#include "traccc/device/globalIndex.hpp"

// Project include(s).
#include "traccc/definitions/qualifiers.hpp"
#include "traccc/edm/measurement.hpp"
#include "traccc/edm/track_candidate.hpp"
#include "traccc/edm/track_parameters.hpp"
#include "traccc/finding/candidate_link.hpp"
#include "traccc/finding/finding_config.hpp"

// VecMem include(s).
#include <vecmem/containers/data/jagged_vector_view.hpp>
#include <vecmem/containers/data/vector_view.hpp>

namespace traccc::device {

/// (Event Data) Payload for the @c traccc::device::build_tracks function
struct build_tracks_payload {
/**
* @brief View object to the vector of measurements
Expand Down Expand Up @@ -64,11 +74,12 @@ struct build_tracks_payload {
/// @param[in] globalIndex The index of the current thread
/// @param[in] cfg Track finding config object
/// @param[inout] payload The function call payload
template <typename config_t>
TRACCC_DEVICE inline void build_tracks(std::size_t globalIndex,
const config_t cfg,
///
TRACCC_DEVICE inline void build_tracks(globalIndex_t globalIndex,
const finding_config& cfg,
const build_tracks_payload& payload);

} // namespace traccc::device

// Include the implementation.
#include "./impl/build_tracks.ipp"
17 changes: 14 additions & 3 deletions device/common/include/traccc/finding/device/fill_sort_keys.hpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2024 CERN for the benefit of the ACTS project
* (c) 2024-2025 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

// Local include(s).
#include "traccc/device/globalIndex.hpp"

// Project include(s).
#include "traccc/edm/device/sort_key.hpp"
#include "traccc/edm/track_candidate.hpp"
#include "traccc/edm/track_parameters.hpp"

// VecMem include(s).
#include <vecmem/containers/data/vector_view.hpp>

namespace traccc::device {

/// (Event Data) Payload for the @c traccc::device::fill_sort_keys function
struct fill_sort_keys_payload {
/**
* @brief View object to the vector of bound track parameters
Expand All @@ -34,8 +42,11 @@ struct fill_sort_keys_payload {
///
/// @param[in] globalIndex The index of the current thread
/// @param[inout] payload The function call payload
///
TRACCC_HOST_DEVICE inline void fill_sort_keys(
std::size_t globalIndex, const fill_sort_keys_payload& payload);
globalIndex_t globalIndex, const fill_sort_keys_payload& payload);

} // namespace traccc::device

// Include the implementation.
#include "./impl/fill_sort_keys.ipp"
28 changes: 19 additions & 9 deletions device/common/include/traccc/finding/device/find_tracks.hpp
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) 2023-2024 CERN for the benefit of the ACTS project
* (c) 2023-2025 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/
Expand All @@ -14,12 +14,18 @@
#include "traccc/device/concepts/thread_id.hpp"
#include "traccc/edm/measurement.hpp"
#include "traccc/edm/track_parameters.hpp"
#include "traccc/edm/track_state.hpp"
#include "traccc/finding/candidate_link.hpp"
#include "traccc/finding/finding_config.hpp"
#include "traccc/fitting/kalman_filter/gain_matrix_updater.hpp"

// VecMem include(s).
#include <vecmem/containers/data/vector_view.hpp>

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

namespace traccc::device {

/// (Global Event Data) Payload for the @c traccc::device::find_tracks function
template <typename detector_t>
struct find_tracks_payload {
/**
Expand Down Expand Up @@ -48,7 +54,7 @@ struct find_tracks_payload {
/**
* @brief The total number of input parameters
*/
const unsigned int n_in_params;
unsigned int n_in_params;

/**
* @brief View object to the vector of barcodes for each measurement
Expand All @@ -69,12 +75,12 @@ struct find_tracks_payload {
/**
* @brief The current step identifier
*/
const unsigned int step;
unsigned int step;

/**
* @brief The maximum number of new tracks to find
*/
const unsigned int n_max_candidates;
unsigned int n_max_candidates;

/**
* @brief View object to the output track parameter vector
Expand All @@ -98,6 +104,7 @@ struct find_tracks_payload {
unsigned int* n_total_candidates;
};

/// (Shared Event Data) Payload for the @c traccc::device::find_tracks function
struct find_tracks_shared_payload {
/**
* @brief Shared-memory vector with the number of measurements found per
Expand Down Expand Up @@ -129,12 +136,15 @@ struct find_tracks_shared_payload {
/// @param[in] cfg Track finding config object
/// @param[inout] payload The global memory payload
/// @param[inout] shared_payload The shared memory payload
template <concepts::thread_id1 thread_id_t, concepts::barrier barrier_t,
typename detector_t, typename config_t>
///
template <typename detector_t, concepts::thread_id1 thread_id_t,
concepts::barrier barrier_t>
TRACCC_DEVICE inline void find_tracks(
thread_id_t& thread_id, barrier_t& barrier, const config_t cfg,
thread_id_t& thread_id, barrier_t& barrier, const finding_config& cfg,
const find_tracks_payload<detector_t>& payload,
const find_tracks_shared_payload& shared_payload);

} // namespace traccc::device

// Include the implementation.
#include "./impl/find_tracks.ipp"
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2023 CERN for the benefit of the ACTS project
* (c) 2023-2025 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

// Project include(s).
#include "detray/navigation/navigator.hpp"
#include "detray/propagator/actors/pointwise_material_interactor.hpp"
#include "traccc/definitions/qualifiers.hpp"
#include "traccc/finding/finding_config.hpp"
#include "traccc/utils/particle.hpp"

// Detray include(s).
#include <detray/navigation/navigator.hpp>
#include <detray/propagator/actors/pointwise_material_interactor.hpp>

namespace traccc::device {

template <typename detector_t>
TRACCC_DEVICE inline void apply_interaction(
std::size_t globalIndex, const finding_config& cfg,
const globalIndex_t globalIndex, const finding_config& cfg,
const apply_interaction_payload<detector_t>& payload) {

// Type definitions
Expand Down
24 changes: 8 additions & 16 deletions device/common/include/traccc/finding/device/impl/build_tracks.ipp
Original file line number Diff line number Diff line change
@@ -1,37 +1,29 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2023 CERN for the benefit of the ACTS project
* (c) 2023-2025 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

// Project include(s).
#include "traccc/definitions/qualifiers.hpp"
#include "traccc/edm/measurement.hpp"
#include "traccc/edm/track_candidate.hpp"
#include "traccc/edm/track_parameters.hpp"
#include "traccc/finding/candidate_link.hpp"

namespace traccc::device {

template <typename config_t>
TRACCC_DEVICE inline void build_tracks(std::size_t globalIndex,
const config_t cfg,
TRACCC_DEVICE inline void build_tracks(const globalIndex_t globalIndex,
const finding_config& cfg,
const build_tracks_payload& payload) {

measurement_collection_types::const_device measurements(
const measurement_collection_types::const_device measurements(
payload.measurements_view);

bound_track_parameters_collection_types::const_device seeds(
const bound_track_parameters_collection_types::const_device seeds(
payload.seeds_view);

vecmem::jagged_device_vector<const candidate_link> links(
const vecmem::jagged_device_vector<const candidate_link> links(
payload.links_view);

vecmem::device_vector<const typename candidate_link::link_index_type> tips(
payload.tips_view);
const vecmem::device_vector<const typename candidate_link::link_index_type>
tips(payload.tips_view);

track_candidate_container_types::device track_candidates(
payload.track_candidates_view);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2024 CERN for the benefit of the ACTS project
* (c) 2024-2025 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

// Project include(s).
#include "traccc/edm/device/sort_key.hpp"
#include "traccc/edm/track_candidate.hpp"

namespace traccc::device {

TRACCC_HOST_DEVICE inline void fill_sort_keys(
std::size_t globalIndex, const fill_sort_keys_payload& payload) {
const globalIndex_t globalIndex, const fill_sort_keys_payload& payload) {

bound_track_parameters_collection_types::const_device params(
const bound_track_parameters_collection_types::const_device params(
payload.params_view);

// Keys
Expand All @@ -29,10 +25,8 @@ TRACCC_HOST_DEVICE inline void fill_sort_keys(
return;
}

keys_device.at(static_cast<unsigned int>(globalIndex)) =
device::get_sort_key(params.at(static_cast<unsigned int>(globalIndex)));
ids_device.at(static_cast<unsigned int>(globalIndex)) =
static_cast<unsigned int>(globalIndex);
keys_device.at(globalIndex) = device::get_sort_key(params.at(globalIndex));
ids_device.at(globalIndex) = globalIndex;
}

} // namespace traccc::device
Loading

0 comments on commit 63dd4e5

Please sign in to comment.