The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::serialization::checkpoint::DeltaCheckpoint< StorageT > Class Template Reference

Single delta checkpoint object containing all simulator state which changed since some previous DeltaCheckpoint. Can contain all simulator state if it has no previous DeltaCheckpoint. The previous delta can be referenced by getPrev(). More...

#include <DeltaCheckpoint.hpp>

Inheritance diagram for sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >:
Collaboration diagram for sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >:

Public Member Functions

virtual std::string stringize () const override
 Returns a string describing this object.
 
virtual void dumpData (std::ostream &o) const override
 Writes all checkpoint raw data to an ostream.
 
void dumpRestoreChain (std::ostream &o) const
 Dumps the restore chain for this checkpoint.
 
virtual uint64_t getTotalMemoryUse () const noexcept override
 Returns memory usage by this checkpoint.
 
virtual uint64_t getContentMemoryUse () const noexcept override
 Returns memory usage by the content of this checkpoint.
 
Checkpoint Actions
void traceValue (std::ostream &o, const std::vector< ArchData * > &dats, const ArchData *container, uint32_t offset, uint32_t size)
 Implement trace of a value across the restore chain as described in Checkpointer::traceValue.
 
std::stack< DeltaCheckpoint * > getHistoryChain ()
 Returns a stack of checkpoints from this checkpoint as far back as possible until no previous link is found. This is a superset of getRestoreChain and contains checkpoints that do not actually need to be inspected for restoring this checkpoint's data. This may reach the head checkpoint if no gaps are encountered.
 
std::stack< DeltaCheckpoint * > getRestoreChain ()
 Returns a stack of checkpoints that must be restored from top-to-bottom to fully restore the state associated with this checkpoint.
 
std::stack< const DeltaCheckpoint * > getRestoreChain () const
 Const-qualified version of getRestoreChain.
 
virtual void load (const std::vector< ArchData * > &dats) override
 Attempts to restore this checkpoint including any previous deltas (dependencies).
 
bool canDelete () const noexcept
 Can this checkpoint be deleted Cannot be deleted if:
 
void flagDeleted ()
 Allows this checkpoint to be deleted if it is no longer a previous delta of some other delta (i.e. getNexts() returns an empty vector). Sets the checkpoint ID to invalid. Calling multiple times has no effect.
 
bool isFlaggedDeleted () const noexcept
 Indicates whether this checkpoint has been flagged deleted.
 
chkpt_id_t getDeletedID () const noexcept
 Return the ID had by this checkpoint before it was deleted If this checkpoint has not been flagged for deletion, this will be UNIDENTIFIED_CHECKPOINT.
 
virtual std::string getDeletedRepr () const override
 Gets the representation of this deleted checkpoint as part of a checkpoint chain (if that checkpointer supports deletion)
 
bool isSnapshot () const noexcept
 Is this checkpoint a snapshot (contains ALL simulator state)
 
uint32_t getDistanceToPrevSnapshot () const noexcept
 Determines how many checkpoints away the closest, earlier snapshot is.
 
- Public Member Functions inherited from sparta::serialization::checkpoint::Checkpoint
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.
 
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.
 
 Checkpoint ()=delete
 Not default constructable.
 
 Checkpoint (const Checkpoint &)=delete
 Not copy constructable.
 
const Checkpointoperator= (const Checkpoint &)=delete
 Non-assignable.
 
virtual ~Checkpoint ()
 Destructor.
 

Protected Member Functions

void loadState (const std::vector< ArchData * > &dats)
 Loads delta state of this checkpoint to root. Does not look at any other checkpoints checkpoints.
 
- Protected Member Functions inherited from sparta::serialization::checkpoint::Checkpoint
void setID_ (chkpt_id_t id)
 Sets the checkpoint ID.
 
 Checkpoint (chkpt_id_t id, tick_t tick, Checkpoint *prev)
 

Construction & Initialization

class FastCheckpointer
 DeltaCheckpoints can only be constructed by the FastCheckpointer.
 
 DeltaCheckpoint ()=delete
 Not default constructable.
 
 DeltaCheckpoint (const DeltaCheckpoint &)=delete
 Not copy constructable.
 
const DeltaCheckpointoperator= (const DeltaCheckpoint &)=delete
 Non-assignable.
 
virtual ~DeltaCheckpoint ()
 Destructor.
 

Additional Inherited Members

- Public Types inherited from sparta::serialization::checkpoint::Checkpoint
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
 
- Static Public Attributes inherited from sparta::serialization::checkpoint::Checkpoint
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.
 

Detailed Description

template<typename StorageT = storage::StringStreamStorage>
class sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >

Single delta checkpoint object containing all simulator state which changed since some previous DeltaCheckpoint. Can contain all simulator state if it has no previous DeltaCheckpoint. The previous delta can be referenced by getPrev().

Allows timeline branching by having one DeltaCheckpoint be the previous checkpoint of multiple other checkpoints.

Once this checkpoint becomes another's previous checkpoint, that checkpoint can be referenced (among the rest) through getNextDeltas().

Intended to be constructed and manipulated only by a FastCheckpointer instance.

Todo:
Store reverse deltas additional (or maybe instead) so that rewind is quicker

Definition at line 371 of file DeltaCheckpoint.hpp.

Constructor & Destructor Documentation

◆ ~DeltaCheckpoint()

template<typename StorageT = storage::StringStreamStorage>
virtual sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >::~DeltaCheckpoint ( )
inlinevirtual

Destructor.

Note
Checkpoint destructor removes this Checkpoint from the chain.

Prints a warning if checkpoint was not allowed to be deleted

See also
canDelete

Definition at line 459 of file DeltaCheckpoint.hpp.

Here is the call graph for this function:

Member Function Documentation

◆ canDelete()

template<typename StorageT = storage::StringStreamStorage>
bool sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >::canDelete ( ) const
inlinenoexcept

Can this checkpoint be deleted Cannot be deleted if:

  • This checkpoint has any ancestors which are not deletable and not snapshots
  • This checkpoint was not flagged for deletion with flagDeleted
    Warning
    This is a recursive search of a checkpoint tree which has potentially many branches and could have high time cost

Definition at line 707 of file DeltaCheckpoint.hpp.

Here is the call graph for this function:

◆ dumpData()

template<typename StorageT = storage::StringStreamStorage>
virtual void sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >::dumpData ( std::ostream &  o) const
inlineoverridevirtual

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

Implements sparta::serialization::checkpoint::Checkpoint.

Definition at line 494 of file DeltaCheckpoint.hpp.

◆ dumpRestoreChain()

template<typename StorageT = storage::StringStreamStorage>
void sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >::dumpRestoreChain ( std::ostream &  o) const
inline

Dumps the restore chain for this checkpoint.

See also
getRestoreChain()
Parameters
oostream to which chain data will be dumped

Definition at line 503 of file DeltaCheckpoint.hpp.

Here is the call graph for this function:

◆ flagDeleted()

template<typename StorageT = storage::StringStreamStorage>
void sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >::flagDeleted ( )
inline

Allows this checkpoint to be deleted if it is no longer a previous delta of some other delta (i.e. getNexts() returns an empty vector). Sets the checkpoint ID to invalid. Calling multiple times has no effect.

Precondition
Must not already be flagged deleted
Postcondition
isFlaggedDeleted() will return true
getDeletedID() will return the current ID (if any)
See also
canDelete
isFlaggedDeleted

Definition at line 731 of file DeltaCheckpoint.hpp.

Here is the call graph for this function:

◆ getContentMemoryUse()

template<typename StorageT = storage::StringStreamStorage>
virtual uint64_t sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >::getContentMemoryUse ( ) const
inlineoverridevirtualnoexcept

Returns memory usage by the content of this checkpoint.

Implements sparta::serialization::checkpoint::Checkpoint.

Definition at line 539 of file DeltaCheckpoint.hpp.

◆ getDeletedID()

template<typename StorageT = storage::StringStreamStorage>
chkpt_id_t sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >::getDeletedID ( ) const
inlinenoexcept

Return the ID had by this checkpoint before it was deleted If this checkpoint has not been flagged for deletion, this will be UNIDENTIFIED_CHECKPOINT.

Definition at line 754 of file DeltaCheckpoint.hpp.

◆ getDeletedRepr()

template<typename StorageT = storage::StringStreamStorage>
virtual std::string sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >::getDeletedRepr ( ) const
inlineoverridevirtual

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

Returns
"D-" concatenate with ID copied when being deleted. Returns the ID if not yet deleted

Reimplemented from sparta::serialization::checkpoint::Checkpoint.

Definition at line 764 of file DeltaCheckpoint.hpp.

Here is the call graph for this function:

◆ getDistanceToPrevSnapshot()

template<typename StorageT = storage::StringStreamStorage>
uint32_t sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >::getDistanceToPrevSnapshot ( ) const
inlinenoexcept

Determines how many checkpoints away the closest, earlier snapshot is.

Returns
distance to closest snapshot. If this node is a snapshot, returns 0; if immediate getPrev() is a snapshot, returns 1; and so on.
Note
This is a noexcept function, which means that the exception if no snapshot is encountered is uncatchable. This is intentional.

Definition at line 789 of file DeltaCheckpoint.hpp.

Here is the call graph for this function:

◆ getHistoryChain()

template<typename StorageT = storage::StringStreamStorage>
std::stack< DeltaCheckpoint * > sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >::getHistoryChain ( )
inline

Returns a stack of checkpoints from this checkpoint as far back as possible until no previous link is found. This is a superset of getRestoreChain and contains checkpoints that do not actually need to be inspected for restoring this checkpoint's data. This may reach the head checkpoint if no gaps are encountered.

Definition at line 633 of file DeltaCheckpoint.hpp.

Here is the call graph for this function:

◆ getRestoreChain() [1/2]

template<typename StorageT = storage::StringStreamStorage>
std::stack< DeltaCheckpoint * > sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >::getRestoreChain ( )
inline

Returns a stack of checkpoints that must be restored from top-to-bottom to fully restore the state associated with this checkpoint.

Definition at line 649 of file DeltaCheckpoint.hpp.

Here is the call graph for this function:

◆ getRestoreChain() [2/2]

template<typename StorageT = storage::StringStreamStorage>
std::stack< const DeltaCheckpoint * > sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >::getRestoreChain ( ) const
inline

Const-qualified version of getRestoreChain.

Definition at line 666 of file DeltaCheckpoint.hpp.

Here is the call graph for this function:

◆ getTotalMemoryUse()

template<typename StorageT = storage::StringStreamStorage>
virtual uint64_t sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >::getTotalMemoryUse ( ) const
inlineoverridevirtualnoexcept

Returns memory usage by this checkpoint.

Implements sparta::serialization::checkpoint::Checkpoint.

Definition at line 530 of file DeltaCheckpoint.hpp.

Here is the call graph for this function:

◆ isFlaggedDeleted()

template<typename StorageT = storage::StringStreamStorage>
bool sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >::isFlaggedDeleted ( ) const
inlinenoexcept

Indicates whether this checkpoint has been flagged deleted.

Note
Does not imply that the checkpoint can safely be deleted; only that it was flagged for deletion.
If false, Checkpoint ID will also be UNIDENTIFIED_CHECKPOINT
See also
flagDeleted()

Definition at line 745 of file DeltaCheckpoint.hpp.

Here is the call graph for this function:

◆ isSnapshot()

template<typename StorageT = storage::StringStreamStorage>
bool sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >::isSnapshot ( ) const
inlinenoexcept

Is this checkpoint a snapshot (contains ALL simulator state)

Definition at line 777 of file DeltaCheckpoint.hpp.

◆ load()

template<typename StorageT = storage::StringStreamStorage>
virtual void sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >::load ( const std::vector< ArchData * > &  dats)
inlineoverridevirtual

Attempts to restore this checkpoint including any previous deltas (dependencies).

Uses loadState to restore state from each checkpoint in the restore chain.

Implements sparta::serialization::checkpoint::Checkpoint.

Definition at line 687 of file DeltaCheckpoint.hpp.

Here is the call graph for this function:

◆ loadState()

template<typename StorageT = storage::StringStreamStorage>
void sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >::loadState ( const std::vector< ArchData * > &  dats)
inlineprotected

Loads delta state of this checkpoint to root. Does not look at any other checkpoints checkpoints.

See also
load

Definition at line 842 of file DeltaCheckpoint.hpp.

Here is the call graph for this function:

◆ stringize()

template<typename StorageT = storage::StringStreamStorage>
virtual std::string sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >::stringize ( ) const
inlineoverridevirtual

Returns a string describing this object.

Reimplemented from sparta::serialization::checkpoint::Checkpoint.

Definition at line 472 of file DeltaCheckpoint.hpp.

Here is the call graph for this function:

◆ traceValue()

template<typename StorageT = storage::StringStreamStorage>
void sparta::serialization::checkpoint::DeltaCheckpoint< StorageT >::traceValue ( std::ostream &  o,
const std::vector< ArchData * > &  dats,
const ArchData container,
uint32_t  offset,
uint32_t  size 
)
inline

Implement trace of a value across the restore chain as described in Checkpointer::traceValue.

Definition at line 550 of file DeltaCheckpoint.hpp.

Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ FastCheckpointer

template<typename StorageT = storage::StringStreamStorage>
friend class FastCheckpointer
friend

DeltaCheckpoints can only be constructed by the FastCheckpointer.

Definition at line 448 of file DeltaCheckpoint.hpp.


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