SMAUG
Simulating Machine Learning Applications on gem5-Aladdin
debug_stream.cpp
1 #include <cassert>
2 #include "smaug/utility/debug_stream.h"
3 
4 namespace smaug {
5 
6 static int globalDebugLevel = -1;
7 static DebugStream nullStream(false);
8 static DebugStream debugStream(true);
9 
10 void initDebugStream(int debugLevel) {
11  assert(globalDebugLevel == -1 &&
12  "Debug stream cannot initialized more than once!");
13  globalDebugLevel = debugLevel;
14 }
15 
16 const DebugStream& dout(int debugLevel) {
17  if (debugLevel >= 0 && debugLevel <= globalDebugLevel)
18  return debugStream;
19  return nullStream;
20 }
21 
22 } // namespace smaug
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