SST  14.0.0
StructuralSimulationToolkit
SST::Output Class Reference

Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file. More...

#include <output.h>

Inheritance diagram for SST::Output:
SST::Core::Serialization::serializable

Public Types

enum  output_location_t { NONE, STDOUT, STDERR, FILE }
 Choice of output location. More...
 

Public Member Functions

 Output (const std::string &prefix, uint32_t verbose_level, uint32_t verbose_mask, output_location_t location, const std::string &localoutputfilename="")
 Constructor. More...
 
 Output ()
 Default Constructor. More...
 
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. More...
 
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. More...
 
void output (const char *format,...) const
 Output the message with formatting as specified by the format parameter. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
void setPrefix (const std::string &prefix)
 Sets object prefix. More...
 
std::string getPrefix () const
 Returns object prefix.
 
void setVerboseMask (uint32_t verbose_mask)
 Sets object verbose mask. More...
 
uint32_t getVerboseMask () const
 Returns object verbose mask.
 
void setVerboseLevel (uint32_t verbose_level)
 Sets object verbose level. More...
 
uint32_t getVerboseLevel () const
 Returns object verbose level.
 
void setOutputLocation (output_location_t location)
 Sets object output location. More...
 
output_location_t getOutputLocation () const
 Returns object output location.
 
void flush () const
 This method allows for the manual flushing of the output. More...
 
void serialize_order (SST::Core::Serialization::serializer &ser) override
 
ImplementSerializable(SST::Output) private void setTargetOutput (output_location_t location)
 
void openSSTTargetFile () const
 
void closeSSTTargetFile ()
 
int getMPIWorldRank () const
 
int getMPIWorldSize () const
 
uint32_t getNumThreads () const
 
uint32_t getThreadRank () const
 
std::string buildPrefixString (uint32_t line, const std::string &file, const std::string &func) const
 
void outputprintf (uint32_t line, const std::string &file, const std::string &func, const char *format, va_list arg) const
 
void outputprintf (const char *format, va_list arg) const
 
friend int ::main (int argc, char **argv)
 
- Public Member Functions inherited from SST::Core::Serialization::serializable
virtual const char * cls_name () const =0
 
virtual uint32_t cls_id () const =0
 
virtual std::string serialization_name () const =0
 

Static Public Member Functions

static void setFileName (const std::string &filename)
 This method sets the static filename used by SST. More...
 
static OutputgetDefaultObject ()
 
static OutputsetDefaultObject (const std::string &prefix, uint32_t verbose_level, uint32_t verbose_mask, output_location_t location, const std::string &localoutputfilename="")
 
static void setWorldSize (int num_ranks, int num_threads, int mpiRank)
 
static void setThreadID (std::thread::id mach, uint32_t user)
 

Data Fields

bool m_objInitialized
 
std::string m_outputPrefix
 
uint32_t m_verboseLevel
 
uint32_t m_verboseMask
 
output_location_t m_targetLoc
 
std::FILE ** m_targetOutputRef
 
std::FILE ** m_targetFileHandleRef
 
std::string * m_targetFileNameRef
 
uint32_t * m_targetFileAccessCountRef
 
std::string m_sstLocalFileName
 
std::FILE * m_sstLocalFileHandle
 
uint32_t m_sstLocalFileAccessCount
 

Static Public Attributes

static constexpr uint32_t PrintAll = std::numeric_limits<uint32_t>::max()
 
static Output m_defaultObject
 
static std::string m_sstGlobalSimFileName = ""
 
static std::FILE * m_sstGlobalSimFileHandle = nullptr
 
static uint32_t m_sstGlobalSimFileAccessCount = 0
 
static std::unordered_map< std::thread::id, uint32_t > m_threadMap
 
static int m_worldSize_ranks
 
static int m_worldSize_threads
 
static int m_mpiRank = 0
 
- Static Public Attributes inherited from SST::Core::Serialization::serializable
static constexpr uint32_t NullClsId = std::numeric_limits<uint32_t>::max()
 

Additional Inherited Members

- Protected Types inherited from SST::Core::Serialization::serializable
enum  cxn_flag_t { ConstructorFlag }
 
- Static Protected Member Functions inherited from SST::Core::Serialization::serializable
static void serializable_abort (uint32_t line, const char *file, const char *func, const char *obj)
 

Detailed Description

Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file.

All components should use this class to log any information.

Member Enumeration Documentation

◆ output_location_t

Choice of output location.

Enumerator
NONE 

No output

STDOUT 

Print to stdout

STDERR 

Print to stderr

FILE 

Print to a file

Constructor & Destructor Documentation

◆ Output() [1/2]

SST::Output::Output ( const std::string &  prefix,
uint32_t  verbose_level,
uint32_t  verbose_mask,
output_location_t  location,
const std::string &  localoutputfilename = "" 
)

Constructor.

Set up output configuration.

Parameters
prefixPrefix to be prepended to all strings emitted by calls to debug(), verbose(), fatal() and possibly output(). NOTE: No space will be inserted between the prepended prefix string and the normal output string. Prefix can contain the following escape codes:
  • @f Name of the file in which output call was made.
  • @l Line number in the file in which output call was made.
  • @p Name of the function from which output call was made.
  • @r MPI rank of the calling process. Will be empty if MPI_COMM_WORLD size is 1.
  • @R MPI rank of the calling process. Will be 0 if MPI_COMM_WORLD size is 1.
  • @i Thread Id of the calling process. Will be empty if number of threads is 1.
  • @I Thread Id of the calling process. Will be 0 if number of threads is 1.
  • @x Rank information of the calling process. Will be empty if number of MPI ranks and number of threads are both 1 Same as [@r:@i]
  • @X Rank information of the calling process. Will be [0.0] if number of MPI ranks and number of threads are both 1 Same as [@R:@I]
  • @t Simulation time. Will be the raw simulation cycle time retrieved from the SST Core.
verbose_levelDebugging output level. Calls to debug(), verbose() and fatal() are only output if their output_level parameter is less than or equal to the verbose_level currently set for the object
verbose_maskBitmask of allowed message types for debug(), verbose() and fatal(). The Output object will only output the message if the set bits of the output_bits parameter are set in the verbose_mask of the object. It uses this logic: if (~verbose_mask & output_bits == 0) then output is enabled.
locationOutput location. Output will be directed to STDOUT, STDERR, FILE, or NONE. If FILE output is selected, the output will be directed to the file defined by the –debug runtime parameter, or to the file 'sst_output' if the –debug parameter is not defined. If the size of MPI_COMM_WORLD is > 1, then the rank process will be appended to the file name.
localoutputfilename.Send the output of this class to the file identified in localoutputfilename instead of the of the normal output file set by the run time parameter –debug-file. location parameter must be set to FILE. This parameter is intended for special case debug purposes only.

References init().

◆ Output() [2/2]

SST::Output::Output ( )

Default Constructor.

User must call init() to properly initialize obj. Until init() is called, no output will occur.

References NONE.

Member Function Documentation

◆ debug()

void SST::Output::debug ( uint32_t  line,
const char *  file,
const char *  func,
uint32_t  output_level,
uint32_t  output_bits,
const char *  format,
  ... 
) const
inline

Output the debug message with formatting as specified by the format parameter.

Output will only occur if specified output_level and output_bits meet criteria defined by object. The output will be prepended with the expanded prefix set in the object. NOTE: Debug outputs will only occur if the SST_DEBUG_OUTPUT is defined. this define can be set in source code or by setting the –enable-debug option during SST configuration.

Parameters
lineLine number of calling function (use CALL_INFO macro)
fileFile name calling function (use CALL_INFO macro)
funcFunction name calling function (use CALL_INFO macro)
output_levelFor output to occur, output_level must be less than or equal to verbose_level set in object
output_bitsThe Output object will only output the message if the set bits of the output_bits parameter are set in the verbose_mask of the object. It uses this logic: if (~verbose_mask & output_bits == 0) then output is enabled.
formatFormat string. All valid formats for printf are available.
...Arguments for format.

References NONE.

◆ debugPrefix()

void SST::Output::debugPrefix ( const char *  tempPrefix,
uint32_t  line,
const char *  file,
const char *  func,
uint32_t  output_level,
uint32_t  output_bits,
const char *  format,
  ... 
)
inline

Output the debug message with formatting as specified by the format parameter.

Output will only occur if specified output_level and output_bits meet criteria defined by object. The output will be prepended with the expanded prefix set in the object.

Parameters
tempPrefixFor just this call use this prefix
lineLine number of calling function (use CALL_INFO macro)
fileFile name calling function (use CALL_INFO macro)
funcFunction name calling function (use CALL_INFO macro)
output_levelFor output to occur, output_level must be less than or equal to verbose_level set in object
output_bitsThe Output object will only output the message if the set bits of the output_bits parameter are set in the verbose_mask of the object. It uses this logic: if (~verbose_mask & output_bits == 0) then output is enabled.
formatFormat string. All valid formats for printf are available.
...Arguments for format.

References NONE.

◆ fatal()

void SST::Output::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.

Message will be sent to the output location and to stderr. The output will be prepended with the expanded prefix set in the object. NOTE: fatal() will call MPI_Abort(exit_code) to terminate simulation.

Parameters
lineLine number of calling function (use CALL_INFO macro)
fileFile name calling function (use CALL_INFO macro)
funcFunction name calling function (use CALL_INFO macro)
exit_codeThe exit code used for termination of simulation. will be passed to MPI_Abort()
formatFormat string. All valid formats for printf are available.
...Arguments for format.

References SST::Simulation_impl::emergencyShutdown(), flush(), NONE, STDERR, and STDOUT.

Referenced by SST::Event::clone(), SST::Factory::CreateComponent(), SST::Core::SSTPythonModelDefinition::createConfigGraph(), SST::Factory::CreatePartitioner(), SST::SSTElementPythonModule::createPrimaryModule(), SST::Factory::CreateStatistic(), SST::Factory::DoesSubComponentSlotExist(), SST::Factory::GetComponentInfoStatisticEnableLevel(), SST::Factory::GetComponentInfoStatisticUnits(), SST::Simulation_impl::getNextClockCycle(), SST::Factory::getParamNames(), SST::TimeLord::getTimeConverter(), SST::Simulation_impl::intializeProfileTools(), SST::Factory::isPortNameValid(), SST::Factory::isProfilePointValid(), SST::BaseComponent::isUserSubComponentLoadableUsingAPI(), SST::BaseComponent::loadUserSubComponent(), SST::Statistics::Statistic< void >::outputStatisticFields(), SST::Core::Serialization::pvt::ser_packer::pack_buffer(), SST::Link::recv(), SST::Exit::refDec(), SST::Link::replaceFunctor(), SST::Simulation_impl::reregisterClock(), SST::Link::send_impl(), SST::Link::sendUntimedData(), SST::Link::setFunctor(), and SST::Core::Serialization::pvt::ser_unpacker::unpack_buffer().

◆ flush()

void SST::Output::flush ( ) const
inline

This method allows for the manual flushing of the output.

Referenced by fatal().

◆ init()

void SST::Output::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.

Parameters
prefixPrefix to be prepended to all strings emitted by calls to debug(), verbose(), fatal() and possibly output(). NOTE: No space will be inserted between the prepended prefix string and the normal output string. Prefix can contain the following escape codes:
  • @f Name of the file in which output call was made.
  • @l Line number in the file in which output call was made.
  • @p Name of the function from which output call was made.
  • @r MPI rank of the calling process. Will be empty if MPI_COMM_WORLD size is 1.
  • @R MPI rank of the calling process. Will be 0 if MPI_COMM_WORLD size is 1.
  • @i Thread Id of the calling process. Will be empty if number of threads is 1.
  • @I Thread Id of the calling process. Will be 0 if number of threads is 1.
  • @x Rank information of the calling process. Will be empty if number of MPI ranks and number of threads are both 1 Same as [@r:@i]
  • @X Rank information of the calling process. Will be [0.0] if number of MPI ranks and number of threads are both 1 Same as [@R:@I]
  • @t Simulation time. Will be the raw simulation cycle time retrieved from the SST Core.
verbose_levelDebugging output level. Calls to debug(), verbose() and fatal() are only output if their output_level parameter is less than or equal to the verbose_level currently set for the object
verbose_maskBitmask of allowed message types for debug(), verbose() and fatal(). The Output object will only output the message if the set bits of the output_bits parameter are set in the verbose_mask of the object. It uses this logic: if (~verbose_mask & output_bits == 0) then output is enabled.
locationOutput location. Output will be directed to STDOUT, STDERR, FILE, or NONE. If FILE output is selected, the output will be directed to the file defined by the –debug runtime parameter, or to the file 'sst_output' if the –debug parameter is not defined. If the size of MPI_COMM_WORLD is > 1, then the rank process will be appended to the file name.
localoutputfilename.Send the output of this class to the file identified in localoutputfilename instead of the of the normal output file set by the run time parameter –debug-file. location parameter must be set to FILE. This parameter is intended for special case debug purposes only.

Referenced by Output().

◆ output() [1/2]

void SST::Output::output ( uint32_t  line,
const char *  file,
const char *  func,
const char *  format,
  ... 
) const
inline

Output the message with formatting as specified by the format parameter.

The output will be prepended with the expanded prefix set in the object.

Parameters
lineLine number of calling function (use CALL_INFO macro)
fileFile name calling function (use CALL_INFO macro)
funcFunction name calling function (use CALL_INFO macro)
formatFormat string. All valid formats for printf are available.
...Argument strings for format.

References NONE.

Referenced by SST::SimulatorHeartbeat::execute(), SST::CheckpointAction::execute(), SST::CoreTestMemPoolTest::MemPoolTestComponent::finish(), SST::IMPL::TimeVortexPQBase< true >::print(), SST::OneShot::print(), SST::Exit::print(), SST::IMPL::TimeVortexBinnedMapBase< true >::print(), SST::Params::print_all_params(), SST::Simulation_impl::printStatus(), SST::Statistics::StatisticOutputTextBase::printUsage(), SST::Statistics::StatisticOutputJSON::printUsage(), SST::Statistics::StatisticOutputCSV::printUsage(), and SST::Params::verifyKey().

◆ output() [2/2]

void SST::Output::output ( const char *  format,
  ... 
) const
inline

Output the message with formatting as specified by the format parameter.

Parameters
formatFormat string. All valid formats for printf are available.
...Arguments for format.

References NONE.

◆ setFileName()

void SST::Output::setFileName ( const std::string &  filename)
static

This method sets the static filename used by SST.

It can only be called once, and is automatically called by the SST Core. No components should call this method.

◆ setOutputLocation()

void SST::Output::setOutputLocation ( output_location_t  location)

Sets object output location.

Parameters
locationOutput location. Output will be directed to STDOUT, STDERR, FILE, or NONE. If FILE output is selected, the output will be directed to the file defined by the –debug runtime parameter, or to the file 'sst_output' if the –debug parameter is not defined. If the size of MPI_COMM_WORLD is > 1, then the rank process will be appended to the file name.

◆ setPrefix()

void SST::Output::setPrefix ( const std::string &  prefix)

Sets object prefix.

Parameters
prefixPrefix to be prepended to all strings emitted by calls to debug(), verbose(), fatal() and possibly output(). NOTE: No space will be inserted between the prepended prefix string and the normal output string. Prefix can contain the following escape codes:
  • @f Name of the file in which output call was made.
  • @l Line number in the file in which output call was made.
  • @p Name of the function from which output call was made.
  • @r MPI rank of the calling process. Will be empty if MPI_COMM_WORLD size is 1.
  • @R MPI rank of the calling process. Will be 0 if MPI_COMM_WORLD size is 1.
  • @i Thread Id of the calling process. Will be empty if number of threads is 1.
  • @I Thread Id of the calling process. Will be 0 if number of threads is 1.
  • @x Rank information of the calling process. Will be empty if number of MPI ranks and number of threads are both 1 Same as [@r:@i]
  • @X Rank information of the calling process. Will be [0.0] if number of MPI ranks and number of threads are both 1 Same as [@R:@I]
  • @t Simulation time. Will be the raw simulation cycle time retrieved from the SST Core.

◆ setVerboseLevel()

void SST::Output::setVerboseLevel ( uint32_t  verbose_level)

Sets object verbose level.

Parameters
verbose_levelDebugging output level. Calls to debug(), verbose() and fatal() are only output if their output_level parameter is less than or equal to the verbose_level currently set for the object

◆ setVerboseMask()

void SST::Output::setVerboseMask ( uint32_t  verbose_mask)

Sets object verbose mask.

Parameters
verbose_maskBitmask of allowed message types for debug(), verbose() and fatal(). The Output object will only output the message if the set bits of the output_bits parameter are set in the verbose_mask of the object. It uses this logic: if (~verbose_mask & output_bits == 0) then output is enabled.

◆ verbose()

void SST::Output::verbose ( uint32_t  line,
const char *  file,
const char *  func,
uint32_t  output_level,
uint32_t  output_bits,
const char *  format,
  ... 
) const
inline

Output the verbose message with formatting as specified by the format parameter.

Output will only occur if specified output_level and output_bits meet criteria defined by object. The output will be prepended with the expanded prefix set in the object.

Parameters
lineLine number of calling function (use CALL_INFO macro)
fileFile name calling function (use CALL_INFO macro)
funcFunction name calling function (use CALL_INFO macro)
output_levelFor output to occur, output_level must be less than or equal to verbose_level set in object
output_bitsThe Output object will only output the message if the set bits of the output_bits parameter are set in the verbose_mask of the object. It uses this logic: if (~verbose_mask & output_bits == 0) then output is enabled.
formatFormat string. All valid formats for printf are available.
...Arguments for format.

References NONE.

Referenced by SST::Core::SSTPythonModelDefinition::createConfigGraph(), and SST::Exit::refDec().

◆ verbosePrefix()

void SST::Output::verbosePrefix ( const char *  tempPrefix,
uint32_t  line,
const char *  file,
const char *  func,
uint32_t  output_level,
uint32_t  output_bits,
const char *  format,
  ... 
)
inline

Output the verbose message with formatting as specified by the format parameter.

Output will only occur if specified output_level and output_bits meet criteria defined by object. The output will be prepended with the expanded prefix set in the object.

Parameters
tempPrefixFor just this call use this prefix
lineLine number of calling function (use CALL_INFO macro)
fileFile name calling function (use CALL_INFO macro)
funcFunction name calling function (use CALL_INFO macro)
output_levelFor output to occur, output_level must be less than or equal to verbose_level set in object
output_bitsThe Output object will only output the message if the set bits of the output_bits parameter are set in the verbose_mask of the object. It uses this logic: if (~verbose_mask & output_bits == 0) then output is enabled.
formatFormat string. All valid formats for printf are available.
...Arguments for format.

References NONE.


The documentation for this class was generated from the following files: