Skip to content

Commit fd34bb2

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 fd34bb2

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

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

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 "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 "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;

0 commit comments

Comments
 (0)