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);
354 void fatal(uint32_t line,
const char* file,
const char* func,
356 const char* format, ...) const
357 __attribute__ ((format (printf, 6, 7))) ;
388 void setPrefix(const std::
string& prefix);
430 inline
void flush()
const {std::fflush(*m_targetOutputRef);}
437 static void setFileName(
const std::string& filename);
439 static Output& getDefaultObject() {
return m_defaultObject; }
444 void openSSTTargetFile()
const;
445 void closeSSTTargetFile();
447 int getMPIWorldRank()
const;
448 int getMPIWorldSize()
const;
449 uint32_t getNumThreads()
const;
450 uint32_t getThreadRank()
const;
451 std::string buildPrefixString(uint32_t line,
452 const std::string& file,
453 const std::string& func)
const;
454 void outputprintf(uint32_t line,
455 const std::string &file,
456 const std::string &func,
459 void outputprintf(
const char *format, va_list arg)
const;
461 friend int ::main(
int argc,
char **argv);
462 static Output& setDefaultObject(
const std::string& prefix, uint32_t verbose_level,
464 std::string localoutputfilename =
"")
466 m_defaultObject.
init(prefix, verbose_level, verbose_mask, location, localoutputfilename);
467 return getDefaultObject();
470 static void setWorldSize(
const RankInfo &ri,
int mpiRank)
476 static void setThreadID(std::thread::id mach, uint32_t user)
478 m_threadMap.insert(std::make_pair(mach, user));
483 bool m_objInitialized;
484 std::string m_outputPrefix;
485 uint32_t m_verboseLevel;
486 uint32_t m_verboseMask;
489 static Output m_defaultObject;
498 std::FILE** m_targetOutputRef;
503 std::FILE** m_targetFileHandleRef;
504 std::string* m_targetFileNameRef;
505 uint32_t* m_targetFileAccessCountRef;
508 static std::string m_sstGlobalSimFileName;
509 static std::FILE* m_sstGlobalSimFileHandle;
510 static uint32_t m_sstGlobalSimFileAccessCount;
513 std::string m_sstLocalFileName;
514 std::FILE* m_sstLocalFileHandle;
515 uint32_t m_sstLocalFileAccessCount;
517 static std::unordered_map<std::thread::id, uint32_t> m_threadMap;
518 static RankInfo m_worldSize;
519 static int m_mpiRank;
526 TraceFunction(uint32_t line,
const char* file,
const char* func);
529 Output& getOutput() {
return output;}
535 std::string
function;
543 #endif // SST_CORE_OUTPUT_H
Output object provides consistent method for outputting 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:103
void setOutputLocation(output_location_t location)
Sets object output location.
Definition: output.cc:139
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:109
void setVerboseMask(uint32_t verbose_mask)
Sets object verbose mask.
Definition: output.cc:115
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:71
Output()
Default Constructor.
Definition: output.cc:59
std::string getPrefix() const
Returns object prefix.
Definition: output.cc:133
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:218
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:155
uint32_t getVerboseMask() const
Returns object verbose mask.
Definition: output.cc:121
void flush() const
This method allows for the manual flushing of the output.
Definition: output.h:430
output_location_t getOutputLocation() const
Returns object output location.
Definition: output.cc:149
void setPrefix(const std::string &prefix)
Sets object prefix.
Definition: output.cc:127