The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::serialization::checkpoint::Checkpoint Class Referenceabstract

Single checkpoint object interface with a tick number and an ID unique to the owning Checkpointer instance. More...

#include <Checkpoint.hpp>

Inheritance diagram for sparta::serialization::checkpoint::Checkpoint:

Public Types

Local Types
typedef sparta::Scheduler::Tick tick_t
 tick_t Tick type to which checkpoints will refer
 
typedef uint64_t chkpt_id_t
 tick_t Tick type to which checkpoints will refer
 

Public Member Functions

virtual std::string stringize () const
 Returns a string describing this object.
 
virtual void dumpData (std::ostream &o) const =0
 Writes all checkpoint raw data to an ostream.
 
virtual uint64_t getTotalMemoryUse () const noexcept=0
 Returns memory usage by this checkpoint including any framework data structures.
 
virtual uint64_t getContentMemoryUse () const noexcept=0
 Returns memory usage by this checkpoint solely for the checkpointed content.
 
Checkpoint Actions
virtual void load (const std::vector< ArchData * > &dats)=0
 Attempts to restore this checkpoint state to the simulation state (ArchData) objects given to this Checkpoint at construction.
 
tick_t getTick () const noexcept
 Returns the tick number at which this checkpoint was taken.
 
chkpt_id_t getID () const noexcept
 Returns the ID of this checkpoint.
 
virtual std::string getDeletedRepr () const
 Gets the representation of this deleted checkpoint as part of a checkpoint chain (if that checkpointer supports deletion)
 
CheckpointgetPrev () const noexcept
 Returns the previous checkpoint. If this checkpoint is a snapshot, it has no previous checkpoint.
 
void setPrev (Checkpoint *prev) noexcept
 Sets the previous checkpoint of this checkpoint to prev.
 
void addNext (Checkpoint *next)
 Adds another next checkpoint following *this.
 
void removeNext (Checkpoint *next)
 Removes a checkpoint following *this because it was deleted.
 
const std::vector< Checkpoint * > & getNexts () const noexcept
 Returns next checkpoint following *this. May be an empty vector if there are no later checkpoints following this Checkpoint.
 

Static Public Attributes

static const chkpt_id_t MIN_CHECKPOINT = 0
 Indicates the smallest valid checkpoint id.
 
static const chkpt_id_t UNIDENTIFIED_CHECKPOINT = ~(chkpt_id_t)0
 Indicates unidentified checkpoint (could mean 'invalid' or 'any') depending on context.
 

Protected Member Functions

void setID_ (chkpt_id_t id)
 Sets the checkpoint ID.
 

Construction & Initialization

 Checkpoint ()=delete
 Not default constructable.
 
 Checkpoint (const Checkpoint &)=delete
 Not copy constructable.
 
const Checkpointoperator= (const Checkpoint &)=delete
 Non-assignable.
 
virtual ~Checkpoint ()
 Destructor.
 
 Checkpoint (chkpt_id_t id, tick_t tick, Checkpoint *prev)
 

Detailed Description

Single checkpoint object interface with a tick number and an ID unique to the owning Checkpointer instance.

A subclass of Checkpointer is expected to hold or refer to some checkpoint data in memory or on disk at construction which can be restored with load()

Definition at line 28 of file Checkpoint.hpp.

Member Typedef Documentation

◆ chkpt_id_t

tick_t Tick type to which checkpoints will refer

Definition at line 40 of file Checkpoint.hpp.

◆ tick_t

tick_t Tick type to which checkpoints will refer

Definition at line 37 of file Checkpoint.hpp.

Constructor & Destructor Documentation

◆ Checkpoint()

sparta::serialization::checkpoint::Checkpoint::Checkpoint ( chkpt_id_t  id,
tick_t  tick,
Checkpoint prev 
)
inlineprotected
Note
Should only be constructed by subclasses

Definition at line 75 of file Checkpoint.hpp.

◆ ~Checkpoint()

virtual sparta::serialization::checkpoint::Checkpoint::~Checkpoint ( )
inlinevirtual

Destructor.

Removes this checkpoint from the chain and patches chain between prev and each item in the nexts list

Definition at line 92 of file Checkpoint.hpp.

Here is the call graph for this function:

Member Function Documentation

◆ addNext()

void sparta::serialization::checkpoint::Checkpoint::addNext ( Checkpoint next)
inline

Adds another next checkpoint following *this.

Parameters
nextNext checkpoint (later in simulator ticks) than *this. Cannot be nullptr. Must contain (at a minimum) all state which changed since *this checkpoint was taken. next->getPrev() must be this checkpoint and next->getTick() must be >= this->getTick()
Exceptions
CheckpointErrorif next argument is nullptr or already in next checkpoints list or if next->getTick() < this->getTick()

Definition at line 197 of file Checkpoint.hpp.

Here is the call graph for this function:

◆ dumpData()

virtual void sparta::serialization::checkpoint::Checkpoint::dumpData ( std::ostream &  o) const
pure virtual

Writes all checkpoint raw data to an ostream.

Parameters
oostream to which raw data will be written
Note
No newlines or other extra characters will be appended

Implemented in sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >.

◆ getContentMemoryUse()

virtual uint64_t sparta::serialization::checkpoint::Checkpoint::getContentMemoryUse ( ) const
pure virtualnoexcept

Returns memory usage by this checkpoint solely for the checkpointed content.

Implemented in sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >.

◆ getDeletedRepr()

virtual std::string sparta::serialization::checkpoint::Checkpoint::getDeletedRepr ( ) const
inlinevirtual

Gets the representation of this deleted checkpoint as part of a checkpoint chain (if that checkpointer supports deletion)

Reimplemented in sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >.

Definition at line 166 of file Checkpoint.hpp.

◆ getID()

chkpt_id_t sparta::serialization::checkpoint::Checkpoint::getID ( ) const
inlinenoexcept

Returns the ID of this checkpoint.

Note
Number has no sequential meaning - it is effectively a random ID.

Definition at line 160 of file Checkpoint.hpp.

◆ getNexts()

const std::vector< Checkpoint * > & sparta::serialization::checkpoint::Checkpoint::getNexts ( ) const
inlinenoexcept

Returns next checkpoint following *this. May be an empty vector if there are no later checkpoints following this Checkpoint.

Returning an empty vector implies that there are no checkpoints descended from this

Definition at line 243 of file Checkpoint.hpp.

◆ getPrev()

Checkpoint * sparta::serialization::checkpoint::Checkpoint::getPrev ( ) const
inlinenoexcept

Returns the previous checkpoint. If this checkpoint is a snapshot, it has no previous checkpoint.

Definition at line 174 of file Checkpoint.hpp.

◆ getTick()

tick_t sparta::serialization::checkpoint::Checkpoint::getTick ( ) const
inlinenoexcept

Returns the tick number at which this checkpoint was taken.

Definition at line 153 of file Checkpoint.hpp.

◆ getTotalMemoryUse()

virtual uint64_t sparta::serialization::checkpoint::Checkpoint::getTotalMemoryUse ( ) const
pure virtualnoexcept

Returns memory usage by this checkpoint including any framework data structures.

Implemented in sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >.

◆ load()

virtual void sparta::serialization::checkpoint::Checkpoint::load ( const std::vector< ArchData * > &  dats)
pure virtual

Attempts to restore this checkpoint state to the simulation state (ArchData) objects given to this Checkpoint at construction.

Implemented in sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >.

◆ removeNext()

void sparta::serialization::checkpoint::Checkpoint::removeNext ( Checkpoint next)
inline

Removes a checkpoint following *this because it was deleted.

Parameters
nextNext checkpoint to remove. Must be found in this object's nexts list. next->getPrev() must be this. Must not be nullptr.
Warning
Do not call this within a loop of getNexts(). Iterators on that object will be invalidated

Definition at line 222 of file Checkpoint.hpp.

Here is the call graph for this function:

◆ setID_()

void sparta::serialization::checkpoint::Checkpoint::setID_ ( chkpt_id_t  id)
inlineprotected

Sets the checkpoint ID.

Definition at line 253 of file Checkpoint.hpp.

◆ setPrev()

void sparta::serialization::checkpoint::Checkpoint::setPrev ( Checkpoint prev)
inlinenoexcept

Sets the previous checkpoint of this checkpoint to prev.

Parameters
prevNew previou checkpoint. Overwrites previous This will often be accompanied by a call to addNext on the prev argument

Definition at line 184 of file Checkpoint.hpp.

◆ stringize()

virtual std::string sparta::serialization::checkpoint::Checkpoint::stringize ( ) const
inlinevirtual

Returns a string describing this object.

Reimplemented in sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >.

Definition at line 113 of file Checkpoint.hpp.

Here is the call graph for this function:

Member Data Documentation

◆ MIN_CHECKPOINT

const chkpt_id_t sparta::serialization::checkpoint::Checkpoint::MIN_CHECKPOINT = 0
static

Indicates the smallest valid checkpoint id.

Definition at line 48 of file Checkpoint.hpp.

◆ UNIDENTIFIED_CHECKPOINT

const chkpt_id_t sparta::serialization::checkpoint::Checkpoint::UNIDENTIFIED_CHECKPOINT = ~(chkpt_id_t)0
static

Indicates unidentified checkpoint (could mean 'invalid' or 'any') depending on context.

Definition at line 54 of file Checkpoint.hpp.


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