|
The Sparta Modeling Framework
|
Checkpointer interface. Defines an ID-based checkpointing API for tree of related checkpoints which could be stored as ordered deltas internally. More...
#include <Checkpointer.hpp>


Public Types | |
Local Types | |
| typedef Checkpoint::tick_t | tick_t |
| tick_t Tick type to which checkpoints will refer | |
| typedef Checkpoint::chkpt_id_t | chkpt_id_t |
| tick_t Tick type to which checkpoints will refer | |
Public Member Functions | |
Construction & Initialization | |
| Checkpointer (TreeNode &root, sparta::Scheduler *sched=nullptr) | |
| Checkpointer Constructor. | |
| Checkpointer (const std::vector< TreeNode * > &roots, sparta::Scheduler *sched=nullptr) | |
| Checkpointer Constructor. | |
| virtual | ~Checkpointer () |
| Destructor. | |
Attributes | |
| const std::vector< TreeNode * > & | getRoots () const noexcept |
| Returns the root(s) associated with this checkpointer. | |
| const Scheduler * | getScheduler () const noexcept |
| Returns the sheduler associated with this checkpointer. | |
| virtual uint64_t | getTotalMemoryUse () const noexcept=0 |
| Computes and returns the memory usage by this checkpointer at this moment including any framework overhead. | |
| virtual uint64_t | getContentMemoryUse () const noexcept=0 |
| Computes and returns the memory usage by this checkpointer at this moment purely for the checkpoint state being held. | |
| uint64_t | getTotalCheckpointsCreated () const noexcept |
| Returns the total number of checkpoints which have been created by this checkpointer. This is unrelated to the current number of checkpoints in existance. Includes the head checkpoint if created. | |
Checkpointing Actions & Queries | |
| void | createHead () |
| Creates a head without taking an identified checkpoint. Cannot already have a head. | |
| chkpt_id_t | createCheckpoint (bool force_snapshot=false) |
| Creates a checkpoint at the given scheduler's current tick with a new checkpoint ID some point after the current checkpoint (see getCurrentID). If the current checkpoint already has other next checkpoints, the new checkpoint will be an alternate branch of the current checkpoint. This snapshot may be stored as a full snapshot if the checkpointer requires it, or if the snapshot threshold is exceeded, or if the force_snapshot argument is true Current tick will be read from scheduler (if not null) and must be >= the head checkpoint's tick. The current tick must also be >= the current checkpoints tick (See getCurrenTick). | |
| virtual void | deleteCheckpoint (chkpt_id_t id)=0 |
| Deletes a checkpoint by ID. | |
| virtual void | loadCheckpoint (chkpt_id_t id)=0 |
| Loads state from a specific checkpoint by ID. | |
| void | forgetCurrent () |
| Forgets the current checkpoint and current checkpoint (resetting to the head checkpoint) so that checkpoints can be taken at a different time without assuming simulation state continutiy with this checkpointers. This is ONLY to be used by a simulator IFF another checkpointer restores state at another cycle or the simulator resets but this checkpointer's tree is still expected to exist. | |
| virtual std::vector< chkpt_id_t > | getCheckpointsAt (tick_t t)=0 |
| Gets all checkpoints taken at tick t on any timeline. | |
| virtual std::vector< chkpt_id_t > | getCheckpoints ()=0 |
| Gets all known checkpoint IDs available on any timeline sorted by tick (or equivalently checkpoint ID). | |
| virtual uint32_t | getNumCheckpoints () const noexcept=0 |
| Gets the current number of checkpoints having valid IDs which a client of this interface can refer to. | |
| virtual std::deque< chkpt_id_t > | getCheckpointChain (chkpt_id_t id)=0 |
| Debugging utility which gets a deque of checkpoints representing a chain starting at the checkpoint head and ending at the checkpoint specified by id. Ths results can contain Checkpoint::UNIDENTIFIED_CHECKPOINT to represent temporary deleted checkpoints in the chain. | |
| virtual bool | hasCheckpoint (chkpt_id_t id) noexcept=0 |
| Tests whether this checkpoint manager has a checkpoint with the given id. | |
| const CheckpointBase * | getHead () const noexcept |
| Returns the head checkpoint which is equivalent to the earliest checkpoint taken. | |
| chkpt_id_t | getHeadID () const noexcept |
| Returns the checkpoint ID of the head checkpoint (if it exists) which is equivalent to the earliest checkpoint taken. | |
| chkpt_id_t | getCurrentID () const |
| Returns the current checkpoint ID. This is mainly a debugging utility as the current ID changes when adding, deleting, and loading checkpoints based on whether the checkpoints take were deltas or snapshots. A correct integration of the checkpointer by a simulator should not depend on this method for behavior decisions. | |
| tick_t | getCurrentTick () const |
| Gets the tick number of the current checkpoint (see getCurrentID). This is the tick number of the latest checkpoint either saved or written through this checkpointer. The next checkpoint taken will be on the same chain as a checkpoint taken at this tick. | |
| virtual std::vector< chkpt_id_t > | getNextIDs (chkpt_id_t id)=0 |
| Returns IDs of the checkpoints immediately following the given checkpoint. | |
Printing Methods | |
| virtual std::string | stringize () const |
| Returns a string describing this object. | |
| virtual void | dumpList (std::ostream &o)=0 |
| Dumps this checkpointer's flat list of checkpoints to an ostream with a newline following each checkpoint. | |
| virtual void | dumpData (std::ostream &o)=0 |
| Dumps this checkpointer's data to an ostream with a newline following each checkpoint. | |
| virtual void | dumpAnnotatedData (std::ostream &o)=0 |
| Dumps this checkpointer's data to an ostream with annotations between each ArchData and a newline following each checkpoint description and each checkpoint data dump. | |
| virtual void | traceValue (std::ostream &o, chkpt_id_t id, const ArchData *container, uint32_t offset, uint32_t size)=0 |
| Debugging utility which dumps values in some bytes across a chain of checkpoints. The intent is to show the values loaded when attempting to restore needed to restore the given value in the selected checkpoint. | |
| void | dumpTree (std::ostream &o) |
| Dumps this checkpointer's tree to an ostream with a line for each branch. Printout timescale is not relevant. Multi-line printouts for deep branches will be difficult to read. | |
| void | dumpBranch (std::ostream &o, const chkpt_id_t chkpt, uint32_t indent, uint32_t pos, std::deque< uint32_t > &continues) |
| Recursively dumps one branch (and sub-branches) to an ostream with a line for each branch. | |
Protected Member Functions | |
| virtual void | createHead_ ()=0 |
| Create a head node. | |
| virtual chkpt_id_t | createCheckpoint_ (bool force_snapshot=false)=0 |
| Create a checkpoint. | |
| virtual void | dumpCheckpointNode_ (const chkpt_id_t id, std::ostream &o) |
| const std::vector< ArchData * > & | getArchDatas () const |
| Returns ArchDatas enumerated by this Checkpointer for iteration when saving or loading checkpoint data. | |
| CheckpointBase * | getHead_ () noexcept |
| Non-const variant of getHead_. | |
| const CheckpointBase * | getHead_ () const noexcept |
| Gets the head checkpoint. Returns nullptr if none created yet. | |
| void | setHead_ (CheckpointBase *head) |
| Sets the head checkpointer pointer to head for the first time. | |
| CheckpointBase * | getCurrent_ () const noexcept |
| Gets the current checkpointer pointer. Returns nullptr if there is no current checkpoint object. | |
| void | setCurrent_ (CheckpointBase *current) |
| Sets the current checkpoint pointer. | |
Protected Attributes | |
| Scheduler *const | sched_ |
| Scheduler whose tick count will be set and read. Cannnot be updated after first checkpoint without bad side effects. Keeping this const for simplicity. | |
Checkpointer interface. Defines an ID-based checkpointing API for tree of related checkpoints which could be stored as ordered deltas internally.
Internal storage and structure are to be defined by implementations of this interface
A checkpoint tree may look something like the following, where each checkpoint is shown here by its simulation tick number (not ID)
* t=0 (head) --> t=100 +-> t=300 * | * `-> t=320 --> t=400 +-> t=500 * | `-> t=430 * `-> t=300 *
The procedure for using a Checkpointer is generally:
Then:
Definition at line 56 of file Checkpointer.hpp.
tick_t Tick type to which checkpoints will refer
Definition at line 68 of file Checkpointer.hpp.
tick_t Tick type to which checkpoints will refer
Definition at line 65 of file Checkpointer.hpp.
|
inline |
Checkpointer Constructor.
| root | TreeNode at which checkpoints will be taken. This cannot be changed later. This does not necessarily need to be a RootTreeNode. Before the first checkpoint is taken, this node must be finalized (see sparta::TreeNode::isFinalized). At this point, the node does not need to be finalized |
| sched | Relevant scheduler. If nullptr (default), the checkpoints will not have their Ticks assigned |
Definition at line 87 of file Checkpointer.hpp.
|
inline |
Checkpointer Constructor.
| roots | TreeNodes at which checkpoints will be taken. This cannot be changed later. These do not necessarily need to be RootTreeNodes. Before the first checkpoint is taken, these nodes must be finalized (see sparta::TreeNode::isFinalized). At this point, the nodes do not need to be finalized. |
| sched | Relevant scheduler. If nullptr (default), the checkpoints will not have their Ticks assigned |
Definition at line 103 of file Checkpointer.hpp.
|
inlinevirtual |
Destructor.
Definition at line 111 of file Checkpointer.hpp.
|
inline |
Creates a checkpoint at the given scheduler's current tick with a new checkpoint ID some point after the current checkpoint (see getCurrentID). If the current checkpoint already has other next checkpoints, the new checkpoint will be an alternate branch of the current checkpoint. This snapshot may be stored as a full snapshot if the checkpointer requires it, or if the snapshot threshold is exceeded, or if the force_snapshot argument is true Current tick will be read from scheduler (if not null) and must be >= the head checkpoint's tick. The current tick must also be >= the current checkpoints tick (See getCurrenTick).
| force_snapshot | Forces the newly-created checkpoint to be a full snapshot instead of allowing the checkpointer to decide based on getSnapshotThreshold. A snapshot takes more time and space to store, but this can be a performance optimization if this checkpoint will be re-loaded very frequently |
| CheckpointError | if a head checkpoint exists and the current tick is less than the head checkpoint's tick, or if the root TreeNode is not finalized. Also throws if the number of checkpoint IDs has been exhausted (i.e. all values of a chkpt_id_t have been used as IDs). This is unlikely and has a special exception message. |
Definition at line 246 of file Checkpointer.hpp.

|
protectedpure virtual |
Create a checkpoint.
|
inline |
Creates a head without taking an identified checkpoint. Cannot already have a head.
| CheckpointError | if root is not yet finalized or a head already exists for this checkpointer |
Generally, this is called after all simulation state is initialized (e.g. resisters set) since it makes little sense to go back to a pre-initialized state.
Test for a head if necessary with getHead(). Typically, this should be called before running the simulation.
Definition at line 182 of file Checkpointer.hpp.

|
protectedpure virtual |
Create a head node.
|
pure virtual |
Deletes a checkpoint by ID.
| id | ID of checkpoint to delete. Must not be Checkpoint::UNIDENTIFIED_CHECKPOINT and must not be equal to the ID of the head checkpoint. |
| CheckpointError | if this manager has no checkpoint with given id. Test with hasCheckpoint first. If id == Checkpoint::UNIDENTIFIED_CHECKPOINT, always throws. Throws if id == getHeadID(). Head cannot be deleted |
Internally, this deletion may be effective-only and actual data may still exist in an incaccessible form as part of the checkpoint tree implementation.
If the current checkpoint is deleted, current will be updated back along the current checkpoints previous checkpoint chain until a non deleted checkpoint is found. This will become the new current checkpoint
Implemented in sparta::serialization::checkpoint::DatabaseCheckpointer, and sparta::serialization::checkpoint::FastCheckpointer.
|
pure virtual |
Dumps this checkpointer's data to an ostream with annotations between each ArchData and a newline following each checkpoint description and each checkpoint data dump.
| o | ostream to dump to |
Implemented in sparta::serialization::checkpoint::DatabaseCheckpointer, and sparta::serialization::checkpoint::FastCheckpointer.
|
inline |
Recursively dumps one branch (and sub-branches) to an ostream with a line for each branch.
| o | ostream to dump to |
| chkpt | Checkpoint to start printint at |
| indent | Number of spaces to indent before printing this branch |
| pos | Position on line. |
| continues | Vector of continue indent points where '|' characters should be printed on lines whose indent amount is greater than each particular indent point. This creates the vertical lines expected in directory-like tree-view displays |
Definition at line 543 of file Checkpointer.hpp.

|
inlineprotectedvirtual |
Reimplemented in sparta::serialization::checkpoint::FastCheckpointer.
Definition at line 641 of file Checkpointer.hpp.
|
pure virtual |
Dumps this checkpointer's data to an ostream with a newline following each checkpoint.
| o | ostream to dump to |
Implemented in sparta::serialization::checkpoint::DatabaseCheckpointer, and sparta::serialization::checkpoint::FastCheckpointer.
|
pure virtual |
Dumps this checkpointer's flat list of checkpoints to an ostream with a newline following each checkpoint.
| o | ostream to dump to |
Implemented in sparta::serialization::checkpoint::DatabaseCheckpointer, and sparta::serialization::checkpoint::FastCheckpointer.
|
inline |
Dumps this checkpointer's tree to an ostream with a line for each branch. Printout timescale is not relevant. Multi-line printouts for deep branches will be difficult to read.
| o | ostream to dump to |
Definition at line 525 of file Checkpointer.hpp.

|
inline |
Forgets the current checkpoint and current checkpoint (resetting to the head checkpoint) so that checkpoints can be taken at a different time without assuming simulation state continutiy with this checkpointers. This is ONLY to be used by a simulator IFF another checkpointer restores state at another cycle or the simulator resets but this checkpointer's tree is still expected to exist.
Definition at line 309 of file Checkpointer.hpp.
|
inlineprotected |
Returns ArchDatas enumerated by this Checkpointer for iteration when saving or loading checkpoint data.
Definition at line 649 of file Checkpointer.hpp.
|
pure virtual |
Debugging utility which gets a deque of checkpoints representing a chain starting at the checkpoint head and ending at the checkpoint specified by id. Ths results can contain Checkpoint::UNIDENTIFIED_CHECKPOINT to represent temporary deleted checkpoints in the chain.
| id | ID of checkpoint that terminates the chain |
| CheckpointError | if id does not refer to a valid checkpoint. |
Implemented in sparta::serialization::checkpoint::DatabaseCheckpointer, and sparta::serialization::checkpoint::FastCheckpointer.
|
pure virtual |
Gets all known checkpoint IDs available on any timeline sorted by tick (or equivalently checkpoint ID).
Implemented in sparta::serialization::checkpoint::DatabaseCheckpointer, and sparta::serialization::checkpoint::FastCheckpointer.
|
pure virtual |
Gets all checkpoints taken at tick t on any timeline.
| t | Tick number at which checkpoints should found. |
Implemented in sparta::serialization::checkpoint::DatabaseCheckpointer, and sparta::serialization::checkpoint::FastCheckpointer.
|
pure virtualnoexcept |
Computes and returns the memory usage by this checkpointer at this moment purely for the checkpoint state being held.
Implemented in sparta::serialization::checkpoint::DatabaseCheckpointer, and sparta::serialization::checkpoint::FastCheckpointer.
|
inlineprotectednoexcept |
Gets the current checkpointer pointer. Returns nullptr if there is no current checkpoint object.
Definition at line 684 of file Checkpointer.hpp.
|
inline |
Returns the current checkpoint ID. This is mainly a debugging utility as the current ID changes when adding, deleting, and loading checkpoints based on whether the checkpoints take were deltas or snapshots. A correct integration of the checkpointer by a simulator should not depend on this method for behavior decisions.
The current checkpoint refers to the most recent checkpoint either loaded or created. This value is used to refer to the previous-checkpoint when creating a delta checkpoint.
Loading, creating, and deleting a checkpoint updates the current checkpoint.
If the previous current checkpoint was deleted, current is updated to refer back to the most recent previous checkpoint in the same previous-checkpoint chain of one which was deleted.
Definition at line 424 of file Checkpointer.hpp.

|
inline |
Gets the tick number of the current checkpoint (see getCurrentID). This is the tick number of the latest checkpoint either saved or written through this checkpointer. The next checkpoint taken will be on the same chain as a checkpoint taken at this tick.
Definition at line 444 of file Checkpointer.hpp.

|
inlinenoexcept |
Returns the head checkpoint which is equivalent to the earliest checkpoint taken.
The head checkpoint has an ID of Checkpoint::UNIDENTIFIED_CHECKPOINT and can never be deleted.
Definition at line 380 of file Checkpointer.hpp.
|
inlineprotectednoexcept |
Gets the head checkpoint. Returns nullptr if none created yet.
Definition at line 663 of file Checkpointer.hpp.
|
inlineprotectednoexcept |
Non-const variant of getHead_.
Definition at line 656 of file Checkpointer.hpp.
|
inlinenoexcept |
Returns the checkpoint ID of the head checkpoint (if it exists) which is equivalent to the earliest checkpoint taken.
The head checkpoint can never be deleted.
Definition at line 393 of file Checkpointer.hpp.

|
pure virtual |
Returns IDs of the checkpoints immediately following the given checkpoint.
Implemented in sparta::serialization::checkpoint::DatabaseCheckpointer, and sparta::serialization::checkpoint::FastCheckpointer.
|
pure virtualnoexcept |
Gets the current number of checkpoints having valid IDs which a client of this interface can refer to.
Ignores any internal temporary or deleted checkpoints without visible IDs
Implemented in sparta::serialization::checkpoint::DatabaseCheckpointer, and sparta::serialization::checkpoint::FastCheckpointer.
|
inlinenoexcept |
Returns the root(s) associated with this checkpointer.
Definition at line 124 of file Checkpointer.hpp.
|
inlinenoexcept |
Returns the sheduler associated with this checkpointer.
Definition at line 129 of file Checkpointer.hpp.
|
inlinenoexcept |
Returns the total number of checkpoints which have been created by this checkpointer. This is unrelated to the current number of checkpoints in existance. Includes the head checkpoint if created.
Definition at line 150 of file Checkpointer.hpp.
|
pure virtualnoexcept |
Computes and returns the memory usage by this checkpointer at this moment including any framework overhead.
Implemented in sparta::serialization::checkpoint::DatabaseCheckpointer, and sparta::serialization::checkpoint::FastCheckpointer.
|
pure virtualnoexcept |
Tests whether this checkpoint manager has a checkpoint with the given id.
Implemented in sparta::serialization::checkpoint::DatabaseCheckpointer, and sparta::serialization::checkpoint::FastCheckpointer.
|
pure virtual |
Loads state from a specific checkpoint by ID.
| CheckpointError | if id does not refer to checkpoint that exists or if checkpoint could not be load. |
Implemented in sparta::serialization::checkpoint::DatabaseCheckpointer, and sparta::serialization::checkpoint::FastCheckpointer.
|
inlineprotected |
Sets the current checkpoint pointer.
| current | Pointer to set as current checkpoint. The next checkpoint created will follow the current checkpoint set here. Cannot be nullptr |
Definition at line 694 of file Checkpointer.hpp.
|
inlineprotected |
Sets the head checkpointer pointer to head for the first time.
| head | New head checkpoint pointer. Must not be nullptr |
Definition at line 674 of file Checkpointer.hpp.
|
inlinevirtual |
Returns a string describing this object.
Reimplemented in sparta::serialization::checkpoint::DatabaseCheckpointer, and sparta::serialization::checkpoint::FastCheckpointer.
Definition at line 467 of file Checkpointer.hpp.

|
pure virtual |
Debugging utility which dumps values in some bytes across a chain of checkpoints. The intent is to show the values loaded when attempting to restore needed to restore the given value in the selected checkpoint.
| o | ostream with each value and checkpoint ID will be printed |
| id | ID of checkpoint to "restore" value from |
| container | ArchData in which the data being traced lives |
| offset | Offset into container |
| size | Bytes to read at offset |
Implemented in sparta::serialization::checkpoint::DatabaseCheckpointer, and sparta::serialization::checkpoint::FastCheckpointer.
|
protected |
Scheduler whose tick count will be set and read. Cannnot be updated after first checkpoint without bad side effects. Keeping this const for simplicity.
Definition at line 705 of file Checkpointer.hpp.