geopm  3.1.1.dev296+g5916b956
GEOPM - Global Extensible Open Power Manager
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
geopm::Agent Class Referenceabstract

#include <Agent.hpp>

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

Public Member Functions

 Agent ()=default
 
virtual ~Agent ()=default
 
virtual void init (int level, const std::vector< int > &fan_in, bool is_level_root)=0
 Set the level where this Agent is active and push signals/controls for that level. More...
 
virtual void validate_policy (std::vector< double > &policy) const =0
 Called by Controller to validate incoming policy values and configure defaults requested in incoming policy. Policy sender can request default value with 'NaN' at the desired offset in the policy vector. Returned policy should not contain 'NaN's and be consumeable by descend and adjust_platform. More...
 
virtual void split_policy (const std::vector< double > &in_policy, std::vector< std::vector< double > > &out_policy)=0
 Called by Controller to split policy for children at next level down the tree. More...
 
virtual bool do_send_policy (void) const =0
 Called by Controller to determine if new policy values should be sent down the tree to the Agent's children. More...
 
virtual void aggregate_sample (const std::vector< std::vector< double > > &in_sample, std::vector< double > &out_sample)=0
 Aggregate samples from children for the next level up the tree. More...
 
virtual bool do_send_sample (void) const =0
 
virtual void adjust_platform (const std::vector< double > &in_policy)=0
 Adjust the platform settings based the policy from above. More...
 
virtual bool do_write_batch (void) const =0
 Called by the Controller to decide whether to call write_batch() to update platform controls. More...
 
virtual void sample_platform (std::vector< double > &out_sample)=0
 Read signals from the platform and interpret/aggregate these signals to create a sample which can be sent up the tree. More...
 
virtual void wait (void)=0
 Called by Controller to wait for sample period to elapse. This controls the cadence of the Controller main loop. More...
 
virtual std::vector< std::pair< std::string, std::string > > report_header (void) const =0
 Custom fields that will be added to the report header when this agent is used. More...
 
virtual std::vector< std::pair< std::string, std::string > > report_host (void) const =0
 Custom fields for the host section of the report. More...
 
virtual std::map< uint64_t, std::vector< std::pair< std::string, std::string > > > report_region (void) const =0
 Custom fields for each region in the report. More...
 
virtual std::vector< std::string > trace_names (void) const =0
 Column headers to be added to the trace. More...
 
virtual std::vector< std::function< std::string(double)> > trace_formats (void) const
 Returns format string for each column added to the trace. More...
 
virtual void trace_values (std::vector< double > &values)=0
 Called by Controller to get latest values to be added to the trace. More...
 
virtual void enforce_policy (const std::vector< double > &policy) const =0
 Enforce the policy one time with PlatformIO::write_control(). Called to enforce static policies in the absence of a Controller. More...
 

Static Public Member Functions

static std::vector< std::string > agent_names (void)
 
static std::unique_ptr< Agentmake_unique (const std::string &agent_name)
 
static int num_policy (const std::map< std::string, std::string > &dictionary)
 Used to look up the number of values in the policy vector sent down the tree for a specific Agent. This should be called with the dictionary returned by agent_factory().dictionary(agent_name) for the Agent of interest. More...
 
static int num_policy (const std::string &agent_name)
 Used to look up the number of values in the policy vector sent down the tree for a specific Agent. More...
 
static int num_sample (const std::map< std::string, std::string > &dictionary)
 Used to look up the number of values in the sample vector sent up the tree for a specific Agent. This should be called with the dictionary returned by agent_factory().dictionary(agent_name) for the Agent of interest. More...
 
static int num_sample (const std::string &agent_name)
 Used to look up the number of values in the sample vector sent up the tree for a specific Agent. More...
 
static std::vector< std::string > policy_names (const std::map< std::string, std::string > &dictionary)
 Used to look up the names of values in the policy vector sent down the tree for a specific Agent. This should be called with the dictionary returned by agent_factory().dictionary(agent_name) for the Agent of interest. More...
 
static std::vector< std::string > policy_names (const std::string &agent_name)
 Used to look up the names of values in the policy vector sent down the tree for a specific Agent. More...
 
static std::vector< std::string > sample_names (const std::map< std::string, std::string > &dictionary)
 Used to look up the names of values in the sample vector sent up the tree for a specific Agent. This should be called with the dictionary returned by agent_factory().dictionary(agent_name) for the Agent of interest. More...
 
static std::vector< std::string > sample_names (const std::string &agent_name)
 Used to look up the names of values in the sample vector sent up the tree for a specific Agent. More...
 
static std::map< std::string, std::string > make_dictionary (const std::vector< std::string > &policy_names, const std::vector< std::string > &sample_names)
 Used to create a correctly-formatted dictionary for an Agent at the time the Agent is registered with the factory. Concrete Agent classes may provide policy_names() and sample_names() methods to provide the vectors to be passed to this method. More...
 
static void aggregate_sample (const std::vector< std::vector< double > > &in_sample, const std::vector< std::function< double(const std::vector< double > &)> > &agg_func, std::vector< double > &out_sample)
 Generically aggregate a vector of samples given a vector of aggregation functions. This helper method applies a different aggregation function to each sample element while aggregating across child samples. More...
 

Static Public Attributes

static const std::string M_PLUGIN_PREFIX = "libgeopmagent_"
 

Constructor & Destructor Documentation

◆ Agent()

geopm::Agent::Agent ( )
default

◆ ~Agent()

virtual geopm::Agent::~Agent ( )
virtualdefault

Member Function Documentation

◆ adjust_platform()

virtual void geopm::Agent::adjust_platform ( const std::vector< double > &  in_policy)
pure virtual

Adjust the platform settings based the policy from above.

Parameters
[in]policySettings for each control in the policy.

Implemented in geopm::PowerGovernorAgent, geopm::PowerBalancerAgent, geopm::MonitorAgent, geopm::GPUActivityAgent, geopm::FrequencyMapAgent, geopm::FFNetAgent, and geopm::CPUActivityAgent.

◆ agent_names()

std::vector< std::string > geopm::Agent::agent_names ( void  )
static

◆ aggregate_sample() [1/2]

void geopm::Agent::aggregate_sample ( const std::vector< std::vector< double > > &  in_sample,
const std::vector< std::function< double(const std::vector< double > &)>  ,
agg_func,
std::vector< double > &  out_sample 
)
static

Generically aggregate a vector of samples given a vector of aggregation functions. This helper method applies a different aggregation function to each sample element while aggregating across child samples.

Parameters
[in]in_sampleVector over children of the sample vector received from each child.
[in]agg_funcA vector over agent samples of the aggregation function that is applied.
[out]out_sampleSample vector resulting from the applying the aggregation across child samples.

◆ aggregate_sample() [2/2]

virtual void geopm::Agent::aggregate_sample ( const std::vector< std::vector< double > > &  in_sample,
std::vector< double > &  out_sample 
)
pure virtual

Aggregate samples from children for the next level up the tree.

Parameters
[in]in_sampleVector of sample vectors, one from each child.
[out]out_sampleAggregated sample values to be sent up to the parent.

Implemented in geopm::PowerGovernorAgent, geopm::PowerBalancerAgent, geopm::MonitorAgent, geopm::GPUActivityAgent, geopm::FrequencyMapAgent, geopm::FFNetAgent, and geopm::CPUActivityAgent.

◆ do_send_policy()

virtual bool geopm::Agent::do_send_policy ( void  ) const
pure virtual

Called by Controller to determine if new policy values should be sent down the tree to the Agent's children.

Returns
True if the policy has been updated since last call.

Implemented in geopm::PowerGovernorAgent, geopm::PowerBalancerAgent, geopm::MonitorAgent, geopm::GPUActivityAgent, geopm::FrequencyMapAgent, geopm::FFNetAgent, and geopm::CPUActivityAgent.

◆ do_send_sample()

virtual bool geopm::Agent::do_send_sample ( void  ) const
pure virtual

◆ do_write_batch()

virtual bool geopm::Agent::do_write_batch ( void  ) const
pure virtual

Called by the Controller to decide whether to call write_batch() to update platform controls.

Returns
True if platform was adjusted, false otherwise.

Implemented in geopm::PowerGovernorAgent, geopm::PowerBalancerAgent, geopm::MonitorAgent, geopm::GPUActivityAgent, geopm::FrequencyMapAgent, geopm::FFNetAgent, and geopm::CPUActivityAgent.

◆ enforce_policy()

virtual void geopm::Agent::enforce_policy ( const std::vector< double > &  policy) const
pure virtual

Enforce the policy one time with PlatformIO::write_control(). Called to enforce static policies in the absence of a Controller.

Implemented in geopm::PowerGovernorAgent, geopm::PowerBalancerAgent, geopm::MonitorAgent, geopm::GPUActivityAgent, geopm::FrequencyMapAgent, geopm::FFNetAgent, and geopm::CPUActivityAgent.

◆ init()

virtual void geopm::Agent::init ( int  level,
const std::vector< int > &  fan_in,
bool  is_level_root 
)
pure virtual

Set the level where this Agent is active and push signals/controls for that level.

Parameters
[in]levelLevel of the tree where this agent is active. Note that only agents at level zero execute sample_platform() and adjust_platform().
[in]fan_inVector over level giving the the number of Agents that report to each root Agent operating at the level.
[in]is_level_rootTrue if the agent plays the role of root of the level. Only root agents for a level execute ascend() and descend().

Implemented in geopm::PowerGovernorAgent, geopm::PowerBalancerAgent, geopm::MonitorAgent, geopm::GPUActivityAgent, geopm::FrequencyMapAgent, geopm::FFNetAgent, and geopm::CPUActivityAgent.

◆ make_dictionary()

std::map< std::string, std::string > geopm::Agent::make_dictionary ( const std::vector< std::string > &  policy_names,
const std::vector< std::string > &  sample_names 
)
static

Used to create a correctly-formatted dictionary for an Agent at the time the Agent is registered with the factory. Concrete Agent classes may provide policy_names() and sample_names() methods to provide the vectors to be passed to this method.

◆ make_unique()

std::unique_ptr< Agent > geopm::Agent::make_unique ( const std::string &  agent_name)
static

◆ num_policy() [1/2]

int geopm::Agent::num_policy ( const std::map< std::string, std::string > &  dictionary)
static

Used to look up the number of values in the policy vector sent down the tree for a specific Agent. This should be called with the dictionary returned by agent_factory().dictionary(agent_name) for the Agent of interest.

Parameters
[in]dictionaryFactory dictionary for the agent.

◆ num_policy() [2/2]

int geopm::Agent::num_policy ( const std::string &  agent_name)
static

Used to look up the number of values in the policy vector sent down the tree for a specific Agent.

Parameters
[in]agent_nameName of the agent.

◆ num_sample() [1/2]

int geopm::Agent::num_sample ( const std::map< std::string, std::string > &  dictionary)
static

Used to look up the number of values in the sample vector sent up the tree for a specific Agent. This should be called with the dictionary returned by agent_factory().dictionary(agent_name) for the Agent of interest.

Parameters
[in]dictionaryFactory dictionary for the agent.

◆ num_sample() [2/2]

int geopm::Agent::num_sample ( const std::string &  agent_name)
static

Used to look up the number of values in the sample vector sent up the tree for a specific Agent.

Parameters
[in]agent_nameName of the agent.

◆ policy_names() [1/2]

std::vector< std::string > geopm::Agent::policy_names ( const std::map< std::string, std::string > &  dictionary)
static

Used to look up the names of values in the policy vector sent down the tree for a specific Agent. This should be called with the dictionary returned by agent_factory().dictionary(agent_name) for the Agent of interest.

Parameters
[in]dictionaryFactory dictionary for the agent.

◆ policy_names() [2/2]

std::vector< std::string > geopm::Agent::policy_names ( const std::string &  agent_name)
static

Used to look up the names of values in the policy vector sent down the tree for a specific Agent.

Parameters
[in]agent_nameName of the agent.

◆ report_header()

virtual std::vector<std::pair<std::string, std::string> > geopm::Agent::report_header ( void  ) const
pure virtual

Custom fields that will be added to the report header when this agent is used.

Implemented in geopm::PowerGovernorAgent, geopm::PowerBalancerAgent, geopm::MonitorAgent, geopm::GPUActivityAgent, geopm::FrequencyMapAgent, geopm::FFNetAgent, and geopm::CPUActivityAgent.

◆ report_host()

virtual std::vector<std::pair<std::string, std::string> > geopm::Agent::report_host ( void  ) const
pure virtual

◆ report_region()

virtual std::map<uint64_t, std::vector<std::pair<std::string, std::string> > > geopm::Agent::report_region ( void  ) const
pure virtual

◆ sample_names() [1/2]

std::vector< std::string > geopm::Agent::sample_names ( const std::map< std::string, std::string > &  dictionary)
static

Used to look up the names of values in the sample vector sent up the tree for a specific Agent. This should be called with the dictionary returned by agent_factory().dictionary(agent_name) for the Agent of interest.

Parameters
[in]dictionaryFactory dictionary for the agent.

◆ sample_names() [2/2]

std::vector< std::string > geopm::Agent::sample_names ( const std::string &  agent_name)
static

Used to look up the names of values in the sample vector sent up the tree for a specific Agent.

Parameters
[in]agent_nameName of the agent.

◆ sample_platform()

virtual void geopm::Agent::sample_platform ( std::vector< double > &  out_sample)
pure virtual

Read signals from the platform and interpret/aggregate these signals to create a sample which can be sent up the tree.

Parameters
[out]sampleVector of agent specific sample values to be sent up the tree.

Implemented in geopm::PowerGovernorAgent, geopm::PowerBalancerAgent, geopm::MonitorAgent, geopm::GPUActivityAgent, geopm::FrequencyMapAgent, geopm::FFNetAgent, and geopm::CPUActivityAgent.

◆ split_policy()

virtual void geopm::Agent::split_policy ( const std::vector< double > &  in_policy,
std::vector< std::vector< double > > &  out_policy 
)
pure virtual

Called by Controller to split policy for children at next level down the tree.

Parameters
[in]in_policyPolicy values from the parent.
[out]out_policyVector of policies to be sent to each child.

Implemented in geopm::PowerGovernorAgent, geopm::PowerBalancerAgent, geopm::MonitorAgent, geopm::GPUActivityAgent, geopm::FrequencyMapAgent, geopm::FFNetAgent, and geopm::CPUActivityAgent.

◆ trace_formats()

std::vector< std::function< std::string(double)> > geopm::Agent::trace_formats ( void  ) const
virtual

◆ trace_names()

virtual std::vector<std::string> geopm::Agent::trace_names ( void  ) const
pure virtual

◆ trace_values()

virtual void geopm::Agent::trace_values ( std::vector< double > &  values)
pure virtual

◆ validate_policy()

virtual void geopm::Agent::validate_policy ( std::vector< double > &  policy) const
pure virtual

Called by Controller to validate incoming policy values and configure defaults requested in incoming policy. Policy sender can request default value with 'NaN' at the desired offset in the policy vector. Returned policy should not contain 'NaN's and be consumeable by descend and adjust_platform.

Parameters
[in,out]policyPolicy replace NaN's with defaults. If a value of policy is not NaN but the value is not supported by the Agent the method will throw a geopm::Exception with error code GEOPM_ERROR_INVALID.

Implemented in geopm::PowerGovernorAgent, geopm::PowerBalancerAgent, geopm::MonitorAgent, geopm::FrequencyMapAgent, geopm::GPUActivityAgent, geopm::FFNetAgent, and geopm::CPUActivityAgent.

◆ wait()

virtual void geopm::Agent::wait ( void  )
pure virtual

Called by Controller to wait for sample period to elapse. This controls the cadence of the Controller main loop.

Implemented in geopm::PowerGovernorAgent, geopm::PowerBalancerAgent, geopm::MonitorAgent, geopm::GPUActivityAgent, geopm::FrequencyMapAgent, geopm::FFNetAgent, and geopm::CPUActivityAgent.

Member Data Documentation

◆ M_PLUGIN_PREFIX

const std::string geopm::Agent::M_PLUGIN_PREFIX = "libgeopmagent_"
static

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