ttg 1.0.0
Template Task Graph (TTG): flowgraph-based programming model for high-performance distributed-memory algorithms
Loading...
Searching...
No Matches
trace.h
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-3-Clause
2#ifndef TTG_TRACE_H
3#define TTG_TRACE_H
4
5#include "ttg/util/print.h"
6
7namespace ttg {
8 namespace detail {
9 inline bool &trace_accessor() {
10 static bool trace = false;
11 return trace;
12 }
13 } // namespace detail
14
16 inline constexpr bool trace_enabled() {
17#ifdef TTG_ENABLE_TRACE
18 return true;
19#else
20 return false;
21#endif
22 }
23
25
29 inline bool tracing() {
30 if constexpr (trace_enabled())
32 else
33 return false;
34 }
35
37 inline void trace_on() { if constexpr (trace_enabled()) detail::trace_accessor() = true; }
39 inline void trace_off() { if constexpr (trace_enabled()) detail::trace_accessor() = false; }
40
43 template <typename T, typename... Ts>
44 inline void trace(const T &t, const Ts &... ts) {
45 if constexpr (trace_enabled()) {
46 if (tracing()) {
47 log(t, ts...);
48 }
49 }
50 }
51
52} // namespace ttg
53
54#endif // TTG_TRACE_H
bool & trace_accessor()
Definition trace.h:9
top-level TTG namespace contains runtime-neutral functionality
Definition keymap.h:9
void trace_off()
disables tracing; if trace_enabled()==true this has no effect
Definition trace.h:39
void trace_on()
enables tracing; if trace_enabled()==true this has no effect
Definition trace.h:37
void log(const T &t, const Ts &... ts)
atomically prints to std::clog a sequence of items (separated by ttg::print_separator) followed by st...
Definition print.h:147
bool tracing()
returns whether tracing is enabled
Definition trace.h:29
void trace(const T &t, const Ts &... ts)
Definition trace.h:44
constexpr bool trace_enabled()
returns whether tracing was enabled at configure time
Definition trace.h:16