Skip to content

Commit e939705

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 2b95e84 commit e939705

File tree

149 files changed

+1419
-649
lines changed

Some content is hidden

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

149 files changed

+1419
-649
lines changed

benchmarks/cpu/toy_detector_cpu.cpp

+9-4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
#include <benchmark/benchmark.h>
3939

4040
BENCHMARK_F(ToyDetectorBenchmark, CPU)(benchmark::State& state) {
41+
std::unique_ptr<const Acts::Logger> _logger =
42+
Acts::getDefaultLogger("TracccBenchmark", Acts::Logging::Level::INFO);
43+
ACTS_LOCAL_LOGGER(std::move(_logger));
4144

4245
// Type declarations
4346
using host_detector_type = traccc::default_detector::host;
@@ -53,11 +56,13 @@ BENCHMARK_F(ToyDetectorBenchmark, CPU)(benchmark::State& state) {
5356
auto field = detray::bfield::create_const_field<scalar_type>(B);
5457

5558
// Algorithms
56-
traccc::seeding_algorithm sa(seeding_cfg, grid_cfg, filter_cfg, host_mr);
57-
traccc::track_params_estimation tp(host_mr);
59+
traccc::seeding_algorithm sa(seeding_cfg, grid_cfg, filter_cfg, host_mr,
60+
logger().clone());
61+
traccc::track_params_estimation tp(host_mr, logger().clone());
5862
traccc::host::combinatorial_kalman_filter_algorithm host_finding(
59-
finding_cfg);
60-
traccc::host::kalman_fitting_algorithm host_fitting(fitting_cfg, host_mr);
63+
finding_cfg, logger().clone());
64+
traccc::host::kalman_fitting_algorithm host_fitting(fitting_cfg, host_mr,
65+
logger().clone());
6166

6267
for (auto _ : state) {
6368

benchmarks/cuda/toy_detector_cuda.cpp

+10-5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
#include <benchmark/benchmark.h>
4242

4343
BENCHMARK_F(ToyDetectorBenchmark, CUDA)(benchmark::State& state) {
44+
std::unique_ptr<const Acts::Logger> _logger =
45+
Acts::getDefaultLogger("TracccTest", Acts::Logging::Level::INFO);
46+
ACTS_LOCAL_LOGGER(std::move(_logger));
4447

4548
// Type declarations
4649
using rk_stepper_type = detray::rk_stepper<
@@ -77,19 +80,21 @@ BENCHMARK_F(ToyDetectorBenchmark, CUDA)(benchmark::State& state) {
7780

7881
// Algorithms
7982
traccc::cuda::seeding_algorithm sa_cuda(seeding_cfg, grid_cfg, filter_cfg,
80-
mr, async_copy, stream);
81-
traccc::cuda::track_params_estimation tp_cuda(mr, async_copy, stream);
83+
mr, async_copy, stream,
84+
logger().clone());
85+
traccc::cuda::track_params_estimation tp_cuda(mr, async_copy, stream,
86+
logger().clone());
8287
traccc::cuda::finding_algorithm<rk_stepper_type, device_navigator_type>
83-
device_finding(finding_cfg, mr, async_copy, stream);
88+
device_finding(finding_cfg, mr, async_copy, stream, logger().clone());
8489
traccc::cuda::fitting_algorithm<device_fitter_type> device_fitting(
85-
fitting_cfg, mr, async_copy, stream);
90+
fitting_cfg, mr, async_copy, stream, logger().clone());
8691

8792
// Detector view object
8893
auto det_view = detray::get_data(det);
8994

9095
// D2H copy object
9196
traccc::device::container_d2h_copy_alg<traccc::track_state_container_types>
92-
track_state_d2h{{device_mr, &host_mr}, copy};
97+
track_state_d2h{{device_mr, &host_mr}, copy, logger().clone()};
9398

9499
for (auto _ : state) {
95100

core/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ traccc_add_library( traccc_core core TYPE SHARED
116116
"src/ambiguity_resolution/greedy_ambiguity_resolution_algorithm.cpp" )
117117
target_link_libraries( traccc_core
118118
PUBLIC Eigen3::Eigen vecmem::core detray::core detray::detectors
119-
traccc::algebra )
119+
traccc::algebra ActsCore )
120120

121121
# Prevent Eigen from getting confused when building code for a
122122
# CUDA or HIP backend with SYCL.

core/include/traccc/ambiguity_resolution/greedy_ambiguity_resolution_algorithm.hpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#pragma once
99

1010
// System include
11+
#include <Acts/Utilities/Logger.hpp>
1112
#include <algorithm>
1213
#include <initializer_list>
1314
#include <iostream>
@@ -110,8 +111,9 @@ 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, std::unique_ptr<const Acts::Logger> logger)
116+
: _config{cfg}, _logger{std::move(logger)} {}
115117

116118
/// Run the algorithm
117119
///
@@ -156,6 +158,10 @@ class greedy_ambiguity_resolution_algorithm
156158
state_t& final_state) const;
157159

158160
config_t _config;
161+
162+
std::unique_ptr<const Acts::Logger> _logger;
163+
164+
const Acts::Logger& logger() const override { return *_logger; }
159165
};
160166

161167
} // namespace traccc

core/include/traccc/clusterization/clusterization_algorithm.hpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ 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(vecmem::memory_resource& mr,
45+
std::unique_ptr<const Acts::Logger> logger);
4546

4647
/// Construct measurements for each detector module
4748
///
@@ -68,6 +69,14 @@ class clusterization_algorithm
6869
/// Reference to the host-accessible memory resource
6970
std::reference_wrapper<vecmem::memory_resource> m_mr;
7071

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

7382
} // namespace traccc::host

core/include/traccc/clusterization/measurement_creation_algorithm.hpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ 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(vecmem::memory_resource &mr,
43+
std::unique_ptr<const Acts::Logger> logger);
4344

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

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

6373
} // 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 Acts::Logger> m_logger;
41+
42+
/// Logger access method
43+
const Acts::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

+10-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ 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(vecmem::memory_resource& mr,
38+
std::unique_ptr<const Acts::Logger> logger);
3839

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

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

5968
} // namespace traccc::host

core/include/traccc/finding/combinatorial_kalman_filter_algorithm.hpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ 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, std::unique_ptr<const Acts::Logger> logger);
5051

5152
/// Execute the algorithm
5253
///
@@ -88,6 +89,14 @@ class combinatorial_kalman_filter_algorithm
8889
/// Algorithm configuration
8990
config_type m_config;
9091

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

93102
} // 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 Acts::Logger> logger);
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 Acts::Logger> m_logger;
93+
94+
/// Logger access method
95+
const Acts::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

+12-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ 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(const seedfinder_config& config,
36+
std::unique_ptr<const Acts::Logger> logger)
37+
: m_config(config), m_logger(std::move(logger)) {}
3638

3739
/// Callable operator for doublet finding per middle spacepoint
3840
///
@@ -99,6 +101,15 @@ struct doublet_finding
99101

100102
private:
101103
seedfinder_config m_config;
104+
105+
/// Algorithm-specific logger object
106+
std::unique_ptr<const Acts::Logger> m_logger;
107+
108+
/// Logger access method
109+
const Acts::Logger& logger() const override {
110+
assert(m_logger.get() != nullptr);
111+
return *m_logger;
112+
}
102113
};
103114

104115
} // namespace traccc

core/include/traccc/seeding/seed_filtering.hpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#pragma once
99

10+
#include <Acts/Utilities/Logger.hpp>
11+
1012
// Library include(s).
1113
#include "traccc/edm/seed.hpp"
1214
#include "traccc/edm/spacepoint.hpp"
@@ -21,7 +23,8 @@ class seed_filtering {
2123

2224
public:
2325
/// Constructor with the seed filter configuration
24-
seed_filtering(const seedfilter_config& config);
26+
seed_filtering(const seedfilter_config& config,
27+
std::unique_ptr<const Acts::Logger> logger);
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 Acts::Logger> m_logger;
48+
49+
/// Logger access method
50+
const Acts::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

+10-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class seed_finding
3131
/// @param filter_config is the seed filter configuration
3232
///
3333
seed_finding(const seedfinder_config& find_config,
34-
const seedfilter_config& filter_config);
34+
const seedfilter_config& filter_config,
35+
std::unique_ptr<const Acts::Logger> logger);
3536

3637
/// Callable operator for the seed finding
3738
///
@@ -53,6 +54,14 @@ class seed_finding
5354
/// Algorithm performing the seed selection
5455
seed_filtering m_seed_filtering;
5556

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

5867
} // namespace traccc

core/include/traccc/seeding/seeding_algorithm.hpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class seeding_algorithm : public algorithm<seed_collection_types::host(
3131
seeding_algorithm(const seedfinder_config& finder_config,
3232
const spacepoint_grid_config& grid_config,
3333
const seedfilter_config& filter_config,
34-
vecmem::memory_resource& mr);
34+
vecmem::memory_resource& mr,
35+
std::unique_ptr<const Acts::Logger> logger);
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 Acts::Logger> m_logger;
53+
54+
/// Logger access method
55+
const Acts::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 Acts::Logger> logger);
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 Acts::Logger> m_logger;
77+
78+
/// Logger access method
79+
const Acts::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

0 commit comments

Comments
 (0)