LAMA
tracing::RegionTable Class Reference

Class to collect timing information about different regions in an instrumented program. More...

#include <RegionTable.hpp>

Data Structures

struct  CallEntry
 Structure for entry on the call stack (id, starttime) More...
struct  CmpString
struct  RegionEntry
 Structure for inclusive and exclusive time of each timer. More...

Public Member Functions

 RegionTable (lama::Thread::Id threadId)
 Constructor of a new region table.
 ~RegionTable ()
 Destructor.
lama::Thread::Id getId () const
 Query of the thread id to which thread table belongs.
int getRegion (const char *id, const char *file, int lno)
 Get the id of a region, createas a new entry if region is not available yet.
void init ()
 Initialization of the timers.
void start (int regionId, double wallTime)
 Enter a region with the timestamp.
void stop (int regionId, double wallTime)
 Leave the region with the timestamp.
void stop (const char *regionName, double wallTime)
 Leave the region with the timestamp.
double elapsed (int regionId)
 Return the elapsed time up to now.
double spent (int regionId)
 Return the accumulated time of a region.
double spentExclusive (int regionId)
 Return the exclusive time.
double spentLast (int regionId)
 Return the time of last execution.
const char * getName (int regionId)
 Get name of the region.
void printTimer ()
 This routine prints timing information.
void printTimer (FILE *f)

Private Member Functions

 LAMA_LOG_DECL_STATIC_LOGGER (logger)

Private Attributes

std::vector< CallEntrycallStack
std::vector< RegionEntryarray
 Entries for all timers.
lama::Thread::Id mThreadId
std::map< const char *, int,
CmpString
mapTimer
 Map of region strings to region ids that are the indexes to array.

Detailed Description

Class to collect timing information about different regions in an instrumented program.

For each region timers are defined. Timing for a routine must be started and stopped according a subroutine call structure.

      start(region1)
        start(region2)
        stop(region2)
        start(region3)
        elapsed(region1)
        stop(region3)
      stop(region1)

At the end of a run, inclusive and exclusive time is available for all regions.


Constructor & Destructor Documentation

Constructor of a new region table.

Parameters:
[in]threadIdid of the thread to which region table belongs

Destructor.

References printTimer().


Member Function Documentation

double tracing::RegionTable::elapsed ( int  regionId)

Return the elapsed time up to now.

It will add also the time of a running region.

References array, callStack, tracing::RegionTable::CallEntry::mRegion, tracing::RegionTable::CallEntry::mTimeStart, and tracing::walltime().

int tracing::RegionTable::getRegion ( const char *  id,
const char *  file,
int  lno 
)

Get the id of a region, createas a new entry if region is not available yet.

Parameters:
[in]idis the name of the region
[in]fileis the name of the source file where region is defined
[in]lnois the line number of the region in the source file

References array, mapTimer, tracing::RegionTable::RegionEntry::mFile, tracing::RegionTable::RegionEntry::mLine, tracing::RegionTable::RegionEntry::mName, and mThreadId.

Referenced by tracing::TraceRegionRecord::enter(), tracing::TraceRegionRecord::spentLast(), and tracing::TraceRegionRecord::start().

Initialization of the timers.

Resets all timers.

References callStack.

This routine prints timing information.

References tracing::printMutex.

Referenced by ~RegionTable(), and tracing::TraceConfig::~TraceConfig().

References array, mapTimer, and mThreadId.

double tracing::RegionTable::spent ( int  regionId)

Return the accumulated time of a region.

References array.

double tracing::RegionTable::spentExclusive ( int  regionId)

Return the exclusive time.

References array.

double tracing::RegionTable::spentLast ( int  regionId)

Return the time of last execution.

References array.

Referenced by tracing::TraceRegionRecord::spentLast().

void tracing::RegionTable::start ( int  regionId,
double  wallTime 
)

Enter a region with the timestamp.

References callStack.

Referenced by tracing::TraceRegionRecord::enter(), and tracing::TraceRegionRecord::start().

void tracing::RegionTable::stop ( int  regionId,
double  wallTime 
)

Leave the region with the timestamp.

Parameters:
[in]regionIdis the id of region to leave, must match the last on call stack
[in]wallTimeis time stamp of call

References array, callStack, tracing::RegionTable::CallEntry::mRegion, and tracing::RegionTable::CallEntry::mTimeStart.

Referenced by tracing::TraceRegionRecord::stop(), stop(), and tracing::TraceRegionRecord::~TraceRegionRecord().

void tracing::RegionTable::stop ( const char *  regionName,
double  wallTime 
)

Leave the region with the timestamp.

References array, callStack, getName(), tracing::RegionTable::CallEntry::mRegion, and stop().


Field Documentation

std::vector<RegionEntry> tracing::RegionTable::array [private]

Entries for all timers.

Referenced by elapsed(), getName(), getRegion(), printTimer(), spent(), spentExclusive(), spentLast(), and stop().

Referenced by elapsed(), init(), start(), and stop().

std::map<const char*, int, CmpString> tracing::RegionTable::mapTimer [private]

Map of region strings to region ids that are the indexes to array.

Timer strings are given by pointer; pointers will be always valid as string remains as member variable in array.

Referenced by getRegion(), and printTimer().


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