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

Thread ID Cleanup, main branch (2025.01.09.) #810

Merged
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
53 changes: 0 additions & 53 deletions device/alpaka/include/traccc/alpaka/utils/thread_id.hpp

This file was deleted.

6 changes: 3 additions & 3 deletions device/alpaka/src/clusterization/clusterization_algorithm.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 All @@ -9,10 +9,10 @@
#include "traccc/alpaka/clusterization/clusterization_algorithm.hpp"

#include "../utils/barrier.hpp"
#include "../utils/thread_id.hpp"
#include "../utils/utils.hpp"

// Project include(s)
#include "traccc/alpaka/utils/thread_id.hpp"
#include "traccc/clusterization/clustering_config.hpp"
#include "traccc/clusterization/device/ccl_kernel.hpp"

Expand All @@ -36,7 +36,7 @@ struct CCLKernel {
measurement_collection_types::view measurements_view,
vecmem::data::vector_view<unsigned int> cell_links) const {

traccc::alpaka::thread_id1 thread_id(acc);
details::thread_id1 thread_id(acc);

auto& partition_start =
::alpaka::declareSharedVar<std::size_t, __COUNTER__>(acc);
Expand Down
69 changes: 69 additions & 0 deletions device/alpaka/src/utils/thread_id.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* traccc library, part of the ACTS project (R&D line)
*
* (c) 2024-2025 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

// Local include(s).
#include "utils.hpp"

// Project include(s).
#include "traccc/definitions/qualifiers.hpp"
#include "traccc/device/concepts/thread_id.hpp"

// Alpaka include(s).
#include <alpaka/alpaka.hpp>

namespace traccc::alpaka::details {

/// An Alpaka thread identifier type
template <typename Acc>
struct thread_id1 {
TRACCC_HOST_DEVICE explicit thread_id1(const Acc& acc) : m_acc(acc) {}

unsigned int inline TRACCC_HOST_DEVICE getLocalThreadId() const {
return static_cast<unsigned int>(
::alpaka::getIdx<::alpaka::Block, ::alpaka::Threads>(m_acc)[0u]);
}

unsigned int inline TRACCC_HOST_DEVICE getLocalThreadIdX() const {
return getLocalThreadId();
}

unsigned int inline TRACCC_HOST_DEVICE getGlobalThreadId() const {
return getLocalThreadId() + getBlockIdX() * getBlockDimX();
}

unsigned int inline TRACCC_HOST_DEVICE getGlobalThreadIdX() const {
return getLocalThreadId() + getBlockIdX() * getBlockDimX();
}

unsigned int inline TRACCC_HOST_DEVICE getBlockIdX() const {
return static_cast<unsigned int>(
::alpaka::getIdx<::alpaka::Grid, ::alpaka::Blocks>(m_acc)[0u]);
}

unsigned int inline TRACCC_HOST_DEVICE getBlockDimX() const {
return static_cast<unsigned int>(
::alpaka::getWorkDiv<::alpaka::Block, ::alpaka::Threads>(
m_acc)[0u]);
}

unsigned int inline TRACCC_HOST_DEVICE getGridDimX() const {
return static_cast<unsigned int>(
::alpaka::getWorkDiv<::alpaka::Grid, ::alpaka::Blocks>(m_acc)[0u]);
}

private:
const Acc& m_acc;
};

/// Verify that @c traccc::alpaka::details::thread_id1 fulfills the
/// @c traccc::device::concepts::thread_id1 concept.
static_assert(traccc::device::concepts::thread_id1<thread_id1<Acc>>);

} // namespace traccc::alpaka::details
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) 2022-2024 CERN for the benefit of the ACTS project
* (c) 2022-2025 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/
Expand Down Expand Up @@ -254,8 +254,7 @@ TRACCC_DEVICE inline void ccl_kernel(
*/
if (thread_id.getLocalThreadIdX() == 0) {
unsigned int start =
static_cast<unsigned int>(thread_id.getBlockIdX()) *
cfg.target_partition_size();
thread_id.getBlockIdX() * cfg.target_partition_size();
assert(start < num_cells);
unsigned int end =
std::min(num_cells, start + cfg.target_partition_size());
Expand Down
10 changes: 6 additions & 4 deletions device/common/include/traccc/finding/device/find_tracks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@

#pragma once

// Local include(s).
#include "traccc/device/concepts/barrier.hpp"
#include "traccc/device/concepts/thread_id.hpp"

// Project include(s).
#include "traccc/definitions/primitives.hpp"
#include "traccc/definitions/qualifiers.hpp"
#include "traccc/device/concepts/barrier.hpp"
#include "traccc/device/concepts/thread_id.hpp"
#include "traccc/edm/measurement.hpp"
#include "traccc/edm/track_parameters.hpp"
#include "traccc/finding/candidate_link.hpp"
Expand Down Expand Up @@ -140,8 +142,8 @@ struct find_tracks_shared_payload {
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 finding_config& cfg,
const find_tracks_payload<detector_t>& payload,
const thread_id_t& thread_id, const barrier_t& barrier,
const finding_config& cfg, const find_tracks_payload<detector_t>& payload,
const find_tracks_shared_payload& shared_payload);

} // namespace traccc::device
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ namespace traccc::device {
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 finding_config& cfg,
const find_tracks_payload<detector_t>& payload,
const thread_id_t& thread_id, const barrier_t& barrier,
const finding_config& cfg, const find_tracks_payload<detector_t>& payload,
const find_tracks_shared_payload& shared_payload) {

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#include "traccc/utils/particle.hpp"

// Detray include(s).
#include "detray/utils/tuple.hpp"
#include "detray/propagator/constrained_step.hpp"
#include "detray/utils/tuple_helpers.hpp"

namespace traccc::device {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "traccc/definitions/qualifiers.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/vector_view.hpp>
Expand Down
12 changes: 6 additions & 6 deletions device/common/include/traccc/fitting/device/fill_sort_keys.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +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).
// Local include(s).
#include "traccc/device/global_index.hpp"
#include "traccc/edm/device/sort_key.hpp"
#include "traccc/edm/track_candidate.hpp"

// System include(s).
#include <cstddef>
// Project include(s).
#include "traccc/edm/track_candidate.hpp"

namespace traccc::device {

Expand All @@ -24,7 +24,7 @@ namespace traccc::device {
/// @param[out] ids_view The param ids
///
TRACCC_HOST_DEVICE inline void fill_sort_keys(
std::size_t globalIndex,
global_index_t globalIndex,
const track_candidate_container_types::const_view& track_candidates_view,
vecmem::data::vector_view<device::sort_key> keys_view,
vecmem::data::vector_view<unsigned int> ids_view);
Expand Down
10 changes: 5 additions & 5 deletions device/common/include/traccc/fitting/device/fit.hpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2022 CERN for the benefit of the ACTS project
* (c) 2022-2025 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

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

// Project include(s).
#include "traccc/definitions/qualifiers.hpp"
#include "traccc/edm/track_candidate.hpp"
#include "traccc/edm/track_state.hpp"

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

namespace traccc::device {

/// Function used for fitting a track for a given track candidates
Expand All @@ -26,7 +26,7 @@ namespace traccc::device {
///
template <typename fitter_t>
TRACCC_HOST_DEVICE inline void fit(
std::size_t globalIndex,
global_index_t globalIndex,
typename fitter_t::detector_type::view_type det_data,
const typename fitter_t::bfield_type field_data,
const typename fitter_t::config_type cfg,
Expand Down
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 All @@ -10,12 +10,12 @@
namespace traccc::device {

TRACCC_HOST_DEVICE inline void fill_sort_keys(
std::size_t globalIndex,
const global_index_t globalIndex,
const track_candidate_container_types::const_view& track_candidates_view,
vecmem::data::vector_view<device::sort_key> keys_view,
vecmem::data::vector_view<unsigned int> ids_view) {

track_candidate_container_types::const_device track_candidates(
const track_candidate_container_types::const_device track_candidates(
track_candidates_view);

// Keys
Expand All @@ -29,12 +29,9 @@ TRACCC_HOST_DEVICE inline void fill_sort_keys(
}

// Key = The number of measurements
keys_device.at(static_cast<unsigned int>(globalIndex)) =
static_cast<traccc::scalar>(
track_candidates.at(static_cast<unsigned int>(globalIndex))
.items.size());
ids_device.at(static_cast<unsigned int>(globalIndex)) =
static_cast<unsigned int>(globalIndex);
keys_device.at(globalIndex) = static_cast<traccc::scalar>(
track_candidates.at(globalIndex).items.size());
ids_device.at(globalIndex) = globalIndex;
}

} // namespace traccc::device
7 changes: 3 additions & 4 deletions device/common/include/traccc/fitting/device/impl/fit.ipp
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) 2022-2024 CERN for the benefit of the ACTS project
* (c) 2022-2025 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/
Expand All @@ -11,7 +11,7 @@ namespace traccc::device {

template <typename fitter_t>
TRACCC_HOST_DEVICE inline void fit(
std::size_t globalIndex,
const global_index_t globalIndex,
typename fitter_t::detector_type::view_type det_data,
const typename fitter_t::bfield_type field_data,
const typename fitter_t::config_type cfg,
Expand All @@ -34,8 +34,7 @@ TRACCC_HOST_DEVICE inline void fit(
return;
}

const unsigned int param_id =
param_ids.at(static_cast<unsigned int>(globalIndex));
const unsigned int param_id = param_ids.at(globalIndex);
stephenswat marked this conversation as resolved.
Show resolved Hide resolved

// Track candidates per track
const auto& track_candidates_per_track =
Expand Down
14 changes: 7 additions & 7 deletions device/common/include/traccc/seeding/device/count_doublets.hpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2021-2023 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
*/

#pragma once

// Project include(s).
#include "traccc/definitions/qualifiers.hpp"
// Local include(s).
#include "traccc/device/fill_prefix_sum.hpp"
#include "traccc/device/global_index.hpp"
#include "traccc/edm/device/doublet_counter.hpp"

// Project include(s).
#include "traccc/definitions/qualifiers.hpp"
#include "traccc/seeding/detail/seeding_config.hpp"
#include "traccc/seeding/detail/spacepoint_grid.hpp"

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

namespace traccc::device {

/// Function used for calculating the number of spacepoint doublets
Expand All @@ -35,7 +35,7 @@ namespace traccc::device {
///
TRACCC_HOST_DEVICE
inline void count_doublets(
std::size_t globalIndex, const seedfinder_config& config,
global_index_t globalIndex, const seedfinder_config& config,
const sp_grid_const_view& sp_view,
const vecmem::data::vector_view<const prefix_sum_element_t>& sp_ps_view,
doublet_counter_collection_types::view doublet_view, unsigned int& nMidBot,
Expand Down
Loading
Loading