preCICE v3.1.2
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
precice::profiling::EventRegistry Class Reference

#include <EventUtils.hpp>

Collaboration diagram for precice::profiling::EventRegistry:
[legend]

Public Member Functions

 ~EventRegistry ()
 
 EventRegistry (EventRegistry const &)=delete
 Deleted copy and move SMFs for singleton pattern.
 
 EventRegistry (EventRegistry &&)=delete
 
EventRegistryoperator= (EventRegistry const &)=delete
 
EventRegistryoperator= (EventRegistry &&)=delete
 
void initialize (std::string_view applicationName, int rank=0, int size=1)
 Sets the global start time.
 
void setWriteQueueMax (std::size_t size)
 Sets the maximum size of the writequeue before calling flush(). Use 0 to flush on destruction.
 
void setDirectory (std::string_view directory)
 Sets the directory where to write the event files to.
 
void setMode (Mode mode)
 Sets the operational mode of the registry.
 
void startBackend ()
 Create the file and starts the filestream if profiling is turned on.
 
void finalize ()
 Sets the global end time and flushes buffers.
 
void clear ()
 Clears the registry.
 
void put (PendingEntry pe)
 Records an event.
 
void flush ()
 Writes all recorded events to file and flushes the buffer.
 
bool accepting (EventClass ec) const
 Should an event of this class be forwarded to the registry?
 
int nameToID (std::string_view name)
 

Static Public Member Functions

static EventRegistryinstance ()
 Returns the only instance (singleton) of the EventRegistry class.
 

Public Attributes

std::string prefix
 Currently active prefix. Changing that applies only to newly created events.
 

Private Member Functions

 EventRegistry ()=default
 Private, empty constructor for singleton pattern.
 
void stopBackend ()
 Stops the global event, flushes the buffers and closes the filestream.
 

Private Attributes

std::string _applicationName
 The name of the current participant.
 
std::string _directory
 
Mode _mode = Mode::Fundamental
 The operational mode of the registry.
 
int _rank = 0
 The rank/number of parallel instance of the current program.
 
int _size = 1
 The amount of parallel instances of the current program.
 
bool _firstwrite = true
 Indicator for the first record to be written.
 
std::optional< int > _globalId
 The id of the global event.
 
std::map< std::string, int, std::less<> > _nameDict
 
std::vector< PendingEntry_writeQueue
 
std::size_t _writeQueueMax = 0
 
std::ofstream _output
 
bool _initialized = false
 
bool _finalized = false
 
bool _isBackendRunning = false
 
Event::Clock::time_point _initClock
 The initial time clock, used to take runtime measurements.
 
std::chrono::system_clock::time_point _initTime
 The initial time, used to describe when the run started.
 
logging::Logger _log {"Events"}
 

Detailed Description

High level object that stores data of all events.

Call EventRegistry::initialize at the beginning of your application and EventRegistry::finalize at the end.

Use setWriteQueueMax() to adjust buffering behaviour.

Definition at line 80 of file EventUtils.hpp.

Constructor & Destructor Documentation

◆ ~EventRegistry()

precice::profiling::EventRegistry::~EventRegistry ( )

Definition at line 44 of file EventUtils.cpp.

Here is the call graph for this function:

◆ EventRegistry() [1/3]

precice::profiling::EventRegistry::EventRegistry ( EventRegistry const & )
delete

Deleted copy and move SMFs for singleton pattern.

◆ EventRegistry() [2/3]

precice::profiling::EventRegistry::EventRegistry ( EventRegistry && )
delete

◆ EventRegistry() [3/3]

precice::profiling::EventRegistry::EventRegistry ( )
privatedefault

Private, empty constructor for singleton pattern.

Member Function Documentation

◆ accepting()

bool precice::profiling::EventRegistry::accepting ( EventClass ec) const
inline

Should an event of this class be forwarded to the registry?

Definition at line 126 of file EventUtils.hpp.

◆ clear()

void precice::profiling::EventRegistry::clear ( )

Clears the registry.

Definition at line 177 of file EventUtils.cpp.

◆ finalize()

void precice::profiling::EventRegistry::finalize ( )

Sets the global end time and flushes buffers.

Definition at line 165 of file EventUtils.cpp.

◆ flush()

void precice::profiling::EventRegistry::flush ( )

Writes all recorded events to file and flushes the buffer.

Definition at line 232 of file EventUtils.cpp.

◆ initialize()

void precice::profiling::EventRegistry::initialize ( std::string_view applicationName,
int rank = 0,
int size = 1 )

Sets the global start time.

Parameters
[in]applicationNameA name that is added to the logfile to distinguish different participants
[in]rankthe current number of the parallel instance
[in]sizethe total number of a parallel instances

Definition at line 55 of file EventUtils.cpp.

Here is the call graph for this function:

◆ instance()

EventRegistry & precice::profiling::EventRegistry::instance ( )
static

Returns the only instance (singleton) of the EventRegistry class.

Definition at line 49 of file EventUtils.cpp.

Here is the call graph for this function:

◆ nameToID()

int precice::profiling::EventRegistry::nameToID ( std::string_view name)

Definition at line 257 of file EventUtils.cpp.

◆ operator=() [1/2]

EventRegistry & precice::profiling::EventRegistry::operator= ( EventRegistry && )
delete

◆ operator=() [2/2]

EventRegistry & precice::profiling::EventRegistry::operator= ( EventRegistry const & )
delete

◆ put()

void precice::profiling::EventRegistry::put ( PendingEntry pe)

Records an event.

Definition at line 182 of file EventUtils.cpp.

◆ setDirectory()

void precice::profiling::EventRegistry::setDirectory ( std::string_view directory)

Sets the directory where to write the event files to.

Definition at line 82 of file EventUtils.cpp.

◆ setMode()

void precice::profiling::EventRegistry::setMode ( Mode mode)

Sets the operational mode of the registry.

Definition at line 87 of file EventUtils.cpp.

◆ setWriteQueueMax()

void precice::profiling::EventRegistry::setWriteQueueMax ( std::size_t size)

Sets the maximum size of the writequeue before calling flush(). Use 0 to flush on destruction.

Definition at line 77 of file EventUtils.cpp.

◆ startBackend()

void precice::profiling::EventRegistry::startBackend ( )

Create the file and starts the filestream if profiling is turned on.

Definition at line 107 of file EventUtils.cpp.

Here is the call graph for this function:

◆ stopBackend()

void precice::profiling::EventRegistry::stopBackend ( )
private

Stops the global event, flushes the buffers and closes the filestream.

Definition at line 148 of file EventUtils.cpp.

Member Data Documentation

◆ _applicationName

std::string precice::profiling::EventRegistry::_applicationName
private

The name of the current participant.

Definition at line 138 of file EventUtils.hpp.

◆ _directory

std::string precice::profiling::EventRegistry::_directory
private

Definition at line 140 of file EventUtils.hpp.

◆ _finalized

bool precice::profiling::EventRegistry::_finalized = false
private

Definition at line 169 of file EventUtils.hpp.

◆ _firstwrite

bool precice::profiling::EventRegistry::_firstwrite = true
private

Indicator for the first record to be written.

Definition at line 152 of file EventUtils.hpp.

◆ _globalId

std::optional<int> precice::profiling::EventRegistry::_globalId
private

The id of the global event.

Definition at line 155 of file EventUtils.hpp.

◆ _initClock

Event::Clock::time_point precice::profiling::EventRegistry::_initClock
private

The initial time clock, used to take runtime measurements.

Definition at line 174 of file EventUtils.hpp.

◆ _initialized

bool precice::profiling::EventRegistry::_initialized = false
private

Definition at line 167 of file EventUtils.hpp.

◆ _initTime

std::chrono::system_clock::time_point precice::profiling::EventRegistry::_initTime
private

The initial time, used to describe when the run started.

Definition at line 177 of file EventUtils.hpp.

◆ _isBackendRunning

bool precice::profiling::EventRegistry::_isBackendRunning = false
private

Definition at line 171 of file EventUtils.hpp.

◆ _log

logging::Logger precice::profiling::EventRegistry::_log {"Events"}
private

Definition at line 182 of file EventUtils.hpp.

◆ _mode

Mode precice::profiling::EventRegistry::_mode = Mode::Fundamental
private

The operational mode of the registry.

Definition at line 143 of file EventUtils.hpp.

◆ _nameDict

std::map<std::string, int, std::less<> > precice::profiling::EventRegistry::_nameDict
private

Definition at line 160 of file EventUtils.hpp.

◆ _output

std::ofstream precice::profiling::EventRegistry::_output
private

Definition at line 165 of file EventUtils.hpp.

◆ _rank

int precice::profiling::EventRegistry::_rank = 0
private

The rank/number of parallel instance of the current program.

Definition at line 146 of file EventUtils.hpp.

◆ _size

int precice::profiling::EventRegistry::_size = 1
private

The amount of parallel instances of the current program.

Definition at line 149 of file EventUtils.hpp.

◆ _writeQueue

std::vector<PendingEntry> precice::profiling::EventRegistry::_writeQueue
private

Definition at line 162 of file EventUtils.hpp.

◆ _writeQueueMax

std::size_t precice::profiling::EventRegistry::_writeQueueMax = 0
private

Definition at line 163 of file EventUtils.hpp.

◆ prefix

std::string precice::profiling::EventRegistry::prefix

Currently active prefix. Changing that applies only to newly created events.

Definition at line 134 of file EventUtils.hpp.


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