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

MemChecker. More...

#include <mem_checker.hh>

Inheritance diagram for gem5::MemChecker:
gem5::SimObject gem5::EventManager gem5::Serializable gem5::Drainable gem5::statistics::Group gem5::Named

Classes

class  ByteTracker
 The ByteTracker keeps track of transactions for the same byte – all outstanding reads, the completed reads (and what they observed) and write clusters (see WriteCluster). More...
 
class  Transaction
 The Transaction class captures the lifetimes of read and write operations, and the values they consumed or produced respectively. More...
 
class  WriteCluster
 The WriteCluster class captures sets of writes where all writes are overlapping with at least one other write. More...
 

Public Types

typedef uint64_t Serial
 The Serial type is used to be able to uniquely identify a transaction as it passes through the system.
 
typedef std::list< TransactionTransactionList
 
typedef std::list< WriteClusterWriteClusterList
 
- Public Types inherited from gem5::SimObject
typedef SimObjectParams Params
 

Public Member Functions

 MemChecker (const MemCheckerParams &p)
 
virtual ~MemChecker ()
 
Serial startRead (Tick start, Addr addr, size_t size)
 Starts a read transaction.
 
Serial startWrite (Tick start, Addr addr, size_t size, const uint8_t *data)
 Starts a write transaction.
 
bool completeRead (Serial serial, Tick complete, Addr addr, size_t size, uint8_t *data)
 Completes a previously started read transaction.
 
void completeWrite (Serial serial, Tick complete, Addr addr, size_t size)
 Completes a previously started write transaction.
 
void abortWrite (Serial serial, Addr addr, size_t size)
 Aborts a previously started write transaction.
 
void reset ()
 Resets the entire checker.
 
void reset (Addr addr, size_t size)
 Resets an address-range.
 
const std::string & getErrorMessage () const
 In completeRead, if an error is encountered, this does not print nor cause an error, but instead should be handled by the caller.
 
- Public Member Functions inherited from gem5::SimObject
const Paramsparams () const
 
 SimObject (const Params &p)
 
virtual ~SimObject ()
 
virtual void init ()
 init() is called after all C++ SimObjects have been created and all ports are connected.
 
virtual void loadState (CheckpointIn &cp)
 loadState() is called on each SimObject when restoring from a checkpoint.
 
virtual void initState ()
 initState() is called on each SimObject when not restoring from a checkpoint.
 
virtual void regProbePoints ()
 Register probe points for this object.
 
virtual void regProbeListeners ()
 Register probe listeners for this object.
 
ProbeManagergetProbeManager ()
 Get the probe manager for this object.
 
virtual PortgetPort (const std::string &if_name, PortID idx=InvalidPortID)
 Get a port with a given name and index.
 
virtual void startup ()
 startup() is the final initialization call before simulation.
 
DrainState drain () override
 Provide a default implementation of the drain interface for objects that don't need draining.
 
virtual void memWriteback ()
 Write back dirty buffers to memory using functional writes.
 
virtual void memInvalidate ()
 Invalidate the contents of memory buffers.
 
void serialize (CheckpointOut &cp) const override
 Serialize an object.
 
void unserialize (CheckpointIn &cp) override
 Unserialize an object.
 
- Public Member Functions inherited from gem5::EventManager
EventQueueeventQueue () const
 
void schedule (Event &event, Tick when)
 
void deschedule (Event &event)
 
void reschedule (Event &event, Tick when, bool always=false)
 
void schedule (Event *event, Tick when)
 
void deschedule (Event *event)
 
void reschedule (Event *event, Tick when, bool always=false)
 
void wakeupEventQueue (Tick when=(Tick) -1)
 This function is not needed by the usual gem5 event loop but may be necessary in derived EventQueues which host gem5 on other schedulers.
 
void setCurTick (Tick newVal)
 
 EventManager (EventManager &em)
 Event manger manages events in the event queue.
 
 EventManager (EventManager *em)
 
 EventManager (EventQueue *eq)
 
- Public Member Functions inherited from gem5::Serializable
 Serializable ()
 
virtual ~Serializable ()
 
void serializeSection (CheckpointOut &cp, const char *name) const
 Serialize an object into a new section.
 
void serializeSection (CheckpointOut &cp, const std::string &name) const
 
void unserializeSection (CheckpointIn &cp, const char *name)
 Unserialize an a child object.
 
void unserializeSection (CheckpointIn &cp, const std::string &name)
 
- Public Member Functions inherited from gem5::Drainable
DrainState drainState () const
 Return the current drain state of an object.
 
virtual void notifyFork ()
 Notify a child process of a fork.
 
- Public Member Functions inherited from gem5::statistics::Group
 Group (Group *parent, const char *name=nullptr)
 Construct a new statistics group.
 
virtual ~Group ()
 
virtual void regStats ()
 Callback to set stat parameters.
 
virtual void resetStats ()
 Callback to reset stats.
 
virtual void preDumpStats ()
 Callback before stats are dumped.
 
void addStat (statistics::Info *info)
 Register a stat with this group.
 
const std::map< std::string, Group * > & getStatGroups () const
 Get all child groups associated with this object.
 
const std::vector< Info * > & getStats () const
 Get all stats associated with this object.
 
void addStatGroup (const char *name, Group *block)
 Add a stat block as a child of this block.
 
const InforesolveStat (std::string name) const
 Resolve a stat by its name within this group.
 
void mergeStatGroup (Group *block)
 Merge the contents (stats & children) of a block to this block.
 
 Group ()=delete
 
 Group (const Group &)=delete
 
Groupoperator= (const Group &)=delete
 
- Public Member Functions inherited from gem5::Named
 Named (const std::string &name_)
 
virtual ~Named ()=default
 
virtual std::string name () const
 

Static Public Attributes

static const Serial SERIAL_INITIAL = 0
 Initial serial.
 
static const Tick TICK_INITIAL = 0
 The initial tick the system starts with.
 
static const Tick TICK_FUTURE = MaxTick
 The maximum value that curTick() could ever return.
 
static const uint8_t DATA_INITIAL = 0x00
 Initial data value.
 

Private Member Functions

ByteTrackergetByteTracker (Addr addr)
 Returns the instance of ByteTracker for the requested location.
 

Private Attributes

std::string errorMessage
 Detailed error message of the last violation in completeRead.
 
Serial nextSerial
 Next distinct serial to be assigned to the next transaction to be started.
 
std::unordered_map< Addr, ByteTrackerbyte_trackers
 Maintain a map of address --> byte-tracker.
 

Additional Inherited Members

- Static Public Member Functions inherited from gem5::SimObject
static void serializeAll (const std::string &cpt_dir)
 Create a checkpoint by serializing all SimObjects in the system.
 
static SimObjectfind (const char *name)
 Find the SimObject with the given name and return a pointer to it.
 
static void setSimObjectResolver (SimObjectResolver *resolver)
 There is a single object name resolver, and it is only set when simulation is restoring from checkpoints.
 
static SimObjectResolvergetSimObjectResolver ()
 There is a single object name resolver, and it is only set when simulation is restoring from checkpoints.
 
- Static Public Member Functions inherited from gem5::Serializable
static const std::string & currentSection ()
 Gets the fully-qualified name of the active section.
 
static void generateCheckpointOut (const std::string &cpt_dir, std::ofstream &outstream)
 Generate a checkpoint file so that the serialization can be routed to it.
 
- Protected Member Functions inherited from gem5::Drainable
 Drainable ()
 
virtual ~Drainable ()
 
virtual void drainResume ()
 Resume execution after a successful drain.
 
void signalDrainDone () const
 Signal that an object is drained.
 
- Protected Attributes inherited from gem5::SimObject
const SimObjectParams & _params
 Cached copy of the object parameters.
 
- Protected Attributes inherited from gem5::EventManager
EventQueueeventq
 A pointer to this object's event queue.
 

Detailed Description

MemChecker.

Verifies that reads observe the values from permissible writes. As memory operations have a start and completion time, we consider them as transactions which have a start and end time. Because of this, the lifetimes of transactions of memory operations may be overlapping – we assume that if there is overlap between writes, they could be reordered by the memory subsystem, and a read could any of these. For more detail, see comments of inExpectedData().

For simplicity, the permissible values a read can observe are only dependent on the particular location, and we do not consider the effect of multi-byte reads or writes. This precludes us from discovering single-copy atomicity violations.

Definition at line 74 of file mem_checker.hh.

Member Typedef Documentation

◆ Serial

typedef uint64_t gem5::MemChecker::Serial

The Serial type is used to be able to uniquely identify a transaction as it passes through the system.

It's value is independent of any other system counters.

Definition at line 82 of file mem_checker.hh.

◆ TransactionList

◆ WriteClusterList

Constructor & Destructor Documentation

◆ MemChecker()

gem5::MemChecker::MemChecker ( const MemCheckerParams & p)
inline

Definition at line 377 of file mem_checker.hh.

◆ ~MemChecker()

virtual gem5::MemChecker::~MemChecker ( )
inlinevirtual

Definition at line 382 of file mem_checker.hh.

Member Function Documentation

◆ abortWrite()

void gem5::MemChecker::abortWrite ( MemChecker::Serial serial,
Addr addr,
size_t size )
inline

Aborts a previously started write transaction.

Parameters
serialA serial of a write that was previously started and matches the address of the previously started write.
addrAddress for write.
sizeThe size of the data written.

Definition at line 560 of file mem_checker.hh.

References gem5::MemChecker::ByteTracker::abortWrite(), gem5::X86ISA::addr, DPRINTF, getByteTracker(), and gem5::ArmISA::i.

Referenced by gem5::MemCheckerMonitor::recvTimingResp().

◆ completeRead()

bool gem5::MemChecker::completeRead ( MemChecker::Serial serial,
Tick complete,
Addr addr,
size_t size,
uint8_t * data )

Completes a previously started read transaction.

Parameters
serialA serial of a read that was previously started and matches the address of the previously started read.
completeTick we received the response from the memory subsystem.
addrAddress for read.
sizeSize of data received.
dataPointer to size bytes, containing data received.
Returns
True if the data we received is in the expected set, false otherwise.

Definition at line 302 of file mem_checker.cc.

References gem5::X86ISA::addr, gem5::MemChecker::ByteTracker::completeRead(), gem5::csprintf(), data, DPRINTF, errorMessage, getByteTracker(), gem5::ArmISA::i, and gem5::MemChecker::ByteTracker::lastExpectedData().

Referenced by gem5::MemCheckerMonitor::recvTimingResp().

◆ completeWrite()

void gem5::MemChecker::completeWrite ( MemChecker::Serial serial,
Tick complete,
Addr addr,
size_t size )
inline

Completes a previously started write transaction.

Parameters
serialA serial of a write that was previously started and matches the address of the previously started write.
completeTick we received acknowledgment of completion from the memory subsystem.
addrAddress for write.
sizeThe size of the data written.

Definition at line 547 of file mem_checker.hh.

References gem5::X86ISA::addr, gem5::MemChecker::ByteTracker::completeWrite(), DPRINTF, getByteTracker(), and gem5::ArmISA::i.

Referenced by gem5::MemCheckerMonitor::recvTimingResp().

◆ getByteTracker()

ByteTracker * gem5::MemChecker::getByteTracker ( Addr addr)
inlineprivate

Returns the instance of ByteTracker for the requested location.

Definition at line 482 of file mem_checker.hh.

References gem5::X86ISA::addr, and byte_trackers.

Referenced by abortWrite(), completeRead(), completeWrite(), startRead(), and startWrite().

◆ getErrorMessage()

const std::string & gem5::MemChecker::getErrorMessage ( ) const
inline

In completeRead, if an error is encountered, this does not print nor cause an error, but instead should be handled by the caller.

However, to record information about the cause of an error, completeRead creates an errorMessage. This function returns the last error that was detected in completeRead.

Returns
Reference to string of error message.

Definition at line 476 of file mem_checker.hh.

References errorMessage.

Referenced by gem5::MemCheckerMonitor::recvTimingResp().

◆ reset() [1/2]

void gem5::MemChecker::reset ( )
inline

Resets the entire checker.

Note that if there are transactions in-flight, this will cause a warning to be issued if these are completed after the reset. This does not reset nextSerial to avoid such a race condition: where a transaction started before a reset with serial S, then reset() was called, followed by a start of a transaction with the same serial S and then receive a completion of the transaction before the reset with serial S.

Definition at line 454 of file mem_checker.hh.

References byte_trackers.

Referenced by gem5::MemCheckerMonitor::recvFunctional(), and gem5::MemCheckerMonitor::recvFunctionalSnoop().

◆ reset() [2/2]

void gem5::MemChecker::reset ( Addr addr,
size_t size )

Resets an address-range.

This may be useful in case other unmonitored parts of the system caused modification to this memory, but we cannot track their written values.

Parameters
addrAddress base.
sizeSize of range to be invalidated.

Definition at line 347 of file mem_checker.cc.

References gem5::X86ISA::addr, byte_trackers, and gem5::ArmISA::i.

◆ startRead()

MemChecker::Serial gem5::MemChecker::startRead ( Tick start,
Addr addr,
size_t size )
inline

Starts a read transaction.

Parameters
startTick this read was sent to the memory subsystem.
addrAddress for read.
sizeSize of data expected.
Returns
Serial representing the unique identifier for this transaction.

Definition at line 519 of file mem_checker.hh.

References gem5::X86ISA::addr, DPRINTF, getByteTracker(), gem5::ArmISA::i, nextSerial, and gem5::MemChecker::ByteTracker::startRead().

Referenced by gem5::MemCheckerMonitor::recvTimingReq().

◆ startWrite()

MemChecker::Serial gem5::MemChecker::startWrite ( Tick start,
Addr addr,
size_t size,
const uint8_t * data )
inline

Starts a write transaction.

Parameters
startTick when this write was sent to the memory subsystem.
addrAddress for write.
sizeSize of data to be written.
dataPointer to size bytes, containing data to be written.
Returns
Serial representing the unique identifier for this transaction.

Definition at line 533 of file mem_checker.hh.

References gem5::X86ISA::addr, data, DPRINTF, getByteTracker(), gem5::ArmISA::i, nextSerial, and gem5::MemChecker::ByteTracker::startWrite().

Referenced by gem5::MemCheckerMonitor::recvTimingReq().

Member Data Documentation

◆ byte_trackers

std::unordered_map<Addr, ByteTracker> gem5::MemChecker::byte_trackers
private

Maintain a map of address --> byte-tracker.

Per-byte entries are initialized as needed.

The required space for this obviously grows with the number of distinct addresses used for a particular workload. The used size is independent on the number of nodes in the system, those may affect the size of per-byte tracking information.

Access via getByteTracker()!

Definition at line 515 of file mem_checker.hh.

Referenced by getByteTracker(), reset(), and reset().

◆ DATA_INITIAL

const uint8_t gem5::MemChecker::DATA_INITIAL = 0x00
static

Initial data value.

No requirements.

Definition at line 101 of file mem_checker.hh.

Referenced by gem5::MemChecker::ByteTracker::ByteTracker().

◆ errorMessage

std::string gem5::MemChecker::errorMessage
private

Detailed error message of the last violation in completeRead.

Definition at line 496 of file mem_checker.hh.

Referenced by completeRead(), and getErrorMessage().

◆ nextSerial

Serial gem5::MemChecker::nextSerial
private

Next distinct serial to be assigned to the next transaction to be started.

Definition at line 502 of file mem_checker.hh.

Referenced by startRead(), and startWrite().

◆ SERIAL_INITIAL

const Serial gem5::MemChecker::SERIAL_INITIAL = 0
static

Initial serial.

Definition at line 84 of file mem_checker.hh.

Referenced by gem5::MemChecker::ByteTracker::ByteTracker().

◆ TICK_FUTURE

const Tick gem5::MemChecker::TICK_FUTURE = MaxTick
static

◆ TICK_INITIAL

const Tick gem5::MemChecker::TICK_INITIAL = 0
static

The initial tick the system starts with.

Must not be larger than the minimum value that curTick() could return at any time in the system's execution.

Definition at line 91 of file mem_checker.hh.

Referenced by gem5::MemChecker::ByteTracker::ByteTracker(), and gem5::MemChecker::ByteTracker::inExpectedData().


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

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