geopm  3.1.1.dev296+g5916b956
GEOPM - Global Extensible Open Power Manager
Classes | Public Member Functions | List of all members
geopm::SampleAggregatorImp Class Reference

#include <SampleAggregatorImp.hpp>

Inheritance diagram for geopm::SampleAggregatorImp:
Inheritance graph
[legend]
Collaboration diagram for geopm::SampleAggregatorImp:
Collaboration graph
[legend]

Public Member Functions

 SampleAggregatorImp ()
 
 SampleAggregatorImp (PlatformIO &platio)
 
int push_signal (const std::string &signal_name, int domain_type, int domain_idx) override
 Push a signal to be accumulated per-region. More...
 
int push_signal_total (const std::string &signal_idx, int domain_type, int domain_idx) override
 Push a signal to be accumulated per-region as a total. More...
 
int push_signal_average (const std::string &signal_idx, int domain_type, int domain_idx) override
 Push a signal to be accumulated per-region as an average. More...
 
void update (void) override
 Update stored totals for each signal. More...
 
double sample_application (int signal_idx) override
 Get the aggregated value of a signal. More...
 
double sample_epoch (int signal_idx) override
 Get the aggregated value of a signal since the first epoch. More...
 
double sample_region (int signal_idx, uint64_t region_hash) override
 Get the aggregated value of a signal during the execution of a particular region. More...
 
double sample_epoch_last (int signal_idx) override
 Get the aggregated value of a signal over the last completed epoch interval. More...
 
double sample_region_last (int signal_idx, uint64_t region_hash) override
 Get the aggregated value of a signal during the the last completed execution of a particular region. More...
 
void period_duration (double duration) override
 Set the time period for sample_period_last() More...
 
int get_period (void) override
 Get the index of the current time period. More...
 
double sample_period_last (int signal_idx) override
 Get the aggregated value of a signal during the last completed time interval. More...
 
- Public Member Functions inherited from geopm::SampleAggregator
virtual ~SampleAggregator ()=default
 Default destructor of pure virtual base. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from geopm::SampleAggregator
static std::unique_ptr< SampleAggregatormake_unique (void)
 Returns a unique_ptr to a concrete object constructed using the underlying implementation. More...
 
- Protected Member Functions inherited from geopm::SampleAggregator
 SampleAggregator ()=default
 

Constructor & Destructor Documentation

◆ SampleAggregatorImp() [1/2]

geopm::SampleAggregatorImp::SampleAggregatorImp ( )

◆ SampleAggregatorImp() [2/2]

geopm::SampleAggregatorImp::SampleAggregatorImp ( PlatformIO &  platio)

Member Function Documentation

◆ get_period()

int geopm::SampleAggregatorImp::get_period ( void  )
overridevirtual

Get the index of the current time period.

Provides an index of completed durations. Will return zero if periodic sampling is not enabled (when period_duration() was not called prior to update()). When periodic sampling is enabled, the sample_period_last() method will return 0.0 until a full period has elapsed, this corresponds to when get_period() returns a value greater than zero.

Returns
The number of completed durations since the application start.

Implements geopm::SampleAggregator.

◆ period_duration()

void geopm::SampleAggregatorImp::period_duration ( double  duration)
overridevirtual

Set the time period for sample_period_last()

Calling this method prior to the first call to update() enables signals to be accumulated on a periodic basis. The sample_period_last() method is used to sample an accumulated value over the last completed time interval, and the period of the interval is configured by calling this method.

The sample_period_last() method will always return NAN If period_duration() is not called prior to the first call to update(). The period_duration() method will throw an Exception if it is called after the first call to update().

Parameters
[in]durationTime interval in seconds over which the sample_region_last() method is aggregated (must be greater than 0.0).

Implements geopm::SampleAggregator.

◆ push_signal()

int geopm::SampleAggregatorImp::push_signal ( const std::string &  signal_name,
int  domain_type,
int  domain_idx 
)
overridevirtual

Push a signal to be accumulated per-region.

Check the signal behavior and call push_signal_total() or push_signal_average() accordingly.

Parameters
[in]signal_nameName of the signal to sample and aggregate.
[in]domain_typeDomain type over which the region hash and signal should be sampled.
[in]domain_idxDomain over which the region hash and signal should be sampled.
Returns
Index of signal to be used with sample(). This index matches the return value of PlatformIO::push_signal() for the same signal.

Implements geopm::SampleAggregator.

◆ push_signal_average()

int geopm::SampleAggregatorImp::push_signal_average ( const std::string &  signal_name,
int  domain_type,
int  domain_idx 
)
overridevirtual

Push a signal to be accumulated per-region as an average.

The signal name must be a valid signal available through PlatformIO. Note that unlike other signals this is an average value accumulated per region by a time weighted mean of the values sampled while in the region. Region entry and exit are not exact and are determined by the value of the REGION_HASH signal at the time of read_batch(). This aggregation should be used for signals that vary up and down over time such as the CPU frequency.

Parameters
[in]signal_nameName of the signal to sample and aggregate.
[in]domain_typeDomain type over which the region hash and signal should be sampled.
[in]domain_idxDomain over which the region hash and signal should be sampled.
Returns
Index of signal to be used with sample(). This index matches the return value of PlatformIO::push_signal() for the same signal.

Implements geopm::SampleAggregator.

◆ push_signal_total()

int geopm::SampleAggregatorImp::push_signal_total ( const std::string &  signal_name,
int  domain_type,
int  domain_idx 
)
overridevirtual

Push a signal to be accumulated per-region as a total.

The signal name must be a valid signal available through PlatformIO. Note that unlike other signals this is a total accumulated per region by subtracting the value of the signal at the region exit from the region entry. Region entry and exit are not exact and are determined by the value of the REGION_HASH signal at the time of read_batch(). This aggregation should only be used for signals that are monotonically increasing, such as time.

Parameters
[in]signal_nameName of the signal to sample and aggregate.
[in]domain_typeDomain type over which the region hash and signal should be sampled.
[in]domain_idxDomain over which the region hash and signal should be sampled.
Returns
Index of signal to be used with sample(). This index matches the return value of PlatformIO::push_signal() for the same signal.

Implements geopm::SampleAggregator.

◆ sample_application()

double geopm::SampleAggregatorImp::sample_application ( int  signal_idx)
overridevirtual

Get the aggregated value of a signal.

The aggregation type is determined by which method was used to push the signal: push_signal_total() or push_signal_average(). The value returned is aggregated over all samples since the application start.

Parameters
[in]signal_idxIndex returned by a previous call to push_signal_total() or push_signal_average().
Returns
Aggregated value for the signal regardless of region or epoch.

Implements geopm::SampleAggregator.

◆ sample_epoch()

double geopm::SampleAggregatorImp::sample_epoch ( int  signal_idx)
overridevirtual

Get the aggregated value of a signal since the first epoch.

The aggregation type is determined by which method was used to push the signal: push_signal_total() or push_signal_average(). The value returned is aggregated over all samples since the first epoch observed over the domain specified when the signal was pushed.

Parameters
[in]signal_idxIndex returned by a previous call to push_signal_total() or push_signal_average().
Returns
Aggregated value for the signal since first epoch, or NAN if called before first call to update().

Implements geopm::SampleAggregator.

◆ sample_epoch_last()

double geopm::SampleAggregatorImp::sample_epoch_last ( int  signal_idx)
overridevirtual

Get the aggregated value of a signal over the last completed epoch interval.

The aggregation type is determined by which method was used to push the signal: push_signal_total() or push_signal_average(). The value returned is aggregated over all samples between the last two samples when the epoch count changed.

Parameters
[in]signal_idxIndex returned by a previous call to push_signal_total() or push_signal_average().
Returns
Aggregated value for the signal over last epoch, or NAN if called before first call to update().

Implements geopm::SampleAggregator.

◆ sample_period_last()

double geopm::SampleAggregatorImp::sample_period_last ( int  signal_idx)
overridevirtual

Get the aggregated value of a signal during the last completed time interval.

Implements geopm::SampleAggregator.

◆ sample_region()

double geopm::SampleAggregatorImp::sample_region ( int  signal_idx,
uint64_t  region_hash 
)
overridevirtual

Get the aggregated value of a signal during the execution of a particular region.

The aggregation type is determined by which method was used to push the signal: push_signal_total() or push_signal_average(). The value returned is aggregated over all samples where the REGION_HASH signal matched the value specified for the domain pushed. The returned value is zero for push_signal_total() aggregation, and NAN for push_signal_average() aggregation if the region was not observed for any samples.

Parameters
[in]signal_idxIndex returned by a previous call to push_signal_total() or push_signal_average().
[in]region_hashThe region hash to look up data for.
Returns
Aggregated value for the signal during the region, or NAN if called before first call to update().

Implements geopm::SampleAggregator.

◆ sample_region_last()

double geopm::SampleAggregatorImp::sample_region_last ( int  signal_idx,
uint64_t  region_hash 
)
overridevirtual

Get the aggregated value of a signal during the the last completed execution of a particular region.

The aggregation type is determined by which method was used to push the signal: push_signal_total() or push_signal_average(). The value returned is aggregated over the last contiguous set of samples where the REGION_HASH signal matched the value specified for the domain pushed. Note that if the region is currently executing, the value reported is aggregated over the last region interval, not the currently executing interval. The returned value is zero for push_signal_total() aggregation, and NAN for push_signal_average() aggregation if a completed region with the specified hash has not been observed.

Parameters
[in]signal_idxIndex returned by a previous call to push_signal_total() or push_signal_average().
[in]region_hashThe region hash to look up data for.
Returns
Aggregated value for the signal during the last execution of the region, or NAN if called before first call to update() or if period_duration() was not called.

Implements geopm::SampleAggregator.

◆ update()

void geopm::SampleAggregatorImp::update ( void  )
overridevirtual

Update stored totals for each signal.

This method is to be called after each call to PlatformIO::read_batch(). This should be called with every PlatformIO update because sample_total() maybe not be called until the end of execution.

Implements geopm::SampleAggregator.


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