Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue warnings for non-Release builds #701

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions examples/run/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
# Project include(s).
include( traccc-compiler-options-cpp )

# Inform the code that it is being built in Release mode.
if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
add_definitions(-DTRACCC_BUILD_TYPE_IS_RELEASE)
endif()

# Add all the subdirectories that can be built.
add_subdirectory(cpu)

Expand Down
27 changes: 27 additions & 0 deletions examples/run/common/optimization_warning.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2022 CERN for the benefit of the ACTS project
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* (c) 2022 CERN for the benefit of the ACTS project
* (c) 2024 CERN for the benefit of the ACTS project

*
* Mozilla Public License Version 2.0
*/

#pragma once

#include <iostream>

#if !defined(TRACCC_BUILD_TYPE_IS_RELEASE) || !defined(NDEBUG) || \
defined(_DEBUG)
#define TRACCC_OPTIMIZATION_WARNING() \
do { \
std::cout \
<< "WARNING: traccc was built without Release mode, without the " \
"`NDEBUG` flag, or (on MSVC) with the `_DEBUG` flag. " \
"Performance is guaranteed to be much lower and compute " \
"performance results should be considered unreliable!" \
<< std::endl; \
} while (false)
#else
#define TRACCC_OPTIMIZATION_WARNING() \
do { \
} while (false)
#endif
Comment on lines +12 to +27
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coming back to this... Why a macro at this point? A void optimization_warning() function would seem perfectly adequate here. The extra function call is not really an issue, it's all happening during the initialization of the throughput applications. 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I have no idea what the GitHub UI is doing now... 😕

7 changes: 7 additions & 0 deletions examples/run/common/throughput_mt.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#include "traccc/options/track_propagation.hpp"
#include "traccc/options/track_seeding.hpp"

// Local include(s)
#include "optimization_warning.hpp"

// I/O include(s).
#include "traccc/io/read_cells.hpp"
#include "traccc/io/read_detector.hpp"
Expand Down Expand Up @@ -68,6 +71,8 @@ int throughput_mt(std::string_view description, int argc, char* argv[],
argc,
argv};

TRACCC_OPTIMIZATION_WARNING();

// Set up the timing info holder.
performance::timing_info times;

Expand Down Expand Up @@ -226,6 +231,7 @@ int throughput_mt(std::string_view description, int argc, char* argv[],
// Print some results.
std::cout << "Reconstructed track parameters: " << rec_track_params.load()
<< std::endl;
TRACCC_OPTIMIZATION_WARNING();
std::cout << "Time totals:" << std::endl;
std::cout << times << std::endl;
std::cout << "Throughput:" << std::endl;
Expand All @@ -235,6 +241,7 @@ int throughput_mt(std::string_view description, int argc, char* argv[],
<< performance::throughput{throughput_opts.processed_events,
times, "Event processing"}
<< std::endl;
TRACCC_OPTIMIZATION_WARNING();

// Print results to log file
if (throughput_opts.log_file != "\0") {
Expand Down
7 changes: 7 additions & 0 deletions examples/run/common/throughput_st.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#include "traccc/options/track_propagation.hpp"
#include "traccc/options/track_seeding.hpp"

// Local include(s)
#include "optimization_warning.hpp"

// I/O include(s).
#include "traccc/io/read_cells.hpp"
#include "traccc/io/read_detector.hpp"
Expand Down Expand Up @@ -58,6 +61,8 @@ int throughput_st(std::string_view description, int argc, char* argv[],
argc,
argv};

TRACCC_OPTIMIZATION_WARNING();

// Set up the timing info holder.
performance::timing_info times;

Expand Down Expand Up @@ -168,6 +173,7 @@ int throughput_st(std::string_view description, int argc, char* argv[],
// Print some results.
std::cout << "Reconstructed track parameters: " << rec_track_params
<< std::endl;
TRACCC_OPTIMIZATION_WARNING();
std::cout << "Time totals:" << std::endl;
std::cout << times << std::endl;
std::cout << "Throughput:" << std::endl;
Expand All @@ -177,6 +183,7 @@ int throughput_st(std::string_view description, int argc, char* argv[],
<< performance::throughput{throughput_opts.processed_events,
times, "Event processing"}
<< std::endl;
TRACCC_OPTIMIZATION_WARNING();

// Return gracefully.
return 0;
Expand Down
Loading