Peano
Loading...
Searching...
No Matches
tarch::logging::ScorePLogger Class Reference

Command Line Logger. More...

#include <ScorePLogger.h>

Collaboration diagram for tarch::logging::ScorePLogger:

Public Member Functions

 ~ScorePLogger ()
 
bool getLogMachineName () const
 Is public as some analysis frameworks check explicitly whether these features are switched on.
 
bool getLogThreadName () const
 Is public as some analysis frameworks check explicitly whether these features are switched on.
 
bool getLogTrace () const
 Is public as some analysis frameworks check explicitly whether these features are switched on.
 
bool getLogTimeStamp () const
 Is public as some analysis frameworks check explicitly whether these features are switched on.
 
void debug (long int timestampNanoseconds, int rank, int threadId, const std::string &trace, const std::string &message)
 
void info (long int timestampNanoseconds, int rank, int threadId, const std::string &trace, const std::string &message)
 
void warning (long int timestampNanoseconds, int rank, int threadId, const std::string &trace, const std::string &message)
 Write Warning.
 
void error (long int timestampNanoseconds, int rank, int threadId, const std::string &trace, const std::string &message)
 Write Error.
 
void traceIn (long int timestampNanoseconds, int rank, int threadId, const std::string &trace, const std::string &message)
 
void traceOut (long int timestampNanoseconds, int rank, int threadId, const std::string &trace, const std::string &message)
 Log trace out event.
 
void indent (bool indent, const std::string &trace)
 Tells the logger to increment/decrement the indent.
 
void close ()
 

Static Public Member Functions

static ScorePLogger & getInstance ()
 

Private Member Functions

ScorePLogger & operator= (const CommandLineLogger &)=delete
 Declared private since assignment does not make sense for an output class (output information mismatch).
 
 ScorePLogger (const ScorePLogger &)=delete
 Declared private since copying does not make sense for an output class (output information mismatch).
 
std::string constructMessageString (std::string messageType, long int timestampNanoseconds, int rank, int threadId, const std::string &trace, const std::string &message)
 Construct message string.
 
 ScorePLogger ()
 It's a singleton.
 
std::string getTimeStampHumanReadable (long int timestampNanoseconds) const
 

Private Attributes

tarch::multicore::MultiReadSingleWriteSemaphore _semaphore
 

Static Private Attributes

static Log _log
 
static ScorePLogger _singleton
 

Detailed Description

Command Line Logger.

Log output device connecting to Score-P. Implements the LogHandle. Usually there's only one instance of this class for only the Log type aggregates it in a static way.

The logger accepts trace and log statements and forwards them to Score-P. Information messages, warning and errors are also piped onto the terminal. We follow the Score-P documentation from

https://www.vi-hps.org/projects/score-p/documentation/documentation.html

Implementation

The idea is that the tracing holds one region handle per traced function. Per handle, we have to call

SCOREP_USER_REGION_DEFINE
SCOREP_USER_REGION_INIT
SCOREP_USER_REGION_ENTER
SCOREP_USER_REGION_END

in line with https://perftools.pages.jsc.fz-juelich.de/cicd/scorep/tags/latest/html/group__SCOREP__User.html#ga8c8f772145f95dce57dcf86b6998365c. Obviously, define and init should be called only once, while we have an arbitrary number of enter-end calls.

The logger works with lazy generation of regions.

Obviously, we cannot use the define macro, as it creates a static instance and we work with lookup tables here instead of static attributes. Therefore, we do not work with the SCOREP_USER_REGION_DEFINE macro but instead directly with the underlying data type.

Relation to Score-P instrumentation

All of the Score-P labels here are logical. That is, they are tied to the logical function name and not the real one. In practice, this is not true, as Peano uses a lot of trace in and trace out macros to annotate specific regions. Anyway, we kind of replicate the Score-P instrumentation and both the instrumentation and the ScorePLogger can be used in tandem.

Version
Revision
1.19
Author
Tobias Weinzierl

Definition at line 79 of file ScorePLogger.h.

Constructor & Destructor Documentation

◆ ScorePLogger() [1/2]

tarch::logging::ScorePLogger::ScorePLogger ( const ScorePLogger &  )
privatedelete

Declared private since copying does not make sense for an output class (output information mismatch).

◆ ScorePLogger() [2/2]

tarch::logging::ScorePLogger::ScorePLogger ( )
private

It's a singleton.

◆ ~ScorePLogger()

tarch::logging::ScorePLogger::~ScorePLogger ( )

Member Function Documentation

◆ close()

void tarch::logging::ScorePLogger::close ( )

◆ constructMessageString()

std::string tarch::logging::ScorePLogger::constructMessageString ( std::string  messageType,
long int  timestampNanoseconds,
int  rank,
int  threadId,
const std::string &  trace,
const std::string &  message 
)
private

Construct message string.

!!! Thread Safety

The message string relies on the global field _indent. This one might change throughout the execution of this method. However, I accept such a behavior: Changing _indent throughout the message execution makes the method add the wrong number of whitespaces in front of the message. That is a 'bug' we can accept.

To satisfy Intel Inspector et al at least slightly, I copy over _indent before I actually construct the message string. So the indent can't change while we add the spaces/tabs to the output.

◆ debug()

void tarch::logging::ScorePLogger::debug ( long int  timestampNanoseconds,
int  rank,
int  threadId,
const std::string &  trace,
const std::string &  message 
)

◆ error()

void tarch::logging::ScorePLogger::error ( long int  timestampNanoseconds,
int  rank,
int  threadId,
const std::string &  trace,
const std::string &  message 
)

Write Error.

In the implementation, I call a flush on cout before I write to cerr. Otherwise, the cerr messages might overtake cout. Before the operation returns, it does a flush on cerr, too. Otherwise, the message might not occur, i.e. the application might shut down before the message is flushed to the terminal.

◆ getInstance()

static ScorePLogger & tarch::logging::ScorePLogger::getInstance ( )
static

◆ getLogMachineName()

bool tarch::logging::ScorePLogger::getLogMachineName ( ) const

Is public as some analysis frameworks check explicitly whether these features are switched on.

◆ getLogThreadName()

bool tarch::logging::ScorePLogger::getLogThreadName ( ) const

Is public as some analysis frameworks check explicitly whether these features are switched on.

◆ getLogTimeStamp()

bool tarch::logging::ScorePLogger::getLogTimeStamp ( ) const

Is public as some analysis frameworks check explicitly whether these features are switched on.

◆ getLogTrace()

bool tarch::logging::ScorePLogger::getLogTrace ( ) const

Is public as some analysis frameworks check explicitly whether these features are switched on.

◆ getTimeStampHumanReadable()

std::string tarch::logging::ScorePLogger::getTimeStampHumanReadable ( long int  timestampNanoseconds) const
private

◆ indent()

void tarch::logging::ScorePLogger::indent ( bool  indent,
const std::string &  trace 
)

Tells the logger to increment/decrement the indent.

For Score-P, we do not need any indentation. Consequently, we put the nop implementation into the header, so the compiler can inline the call and eventually remove it completely.

Definition at line 212 of file ScorePLogger.h.

◆ info()

void tarch::logging::ScorePLogger::info ( long int  timestampNanoseconds,
int  rank,
int  threadId,
const std::string &  trace,
const std::string &  message 
)

◆ operator=()

ScorePLogger & tarch::logging::ScorePLogger::operator= ( const CommandLineLogger &  )
privatedelete

Declared private since assignment does not make sense for an output class (output information mismatch).

◆ traceIn()

void tarch::logging::ScorePLogger::traceIn ( long int  timestampNanoseconds,
int  rank,
int  threadId,
const std::string &  trace,
const std::string &  message 
)

◆ traceOut()

void tarch::logging::ScorePLogger::traceOut ( long int  timestampNanoseconds,
int  rank,
int  threadId,
const std::string &  trace,
const std::string &  message 
)

Log trace out event.

This event forwards the call to a call of the

SCOREP_USER_REGION_END

macro. In earlier versions, it used to delegate to

SCOREP_USER_REGION_LEAVE

but that macro seems to be discontinued in Score-P 6.

◆ warning()

void tarch::logging::ScorePLogger::warning ( long int  timestampNanoseconds,
int  rank,
int  threadId,
const std::string &  trace,
const std::string &  message 
)

Write Warning.

In the implementation, I call a flush on cout before I write to cerr. Otherwise, the cerr messages might overtake cout. Before the operation returns, it does a flush on cerr, too. Otherwise, the message might not occur, i.e. the application might shut down before the message is flushed to the terminal.

Field Documentation

◆ _log

Log tarch::logging::ScorePLogger::_log
staticprivate

Definition at line 81 of file ScorePLogger.h.

◆ _semaphore

tarch::multicore::MultiReadSingleWriteSemaphore tarch::logging::ScorePLogger::_semaphore
private

Definition at line 85 of file ScorePLogger.h.

◆ _singleton

ScorePLogger tarch::logging::ScorePLogger::_singleton
staticprivate

Definition at line 83 of file ScorePLogger.h.


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