SMAUG
Simulating Machine Learning Applications on gem5-Aladdin
debug_stream.h
1 #ifndef _UTILITY_DEBUG_STREAM_H_
2 #define _UTILITY_DEBUG_STREAM_H_
3 
4 #include <iostream>
5 
6 namespace smaug {
7 
12 class DebugStream {
13  public:
14  DebugStream(bool _enabled) : enabled(_enabled) {}
15 
16 #ifndef FAST_BUILD
17  template <typename T>
18  const DebugStream& operator<<(T message) const {
19  if (enabled)
20  std::cout << message;
21  return *this;
22  }
23 #else
24  template <typename T>
25  const DebugStream& operator<<(T message) const {
26  return *this;
27  }
28 #endif
29 
30  protected:
31  bool enabled;
32 };
33 
35 void initDebugStream(int debugLevel);
36 
38 const DebugStream& dout(int debugLevel);
39 
40 } // namespace smaug
41 
42 #endif
smaug::dout
const DebugStream & dout(int debugLevel)
Returns a DebugStream instance for the given debug level.
Definition: debug_stream.cpp:16
smaug::DebugStream
An stream class to consume debug logs.
Definition: debug_stream.h:12
smaug::initDebugStream
void initDebugStream(int debugLevel)
Initializes the global debug stream for the given debug level.
Definition: debug_stream.cpp:10
smaug
The smaug namespace is the parent namespace of all C++ code in SMAUG.
Definition: backend.cpp:38