walberla::timeloop::PerformanceMeter Class Reference

#include <PerformanceMeter.h>

Classes

struct  Measurement
 This struct holds a measurement definition. More...
 

Public Types

using CountFunction = std::function< uint_t(const IBlock &)>
 

Public Member Functions

 PerformanceMeter (StructuredBlockStorage &blockStorage)
 Creates a PerformanceMeter To actually measure performance, the class has to be connected to a timeloop. More...
 
Timeloop Wiring
void operator() ()
 Call operator which starts/stops the measurement. More...
 
void timingStart ()
 This function is wrapped and returned in getBeforeFunction() More...
 
void timingEnd ()
 This function is wrapped and returned in getAfterFunction() More...
 
std::function< void() > getBeforeFunction ()
 Returns a pointer to the function that starts all measurements Use this function to connect a PerformanceMeter to a timeloop. More...
 
std::function< void() > getAfterFunction ()
 Returns a pointer to the function that ends all measurements Use this function to connect a PerformanceMeter to a timeloop. More...
 
void clear ()
 Resets Timings. More...
 
Measurement Definitions
void addMeasurement (const std::string &name, const CountFunction &countFunction, uint_t countFreq=0, real_t scaling=1)
 Adds a performance measurement, associated with all cells (usually MLUPS) More...
 
void addMeasurement (const std::string &name, real_t scaling=1)
 Adds a performance measurement, associated with all cells (usually MLUPS) More...
 
template<typename FField >
void addMeasurementBasedOnFlagField (const std::string &name, ConstBlockDataID flagFieldID, typename FField::flag_t activeMask, uint_t countFreq=0, real_t scaling=1)
 

Output

WcTimer timer_
 
StructuredBlockStorageblockStorage_
 
std::vector< Measurementmeasurements_
 
bool firstTimingStartStopCall_
 Used for operator() to indicate if called the first time. More...
 
void logResultOnRoot ()
 Logs all added performance measurements on the root process. More...
 
void print (std::ostream &os, int targetRank=0)
 Prints all added measurements to the given output stream on specified process. More...
 
shared_ptr< std::map< std::string, real_t > > getReduced (int targetRank=0)
 Collects the result of the PerformanceMeter from all MPI_Processes. More...
 
void timingStartStop ()
 
void reduce (std::vector< real_t > &totalCells, int targetRank)
 Communicates the total number of cells among processes. More...
 
void updateCellCounts ()
 Loops over measurements and updates them if necessary. More...
 

Member Typedef Documentation

◆ CountFunction

Constructor & Destructor Documentation

◆ PerformanceMeter()

walberla::timeloop::PerformanceMeter::PerformanceMeter ( StructuredBlockStorage blockStorage)

Creates a PerformanceMeter To actually measure performance, the class has to be connected to a timeloop.

see getBeforeFunction() and getAfterFunction()

Parameters
blockStorageblock storage is needed to retrieve the FlagField for cell counting

Member Function Documentation

◆ addMeasurement() [1/2]

void walberla::timeloop::PerformanceMeter::addMeasurement ( const std::string &  name,
const CountFunction countFunction,
uint_t  countFreq = 0,
real_t  scaling = 1 
)

Adds a performance measurement, associated with all cells (usually MLUPS)

Parameters
namename of the performance number (f.e. MLUPS)
countFunctionthis function is called very countFreq'th call and has to return the number of 'active' cells on the given block
countFreqfrequency of counting, if zero the counting happens once in the beginning
scalingThe performance number is multiplied with this scaling factor before printing. Example MLUPS , for the "M" a factor of 1e-6 is needed

Behaves like addMeasurement() function above, with n= total number of cells

◆ addMeasurement() [2/2]

void walberla::timeloop::PerformanceMeter::addMeasurement ( const std::string &  name,
real_t  scaling = 1 
)

Adds a performance measurement, associated with all cells (usually MLUPS)

Parameters
namename of the performance number (f.e. MLUPS)
scalingThe performance number is multiplied with this scaling factor before printing. Example MLUPS , for the "M" a factor of 1e-6 is needed

Behaves like addMeasurement() function above, with n= total number of cells

◆ addMeasurementBasedOnFlagField()

template<typename FField >
void walberla::timeloop::PerformanceMeter::addMeasurementBasedOnFlagField ( const std::string &  name,
ConstBlockDataID  flagFieldID,
typename FField::flag_t  activeMask,
uint_t  countFreq = 0,
real_t  scaling = 1 
)

◆ clear()

void walberla::timeloop::PerformanceMeter::clear ( )

Resets Timings.

Added measurements are not cleared.

◆ getAfterFunction()

std::function< void() > walberla::timeloop::PerformanceMeter::getAfterFunction ( )

Returns a pointer to the function that ends all measurements Use this function to connect a PerformanceMeter to a timeloop.

timeloop.addFuncAfterTimeStep ( perfMeter.getAfterFunction() );

◆ getBeforeFunction()

std::function< void() > walberla::timeloop::PerformanceMeter::getBeforeFunction ( )

Returns a pointer to the function that starts all measurements Use this function to connect a PerformanceMeter to a timeloop.

timeloop.addFuncBeforeTimeStep( perfMeter.getBeforeFunction() );

◆ getReduced()

shared_ptr< std::map< std::string, real_t > > walberla::timeloop::PerformanceMeter::getReduced ( int  targetRank = 0)

Collects the result of the PerformanceMeter from all MPI_Processes.

Parameters
targetRankMPI world rank of the process where the PerformanceMeter is reduced to on all other processes a null pointer is returned. If targetRank < 0 all processes have a valid result
Returns
a map of measurement-name to measurement value if (worldRank == targetRank ) || targetRank < 0 and a null pointer otherwise

◆ logResultOnRoot()

void walberla::timeloop::PerformanceMeter::logResultOnRoot ( )

Logs all added performance measurements on the root process.

◆ operator()()

void walberla::timeloop::PerformanceMeter::operator() ( )

Call operator which starts/stops the measurement.

When the PerformanceMeter is added to a timeloop this operator is called. One measurement period, goes from one operator() call to the next call of operator() -> Add this before all sweeps in the timeloop.

If more fine grained control is needed use getBeforeFunction() and getAfterFunction() then only the sweeps between these functions are measured

◆ print()

void walberla::timeloop::PerformanceMeter::print ( std::ostream &  os,
int  targetRank = 0 
)

Prints all added measurements to the given output stream on specified process.

Parameters
osOutput stream where results are printed
targetRankthe MPI world rank of the process that should print. or a negative value, if all process should print.

◆ reduce()

void walberla::timeloop::PerformanceMeter::reduce ( std::vector< real_t > &  reduced,
int  targetRank 
)
private

Communicates the total number of cells among processes.

Parameters
[out]reducedvector that after returning holds the total number of cells for each Measurement on the process with has world rank = targetRank, or on all processes if targetRank < 0
[in]targetRanksee above

◆ timingEnd()

void walberla::timeloop::PerformanceMeter::timingEnd ( )

This function is wrapped and returned in getAfterFunction()

Stops the timing, if dynamic flags are set, the cells are counted and a running average of the cell count is computed.

◆ timingStart()

void walberla::timeloop::PerformanceMeter::timingStart ( )

This function is wrapped and returned in getBeforeFunction()

◆ timingStartStop()

void walberla::timeloop::PerformanceMeter::timingStartStop ( )
private

◆ updateCellCounts()

void walberla::timeloop::PerformanceMeter::updateCellCounts ( )
private

Loops over measurements and updates them if necessary.

Member Data Documentation

◆ blockStorage_

StructuredBlockStorage& walberla::timeloop::PerformanceMeter::blockStorage_
private

◆ firstTimingStartStopCall_

bool walberla::timeloop::PerformanceMeter::firstTimingStartStopCall_
private

Used for operator() to indicate if called the first time.

◆ measurements_

std::vector<Measurement> walberla::timeloop::PerformanceMeter::measurements_
private

◆ timer_

WcTimer walberla::timeloop::PerformanceMeter::timer_
private

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