geopm  3.1.1.dev214+gba4f9f6d
GEOPM - Global Extensible Open Power Manager
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
geopm::SumAccumulator Class Referenceabstract

Class to track the total increase of a signal while a condition is true. More...

#include <Accumulator.hpp>

Inheritance diagram for geopm::SumAccumulator:
Inheritance graph
[legend]

Public Member Functions

virtual ~SumAccumulator ()=default
 Virtual destructor. More...
 
virtual void update (double delta_signal)=0
 Called in control loop to update state. More...
 
virtual void enter (void)=0
 Mark the beginning of an interval. More...
 
virtual void exit (void)=0
 Mark the end of an interval. More...
 
virtual double total (void) const =0
 Total increase of tracked signal when condition is true. More...
 
virtual double interval_total (void) const =0
 Increase of tracked signal over last interval. More...
 

Static Public Member Functions

static std::unique_ptr< SumAccumulatormake_unique (void)
 Factory constructor. More...
 

Protected Member Functions

 SumAccumulator ()=default
 

Detailed Description

Class to track the total increase of a signal while a condition is true.

There are many monotonically increasing signals provided by PlatformIO, for example: CPU_ENERGY, CPU_CYCLES_THREAD, and CPU_CYCLES_REFERENCE. It is useful to track the amount that these signals increase while a condition is true. In the common case, the condition is that the application is executing a particular region of code. An example use for a SumAccumulator object is to track the increase in the amount of package energy consumed while the application was executing a particular region.

The SumAccumulator is used to accumulate a signal that is monotonically increasing, e.g. energy, in order to track the portion of the total increase that occurred while the condition is true, e.g. while the application was executing a particular region.

Each of these objects is specific to a signal, and it is also particular to a condition that is being tracked. This condition may be: the application is executing a particular profiled region, or the hint signal has a particular value. The user only calls the update() method when the condition is true (e.g. the application is within the tracked region). The enter() and exit() API's are used to track values for the last occurrence of the condition being true. It is expected (though not enforced) that one call to enter() proceeds each call to exit(), and these are used to update the values returned by interval_total().

Constructor & Destructor Documentation

◆ ~SumAccumulator()

virtual geopm::SumAccumulator::~SumAccumulator ( )
virtualdefault

Virtual destructor.

◆ SumAccumulator()

geopm::SumAccumulator::SumAccumulator ( )
protecteddefault

Member Function Documentation

◆ enter()

virtual void geopm::SumAccumulator::enter ( void  )
pure virtual

Mark the beginning of an interval.

Used to mark the beginning of an interval used for the interval_total() reporting. The next call to exit() will close the interval and update the value returned by interval_total() to reflect the interval between the enter() and exit() calls.

Implemented in geopm::SumAccumulatorImp.

◆ exit()

virtual void geopm::SumAccumulator::exit ( void  )
pure virtual

Mark the end of an interval.

Used to mark the end of an interval that was previously started with a call to the enter() API. The call to exit() will update the value returned by interval_total() to reflect the interval since the enter() call.

Implemented in geopm::SumAccumulatorImp.

◆ interval_total()

virtual double geopm::SumAccumulator::interval_total ( void  ) const
pure virtual

Increase of tracked signal over last interval.

Get the increase in the signal while the condition is true over the last interval. An interval is defined by an enter() and exit() call.

Returns
Sum of all values passed to update() during last interval.

Implemented in geopm::SumAccumulatorImp.

◆ make_unique()

std::unique_ptr< SumAccumulator > geopm::SumAccumulator::make_unique ( void  )
static

Factory constructor.

◆ total()

virtual double geopm::SumAccumulator::total ( void  ) const
pure virtual

Total increase of tracked signal when condition is true.

Used to report on the total accumulated sum of all of the updates since the construction of the object.

Returns
Sum of all values passed to update()

Implemented in geopm::SumAccumulatorImp.

◆ update()

virtual void geopm::SumAccumulator::update ( double  delta_signal)
pure virtual

Called in control loop to update state.

Update with the change in the signal being tracked for the sample. This is called once in each control interval where the condition is true. The change in the signal is measured over the period of the last control interval.

Parameters
[in]delta_signalChange in the signal over the control interval.

Implemented in geopm::SumAccumulatorImp.


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