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

Changed device clusterization to flat EDM & cell-level parallelism #299

Merged
2 changes: 2 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ traccc_add_library( traccc_core core TYPE SHARED
"include/traccc/edm/cluster.hpp"
"include/traccc/edm/spacepoint.hpp"
"include/traccc/edm/measurement.hpp"
"include/traccc/edm/alt_measurement.hpp"
"include/traccc/edm/track_parameters.hpp"
"include/traccc/edm/container.hpp"
"include/traccc/edm/internal_spacepoint.hpp"
"include/traccc/edm/seed.hpp"
"include/traccc/edm/alt_seed.hpp"
"include/traccc/edm/cell.hpp"
"include/traccc/edm/track_candidate.hpp"
"include/traccc/edm/track_state.hpp"
Expand Down
5 changes: 3 additions & 2 deletions core/include/traccc/edm/alt_cell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ struct alt_cell {
/// Declare all cell collection types
using alt_cell_collection_types = collection_types<alt_cell>;

/// Type definition for the reading of cells into a single vector using
/// alt_cell. The alt_cells hold a link to a position in the modules vector.
/// Type definition for the reading of cells into a vector of alt_cells and a
/// vector of modules. The alt_cells hold a link to a position in the modules'
/// vector.
struct alt_cell_reader_output_t {
alt_cell_collection_types::host cells;
cell_module_collection_types::host modules;
Expand Down
36 changes: 36 additions & 0 deletions core/include/traccc/edm/alt_measurement.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2022 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

// Project include(s).
#include "traccc/definitions/primitives.hpp"
#include "traccc/edm/cell.hpp"
#include "traccc/edm/container.hpp"

namespace traccc {

/// Alternative measurement structure which contains both the measurement and
/// a link to its module (held in a separate collection).
///
/// This can be used for storing all information in a single collection, whose
/// objects need to have both the header and item information from the
/// measurement container types.
struct alt_measurement {
/// Local 2D coordinates for a measurement on a detector module
point2 local{0., 0.};
/// Variance on the 2D coordinates of the measurement
variance2 variance{0., 0.};

using link_type = cell_module_collection_types::view::size_type;
link_type module_link;
};

/// Declare all alt measurement collection types
using alt_measurement_collection_types = collection_types<alt_measurement>;

} // namespace traccc
50 changes: 50 additions & 0 deletions core/include/traccc/edm/alt_seed.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2022 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

#include "traccc/edm/container.hpp"
#include "traccc/edm/spacepoint.hpp"

namespace traccc {

/// Seed consisting of three spacepoints, z origin and weight
/// This differs from (non-alt) seed in the link_type definition
struct alt_seed {

using link_type = spacepoint_collection_types::host::size_type;

link_type spB_link;
link_type spM_link;
link_type spT_link;

scalar weight;
scalar z_vertex;
Comment on lines +25 to +26
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can discuss this later, perhaps on a different PR, but this information should not really live in the seed EDM.


TRACCC_HOST_DEVICE
std::array<measurement, 3> get_measurements(
const spacepoint_collection_types::const_view& spacepoints_view) const {
const spacepoint_collection_types::const_device spacepoints(
spacepoints_view);
return {spacepoints.at(spB_link).meas, spacepoints.at(spM_link).meas,
spacepoints.at(spT_link).meas};
}

TRACCC_HOST_DEVICE
std::array<spacepoint, 3> get_spacepoints(
const spacepoint_collection_types::const_view& spacepoints_view) const {
const spacepoint_collection_types::const_device spacepoints(
spacepoints_view);
return {spacepoints.at(spB_link), spacepoints.at(spM_link),
spacepoints.at(spT_link)};
}
};

/// Declare all seed collection types
using alt_seed_collection_types = collection_types<alt_seed>;

} // namespace traccc
16 changes: 16 additions & 0 deletions core/include/traccc/edm/internal_spacepoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ struct internal_spacepoint {

link_type m_link;

/// TODO: This is a *VERY* temporary variable which will be removed asap.
/// only here while transitioning from the jagged to non-jagged
/// clusterization and prevent even more code duplication
unsigned int m_link_alt;

scalar m_x;
scalar m_y;
scalar m_z;
Expand All @@ -50,6 +55,17 @@ struct internal_spacepoint {
m_phi = algebra::math::atan2(m_y, m_x);
}

TRACCC_HOST_DEVICE internal_spacepoint(const spacepoint_t& sp,
const unsigned int sp_link,
const vector2& offsetXY)
: m_link_alt(sp_link) {
m_x = sp.global[0] - offsetXY[0];
m_y = sp.global[1] - offsetXY[1];
m_z = sp.global[2];
m_r = algebra::math::sqrt(m_x * m_x + m_y * m_y);
m_phi = algebra::math::atan2(m_y, m_x);
}

TRACCC_HOST_DEVICE
internal_spacepoint(const link_type& sp_link) : m_link(sp_link) {

Expand Down
21 changes: 21 additions & 0 deletions core/include/traccc/seeding/seed_selecting_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#pragma once

#include "traccc/edm/alt_seed.hpp"
#include "traccc/edm/internal_spacepoint.hpp"
#include "traccc/edm/seed.hpp"
#include "traccc/seeding/detail/seeding_config.hpp"
Expand Down Expand Up @@ -77,6 +78,26 @@ struct seed_selecting_helper {
return (triplet_weight > filter_config.seed_min_weight ||
spB.radius() > filter_config.spB_min_radius);
}

/// Cut triplets with criteria
///
/// @param filter_config seed filtering configuration parameters
/// @param sp_collection spacepoint collection
/// @param seed current seed to possibly cut
/// @param triplet_weight triplets' weight
///
/// @return boolean value
template <typename spacepoint_collection_t>
static TRACCC_HOST_DEVICE bool cut_per_middle_sp(
const seedfilter_config& filter_config,
const spacepoint_collection_t& sp_collection, const alt_seed& seed,
const scalar& triplet_weight) {

const auto& spB = sp_collection.at(seed.spB_link);

return (triplet_weight > filter_config.seed_min_weight ||
spB.radius() > filter_config.spB_min_radius);
}
};

} // namespace traccc
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ inline TRACCC_HOST_DEVICE vector2 uv_transform(const scalar& x,
/// @param seed is the input seed
/// @param bfield is the magnetic field
/// @param mass is the mass of particle
template <typename spacepoint_container_t>
template <typename spacepoint_container_t, typename seed_t>
inline TRACCC_HOST_DEVICE bound_vector seed_to_bound_vector(
const spacepoint_container_t& sp_container, const seed& seed,
const spacepoint_container_t& sp_container, const seed_t& seed,
const vector3& bfield, const scalar mass) {

bound_vector params;
Expand Down
15 changes: 7 additions & 8 deletions device/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@ traccc_add_library( traccc_device_common device_common TYPE SHARED
# EDM class(es).
"include/traccc/edm/device/doublet_counter.hpp"
"include/traccc/edm/device/triplet_counter.hpp"
"include/traccc/edm/device/partition.hpp"
# Clusterization function(s).
"include/traccc/clusterization/device/find_clusters.hpp"
"include/traccc/clusterization/device/impl/find_clusters.ipp"
"include/traccc/clusterization/device/count_cluster_cells.hpp"
"include/traccc/clusterization/device/impl/count_cluster_cells.ipp"
"include/traccc/clusterization/device/connect_components.hpp"
"include/traccc/clusterization/device/impl/connect_components.ipp"
"include/traccc/clusterization/device/create_measurements.hpp"
"include/traccc/clusterization/device/impl/create_measurements.ipp"
"include/traccc/clusterization/device/partitioning_algorithm.hpp"
"src/clusterization/partitioning_algorithm.cpp"
"include/traccc/clusterization/device/form_spacepoints.hpp"
"include/traccc/clusterization/device/impl/form_spacepoints.ipp"
"include/traccc/clusterization/device/reduce_problem_cell.hpp"
"include/traccc/clusterization/device/impl/reduce_problem_cell.ipp"
"include/traccc/clusterization/device/aggregate_cluster.hpp"
"include/traccc/clusterization/device/impl/aggregate_cluster.ipp"
# Spacepoint binning function(s).
"include/traccc/seeding/device/count_grid_capacities.hpp"
"include/traccc/seeding/device/impl/count_grid_capacities.ipp"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2022 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/alt_cell.hpp"
#include "traccc/edm/alt_measurement.hpp"
#include "traccc/edm/device/partition.hpp"

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

namespace traccc::device {

/// Function which looks for cells which share the same "parent" index and
/// aggregates them into a cluster.
///
/// @param[in] cells collection of cells
/// @param[in] modules collection of modules to which the cells are linked to
/// @param[in] f array of "parent" indices for all cells in this
/// partition
/// @param[in] start partition start point this cell belongs to
/// @param[in] end partition end point this cell belongs to
/// @param[in] tid current thread id
/// @param[out] out cluster to fill
TRACCC_HOST_DEVICE
inline void aggregate_cluster(
const alt_cell_collection_types::const_device& cells,
const cell_module_collection_types::const_device& modules,
const vecmem::data::vector_view<unsigned short> f_view,
const partition start, const partition end, const unsigned short tid,
alt_measurement& out);

} // namespace traccc::device

// Include the implementation.
#include "traccc/clusterization/device/impl/aggregate_cluster.ipp"

This file was deleted.

This file was deleted.

Loading