Skip to content

Commit

Permalink
Add logging to all traccc algorithms
Browse files Browse the repository at this point in the history
This commit adds ACTS-style loggers to all existing traccc algorithms,
and requires that all future algorithms have the same. It also carefully
threads logger objects through the computation chain. Currently, little
is added in the way of useful logging outputs, as that can happen in a
future commit: this is just infrastructure.
  • Loading branch information
stephenswat committed Feb 5, 2025
1 parent ae79eb3 commit 662adf1
Show file tree
Hide file tree
Showing 127 changed files with 1,845 additions and 633 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ jobs:
options: --preset cuda-fp64
run_tests: false
build: Release
- platform:
name: CUDA
container: ghcr.io/acts-project/ubuntu2404_cuda:69
options: --preset cuda-fp64 -DTRACCC_USE_ACTS_LOGGER=OFF
run_tests: false
build: Release
- platform:
name: "SYCL NVIDIA"
container: ghcr.io/acts-project/ubuntu2404_cuda_oneapi:69
Expand Down
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,21 @@ option( TRACCC_ENABLE_NVTX_PROFILING
# option for algebra plugins (ARRAY EIGEN SMATRIX VC VECMEM)
set(TRACCC_ALGEBRA_PLUGINS ARRAY CACHE STRING "Algebra plugin to use in the build")

# Set up either the ACTS or traccc logger.
if(TRACCC_SETUP_ACTS OR TARGET ActsCore)
set(TRACCC_USE_ACTS_LOGGER_DEFAULT ON)
else()
set(TRACCC_USE_ACTS_LOGGER_DEFAULT OFF)
endif()

option(TRACCC_USE_ACTS_LOGGER "Use Acts's logger" ${TRACCC_USE_ACTS_LOGGER_DEFAULT})

if(TRACCC_USE_ACTS_LOGGER)
message(STATUS "Building traccc with the ACTS logger")
else()
message(STATUS "Building traccc with the built-in logger")
endif()

# Build the traccc code.
add_subdirectory( core )
add_subdirectory( device/common )
Expand Down
6 changes: 6 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ traccc_add_library( traccc_core core TYPE SHARED
"include/traccc/utils/memory_resource.hpp"
"include/traccc/utils/seed_generator.hpp"
"include/traccc/utils/subspace.hpp"
"src/utils/logging.cpp"
# Clusterization algorithmic code.
"include/traccc/clusterization/details/sparse_ccl.hpp"
"include/traccc/clusterization/impl/sparse_ccl.ipp"
Expand Down Expand Up @@ -118,6 +119,11 @@ target_link_libraries( traccc_core
PUBLIC Eigen3::Eigen vecmem::core detray::core detray::detectors
traccc::algebra )

if(TRACCC_USE_ACTS_LOGGER)
target_link_libraries(traccc_core PUBLIC ActsCore)
target_compile_definitions(traccc_core PUBLIC TRACCC_USE_ACTS_LOGGER)
endif()

# Prevent Eigen from getting confused when building code for a
# CUDA or HIP backend with SYCL.
target_compile_definitions( traccc_core
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "traccc/edm/track_candidate.hpp"
#include "traccc/edm/track_state.hpp"
#include "traccc/utils/algorithm.hpp"
#include "traccc/utils/logging.hpp"

// Greedy ambiguity resolution adapted from ACTS code

Expand Down Expand Up @@ -110,8 +111,10 @@ class greedy_ambiguity_resolution_algorithm
/// @param cfg Configuration object
// greedy_ambiguity_resolution_algorithm(const config_type& cfg) :
// _config(cfg) {}
greedy_ambiguity_resolution_algorithm(const config_t cfg = {})
: _config{cfg} {}
greedy_ambiguity_resolution_algorithm(
const config_t cfg,
std::unique_ptr<const Logger> logger = getDummyLogger().clone())
: _config{cfg}, m_logger{std::move(logger)} {}

/// Run the algorithm
///
Expand Down Expand Up @@ -156,6 +159,10 @@ class greedy_ambiguity_resolution_algorithm
state_t& final_state) const;

config_t _config;

std::unique_ptr<const Logger> m_logger;

const Logger& logger() const override { return *m_logger; }
};

} // namespace traccc
12 changes: 11 additions & 1 deletion core/include/traccc/clusterization/clusterization_algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ class clusterization_algorithm
///
/// @param mr The memory resource to use for the result objects
///
clusterization_algorithm(vecmem::memory_resource& mr);
clusterization_algorithm(
vecmem::memory_resource& mr,
std::unique_ptr<const Logger> logger = getDummyLogger().clone());

/// Construct measurements for each detector module
///
Expand All @@ -68,6 +70,14 @@ class clusterization_algorithm
/// Reference to the host-accessible memory resource
std::reference_wrapper<vecmem::memory_resource> m_mr;

/// Algorithm-specific logger object
std::unique_ptr<const Logger> m_logger;

/// Logger access method
const Logger& logger() const override {
assert(m_logger.get() != nullptr);
return *m_logger;
}
}; // class clusterization_algorithm

} // namespace traccc::host
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class measurement_creation_algorithm
///
/// @param mr The memory resource to use in the algorithm
///
measurement_creation_algorithm(vecmem::memory_resource &mr);
measurement_creation_algorithm(
vecmem::memory_resource &mr,
std::unique_ptr<const Logger> logger = getDummyLogger().clone());

/// Callable operator for the connected component, based on one single
/// module
Expand All @@ -58,6 +60,15 @@ class measurement_creation_algorithm
/// The memory resource used by the algorithm
std::reference_wrapper<vecmem::memory_resource> m_mr;

/// Algorithm-specific logger object
std::unique_ptr<const Logger> m_logger;

/// Logger access method
const Logger &logger() const override {
assert(m_logger.get() != nullptr);
return *m_logger;
}

}; // class measurement_creation_algorithm

} // namespace traccc::host
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ class measurement_sorting_algorithm
output_type operator()(const measurement_collection_types::view&
measurements_view) const override;

/// Algorithm-specific logger object
std::unique_ptr<const Logger> m_logger;

/// Logger access method
const Logger& logger() const override {
assert(m_logger.get() != nullptr);
return *m_logger;
}
}; // class measurement_sorting_algorithm

} // namespace traccc::host
12 changes: 11 additions & 1 deletion core/include/traccc/clusterization/sparse_ccl_algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class sparse_ccl_algorithm
///
/// @param mr is the memory resource
///
sparse_ccl_algorithm(vecmem::memory_resource& mr);
sparse_ccl_algorithm(
vecmem::memory_resource& mr,
std::unique_ptr<const Logger> logger = getDummyLogger().clone());

/// @name Operator(s) to use in host code
/// @{
Expand All @@ -54,6 +56,14 @@ class sparse_ccl_algorithm
/// The memory resource used by the algorithm
std::reference_wrapper<vecmem::memory_resource> m_mr;

/// Algorithm-specific logger object
std::unique_ptr<const Logger> m_logger;

/// Logger access method
const Logger& logger() const override {
assert(m_logger.get() != nullptr);
return *m_logger;
}
}; // class sparse_ccl_algorithm

} // namespace traccc::host
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ class combinatorial_kalman_filter_algorithm
using output_type = track_candidate_container_types::host;

/// Constructor with the algorithm's configuration
explicit combinatorial_kalman_filter_algorithm(const config_type& config);
explicit combinatorial_kalman_filter_algorithm(
const config_type& config,
std::unique_ptr<const Logger> logger = getDummyLogger().clone());

/// Execute the algorithm
///
Expand Down Expand Up @@ -88,6 +90,14 @@ class combinatorial_kalman_filter_algorithm
/// Algorithm configuration
config_type m_config;

/// Algorithm-specific logger object
std::unique_ptr<const Logger> m_logger;

/// Logger access method
const Logger& logger() const override {
assert(m_logger.get() != nullptr);
return *m_logger;
}
}; // class combinatorial_kalman_filter_algorithm

} // namespace traccc::host
13 changes: 11 additions & 2 deletions core/include/traccc/fitting/kalman_fitting_algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ class kalman_fitting_algorithm
///
/// @param config The configuration object
///
explicit kalman_fitting_algorithm(const config_type& config,
vecmem::memory_resource& mr);
explicit kalman_fitting_algorithm(
const config_type& config, vecmem::memory_resource& mr,
std::unique_ptr<const Logger> logger = getDummyLogger().clone());

/// Execute the algorithm
///
Expand Down Expand Up @@ -87,6 +88,14 @@ class kalman_fitting_algorithm
/// Memory resource to use in the algorithm
std::reference_wrapper<vecmem::memory_resource> m_mr;

/// Algorithm-specific logger object
std::unique_ptr<const Logger> m_logger;

/// Logger access method
const Logger& logger() const override {
assert(m_logger.get() != nullptr);
return *m_logger;
}
}; // class kalman_fitting_algorithm

} // namespace traccc::host
14 changes: 13 additions & 1 deletion core/include/traccc/seeding/doublet_finding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ struct doublet_finding
///
/// @param seedfinder_config is the configuration parameters
/// @param isp_container is the internal spacepoint container
doublet_finding(const seedfinder_config& config) : m_config(config) {}
doublet_finding(
const seedfinder_config& config,
std::unique_ptr<const Logger> logger = getDummyLogger().clone())
: m_config(config), m_logger(std::move(logger)) {}

/// Callable operator for doublet finding per middle spacepoint
///
Expand Down Expand Up @@ -99,6 +102,15 @@ struct doublet_finding

private:
seedfinder_config m_config;

/// Algorithm-specific logger object
std::unique_ptr<const Logger> m_logger;

/// Logger access method
const Logger& logger() const override {
assert(m_logger.get() != nullptr);
return *m_logger;
}
};

} // namespace traccc
13 changes: 12 additions & 1 deletion core/include/traccc/seeding/seed_filtering.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "traccc/seeding/detail/seeding_config.hpp"
#include "traccc/seeding/detail/spacepoint_grid.hpp"
#include "traccc/seeding/detail/triplet.hpp"
#include "traccc/utils/logging.hpp"

namespace traccc {

Expand All @@ -21,7 +22,9 @@ class seed_filtering {

public:
/// Constructor with the seed filter configuration
seed_filtering(const seedfilter_config& config);
seed_filtering(
const seedfilter_config& config,
std::unique_ptr<const Logger> logger = getDummyLogger().clone());

/// Callable operator for the seed filtering
///
Expand All @@ -40,6 +43,14 @@ class seed_filtering {
/// Seed filter configuration
seedfilter_config m_filter_config;

/// Algorithm-specific logger object
std::unique_ptr<const Logger> m_logger;

/// Logger access method
const Logger& logger() const {
assert(m_logger.get() != nullptr);
return *m_logger;
}
}; // class seed_filtering

} // namespace traccc
14 changes: 12 additions & 2 deletions core/include/traccc/seeding/seed_finding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ class seed_finding
/// @param find_config is seed finder configuration parameters
/// @param filter_config is the seed filter configuration
///
seed_finding(const seedfinder_config& find_config,
const seedfilter_config& filter_config);
seed_finding(
const seedfinder_config& find_config,
const seedfilter_config& filter_config,
std::unique_ptr<const Logger> logger = getDummyLogger().clone());

/// Callable operator for the seed finding
///
Expand All @@ -53,6 +55,14 @@ class seed_finding
/// Algorithm performing the seed selection
seed_filtering m_seed_filtering;

/// Algorithm-specific logger object
std::unique_ptr<const Logger> m_logger;

/// Logger access method
const Logger& logger() const override {
assert(m_logger.get() != nullptr);
return *m_logger;
}
}; // class seed_finding

} // namespace traccc
18 changes: 14 additions & 4 deletions core/include/traccc/seeding/seeding_algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ class seeding_algorithm : public algorithm<seed_collection_types::host(
///
/// @param mr The memory resource to use
///
seeding_algorithm(const seedfinder_config& finder_config,
const spacepoint_grid_config& grid_config,
const seedfilter_config& filter_config,
vecmem::memory_resource& mr);
seeding_algorithm(
const seedfinder_config& finder_config,
const spacepoint_grid_config& grid_config,
const seedfilter_config& filter_config, vecmem::memory_resource& mr,
std::unique_ptr<const Logger> logger = getDummyLogger().clone());

/// Operator executing the algorithm.
///
Expand All @@ -47,6 +48,15 @@ class seeding_algorithm : public algorithm<seed_collection_types::host(
/// Sub-algorithm performing the seed finding
seed_finding m_seed_finding;

/// Algorithm-specific logger object
std::unique_ptr<const Logger> m_logger;

/// Logger access method
const Logger& logger() const override {
assert(m_logger.get() != nullptr);
return *m_logger;
}

}; // class seeding_algorithm

} // namespace traccc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ class silicon_pixel_spacepoint_formation_algorithm
///
/// @param mr is the memory resource
///
silicon_pixel_spacepoint_formation_algorithm(vecmem::memory_resource& mr);
silicon_pixel_spacepoint_formation_algorithm(
vecmem::memory_resource& mr,
std::unique_ptr<const Logger> logger = getDummyLogger().clone());

/// Construct spacepoints from 2D silicon pixel measurements
///
Expand Down Expand Up @@ -70,6 +72,14 @@ class silicon_pixel_spacepoint_formation_algorithm
/// Memory resource to use for the output container
std::reference_wrapper<vecmem::memory_resource> m_mr;

/// Algorithm-specific logger object
std::unique_ptr<const Logger> m_logger;

/// Logger access method
const Logger& logger() const override {
assert(m_logger.get() != nullptr);
return *m_logger;
}
}; // class silicon_pixel_spacepoint_formation_algorithm

} // namespace traccc::host
Loading

0 comments on commit 662adf1

Please sign in to comment.