14 #ifndef SST_CORE_OUTPUT_H
15 #define SST_CORE_OUTPUT_H
24 #ifndef __STDC_FORMAT_MACROS
25 #define __STDC_FORMAT_MACROS
30 #include <unordered_map>
34 #include <sst/core/rankInfo.h>
36 extern int main(
int argc,
char **argv);
41 #define CALL_INFO __LINE__, __FILE__, __FUNCTION__
43 #if defined(__GNUC__) || defined(__clang__)
44 #define CALL_INFO_LONG __LINE__, __FILE__, __PRETTY_FUNCTION__
46 #define CALL_INFO_LONG __LINE__, __FILE__, __FUNCTION__
113 Output(
const std::string& prefix, uint32_t verbose_level,
115 std::string localoutputfilename =
"");
172 void init(
const std::string& prefix, uint32_t verbose_level,
174 std::string localoutputfilename =
"");
184 void output(uint32_t line,
const char* file,
const char* func,
185 const char* format, ...) const
186 __attribute__ ((format (printf, 5, 6)))
189 if (
true == m_objInitialized &&
NONE != m_targetLoc ) {
191 va_start(arg, format);
192 outputprintf(line, file, func, format, arg);
201 void output(
const char* format, ...) const
202 __attribute__ ((format (printf, 2, 3)))
205 if (
true == m_objInitialized &&
NONE != m_targetLoc) {
207 va_start(arg, format);
208 outputprintf(format, arg);
229 void verbose(uint32_t line,
const char* file,
const char* func,
230 uint32_t output_level, uint32_t output_bits,
231 const char* format, ...) const
232 __attribute__ ((format (printf, 7, 8)))
236 if (
true == m_objInitialized &&
NONE != m_targetLoc ) {
239 if (((output_bits & ~m_verboseMask) == 0) &&
240 (output_level <= m_verboseLevel)){
242 va_start(arg, format);
243 outputprintf(line, file, func, format, arg);
266 void verbosePrefix(
const char* tempPrefix, uint32_t line,
const char* file,
const char* func,
267 uint32_t output_level, uint32_t output_bits,
268 const char* format, ...)
269 __attribute__ ((format (printf, 8, 9)))
274 if (
true == m_objInitialized &&
NONE != m_targetLoc ) {
275 const std::string normalPrefix = m_outputPrefix;
276 m_outputPrefix = tempPrefix;
280 if (((output_bits & ~m_verboseMask) == 0) &&
281 (output_level <= m_verboseLevel)){
283 va_start(arg, format);
284 outputprintf(line, file, func, format, arg);
288 m_outputPrefix = normalPrefix;
311 void debug(uint32_t line,
const char* file,
const char* func,
312 uint32_t output_level, uint32_t output_bits,
313 const char* format, ...) const
314 __attribute__ ((format (printf, 7, 8)))
316 #ifdef __SST_DEBUG_OUTPUT__
318 if (
true == m_objInitialized &&
NONE != m_targetLoc ) {
321 if (((output_bits & ~m_verboseMask) == 0) &&
322 (output_level <= m_verboseLevel)){
324 va_start(arg, format);
325 outputprintf(line, file, func, format, arg);
346 void fatal(uint32_t line,
const char* file,
const char* func,
348 const char* format, ...) const
349 __attribute__ ((format (printf, 6, 7))) ;
422 inline
void flush()
const {std::fflush(*m_targetOutputRef);}
429 static void setFileName(
const std::string& filename);
431 static Output& getDefaultObject() {
return m_defaultObject; }
436 void openSSTTargetFile()
const;
437 void closeSSTTargetFile();
439 int getMPIWorldRank()
const;
440 int getMPIWorldSize()
const;
441 uint32_t getNumThreads()
const;
442 uint32_t getThreadRank()
const;
443 std::string buildPrefixString(uint32_t line,
444 const std::string& file,
445 const std::string& func)
const;
446 void outputprintf(uint32_t line,
447 const std::string &file,
448 const std::string &func,
451 void outputprintf(
const char *format, va_list arg)
const;
453 friend int ::main(
int argc,
char **argv);
454 static Output& setDefaultObject(
const std::string& prefix, uint32_t verbose_level,
456 std::string localoutputfilename =
"")
458 m_defaultObject.
init(prefix, verbose_level, verbose_mask, location, localoutputfilename);
459 return getDefaultObject();
462 static void setWorldSize(
const RankInfo &ri,
int mpiRank)
468 static void setThreadID(std::thread::id mach, uint32_t user)
470 m_threadMap.insert(std::make_pair(mach, user));
475 bool m_objInitialized;
476 std::string m_outputPrefix;
477 uint32_t m_verboseLevel;
478 uint32_t m_verboseMask;
481 static Output m_defaultObject;
490 std::FILE** m_targetOutputRef;
495 std::FILE** m_targetFileHandleRef;
496 std::string* m_targetFileNameRef;
497 uint32_t* m_targetFileAccessCountRef;
500 static std::string m_sstGlobalSimFileName;
501 static std::FILE* m_sstGlobalSimFileHandle;
502 static uint32_t m_sstGlobalSimFileAccessCount;
505 std::string m_sstLocalFileName;
506 std::FILE* m_sstLocalFileHandle;
507 uint32_t m_sstLocalFileAccessCount;
509 static std::unordered_map<std::thread::id, uint32_t> m_threadMap;
510 static RankInfo m_worldSize;
511 static int m_mpiRank;
518 TraceFunction(uint32_t line,
const char* file,
const char* func);
521 Output& getOutput() {
return output;}
527 std::string
function;
535 #endif // SST_CORE_OUTPUT_H
Output object provides consistant method for outputing data to stdout, stderr and/or sst debug file...
Definition: output.h:54
void setVerboseLevel(uint32_t verbose_level)
Sets object verbose level.
Definition: output.cc:100
void setOutputLocation(output_location_t location)
Sets object output location.
Definition: output.cc:136
void debug(uint32_t line, const char *file, const char *func, uint32_t output_level, uint32_t output_bits, const char *format,...) const
Output the debug message with formatting as specified by the format parameter.
Definition: output.h:311
output_location_t
Choice of output location.
Definition: output.h:59
uint32_t getVerboseLevel() const
Returns object verbose level.
Definition: output.cc:106
void setVerboseMask(uint32_t verbose_mask)
Sets object verbose mask.
Definition: output.cc:112
void output(const char *format,...) const
Output the message with formatting as specified by the format parameter.
Definition: output.h:201
void init(const std::string &prefix, uint32_t verbose_level, uint32_t verbose_mask, output_location_t location, std::string localoutputfilename="")
Initialize the object after construction.
Definition: output.cc:68
Output()
Default Constructor.
Definition: output.cc:56
std::string getPrefix() const
Returns object prefix.
Definition: output.cc:130
void verbose(uint32_t line, const char *file, const char *func, uint32_t output_level, uint32_t output_bits, const char *format,...) const
Output the verbose message with formatting as specified by the format parameter.
Definition: output.h:229
void verbosePrefix(const char *tempPrefix, uint32_t line, const char *file, const char *func, uint32_t output_level, uint32_t output_bits, const char *format,...)
Output the verbose message with formatting as specified by the format parameter.
Definition: output.h:266
static void setFileName(const std::string &filename)
This method sets the static filename used by SST.
Definition: output.cc:215
void output(uint32_t line, const char *file, const char *func, const char *format,...) const
Output the message with formatting as specified by the format parameter.
Definition: output.h:184
void fatal(uint32_t line, const char *file, const char *func, uint32_t exit_code, const char *format,...) const
Output the fatal message with formatting as specified by the format parameter.
Definition: output.cc:152
uint32_t getVerboseMask() const
Returns object verbose mask.
Definition: output.cc:118
void flush() const
This method allows for the manual flushing of the output.
Definition: output.h:422
output_location_t getOutputLocation() const
Returns object output location.
Definition: output.cc:146
void setPrefix(const std::string &prefix)
Sets object prefix.
Definition: output.cc:124