gem5 v24.0.0.0
Loading...
Searching...
No Matches
gem5::PerfKvmTimer Class Reference

PerfEvent based timer using the host's CPU cycle counter. More...

#include <timer.hh>

Inheritance diagram for gem5::PerfKvmTimer:
gem5::BaseKvmTimer

Public Member Functions

 PerfKvmTimer (PerfKvmCounter &ctr, int signo, float hostFactor, Tick hostFreq)
 Create a timer that uses an existing hardware cycle counter.
 
 ~PerfKvmTimer ()
 
void arm (Tick ticks)
 Arm the timer so that it fires after a certain number of ticks.
 
void disarm ()
 Disarm the timer.
 
- Public Member Functions inherited from gem5::BaseKvmTimer
 BaseKvmTimer (int signo, float hostFactor, Tick hostFreq)
 Setup basic timer functionality shared by all timer implementations.
 
virtual ~BaseKvmTimer ()
 
virtual bool expired ()
 
Tick resolution ()
 Determine the resolution of the timer in ticks.
 
Tick ticksFromHostCycles (uint64_t cycles)
 Convert cycles executed on the host into Ticks executed in the simulator.
 
Tick ticksFromHostNs (uint64_t ns)
 Convert nanoseconds executed on the host into Ticks executed in the simulator.
 

Protected Member Functions

Tick calcResolution ()
 Calculate the timer resolution, used by resolution() which caches the result.
 
- Protected Member Functions inherited from gem5::BaseKvmTimer
uint64_t hostNs (Tick ticks)
 Convert a time in simulator ticks to host nanoseconds.
 
uint64_t hostCycles (Tick ticks)
 Convert a time in simulator ticks to host cycles.
 

Private Attributes

PerfKvmCounterhwOverflow
 

Additional Inherited Members

- Protected Attributes inherited from gem5::BaseKvmTimer
int signo
 Signal to deliver when the timer times out.
 

Detailed Description

PerfEvent based timer using the host's CPU cycle counter.

Warning
There is a known problem in some versions of the PerfEvent API that prevents the counter overflow period from being updated reliably, which might break this timer. See PerfKvmCounter::period() for details.

Definition at line 221 of file timer.hh.

Constructor & Destructor Documentation

◆ PerfKvmTimer()

gem5::PerfKvmTimer::PerfKvmTimer ( PerfKvmCounter & ctr,
int signo,
float hostFactor,
Tick hostFreq )

Create a timer that uses an existing hardware cycle counter.

Note
The performance counter must be configured for overflow sampling, which in practice means that it must have a non-zero sample period. The initial sample period is ignored since period will be updated when arm() is called.
Parameters
ctrAttached performance counter configured for overflow reporting.
signoSignal to deliver
hostFactorPerformance scaling factor
hostFreqClock frequency of the host

Definition at line 171 of file timer.cc.

References gem5::PerfKvmCounter::enableSignals(), hwOverflow, and gem5::BaseKvmTimer::signo.

◆ ~PerfKvmTimer()

gem5::PerfKvmTimer::~PerfKvmTimer ( )

Definition at line 179 of file timer.cc.

Member Function Documentation

◆ arm()

void gem5::PerfKvmTimer::arm ( Tick ticks)
virtual

Arm the timer so that it fires after a certain number of ticks.

Note
A timer implementation is free to convert between simulation ticks and virtualized time using any method it chooses. The accuracy of the timer therefore depends on what it measures, an accurate timer implementation should measure the number of cycles or instructions executed in the guest. If such counters are unavailable, it may fallback to wall clock time.
Parameters
ticksNumber of ticks until the timer fires

Implements gem5::BaseKvmTimer.

Definition at line 184 of file timer.cc.

References gem5::BaseKvmTimer::hostCycles(), hwOverflow, gem5::PerfKvmCounter::period(), and gem5::PerfKvmCounter::refresh().

◆ calcResolution()

Tick gem5::PerfKvmTimer::calcResolution ( )
protectedvirtual

Calculate the timer resolution, used by resolution() which caches the result.

Returns
Minimum number of ticks the timer can resolve

Implements gem5::BaseKvmTimer.

Definition at line 197 of file timer.cc.

References gem5::MIN_HOST_CYCLES, and gem5::BaseKvmTimer::ticksFromHostCycles().

◆ disarm()

void gem5::PerfKvmTimer::disarm ( )
virtual

Disarm the timer.

When this method has returned, the timer may no longer deliver signals upon timeout.

Implements gem5::BaseKvmTimer.

Definition at line 191 of file timer.cc.

References hwOverflow, and gem5::PerfKvmCounter::stop().

Member Data Documentation

◆ hwOverflow

PerfKvmCounter& gem5::PerfKvmTimer::hwOverflow
private

Definition at line 250 of file timer.hh.

Referenced by arm(), disarm(), and PerfKvmTimer().


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

Generated on Tue Jun 18 2024 16:24:13 for gem5 by doxygen 1.11.0