powerd++  0.4.4
Classes | Public Member Functions | Private Attributes | List of all members
anonymous_namespace{libloadplay.cpp}::Emulator Class Reference

Instances of this class represent an emulator session. More...

Collaboration diagram for anonymous_namespace{libloadplay.cpp}::Emulator:
[legend]

Classes

struct  Core
 Per core information. More...
 

Public Member Functions

 Emulator (ifile< io::link > fin, ofile< io::link > fout, bool const &die)
 The constructor initialises all the members necessary for emulation. More...
 
void operator() ()
 Performs load emulation and prints statistics on io::fout. More...
 

Private Attributes

ifile< io::link > fin
 The input data source.
 
ofile< io::link > fout
 The output data sink.
 
const bool & die
 A reference to a bool that tells the emulator to die.
 
const size_t size = sysctls[CP_TIMES].size()
 The size of the kern.cp_times buffer.
 
const int ncpu = this->size / sizeof(cptime_t[CPUSTATES])
 The number of CPUs in kern.cp_times, may be greater than the hw.ncpu value (e.g. More...
 
std::unique_ptr< Core[]> cores {new Core[this->ncpu]{}}
 Simulation state information for each core.
 
SysctlValuecp_times = sysctls[CP_TIMES]
 The kern.cp_times sysctl handler.
 
std::unique_ptr< cptime_t[]> sum {new cptime_t[CPUSTATES * ncpu]{}}
 The current kern.cp_times values.
 

Detailed Description

Instances of this class represent an emulator session.

This should be run in its own thread and expects the sysctl table to be complete.


Class Documentation

◆ anonymous_namespace{libloadplay.cpp}::Emulator::Core

struct anonymous_namespace{libloadplay.cpp}::Emulator::Core

Per core information.

Collaboration diagram for anonymous_namespace{libloadplay.cpp}::Emulator::Core:
[legend]
Class Members
cycles_t carryCycles[CPUSTATES] The cycles carried over to the next frame in [cycles].

This is determined at the beginning of frame and used to calculated the simulation load at the beginning of the next frame.

SysctlValue * freqCtl The sysctl handler.

The constructor ensures this points to a valid handler.

mhz_t recFreq The recorded clock frequency.

If FREQ_TRACKING is enabled this is updated at during the preliminary stage and used at the beginning of frame stage.

mhz_t runFreq The clock frequency the simulation is running at.

Updated at the end of frame and used in the next frame.

cycles_t runLoadCycles The load cycles simulated for this frame in [cycles].

This is determined at the beginning of frame and used to calculate the reported load at the end of frame.

Constructor & Destructor Documentation

◆ Emulator()

anonymous_namespace{libloadplay.cpp}::Emulator::Emulator ( ifile< io::link >  fin,
ofile< io::link >  fout,
bool const &  die 
)
inline

The constructor initialises all the members necessary for emulation.

It also prints the column headers on stdout.

Exceptions
std::out_of_rangeIn case one of the required sysctls is missing
Parameters
fin,foutThe character input and output streams
dieIf the referenced bool is true, emulation is terminated prematurely

Member Function Documentation

◆ operator()()

void anonymous_namespace{libloadplay.cpp}::Emulator::operator() ( )
inline

Performs load emulation and prints statistics on io::fout.

Reads fin to pull in load changes and updates the kern.cp_times sysctl to represent the current state.

When it runs out of load changes it terminates emulation and sends a SIGINT to the process.

Member Data Documentation

◆ ncpu

const int anonymous_namespace{libloadplay.cpp}::Emulator::ncpu = this->size / sizeof(cptime_t[CPUSTATES])
private

The number of CPUs in kern.cp_times, may be greater than the hw.ncpu value (e.g.

if hyperthreading was turned off).


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