Skip to content

Commit ea034a0

Browse files
committed
Add logging to all traccc algorithms
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.
1 parent 51568d3 commit ea034a0

File tree

126 files changed

+1761
-634
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+1761
-634
lines changed

CMakeLists.txt

+14
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,20 @@ option( TRACCC_ENABLE_NVTX_PROFILING
370370
# option for algebra plugins (ARRAY EIGEN SMATRIX VC VECMEM)
371371
set(TRACCC_ALGEBRA_PLUGINS ARRAY CACHE STRING "Algebra plugin to use in the build")
372372

373+
# Set up either the ACTS or traccc logger.
374+
if(TRACCC_SETUP_ACTS OR TARGET ActsCore)
375+
message(STATUS "Enabling the ACTS logger, because ACTS is set to be enabled or already exists.")
376+
set(TRACCC_USE_ACTS_LOGGER ON)
377+
else()
378+
set(TRACCC_USE_ACTS_LOGGER OFF)
379+
endif()
380+
381+
if(TRACCC_USE_ACTS_LOGGER)
382+
message(STATUS "Building traccc with the ACTS logger")
383+
else()
384+
message(STATUS "Building traccc with the built-in logger")
385+
endif()
386+
373387
# Build the traccc code.
374388
add_subdirectory( core )
375389
add_subdirectory( device/common )

core/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ traccc_add_library( traccc_core core TYPE SHARED
4444
"include/traccc/utils/memory_resource.hpp"
4545
"include/traccc/utils/seed_generator.hpp"
4646
"include/traccc/utils/subspace.hpp"
47+
"src/utils/logging.cpp"
4748
# Clusterization algorithmic code.
4849
"include/traccc/clusterization/details/sparse_ccl.hpp"
4950
"include/traccc/clusterization/impl/sparse_ccl.ipp"
@@ -118,6 +119,11 @@ target_link_libraries( traccc_core
118119
PUBLIC Eigen3::Eigen vecmem::core detray::core detray::detectors
119120
traccc::algebra )
120121

122+
if(TRACCC_USE_ACTS_LOGGER)
123+
target_link_libraries(traccc_core PUBLIC ActsCore)
124+
target_compile_definitions(traccc_core PUBLIC TRACCC_USE_ACTS_LOGGER)
125+
endif()
126+
121127
# Prevent Eigen from getting confused when building code for a
122128
# CUDA or HIP backend with SYCL.
123129
target_compile_definitions( traccc_core

core/include/traccc/ambiguity_resolution/greedy_ambiguity_resolution_algorithm.hpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "traccc/edm/track_candidate.hpp"
2626
#include "traccc/edm/track_state.hpp"
2727
#include "traccc/utils/algorithm.hpp"
28+
#include "traccc/utils/logging.hpp"
2829

2930
// Greedy ambiguity resolution adapted from ACTS code
3031

@@ -110,8 +111,10 @@ class greedy_ambiguity_resolution_algorithm
110111
/// @param cfg Configuration object
111112
// greedy_ambiguity_resolution_algorithm(const config_type& cfg) :
112113
// _config(cfg) {}
113-
greedy_ambiguity_resolution_algorithm(const config_t cfg = {})
114-
: _config{cfg} {}
114+
greedy_ambiguity_resolution_algorithm(
115+
const config_t cfg,
116+
std::unique_ptr<const Logger> logger = getDummyLogger().clone())
117+
: _config{cfg}, _logger{std::move(logger)} {}
115118

116119
/// Run the algorithm
117120
///
@@ -156,6 +159,10 @@ class greedy_ambiguity_resolution_algorithm
156159
state_t& final_state) const;
157160

158161
config_t _config;
162+
163+
std::unique_ptr<const Logger> _logger;
164+
165+
const Logger& logger() const override { return *_logger; }
159166
};
160167

161168
} // namespace traccc

core/include/traccc/clusterization/clusterization_algorithm.hpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ class clusterization_algorithm
4141
///
4242
/// @param mr The memory resource to use for the result objects
4343
///
44-
clusterization_algorithm(vecmem::memory_resource& mr);
44+
clusterization_algorithm(
45+
vecmem::memory_resource& mr,
46+
std::unique_ptr<const Logger> logger = getDummyLogger().clone());
4547

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

73+
/// Algorithm-specific logger object
74+
std::unique_ptr<const Logger> m_logger;
75+
76+
/// Logger access method
77+
const Logger& logger() const override {
78+
assert(m_logger.get() != nullptr);
79+
return *m_logger;
80+
}
7181
}; // class clusterization_algorithm
7282

7383
} // namespace traccc::host

core/include/traccc/clusterization/measurement_creation_algorithm.hpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ class measurement_creation_algorithm
3939
///
4040
/// @param mr The memory resource to use in the algorithm
4141
///
42-
measurement_creation_algorithm(vecmem::memory_resource &mr);
42+
measurement_creation_algorithm(
43+
vecmem::memory_resource &mr,
44+
std::unique_ptr<const Logger> logger = getDummyLogger().clone());
4345

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

63+
/// Algorithm-specific logger object
64+
std::unique_ptr<const Logger> m_logger;
65+
66+
/// Logger access method
67+
const Logger &logger() const override {
68+
assert(m_logger.get() != nullptr);
69+
return *m_logger;
70+
}
71+
6172
}; // class measurement_creation_algorithm
6273

6374
} // namespace traccc::host

core/include/traccc/clusterization/measurement_sorting_algorithm.hpp

+8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ class measurement_sorting_algorithm
3636
output_type operator()(const measurement_collection_types::view&
3737
measurements_view) const override;
3838

39+
/// Algorithm-specific logger object
40+
std::unique_ptr<const Logger> m_logger;
41+
42+
/// Logger access method
43+
const Logger& logger() const override {
44+
assert(m_logger.get() != nullptr);
45+
return *m_logger;
46+
}
3947
}; // class measurement_sorting_algorithm
4048

4149
} // namespace traccc::host

core/include/traccc/clusterization/sparse_ccl_algorithm.hpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ class sparse_ccl_algorithm
3434
///
3535
/// @param mr is the memory resource
3636
///
37-
sparse_ccl_algorithm(vecmem::memory_resource& mr);
37+
sparse_ccl_algorithm(
38+
vecmem::memory_resource& mr,
39+
std::unique_ptr<const Logger> logger = getDummyLogger().clone());
3840

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

59+
/// Algorithm-specific logger object
60+
std::unique_ptr<const Logger> m_logger;
61+
62+
/// Logger access method
63+
const Logger& logger() const override {
64+
assert(m_logger.get() != nullptr);
65+
return *m_logger;
66+
}
5767
}; // class sparse_ccl_algorithm
5868

5969
} // namespace traccc::host

core/include/traccc/finding/combinatorial_kalman_filter_algorithm.hpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ class combinatorial_kalman_filter_algorithm
4646
using output_type = track_candidate_container_types::host;
4747

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

5153
/// Execute the algorithm
5254
///
@@ -88,6 +90,14 @@ class combinatorial_kalman_filter_algorithm
8890
/// Algorithm configuration
8991
config_type m_config;
9092

93+
/// Algorithm-specific logger object
94+
std::unique_ptr<const Logger> m_logger;
95+
96+
/// Logger access method
97+
const Logger& logger() const override {
98+
assert(m_logger.get() != nullptr);
99+
return *m_logger;
100+
}
91101
}; // class combinatorial_kalman_filter_algorithm
92102

93103
} // namespace traccc::host

core/include/traccc/fitting/kalman_fitting_algorithm.hpp

+11-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ class kalman_fitting_algorithm
4848
///
4949
/// @param config The configuration object
5050
///
51-
explicit kalman_fitting_algorithm(const config_type& config,
52-
vecmem::memory_resource& mr);
51+
explicit kalman_fitting_algorithm(
52+
const config_type& config, vecmem::memory_resource& mr,
53+
std::unique_ptr<const Logger> logger = getDummyLogger().clone());
5354

5455
/// Execute the algorithm
5556
///
@@ -87,6 +88,14 @@ class kalman_fitting_algorithm
8788
/// Memory resource to use in the algorithm
8889
std::reference_wrapper<vecmem::memory_resource> m_mr;
8990

91+
/// Algorithm-specific logger object
92+
std::unique_ptr<const Logger> m_logger;
93+
94+
/// Logger access method
95+
const Logger& logger() const override {
96+
assert(m_logger.get() != nullptr);
97+
return *m_logger;
98+
}
9099
}; // class kalman_fitting_algorithm
91100

92101
} // namespace traccc::host

core/include/traccc/seeding/doublet_finding.hpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ struct doublet_finding
3232
///
3333
/// @param seedfinder_config is the configuration parameters
3434
/// @param isp_container is the internal spacepoint container
35-
doublet_finding(const seedfinder_config& config) : m_config(config) {}
35+
doublet_finding(
36+
const seedfinder_config& config,
37+
std::unique_ptr<const Logger> logger = getDummyLogger().clone())
38+
: m_config(config), m_logger(std::move(logger)) {}
3639

3740
/// Callable operator for doublet finding per middle spacepoint
3841
///
@@ -99,6 +102,15 @@ struct doublet_finding
99102

100103
private:
101104
seedfinder_config m_config;
105+
106+
/// Algorithm-specific logger object
107+
std::unique_ptr<const Logger> m_logger;
108+
109+
/// Logger access method
110+
const Logger& logger() const override {
111+
assert(m_logger.get() != nullptr);
112+
return *m_logger;
113+
}
102114
};
103115

104116
} // namespace traccc

core/include/traccc/seeding/seed_filtering.hpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "traccc/seeding/detail/seeding_config.hpp"
1414
#include "traccc/seeding/detail/spacepoint_grid.hpp"
1515
#include "traccc/seeding/detail/triplet.hpp"
16+
#include "traccc/utils/logging.hpp"
1617

1718
namespace traccc {
1819

@@ -21,7 +22,9 @@ class seed_filtering {
2122

2223
public:
2324
/// Constructor with the seed filter configuration
24-
seed_filtering(const seedfilter_config& config);
25+
seed_filtering(
26+
const seedfilter_config& config,
27+
std::unique_ptr<const Logger> logger = getDummyLogger().clone());
2528

2629
/// Callable operator for the seed filtering
2730
///
@@ -40,6 +43,14 @@ class seed_filtering {
4043
/// Seed filter configuration
4144
seedfilter_config m_filter_config;
4245

46+
/// Algorithm-specific logger object
47+
std::unique_ptr<const Logger> m_logger;
48+
49+
/// Logger access method
50+
const Logger& logger() const {
51+
assert(m_logger.get() != nullptr);
52+
return *m_logger;
53+
}
4354
}; // class seed_filtering
4455

4556
} // namespace traccc

core/include/traccc/seeding/seed_finding.hpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ class seed_finding
3030
/// @param find_config is seed finder configuration parameters
3131
/// @param filter_config is the seed filter configuration
3232
///
33-
seed_finding(const seedfinder_config& find_config,
34-
const seedfilter_config& filter_config);
33+
seed_finding(
34+
const seedfinder_config& find_config,
35+
const seedfilter_config& filter_config,
36+
std::unique_ptr<const Logger> logger = getDummyLogger().clone());
3537

3638
/// Callable operator for the seed finding
3739
///
@@ -53,6 +55,14 @@ class seed_finding
5355
/// Algorithm performing the seed selection
5456
seed_filtering m_seed_filtering;
5557

58+
/// Algorithm-specific logger object
59+
std::unique_ptr<const Logger> m_logger;
60+
61+
/// Logger access method
62+
const Logger& logger() const override {
63+
assert(m_logger.get() != nullptr);
64+
return *m_logger;
65+
}
5666
}; // class seed_finding
5767

5868
} // namespace traccc

core/include/traccc/seeding/seeding_algorithm.hpp

+14-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ class seeding_algorithm : public algorithm<seed_collection_types::host(
2828
///
2929
/// @param mr The memory resource to use
3030
///
31-
seeding_algorithm(const seedfinder_config& finder_config,
32-
const spacepoint_grid_config& grid_config,
33-
const seedfilter_config& filter_config,
34-
vecmem::memory_resource& mr);
31+
seeding_algorithm(
32+
const seedfinder_config& finder_config,
33+
const spacepoint_grid_config& grid_config,
34+
const seedfilter_config& filter_config, vecmem::memory_resource& mr,
35+
std::unique_ptr<const Logger> logger = getDummyLogger().clone());
3536

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

51+
/// Algorithm-specific logger object
52+
std::unique_ptr<const Logger> m_logger;
53+
54+
/// Logger access method
55+
const Logger& logger() const override {
56+
assert(m_logger.get() != nullptr);
57+
return *m_logger;
58+
}
59+
5060
}; // class seeding_algorithm
5161

5262
} // namespace traccc

core/include/traccc/seeding/silicon_pixel_spacepoint_formation_algorithm.hpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ class silicon_pixel_spacepoint_formation_algorithm
4242
///
4343
/// @param mr is the memory resource
4444
///
45-
silicon_pixel_spacepoint_formation_algorithm(vecmem::memory_resource& mr);
45+
silicon_pixel_spacepoint_formation_algorithm(
46+
vecmem::memory_resource& mr,
47+
std::unique_ptr<const Logger> logger = getDummyLogger().clone());
4648

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

75+
/// Algorithm-specific logger object
76+
std::unique_ptr<const Logger> m_logger;
77+
78+
/// Logger access method
79+
const Logger& logger() const override {
80+
assert(m_logger.get() != nullptr);
81+
return *m_logger;
82+
}
7383
}; // class silicon_pixel_spacepoint_formation_algorithm
7484

7585
} // namespace traccc::host

core/include/traccc/seeding/spacepoint_binning.hpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ class spacepoint_binning
2929
/// @param grid_config is for spacepoint grid parameter
3030
/// @param mr is the vecmem memory resource
3131
///
32-
spacepoint_binning(const seedfinder_config& config,
33-
const spacepoint_grid_config& grid_config,
34-
vecmem::memory_resource& mr);
32+
spacepoint_binning(
33+
const seedfinder_config& config,
34+
const spacepoint_grid_config& grid_config, vecmem::memory_resource& mr,
35+
std::unique_ptr<const Logger> logger = getDummyLogger().clone());
3536

3637
/// Operator executing the algorithm
3738
///
@@ -46,6 +47,15 @@ class spacepoint_binning
4647
spacepoint_grid_config m_grid_config;
4748
std::pair<output_type::axis_p0_type, output_type::axis_p1_type> m_axes;
4849
std::reference_wrapper<vecmem::memory_resource> m_mr;
50+
51+
/// Algorithm-specific logger object
52+
std::unique_ptr<const Logger> m_logger;
53+
54+
/// Logger access method
55+
const Logger& logger() const override {
56+
assert(m_logger.get() != nullptr);
57+
return *m_logger;
58+
}
4959
};
5060

5161
} // namespace traccc

0 commit comments

Comments
 (0)