12 #ifndef SST_CORE_OUTPUT_H 13 #define SST_CORE_OUTPUT_H 15 #include "sst/core/serialization/serializer_fwd.h" 25 #ifndef __STDC_FORMAT_MACROS 26 #define __STDC_FORMAT_MACROS 33 #include <unordered_map> 35 extern int main(
int argc,
char** argv);
40 #define CALL_INFO __LINE__, __FILE__, __FUNCTION__ 42 #if defined(__GNUC__) || defined(__clang__) 43 #define CALL_INFO_LONG __LINE__, __FILE__, __PRETTY_FUNCTION__ 45 #define CALL_INFO_LONG __LINE__, __FILE__, __FUNCTION__ 65 static constexpr uint32_t PrintAll = std::numeric_limits<uint32_t>::max();
115 const std::string& prefix, uint32_t verbose_level, uint32_t verbose_mask,
output_location_t location,
116 const std::string& localoutputfilename =
"");
173 const std::string& prefix, uint32_t verbose_level, uint32_t verbose_mask,
output_location_t location,
174 const std::string& localoutputfilename =
"");
184 void output(uint32_t line,
const char* file,
const char* func,
const char* format, ...) const
185 __attribute__((format(printf, 5, 6)))
188 if (
true == m_objInitialized &&
NONE != m_targetLoc ) {
190 va_start(arg, format);
191 outputprintf(line, file, func, format, arg);
200 void output(
const char* format, ...) const __attribute__((format(printf, 2, 3)))
203 if (
true == m_objInitialized &&
NONE != m_targetLoc ) {
205 va_start(arg, format);
206 outputprintf(format, arg);
228 uint32_t line,
const char* file,
const char* func, uint32_t output_level, uint32_t output_bits,
229 const char* format, ...) const __attribute__((format(printf, 7, 8)))
233 if (
true == m_objInitialized &&
NONE != m_targetLoc ) {
236 if ( ((output_bits & ~m_verboseMask) == 0) && (output_level <= m_verboseLevel) ) {
238 va_start(arg, format);
239 outputprintf(line, file, func, format, arg);
263 const char* tempPrefix, uint32_t line,
const char* file,
const char* func, uint32_t output_level,
264 uint32_t output_bits,
const char* format, ...) __attribute__((format(printf, 8, 9)))
269 if (
true == m_objInitialized &&
NONE != m_targetLoc ) {
270 const std::string normalPrefix = m_outputPrefix;
271 m_outputPrefix = tempPrefix;
275 if ( ((output_bits & ~m_verboseMask) == 0) && (output_level <= m_verboseLevel) ) {
277 va_start(arg, format);
278 outputprintf(line, file, func, format, arg);
282 m_outputPrefix = normalPrefix;
304 const char* tempPrefix, uint32_t line,
const char* file,
const char* func, uint32_t output_level,
305 uint32_t output_bits,
const char* format, ...) __attribute__((format(printf, 8, 9)))
308 #ifdef __SST_DEBUG_OUTPUT__ 311 if (
true == m_objInitialized &&
NONE != m_targetLoc ) {
312 const std::string normalPrefix = m_outputPrefix;
313 m_outputPrefix = tempPrefix;
317 if ( ((output_bits & ~m_verboseMask) == 0) && (output_level <= m_verboseLevel) ) {
319 va_start(arg, format);
320 outputprintf(line, file, func, format, arg);
324 m_outputPrefix = normalPrefix;
358 uint32_t line,
const char* file,
const char* func, uint32_t output_level, uint32_t output_bits,
359 const char* format, ...) const __attribute__((format(printf, 7, 8)))
361 #ifdef __SST_DEBUG_OUTPUT__ 363 if (
true == m_objInitialized &&
NONE != m_targetLoc ) {
366 if ( ((output_bits & ~m_verboseMask) == 0) && (output_level <= m_verboseLevel) ) {
368 va_start(arg, format);
369 outputprintf(line, file, func, format, arg);
397 void fatal(uint32_t line,
const char* file,
const char* func,
int exit_code,
const char* format, ...) const
398 __attribute__((format(printf, 6, 7)));
470 inline
void flush()
const { std::fflush(*m_targetOutputRef); }
476 static void setFileName(
const std::string& filename);
478 static Output& getDefaultObject() {
return m_defaultObject; }
483 friend class TraceFunction;
486 void openSSTTargetFile()
const;
487 void closeSSTTargetFile();
489 int getMPIWorldRank()
const;
490 int getMPIWorldSize()
const;
491 uint32_t getNumThreads()
const;
492 uint32_t getThreadRank()
const;
493 std::string buildPrefixString(uint32_t line,
const std::string& file,
const std::string& func)
const;
495 uint32_t line,
const std::string& file,
const std::string& func,
const char* format, va_list arg)
const;
496 void outputprintf(
const char* format, va_list arg)
const;
500 outputprintf(uint32_t line,
const std::string& file,
const std::string& func,
const char* format, ...)
const 503 va_start(args, format);
504 outputprintf(line, file, func, format, args);
508 inline void outputprintf(
const char* format, ...)
const 511 va_start(args, format);
512 outputprintf(format, args);
516 friend int ::main(
int argc,
char** argv);
517 static Output& setDefaultObject(
518 const std::string& prefix, uint32_t verbose_level, uint32_t verbose_mask,
output_location_t location,
519 const std::string& localoutputfilename =
"")
521 m_defaultObject.
init(prefix, verbose_level, verbose_mask, location, localoutputfilename);
522 return getDefaultObject();
525 static void setWorldSize(
int num_ranks,
int num_threads,
int mpiRank)
527 m_worldSize_ranks = num_ranks;
528 m_worldSize_threads = num_threads;
532 static void setThreadID(std::thread::id mach, uint32_t user) { m_threadMap.insert(std::make_pair(mach, user)); }
535 bool m_objInitialized;
536 std::string m_outputPrefix;
537 uint32_t m_verboseLevel;
538 uint32_t m_verboseMask;
541 static Output m_defaultObject;
550 std::FILE** m_targetOutputRef;
555 std::FILE** m_targetFileHandleRef;
556 std::string* m_targetFileNameRef;
557 uint32_t* m_targetFileAccessCountRef;
560 static std::string m_sstGlobalSimFileName;
561 static std::FILE* m_sstGlobalSimFileHandle;
562 static uint32_t m_sstGlobalSimFileAccessCount;
565 std::string m_sstLocalFileName;
566 std::FILE* m_sstLocalFileHandle;
567 uint32_t m_sstLocalFileAccessCount;
569 static std::unordered_map<std::thread::id, uint32_t> m_threadMap;
570 static int m_worldSize_ranks;
571 static int m_worldSize_threads;
573 static int m_mpiRank;
602 thread_local
static int trace_level;
603 thread_local
static std::vector<char> indent_array;
606 TraceFunction(uint32_t line,
const char* file,
const char* func,
bool print_sim_info =
true,
bool activate =
true);
613 void output(
const char* format, ...)
const __attribute__((format(printf, 2, 3)));
619 std::string function_;
624 static bool global_active_;
625 static char indent_marker_;
630 #endif // SST_CORE_OUTPUT_H Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file...
Definition: output.h:53
void setVerboseLevel(uint32_t verbose_level)
Sets object verbose level.
Definition: output.cc:111
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:43
void setOutputLocation(output_location_t location)
Sets object output location.
Definition: output.cc:147
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:227
void fatal(uint32_t line, const char *file, const char *func, int exit_code, const char *format,...) const
Output the fatal message with formatting as specified by the format parameter.
Definition: output.cc:163
output_location_t
Choice of output location.
Definition: output.h:58
void setVerboseMask(uint32_t verbose_mask)
Sets object verbose mask.
Definition: output.cc:123
Output()
Default Constructor.
Definition: output.cc:67
void flush() const
This method allows for the manual flushing of the output.
Definition: output.h:470
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:262
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:357
Class to easily trace function enter and exit.
Definition: output.h:600
void debugPrefix(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 debug message with formatting as specified by the format parameter.
Definition: output.h:303
static void setFileName(const std::string &filename)
This method sets the static filename used by SST.
Definition: output.cc:235
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
output_location_t getOutputLocation() const
Returns object output location.
Definition: output.cc:157
uint32_t getVerboseLevel() const
Returns object verbose level.
Definition: output.cc:117
void init(const std::string &prefix, uint32_t verbose_level, uint32_t verbose_mask, output_location_t location, const std::string &localoutputfilename="")
Initialize the object after construction.
Definition: output.cc:80
uint32_t getVerboseMask() const
Returns object verbose mask.
Definition: output.cc:129
void setPrefix(const std::string &prefix)
Sets object prefix.
Definition: output.cc:135
std::string getPrefix() const
Returns object prefix.
Definition: output.cc:141
void output(const char *format,...) const
Output the message with formatting as specified by the format parameter.
Definition: output.h:200
void output(const char *format,...) const
Output the message with formatting as specified by the format parameter.
Definition: output.cc:580