Skip to content

Commit 16b9b57

Browse files
committed
Issue warnings for non-Release builds
A common pitfall when using traccc seems to be that people build it in non-Release mode and then get poor performance. This commit adds a bunch of warning prints to make sure that the code will inform you if you try to run it in non-Release mode.
1 parent e7a03e9 commit 16b9b57

16 files changed

+110
-0
lines changed

CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@ set(TRACCC_ALGEBRA_PLUGINS ARRAY CACHE STRING "Algebra plugin to use in the buil
302302
message(STATUS "Building with plugin type: " ${TRACCC_ALGEBRA_PLUGINS})
303303
add_definitions(-DALGEBRA_PLUGINS_INCLUDE_${TRACCC_ALGEBRA_PLUGINS})
304304

305+
# Inform the code that it is being build in Release mode.
306+
if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
307+
add_definitions(-DTRACCC_BUILD_TYPE_IS_RELEASE)
308+
endif()
309+
305310
# Build the traccc code.
306311
add_subdirectory( core )
307312
add_subdirectory( device/common )
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/** TRACCC library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 2022 CERN for the benefit of the ACTS project
4+
*
5+
* Mozilla Public License Version 2.0
6+
*/
7+
8+
#pragma once
9+
10+
#include <iostream>
11+
12+
#if !defined(TRACCC_BUILD_TYPE_IS_RELEASE) || !defined(NDEBUG) || \
13+
defined(_DEBUG)
14+
#define TRACCC_OPTIMIZATION_WARNING() \
15+
do { \
16+
std::cout \
17+
<< "WARNING: traccc was built without Release mode, without the " \
18+
"`NDEBUG` flag, or (on MSVC) with the `_DEBUG` flag. " \
19+
"Performance is guaranteed to be much lower and compute " \
20+
"performance results should be considered unreliable!" \
21+
<< std::endl; \
22+
} while (false)
23+
#else
24+
#define TRACCC_OPTIMIZATION_WARNING() \
25+
do { \
26+
} while (false)
27+
#endif

examples/run/common/throughput_mt.ipp

+7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
#include "traccc/options/track_propagation.hpp"
1919
#include "traccc/options/track_seeding.hpp"
2020

21+
// Local include(s)
22+
#include "../common/optimization_warning.hpp"
23+
2124
// I/O include(s).
2225
#include "traccc/io/demonstrator_edm.hpp"
2326
#include "traccc/io/read.hpp"
@@ -72,6 +75,8 @@ int throughput_mt(std::string_view description, int argc, char* argv[],
7275
argc,
7376
argv};
7477

78+
TRACCC_OPTIMIZATION_WARNING();
79+
7580
// Set up the timing info holder.
7681
performance::timing_info times;
7782

@@ -242,6 +247,7 @@ int throughput_mt(std::string_view description, int argc, char* argv[],
242247
// Print some results.
243248
std::cout << "Reconstructed track parameters: " << rec_track_params.load()
244249
<< std::endl;
250+
TRACCC_OPTIMIZATION_WARNING();
245251
std::cout << "Time totals:" << std::endl;
246252
std::cout << times << std::endl;
247253
std::cout << "Throughput:" << std::endl;
@@ -251,6 +257,7 @@ int throughput_mt(std::string_view description, int argc, char* argv[],
251257
<< performance::throughput{throughput_opts.processed_events,
252258
times, "Event processing"}
253259
<< std::endl;
260+
TRACCC_OPTIMIZATION_WARNING();
254261

255262
// Print results to log file
256263
if (throughput_opts.log_file != "\0") {

examples/run/common/throughput_st.ipp

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
#include "traccc/options/track_propagation.hpp"
1818
#include "traccc/options/track_seeding.hpp"
1919

20+
// Local include(s)
21+
#include "../common/optimization_warning.hpp"
22+
2023
// I/O include(s).
2124
#include "traccc/io/demonstrator_edm.hpp"
2225
#include "traccc/io/read.hpp"
@@ -62,6 +65,8 @@ int throughput_st(std::string_view description, int argc, char* argv[],
6265
argc,
6366
argv};
6467

68+
TRACCC_OPTIMIZATION_WARNING();
69+
6570
// Set up the timing info holder.
6671
performance::timing_info times;
6772

@@ -192,6 +197,7 @@ int throughput_st(std::string_view description, int argc, char* argv[],
192197
// Print some results.
193198
std::cout << "Reconstructed track parameters: " << rec_track_params
194199
<< std::endl;
200+
TRACCC_OPTIMIZATION_WARNING();
195201
std::cout << "Time totals:" << std::endl;
196202
std::cout << times << std::endl;
197203
std::cout << "Throughput:" << std::endl;
@@ -201,6 +207,7 @@ int throughput_st(std::string_view description, int argc, char* argv[],
201207
<< performance::throughput{throughput_opts.processed_events,
202208
times, "Event processing"}
203209
<< std::endl;
210+
TRACCC_OPTIMIZATION_WARNING();
204211

205212
// Return gracefully.
206213
return 0;

examples/run/cpu/ccl_example.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#include "traccc/edm/cell.hpp"
1212
#include "traccc/io/read_cells.hpp"
1313

14+
// Local include(s).
15+
#include "../common/optimization_warning.hpp"
16+
1417
// VecMem include(s).
1518
#include <vecmem/memory/host_memory_resource.hpp>
1619

@@ -95,6 +98,8 @@ int main(int argc, char* argv[]) {
9598
return -1;
9699
}
97100

101+
TRACCC_OPTIMIZATION_WARNING();
102+
98103
std::string event_file = std::string(argv[1]);
99104

100105
std::cout << "Running " << argv[0] << " on " << event_file << std::endl;
@@ -129,6 +134,7 @@ int main(int argc, char* argv[]) {
129134

130135
auto time_process_p4 = std::chrono::high_resolution_clock::now();
131136

137+
TRACCC_OPTIMIZATION_WARNING();
132138
std::cout << "\nCPU budget allocation" << std::endl;
133139
std::cout << std::fixed;
134140
std::cout << std::setw(13) << "Component"
@@ -155,6 +161,7 @@ int main(int argc, char* argv[]) {
155161
<< " | " << std::setw(10) << std::setprecision(3)
156162
<< delta_ms(time_read_start, time_process_p4) << " ms"
157163
<< std::endl;
164+
TRACCC_OPTIMIZATION_WARNING();
158165

159166
return 0;
160167
}

examples/run/cpu/seeding_example.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#include "traccc/definitions/common.hpp"
1010
#include "traccc/definitions/primitives.hpp"
1111

12+
// Local include(s).
13+
#include "../common/optimization_warning.hpp"
14+
1215
// io
1316
#include "traccc/io/read_geometry.hpp"
1417
#include "traccc/io/read_measurements.hpp"
@@ -261,6 +264,7 @@ int seq_run(const traccc::opts::track_seeding& seeding_opts,
261264
}
262265
}
263266

267+
TRACCC_OPTIMIZATION_WARNING();
264268
std::cout << "==> Statistics ... " << std::endl;
265269
std::cout << "- read " << n_spacepoints << " spacepoints" << std::endl;
266270
std::cout << "- read " << n_measurements << " measurements" << std::endl;
@@ -276,6 +280,7 @@ int seq_run(const traccc::opts::track_seeding& seeding_opts,
276280
} else {
277281
std::cout << "- ambiguity resolution: deactivated" << std::endl;
278282
}
283+
TRACCC_OPTIMIZATION_WARNING();
279284

280285
return EXIT_SUCCESS;
281286
}

examples/run/cpu/seq_example.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#include "traccc/io/utils.hpp"
1313
#include "traccc/io/write.hpp"
1414

15+
// Local include(s).
16+
#include "../common/optimization_warning.hpp"
17+
1518
// algorithms
1619
#include "traccc/ambiguity_resolution/greedy_ambiguity_resolution_algorithm.hpp"
1720
#include "traccc/clusterization/clusterization_algorithm.hpp"
@@ -336,6 +339,7 @@ int seq_run(const traccc::opts::input_data& input_opts,
336339
}
337340
}
338341

342+
TRACCC_OPTIMIZATION_WARNING();
339343
std::cout << "==> Statistics ... " << std::endl;
340344
std::cout << "- read " << n_cells << " cells from " << n_modules
341345
<< " modules" << std::endl;
@@ -349,6 +353,7 @@ int seq_run(const traccc::opts::input_data& input_opts,
349353
std::cout << "- resolved " << n_ambiguity_free_tracks << " tracks"
350354
<< std::endl;
351355
std::cout << "==> Elapsed times...\n" << elapsedTimes << std::endl;
356+
TRACCC_OPTIMIZATION_WARNING();
352357

353358
return EXIT_SUCCESS;
354359
}

examples/run/cuda/seeding_example_cuda.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
#include "traccc/seeding/seeding_algorithm.hpp"
3838
#include "traccc/seeding/track_params_estimation.hpp"
3939

40+
// Local include(s).
41+
#include "../common/optimization_warning.hpp"
42+
4043
// Detray include(s).
4144
#include "detray/core/detector.hpp"
4245
#include "detray/core/detector_metadata.hpp"
@@ -455,6 +458,7 @@ int seq_run(const traccc::opts::track_seeding& seeding_opts,
455458
std::cout << nsd_performance_writer.generate_report_str();
456459
}
457460

461+
TRACCC_OPTIMIZATION_WARNING();
458462
std::cout << "==> Statistics ... " << std::endl;
459463
std::cout << "- read " << n_spacepoints << " spacepoints from "
460464
<< n_modules << " modules" << std::endl;
@@ -469,6 +473,7 @@ int seq_run(const traccc::opts::track_seeding& seeding_opts,
469473
std::cout << "- created (cuda) " << n_fitted_tracks_cuda << " fitted tracks"
470474
<< std::endl;
471475
std::cout << "==>Elapsed times...\n" << elapsedTimes << std::endl;
476+
TRACCC_OPTIMIZATION_WARNING();
472477

473478
return 0;
474479
}

examples/run/cuda/seq_example_cuda.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
#include "traccc/seeding/seeding_algorithm.hpp"
4040
#include "traccc/seeding/track_params_estimation.hpp"
4141

42+
// Local include(s).
43+
#include "../common/optimization_warning.hpp"
44+
4245
// Detray include(s).
4346
#include "detray/core/detector.hpp"
4447
#include "detray/detectors/bfield.hpp"
@@ -492,6 +495,7 @@ int seq_run(const traccc::opts::detector& detector_opts,
492495
sd_performance_writer.finalize();
493496
}
494497

498+
TRACCC_OPTIMIZATION_WARNING();
495499
std::cout << "==> Statistics ... " << std::endl;
496500
std::cout << "- read " << n_cells << " cells from " << n_modules
497501
<< " modules" << std::endl;
@@ -515,6 +519,7 @@ int seq_run(const traccc::opts::detector& detector_opts,
515519
std::cout << "- fitted (cuda) " << n_fitted_tracks_cuda << " tracks"
516520
<< std::endl;
517521
std::cout << "==>Elapsed times...\n" << elapsedTimes << std::endl;
522+
TRACCC_OPTIMIZATION_WARNING();
518523

519524
return 0;
520525
}

examples/run/cuda/truth_finding_example_cuda.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
#include "traccc/resolution/fitting_performance_writer.hpp"
3434
#include "traccc/utils/seed_generator.hpp"
3535

36+
// Local include(s).
37+
#include "../common/optimization_warning.hpp"
38+
3639
// detray include(s).
3740
#include "detray/core/detector.hpp"
3841
#include "detray/core/detector_metadata.hpp"
@@ -331,6 +334,7 @@ int seq_run(const traccc::opts::track_finding& finding_opts,
331334
fit_performance_writer.finalize();
332335
}
333336

337+
TRACCC_OPTIMIZATION_WARNING();
334338
std::cout << "==> Statistics ... " << std::endl;
335339
std::cout << "- created (cuda) " << n_found_tracks_cuda << " found tracks"
336340
<< std::endl;
@@ -341,6 +345,7 @@ int seq_run(const traccc::opts::track_finding& finding_opts,
341345
std::cout << "- created (cpu) " << n_fitted_tracks << " fitted tracks"
342346
<< std::endl;
343347
std::cout << "==>Elapsed times...\n" << elapsedTimes << std::endl;
348+
TRACCC_OPTIMIZATION_WARNING();
344349

345350
return 1;
346351
}

examples/run/cuda/truth_fitting_example_cuda.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
#include "traccc/resolution/fitting_performance_writer.hpp"
3030
#include "traccc/utils/seed_generator.hpp"
3131

32+
// Local include(s).
33+
#include "../common/optimization_warning.hpp"
34+
3235
// detray include(s).
3336
#include "detray/core/detector.hpp"
3437
#include "detray/core/detector_metadata.hpp"
@@ -249,12 +252,14 @@ int main(int argc, char* argv[]) {
249252
fit_performance_writer.finalize();
250253
}
251254

255+
TRACCC_OPTIMIZATION_WARNING();
252256
std::cout << "==> Statistics ... " << std::endl;
253257
std::cout << "- created (cuda) " << n_fitted_tracks_cuda << " fitted tracks"
254258
<< std::endl;
255259
std::cout << "- created (cpu) " << n_fitted_tracks << " fitted tracks"
256260
<< std::endl;
257261
std::cout << "==>Elapsed times...\n" << elapsedTimes << std::endl;
262+
TRACCC_OPTIMIZATION_WARNING();
258263

259264
return EXIT_SUCCESS;
260265
}

examples/run/kokkos/seeding_example_kokkos.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#include "traccc/seeding/seeding_algorithm.hpp"
2424
#include "traccc/seeding/track_params_estimation.hpp"
2525

26+
// Local include(s).
27+
#include "../common/optimization_warning.hpp"
28+
2629
// VecMem include(s).
2730
#include <vecmem/memory/host_memory_resource.hpp>
2831

@@ -135,13 +138,15 @@ int seq_run(const traccc::opts::track_seeding& seeding_opts,
135138
sd_performance_writer.finalize();
136139
}
137140

141+
TRACCC_OPTIMIZATION_WARNING();
138142
std::cout << "==> Statistics ... " << std::endl;
139143
std::cout << "- read " << n_spacepoints << " spacepoints from "
140144
<< n_modules << " modules" << std::endl;
141145
std::cout << "- created (cpu) " << n_seeds << " seeds" << std::endl;
142146
std::cout << "- created (kokkos) " << n_seeds_kokkos << " seeds"
143147
<< std::endl;
144148
std::cout << "==>Elapsed times...\n" << elapsedTimes << std::endl;
149+
TRACCC_OPTIMIZATION_WARNING();
145150

146151
return 0;
147152
}

examples/run/openmp/io_dec_par_example.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#include "traccc/edm/spacepoint.hpp"
1414
#include "traccc/io/demonstrator_edm.hpp"
1515

16+
// Local include(s).
17+
#include "../common/optimization_warning.hpp"
18+
1619
// VecMem include(s).
1720
#include <vecmem/memory/host_memory_resource.hpp>
1821

@@ -88,8 +91,10 @@ traccc::demonstrator_result run(traccc::demonstrator_input input_data,
8891

8992
auto endAlgorithms = std::chrono::system_clock::now();
9093
std::chrono::duration<double> diffAlgo = endAlgorithms - startAlgorithms;
94+
TRACCC_OPTIMIZATION_WARNING();
9195
std::cout << "Algorithms time: " << diffAlgo.count() << " sec."
9296
<< std::endl;
97+
TRACCC_OPTIMIZATION_WARNING();
9398

9499
std::cout << "==> Statistics ... " << std::endl;
95100
std::cout << "- read " << n_cells << " cells from " << n_modules
@@ -148,6 +153,8 @@ int main(int argc, char* argv[]) {
148153

149154
auto end = std::chrono::system_clock::now();
150155
std::chrono::duration<double> diff = end - start;
156+
TRACCC_OPTIMIZATION_WARNING();
151157
std::cout << "Total execution time: " << diff.count() << " sec."
152158
<< std::endl;
159+
TRACCC_OPTIMIZATION_WARNING();
153160
}

examples/run/openmp/par_example.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
#include "traccc/io/read_digitization_config.hpp"
1818
#include "traccc/io/read_geometry.hpp"
1919

20+
// Local include(s).
21+
#include "../common/optimization_warning.hpp"
22+
2023
// VecMem include(s).
2124
#include <vecmem/memory/host_memory_resource.hpp>
2225

@@ -163,6 +166,8 @@ int main(int argc, char *argv[]) {
163166
auto end = std::chrono::system_clock::now();
164167

165168
std::chrono::duration<double> diff = end - start;
169+
TRACCC_OPTIMIZATION_WARNING();
166170
std::cout << "Execution time: " << diff.count() << " sec." << std::endl;
171+
TRACCC_OPTIMIZATION_WARNING();
167172
return result;
168173
}

examples/run/sycl/seeding_example_sycl.sycl

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
// SYCL include(s)
99
#include <CL/sycl.hpp>
1010

11+
// Local include(s).
12+
#include "../common/optimization_warning.hpp"
13+
1114
// algorithms
1215
#include "traccc/seeding/seeding_algorithm.hpp"
1316
#include "traccc/seeding/track_params_estimation.hpp"
@@ -264,12 +267,14 @@ int seq_run(const traccc::opts::track_seeding& seeding_opts,
264267
sd_performance_writer.finalize();
265268
}
266269

270+
TRACCC_OPTIMIZATION_WARNING();
267271
std::cout << "==> Statistics ... " << std::endl;
268272
std::cout << "- read " << n_spacepoints << " spacepoints from "
269273
<< n_modules << " modules" << std::endl;
270274
std::cout << "- created (cpu) " << n_seeds << " seeds" << std::endl;
271275
std::cout << "- created (sycl) " << n_seeds_sycl << " seeds" << std::endl;
272276
std::cout << "==>Elapsed times...\n" << elapsedTimes << std::endl;
277+
TRACCC_OPTIMIZATION_WARNING();
273278

274279
return 0;
275280
}

0 commit comments

Comments
 (0)