Skip to content

Commit 98989e9

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 4370163 commit 98989e9

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

Diff for: examples/run/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
# Project include(s).
88
include( traccc-compiler-options-cpp )
99

10+
# Inform the code that it is being built in Release mode.
11+
if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
12+
add_definitions(-DTRACCC_BUILD_TYPE_IS_RELEASE)
13+
endif()
14+
1015
# Add all the subdirectories that can be built.
1116
add_subdirectory(cpu)
1217

Diff for: examples/run/common/optimization_warning.hpp

+27
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

Diff for: 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 "optimization_warning.hpp"
23+
2124
// I/O include(s).
2225
#include "traccc/io/read_cells.hpp"
2326
#include "traccc/io/read_detector.hpp"
@@ -68,6 +71,8 @@ int throughput_mt(std::string_view description, int argc, char* argv[],
6871
argc,
6972
argv};
7073

74+
TRACCC_OPTIMIZATION_WARNING();
75+
7176
// Set up the timing info holder.
7277
performance::timing_info times;
7378

@@ -226,6 +231,7 @@ int throughput_mt(std::string_view description, int argc, char* argv[],
226231
// Print some results.
227232
std::cout << "Reconstructed track parameters: " << rec_track_params.load()
228233
<< std::endl;
234+
TRACCC_OPTIMIZATION_WARNING();
229235
std::cout << "Time totals:" << std::endl;
230236
std::cout << times << std::endl;
231237
std::cout << "Throughput:" << std::endl;
@@ -235,6 +241,7 @@ int throughput_mt(std::string_view description, int argc, char* argv[],
235241
<< performance::throughput{throughput_opts.processed_events,
236242
times, "Event processing"}
237243
<< std::endl;
244+
TRACCC_OPTIMIZATION_WARNING();
238245

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

Diff for: 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 "optimization_warning.hpp"
22+
2023
// I/O include(s).
2124
#include "traccc/io/read_cells.hpp"
2225
#include "traccc/io/read_detector.hpp"
@@ -58,6 +61,8 @@ int throughput_st(std::string_view description, int argc, char* argv[],
5861
argc,
5962
argv};
6063

64+
TRACCC_OPTIMIZATION_WARNING();
65+
6166
// Set up the timing info holder.
6267
performance::timing_info times;
6368

@@ -168,6 +173,7 @@ int throughput_st(std::string_view description, int argc, char* argv[],
168173
// Print some results.
169174
std::cout << "Reconstructed track parameters: " << rec_track_params
170175
<< std::endl;
176+
TRACCC_OPTIMIZATION_WARNING();
171177
std::cout << "Time totals:" << std::endl;
172178
std::cout << times << std::endl;
173179
std::cout << "Throughput:" << std::endl;
@@ -177,6 +183,7 @@ int throughput_st(std::string_view description, int argc, char* argv[],
177183
<< performance::throughput{throughput_opts.processed_events,
178184
times, "Event processing"}
179185
<< std::endl;
186+
TRACCC_OPTIMIZATION_WARNING();
180187

181188
// Return gracefully.
182189
return 0;

0 commit comments

Comments
 (0)