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

Move [[nodiscard]] and [[maybe_unused]] in front of host/device declarations #892

Merged
merged 3 commits into from
Feb 25, 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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct gain_matrix_smoother {
///
/// @return true if the update succeeds
template <typename mask_group_t, typename index_t>
TRACCC_HOST_DEVICE [[nodiscard]] inline kalman_fitter_status operator()(
[[nodiscard]] TRACCC_HOST_DEVICE inline kalman_fitter_status operator()(
const mask_group_t& /*mask_group*/, const index_t& /*index*/,
track_state<algebra_t>& cur_state,
const track_state<algebra_t>& next_state) {
Expand All @@ -63,7 +63,7 @@ struct gain_matrix_smoother {
}

template <size_type D, typename shape_t>
TRACCC_HOST_DEVICE [[nodiscard]] inline kalman_fitter_status smoothe(
[[nodiscard]] TRACCC_HOST_DEVICE inline kalman_fitter_status smoothe(
track_state<algebra_t>& cur_state,
const track_state<algebra_t>& next_state) const {
const auto meas = cur_state.get_measurement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct gain_matrix_updater {
///
/// @return true if the update succeeds
template <typename mask_group_t, typename index_t>
TRACCC_HOST_DEVICE [[nodiscard]] inline kalman_fitter_status operator()(
[[nodiscard]] TRACCC_HOST_DEVICE inline kalman_fitter_status operator()(
const mask_group_t& /*mask_group*/, const index_t& /*index*/,
track_state<algebra_t>& trk_state,
const bound_track_parameters<algebra_t>& bound_params) const {
Expand All @@ -65,7 +65,7 @@ struct gain_matrix_updater {
}

template <size_type D, typename shape_t>
TRACCC_HOST_DEVICE [[nodiscard]] inline kalman_fitter_status update(
[[nodiscard]] TRACCC_HOST_DEVICE inline kalman_fitter_status update(
track_state<algebra_t>& trk_state,
const bound_track_parameters<algebra_t>& bound_params) const {

Expand Down
12 changes: 6 additions & 6 deletions core/include/traccc/fitting/kalman_filter/kalman_fitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ class kalman_fitter {
/// @param seed_params seed track parameter
/// @param fitter_state the state of kalman fitter
template <typename seed_parameters_t>
TRACCC_HOST_DEVICE [[nodiscard]] kalman_fitter_status fit(
const seed_parameters_t& seed_params, state& fitter_state) {
[[nodiscard]] TRACCC_HOST_DEVICE kalman_fitter_status
fit(const seed_parameters_t& seed_params, state& fitter_state) {

// Run the kalman filtering for a given number of iterations
for (std::size_t i = 0; i < m_cfg.n_iterations; i++) {
Expand Down Expand Up @@ -180,8 +180,8 @@ class kalman_fitter {
/// @param seed_params seed track parameter
/// @param fitter_state the state of kalman fitter
template <typename seed_parameters_t>
TRACCC_HOST_DEVICE [[nodiscard]] kalman_fitter_status filter(
const seed_parameters_t& seed_params, state& fitter_state) {
[[nodiscard]] TRACCC_HOST_DEVICE kalman_fitter_status
filter(const seed_parameters_t& seed_params, state& fitter_state) {

// Create propagator
propagator_type propagator(m_cfg.propagation);
Expand Down Expand Up @@ -229,8 +229,8 @@ class kalman_fitter {
/// track and vertex fitting", R.Frühwirth, NIM A.
///
/// @param fitter_state the state of kalman fitter
TRACCC_HOST_DEVICE [[nodiscard]] kalman_fitter_status smooth(
state& fitter_state) {
[[nodiscard]] TRACCC_HOST_DEVICE kalman_fitter_status
smooth(state& fitter_state) {

auto& track_states = fitter_state.m_fit_actor_state.m_track_states;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct two_filters_smoother {
///
/// @return true if the update succeeds
template <typename mask_group_t, typename index_t>
TRACCC_HOST_DEVICE [[nodiscard]] inline kalman_fitter_status operator()(
[[nodiscard]] TRACCC_HOST_DEVICE inline kalman_fitter_status operator()(
const mask_group_t& /*mask_group*/, const index_t& /*index*/,
track_state<algebra_t>& trk_state,
bound_track_parameters<algebra_t>& bound_params) const {
Expand All @@ -54,7 +54,7 @@ struct two_filters_smoother {
// Reference: The Optimun Linear Smoother as a Combination of Two Optimum
// Linear Filters
template <size_type D, typename shape_t>
TRACCC_HOST_DEVICE [[nodiscard]] inline kalman_fitter_status smoothe(
[[nodiscard]] TRACCC_HOST_DEVICE inline kalman_fitter_status smoothe(
track_state<algebra_t>& trk_state,
bound_track_parameters<algebra_t>& bound_params) const {

Expand Down
2 changes: 1 addition & 1 deletion core/include/traccc/utils/relations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace traccc {
struct [[maybe_unused]] channel0_major_cell_order_relation{
template <typename T1, typename T2> TRACCC_HOST_DEVICE [[maybe_unused]] bool
template <typename T1, typename T2>[[maybe_unused]] TRACCC_HOST_DEVICE bool
Copy link
Member

Choose a reason for hiding this comment

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

I'm not in love with the lack of a space in front of [[maybe_unused]]. 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't like it either but it is clang-format's preference. I think we would need to update the clang-format version used by pre-commit. If I update to v19.1.7, I get this:

/**
 * traccc library, part of the ACTS project (R&D line)
 *
 * (c) 2024 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/silicon_cell_collection.hpp"

namespace traccc {
struct [[maybe_unused]] channel0_major_cell_order_relation {
    template <typename T1, typename T2>
    [[maybe_unused]] TRACCC_HOST_DEVICE bool operator()(
        const edm::silicon_cell<T1>& a, const edm::silicon_cell<T2>& b) const {
        if (a.module_index() == b.module_index()) {
            if (a.channel1() == b.channel1()) {
                return a.channel0() <= b.channel0();
            } else {
                return a.channel1() <= b.channel1();
            }
        } else {
            return true;
        }
    }
};
}  // namespace traccc

which looks nice to me, but there are lots of other changes to other files.

operator()(const edm::silicon_cell<T1>& a, const edm::silicon_cell<T2>& b)
const {if (a.module_index() ==
b.module_index()){if (a.channel1() == b.channel1()){
Expand Down
Loading