Processor Counter Monitor
Public Member Functions | Protected Types | Protected Attributes | Friends | List of all members
pcm::BasicCounterState Class Reference

Basic core counter state. More...

#include <cpucounters.h>

Inheritance diagram for pcm::BasicCounterState:
Inheritance graph
[legend]
Collaboration diagram for pcm::BasicCounterState:
Collaboration graph
[legend]

Public Member Functions

 BasicCounterState (const BasicCounterState &)=default
 
 BasicCounterState (BasicCounterState &&)=default
 
BasicCounterStateoperator= (BasicCounterState &&)=default
 
BasicCounterStateoperator+= (const BasicCounterState &o)
 
void readAndAggregate (std::shared_ptr< SafeMsrHandle >)
 
void readAndAggregateTSC (std::shared_ptr< SafeMsrHandle >)
 
int32 getThermalHeadroom () const
 Returns current thermal headroom below TjMax.
 

Protected Types

enum  {
  L3MissPos = 0, ArchLLCMissPos = 0, L3UnsharedHitPos = 1, ArchLLCRefPos = 1,
  SKLL3HitPos = 1, L2HitMPos = 2, SKLL2MissPos = 2, L2HitPos = 3
}
 

Protected Attributes

checked_uint64 InstRetiredAny {}
 
checked_uint64 CpuClkUnhaltedThread {}
 
checked_uint64 CpuClkUnhaltedRef {}
 
checked_uint64 Event [PERF_MAX_CUSTOM_COUNTERS]
 
uint64 InvariantTSC
 
uint64 CStateResidency [PCM::MAX_C_STATE+1]
 
int32 ThermalHeadroom
 
uint64 L3Occupancy
 
uint64 MemoryBWLocal
 
uint64 MemoryBWTotal
 
uint64 SMICount
 
uint64 FrontendBoundSlots
 
uint64 BadSpeculationSlots
 
uint64 BackendBoundSlots
 
uint64 RetiringSlots
 
uint64 AllSlotsRaw
 
std::unordered_map< uint64, uint64 > MSRValues
 

Friends

class PCM
 
class JSONPrinter
 
template<class CounterStateType >
double getExecUsage (const CounterStateType &before, const CounterStateType &after)
 Computes average number of retired instructions per time interval. More...
 
template<class CounterStateType >
double getIPC (const CounterStateType &before, const CounterStateType &after)
 Computes average number of retired instructions per core cycle (IPC) More...
 
template<class CounterStateType >
double getAverageFrequency (const CounterStateType &before, const CounterStateType &after)
 Computes average core frequency also taking Intel Turbo Boost technology into account. More...
 
template<class CounterStateType >
double getAverageFrequencyFromClocks (const int64 clocks, const CounterStateType &before, const CounterStateType &after)
 
template<class CounterStateType >
double getActiveAverageFrequency (const CounterStateType &before, const CounterStateType &after)
 Computes average core frequency when not in powersaving C0-state (also taking Intel Turbo Boost technology into account) More...
 
template<class CounterStateType >
double getRelativeFrequency (const CounterStateType &before, const CounterStateType &after)
 Computes average core frequency also taking Intel Turbo Boost technology into account. More...
 
template<class CounterStateType >
double getActiveRelativeFrequency (const CounterStateType &before, const CounterStateType &after)
 Computes average core frequency when not in powersaving C0-state (also taking Intel Turbo Boost technology into account) More...
 
template<class CounterStateType >
double getL2CacheHitRatio (const CounterStateType &before, const CounterStateType &after)
 Computes L2 cache hit ratio. More...
 
template<class CounterStateType >
double getL3CacheHitRatio (const CounterStateType &before, const CounterStateType &after)
 Computes L3 cache hit ratio. More...
 
template<class CounterStateType >
uint64 getL3CacheMisses (const CounterStateType &before, const CounterStateType &after)
 Computes number of L3 cache misses. More...
 
template<class CounterStateType >
uint64 getL2CacheMisses (const CounterStateType &before, const CounterStateType &after)
 Computes number of L2 cache misses. More...
 
template<class CounterStateType >
uint64 getL2CacheHits (const CounterStateType &before, const CounterStateType &after)
 Computes number of L2 cache hits. More...
 
template<class CounterStateType >
uint64 getL3CacheHitsNoSnoop (const CounterStateType &before, const CounterStateType &after)
 Computes number of L3 cache hits where no snooping in sibling L2 caches had to be done. More...
 
template<class CounterStateType >
uint64 getL3CacheHitsSnoop (const CounterStateType &before, const CounterStateType &after)
 Computes number of L3 cache hits where snooping in sibling L2 caches had to be done. More...
 
template<class CounterStateType >
uint64 getL3CacheHits (const CounterStateType &before, const CounterStateType &after)
 Computes total number of L3 cache hits. More...
 
template<class CounterStateType >
uint64 getL3CacheOccupancy (const CounterStateType &now)
 Computes L3 Cache Occupancy. More...
 
template<class CounterStateType >
uint64 getLocalMemoryBW (const CounterStateType &before, const CounterStateType &after)
 Computes Local Memory Bandwidth. More...
 
template<class CounterStateType >
uint64 getRemoteMemoryBW (const CounterStateType &before, const CounterStateType &after)
 Computes Remote Memory Bandwidth. More...
 
template<class CounterStateType >
uint64 getCycles (const CounterStateType &before, const CounterStateType &after)
 Computes the number core clock cycles when signal on a specific core is running (not halted) More...
 
template<class CounterStateType >
uint64 getInstructionsRetired (const CounterStateType &before, const CounterStateType &after)
 Computes the number of retired instructions. More...
 
template<class CounterStateType >
uint64 getCycles (const CounterStateType &now)
 Computes the number executed core clock cycles. More...
 
template<class CounterStateType >
uint64 getInstructionsRetired (const CounterStateType &now)
 Computes the number of retired instructions. More...
 
template<class CounterStateType >
uint64 getNumberOfCustomEvents (int32 eventCounterNr, const CounterStateType &before, const CounterStateType &after)
 Returns the number of occurred custom core events. More...
 
template<class CounterStateType >
uint64 getInvariantTSC (const CounterStateType &before, const CounterStateType &after)
 Computes number of invariant time stamp counter ticks. More...
 
template<class CounterStateType >
uint64 getRefCycles (const CounterStateType &before, const CounterStateType &after)
 Computes the number of reference clock cycles while clock signal on the core is running. More...
 
template<class CounterStateType >
double getCoreCStateResidency (int state, const CounterStateType &before, const CounterStateType &after)
 Computes residency in the core C-state. More...
 
template<class CounterStateType >
uint64 getCoreCStateResidency (int state, const CounterStateType &now)
 Reads raw residency counter for the core C-state. More...
 
template<class CounterStateType >
uint64 getSMICount (const CounterStateType &before, const CounterStateType &after)
 Returns the number of occurred system management interrupts. More...
 
template<class CounterStateType >
uint64 getAllSlotsRaw (const CounterStateType &before, const CounterStateType &after)
 
template<class CounterStateType >
uint64 getAllSlots (const CounterStateType &before, const CounterStateType &after)
 
template<class CounterStateType >
double getBackendBound (const CounterStateType &before, const CounterStateType &after)
 Returns unutilized pipeline slots where no uop was delivered due to lack of back-end resources as range 0..1.
 
template<class CounterStateType >
double getFrontendBound (const CounterStateType &before, const CounterStateType &after)
 Returns unutilized pipeline slots where Front-end did not deliver a uop while back-end is ready as range 0..1.
 
template<class CounterStateType >
double getBadSpeculation (const CounterStateType &before, const CounterStateType &after)
 Returns wasted pipeline slots due to incorrect speculation, covering whole penalty: Utilized by uops that do not retire, or Recovery Bubbles (unutilized slots) as range 0..1.
 
template<class CounterStateType >
double getRetiring (const CounterStateType &before, const CounterStateType &after)
 Returns pipeline slots utilized by uops that eventually retire (commit)
 
template<class CounterStateType >
uint64 getMSREvent (const uint64 &index, const PCM::MSRType &type, const CounterStateType &before, const CounterStateType &after)
 

Detailed Description

Basic core counter state.

Intended only for derivation, but not for the direct use

Friends And Related Function Documentation

◆ getActiveAverageFrequency

template<class CounterStateType >
double getActiveAverageFrequency ( const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Computes average core frequency when not in powersaving C0-state (also taking Intel Turbo Boost technology into account)

Parameters
beforeCPU counter state before the experiment
afterCPU counter state after the experiment
Returns
frequency in Hz

◆ getActiveRelativeFrequency

template<class CounterStateType >
double getActiveRelativeFrequency ( const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Computes average core frequency when not in powersaving C0-state (also taking Intel Turbo Boost technology into account)

Parameters
beforeCPU counter state before the experiment
afterCPU counter state after the experiment
Returns
Fraction of nominal frequency (if >1.0 then Turbo was working during the measurement)

◆ getAverageFrequency

template<class CounterStateType >
double getAverageFrequency ( const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Computes average core frequency also taking Intel Turbo Boost technology into account.

Parameters
beforeCPU counter state before the experiment
afterCPU counter state after the experiment
Returns
frequency in Hz

◆ getCoreCStateResidency [1/2]

template<class CounterStateType >
double getCoreCStateResidency ( int  state,
const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Computes residency in the core C-state.

Parameters
stateC-state
beforeCPU counter state before the experiment
afterCPU counter state after the experiment
Returns
residence ratio (0..1): 0 - 0%, 1.0 - 100%

◆ getCoreCStateResidency [2/2]

template<class CounterStateType >
uint64 getCoreCStateResidency ( int  state,
const CounterStateType &  now 
)
friend

Reads raw residency counter for the core C-state.

Parameters
stateC-state #
nowCPU counter state
Returns
raw residency value

◆ getCycles [1/2]

template<class CounterStateType >
uint64 getCycles ( const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Computes the number core clock cycles when signal on a specific core is running (not halted)

Returns number of used cycles (halted cyles are not counted). The counter does not advance in the following conditions:

  • an ACPI C-state is other than C0 for normal operation
  • HLT
  • STPCLK+ pin is asserted
  • being throttled by TM1
  • during the frequency switching phase of a performance state transition

The performance counter for this event counts across performance state transitions using different core clock frequencies

Parameters
beforeCPU counter state before the experiment
afterCPU counter state after the experiment
Returns
number core clock cycles

◆ getCycles [2/2]

template<class CounterStateType >
uint64 getCycles ( const CounterStateType &  now)
friend

Computes the number executed core clock cycles.

Returns number of used cycles (halted cyles are not counted).

Parameters
nowCurrent CPU counter state
Returns
number core clock cycles

◆ getExecUsage

template<class CounterStateType >
double getExecUsage ( const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Computes average number of retired instructions per time interval.

Parameters
beforeCPU counter state before the experiment
afterCPU counter state after the experiment
Returns
usage

◆ getInstructionsRetired [1/2]

template<class CounterStateType >
uint64 getInstructionsRetired ( const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Computes the number of retired instructions.

Parameters
beforeCPU counter state before the experiment
afterCPU counter state after the experiment
Returns
number of retired instructions

◆ getInstructionsRetired [2/2]

template<class CounterStateType >
uint64 getInstructionsRetired ( const CounterStateType &  now)
friend

Computes the number of retired instructions.

Parameters
nowCurrent CPU counter state
Returns
number of retired instructions

◆ getInvariantTSC

template<class CounterStateType >
uint64 getInvariantTSC ( const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Computes number of invariant time stamp counter ticks.

This counter counts irrespectively of C-, P- or T-states

Parameters
beforeCPU counter state before the experiment
afterCPU counter state after the experiment
Returns
number of time stamp counter ticks

◆ getIPC

template<class CounterStateType >
double getIPC ( const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Computes average number of retired instructions per core cycle (IPC)

Parameters
beforeCPU counter state before the experiment
afterCPU counter state after the experiment
Returns
IPC

◆ getL2CacheHitRatio

template<class CounterStateType >
double getL2CacheHitRatio ( const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Computes L2 cache hit ratio.

Parameters
beforeCPU counter state before the experiment
afterCPU counter state after the experiment
Warning
Works only in the DEFAULT_EVENTS programming mode (see program() method)
Returns
value between 0 and 1

◆ getL2CacheHits

template<class CounterStateType >
uint64 getL2CacheHits ( const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Computes number of L2 cache hits.

Parameters
beforeCPU counter state before the experiment
afterCPU counter state after the experiment
Warning
Works only in the DEFAULT_EVENTS programming mode (see program() method)
Returns
number of hits

◆ getL2CacheMisses

template<class CounterStateType >
uint64 getL2CacheMisses ( const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Computes number of L2 cache misses.

Parameters
beforeCPU counter state before the experiment
afterCPU counter state after the experiment
Warning
Works only in the DEFAULT_EVENTS programming mode (see program() method)
Returns
number of misses

◆ getL3CacheHitRatio

template<class CounterStateType >
double getL3CacheHitRatio ( const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Computes L3 cache hit ratio.

Parameters
beforeCPU counter state before the experiment
afterCPU counter state after the experiment
Warning
Works only in the DEFAULT_EVENTS programming mode (see program() method)
Returns
value between 0 and 1

◆ getL3CacheHits

template<class CounterStateType >
uint64 getL3CacheHits ( const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Computes total number of L3 cache hits.

Parameters
beforeCPU counter state before the experiment
afterCPU counter state after the experiment
Warning
Works only in the DEFAULT_EVENTS programming mode (see program() method)
Returns
number of hits

◆ getL3CacheHitsNoSnoop

template<class CounterStateType >
uint64 getL3CacheHitsNoSnoop ( const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Computes number of L3 cache hits where no snooping in sibling L2 caches had to be done.

Parameters
beforeCPU counter state before the experiment
afterCPU counter state after the experiment
Warning
Works only in the DEFAULT_EVENTS programming mode (see program() method)
Returns
number of hits

◆ getL3CacheHitsSnoop

template<class CounterStateType >
uint64 getL3CacheHitsSnoop ( const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Computes number of L3 cache hits where snooping in sibling L2 caches had to be done.

Parameters
beforeCPU counter state before the experiment
afterCPU counter state after the experiment
Warning
Works only in the DEFAULT_EVENTS programming mode (see program() method)
Returns
number of hits

◆ getL3CacheMisses

template<class CounterStateType >
uint64 getL3CacheMisses ( const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Computes number of L3 cache misses.

Parameters
beforeCPU counter state before the experiment
afterCPU counter state after the experiment
Warning
Works only in the DEFAULT_EVENTS programming mode (see program() method)
Returns
number of misses

◆ getL3CacheOccupancy

template<class CounterStateType >
uint64 getL3CacheOccupancy ( const CounterStateType &  now)
friend

Computes L3 Cache Occupancy.

◆ getLocalMemoryBW

template<class CounterStateType >
uint64 getLocalMemoryBW ( const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Computes Local Memory Bandwidth.

◆ getNumberOfCustomEvents

template<class CounterStateType >
uint64 getNumberOfCustomEvents ( int32  eventCounterNr,
const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Returns the number of occurred custom core events.

Read number of events programmed with the CUSTOM_CORE_EVENTS

Parameters
eventCounterNrEvent/counter number (value from 0 to 3)
beforeCPU counter state before the experiment
afterCPU counter state after the experiment
Returns
Number of bytes

◆ getRefCycles

template<class CounterStateType >
uint64 getRefCycles ( const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Computes the number of reference clock cycles while clock signal on the core is running.

The reference clock operates at a fixed frequency, irrespective of core frequency changes due to performance state transitions. See Intel(r) Software Developer's Manual for more details

Parameters
beforeCPU counter state before the experiment
afterCPU counter state after the experiment
Returns
number core clock cycles

◆ getRelativeFrequency

template<class CounterStateType >
double getRelativeFrequency ( const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Computes average core frequency also taking Intel Turbo Boost technology into account.

Parameters
beforeCPU counter state before the experiment
afterCPU counter state after the experiment
Returns
Fraction of nominal frequency

◆ getRemoteMemoryBW

template<class CounterStateType >
uint64 getRemoteMemoryBW ( const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Computes Remote Memory Bandwidth.

◆ getSMICount

template<class CounterStateType >
uint64 getSMICount ( const CounterStateType &  before,
const CounterStateType &  after 
)
friend

Returns the number of occurred system management interrupts.

Parameters
beforeCPU counter state before the experiment
afterCPU counter state after the experiment
Returns
Number of SMIs (system manegement interrupts)

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