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

SoA Spacepoints, main branch (2025.02.19.) #878

Merged
merged 8 commits into from
Feb 27, 2025
Merged
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
13 changes: 5 additions & 8 deletions benchmarks/common/benchmarks/toy_detector_benchmark.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) 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
*/
Expand Down Expand Up @@ -41,7 +41,7 @@ class ToyDetectorBenchmark : public benchmark::Fixture {
static const int n_events = 100u;
static const int n_tracks = 5000u;

std::vector<traccc::spacepoint_collection_types::host> spacepoints;
std::vector<traccc::edm::spacepoint_collection::host> spacepoints;
std::vector<traccc::measurement_collection_types::host> measurements;

// Configs
Expand Down Expand Up @@ -168,13 +168,10 @@ class ToyDetectorBenchmark : public benchmark::Fixture {
for (std::size_t i_evt = 0; i_evt < n_events; i_evt++) {

// Read the hits from the relevant event file
traccc::spacepoint_collection_types::host sp{&host_mr};
traccc::io::read_spacepoints(sp, i_evt, sim_dir);
spacepoints.push_back(sp);

// Read measurements
traccc::edm::spacepoint_collection::host sp{host_mr};
traccc::measurement_collection_types::host meas{&host_mr};
traccc::io::read_measurements(meas, i_evt, sim_dir);
traccc::io::read_spacepoints(sp, meas, i_evt, sim_dir);
spacepoints.push_back(sp);
measurements.push_back(meas);
}
}
Expand Down
13 changes: 8 additions & 5 deletions benchmarks/cpu/toy_detector_cpu.cpp
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) 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
*/
Expand Down Expand Up @@ -49,8 +49,9 @@ BENCHMARK_DEFINE_F(ToyDetectorBenchmark, CPU)(benchmark::State& state) {
auto field = detray::bfield::create_const_field<scalar_type>(B);

// Algorithms
traccc::seeding_algorithm sa(seeding_cfg, grid_cfg, filter_cfg, host_mr);
traccc::track_params_estimation tp(host_mr);
traccc::host::seeding_algorithm sa(seeding_cfg, grid_cfg, filter_cfg,
host_mr);
traccc::host::track_params_estimation tp(host_mr);
traccc::host::combinatorial_kalman_filter_algorithm host_finding(
finding_cfg);
traccc::host::kalman_fitting_algorithm host_fitting(fitting_cfg, host_mr);
Expand All @@ -65,10 +66,12 @@ BENCHMARK_DEFINE_F(ToyDetectorBenchmark, CPU)(benchmark::State& state) {
auto& measurements_per_event = measurements[i_evt];

// Seeding
auto seeds = sa(spacepoints_per_event);
auto seeds = sa(vecmem::get_data(spacepoints_per_event));

// Track param estimation
auto params = tp(spacepoints_per_event, seeds, B);
auto params = tp(vecmem::get_data(measurements_per_event),
vecmem::get_data(spacepoints_per_event),
vecmem::get_data(seeds), B);

// Track finding with CKF
auto track_candidates = host_finding(
Expand Down
9 changes: 5 additions & 4 deletions benchmarks/cuda/toy_detector_cuda.cpp
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) 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
*/
Expand Down Expand Up @@ -107,7 +107,7 @@ BENCHMARK_DEFINE_F(ToyDetectorBenchmark, CUDA)(benchmark::State& state) {
auto& measurements_per_event = measurements[i_evt];

// Copy the spacepoint and module data to the device.
traccc::spacepoint_collection_types::buffer spacepoints_cuda_buffer(
traccc::edm::spacepoint_collection::buffer spacepoints_cuda_buffer(
static_cast<unsigned int>(spacepoints_per_event.size()),
mr.main);
async_copy.setup(spacepoints_cuda_buffer)->ignore();
Expand All @@ -125,13 +125,14 @@ BENCHMARK_DEFINE_F(ToyDetectorBenchmark, CUDA)(benchmark::State& state) {
->ignore();

// Run seeding
traccc::seed_collection_types::buffer seeds_cuda_buffer =
traccc::edm::seed_collection::buffer seeds_cuda_buffer =
sa_cuda(spacepoints_cuda_buffer);

// Run track parameter estimation
traccc::bound_track_parameters_collection_types::buffer
params_cuda_buffer =
tp_cuda(spacepoints_cuda_buffer, seeds_cuda_buffer, B);
tp_cuda(measurements_cuda_buffer, spacepoints_cuda_buffer,
seeds_cuda_buffer, B);

// Run CKF track finding
traccc::track_candidate_container_types::buffer
Expand Down
17 changes: 9 additions & 8 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@ traccc_add_library( traccc_core core TYPE SHARED
"include/traccc/edm/details/container_element.hpp"
"include/traccc/edm/details/device_container.hpp"
"include/traccc/edm/details/host_container.hpp"
"include/traccc/edm/spacepoint.hpp"
"include/traccc/edm/measurement.hpp"
"include/traccc/edm/particle.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/track_candidate.hpp"
"include/traccc/edm/track_state.hpp"
"include/traccc/edm/silicon_cell_collection.hpp"
"include/traccc/edm/impl/silicon_cell_collection.ipp"
"include/traccc/edm/silicon_cluster_collection.hpp"
"include/traccc/edm/spacepoint_collection.hpp"
"include/traccc/edm/impl/spacepoint_collection.ipp"
"include/traccc/edm/seed_collection.hpp"
"include/traccc/edm/impl/seed_collection.ipp"
# Geometry description.
"include/traccc/geometry/detector.hpp"
"include/traccc/geometry/module_map.hpp"
Expand Down Expand Up @@ -90,7 +91,7 @@ traccc_add_library( traccc_core core TYPE SHARED
"include/traccc/seeding/detail/seeding_config.hpp"
"include/traccc/seeding/detail/spacepoint_grid.hpp"
"include/traccc/seeding/seed_selecting_helper.hpp"
"include/traccc/seeding/seed_filtering.hpp"
"src/seeding/seed_filtering.hpp"
"src/seeding/seed_filtering.cpp"
"include/traccc/seeding/seeding_algorithm.hpp"
"src/seeding/seeding_algorithm.cpp"
Expand All @@ -100,11 +101,11 @@ traccc_add_library( traccc_core core TYPE SHARED
"include/traccc/seeding/track_params_estimation.hpp"
"src/seeding/track_params_estimation.cpp"
"include/traccc/seeding/triplet_finding_helper.hpp"
"include/traccc/seeding/doublet_finding.hpp"
"include/traccc/seeding/triplet_finding.hpp"
"include/traccc/seeding/seed_finding.hpp"
"src/seeding/doublet_finding.hpp"
"src/seeding/triplet_finding.hpp"
"include/traccc/seeding/detail/seed_finding.hpp"
"src/seeding/seed_finding.cpp"
"include/traccc/seeding/spacepoint_binning.hpp"
"include/traccc/seeding/detail/spacepoint_binning.hpp"
"src/seeding/spacepoint_binning.cpp"
"include/traccc/seeding/detail/spacepoint_formation.hpp"
"include/traccc/seeding/impl/spacepoint_formation.ipp"
Expand Down
35 changes: 35 additions & 0 deletions core/include/traccc/edm/impl/seed_collection.ipp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2021-2025 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

namespace traccc::edm {

template <typename BASE>
template <typename T>
TRACCC_HOST_DEVICE bool seed<BASE>::operator==(const seed<T>& other) const {

return ((top_index() == other.top_index()) &&
(middle_index() == other.middle_index()) &&
(bottom_index() == other.bottom_index()));
}

template <typename BASE>
template <typename T>
TRACCC_HOST_DEVICE std::strong_ordering seed<BASE>::operator<=>(
const seed<T>& other) const {

if (top_index() != other.top_index()) {
return (top_index() <=> other.top_index());
} else if (middle_index() != other.middle_index()) {
return (middle_index() <=> other.middle_index());
} else {
return (bottom_index() <=> other.bottom_index());
}
}

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

#pragma once

// Local include(s).
#include "traccc/definitions/math.hpp"

namespace traccc::edm {

template <typename BASE>
TRACCC_HOST_DEVICE auto& spacepoint<BASE>::x() {

return global()[0];
}

template <typename BASE>
TRACCC_HOST_DEVICE const auto& spacepoint<BASE>::x() const {

return global()[0];
}

template <typename BASE>
TRACCC_HOST_DEVICE auto& spacepoint<BASE>::y() {

return global()[1];
}

template <typename BASE>
TRACCC_HOST_DEVICE const auto& spacepoint<BASE>::y() const {

return global()[1];
}

template <typename BASE>
TRACCC_HOST_DEVICE auto& spacepoint<BASE>::z() {

return global()[2];
}

template <typename BASE>
TRACCC_HOST_DEVICE const auto& spacepoint<BASE>::z() const {

return global()[2];
}

template <typename BASE>
TRACCC_HOST_DEVICE auto spacepoint<BASE>::radius() const {

const scalar xx = x();
const scalar yy = y();
return math::sqrt(xx * xx + yy * yy);
}

template <typename BASE>
TRACCC_HOST_DEVICE auto spacepoint<BASE>::phi() const {

return math::atan2(y(), x());
}

template <typename BASE>
template <typename T>
TRACCC_HOST_DEVICE bool spacepoint<BASE>::operator==(
const spacepoint<T>& other) const {

return ((measurement_index() == other.measurement_index()) &&
(math::fabs(x() - other.x()) < 1e-6f) &&
(math::fabs(y() - other.y()) < 1e-6f) &&
(math::fabs(z() - other.z()) < 1e-6f) &&
(z_variance() == other.z_variance()) &&
(radius_variance() == other.radius_variance()));
}

template <typename BASE>
template <typename T>
TRACCC_HOST_DEVICE std::weak_ordering spacepoint<BASE>::operator<=>(
const spacepoint<T>& other) const {

return (radius() <=> other.radius());
}

} // namespace traccc::edm
93 changes: 0 additions & 93 deletions core/include/traccc/edm/internal_spacepoint.hpp

This file was deleted.

Loading
Loading