8#include "sparta/functional/ArchData.hpp"
16namespace sparta::serialization::checkpoint
18 class FastCheckpointer;
114 std::stringstream ss;
115 ss <<
"<Checkpoint id=" << chkpt_id_ <<
" at t=" << tick_;
202 throw CheckpointError(
"Attempting to add a next checkpoint whose previous checkpoint pointer is not 'this'");
205 throw CheckpointError(
"Attempting to add a next checkpoint whose tick number (")
206 << next->
getTick() <<
" is less than this checkpoint's tick: " <<
getTick();
208 if(std::find(nexts_.begin(), nexts_.end(), next) != nexts_.end()){
209 throw CheckpointError(
"Next argument already present in this checkpoint's nexts_ list. Cannot re-add");
211 nexts_.push_back(next);
227 throw CheckpointError(
"Attempting to remove a next checkpoint whose previous pointer is not 'this'");
229 auto itr = std::find(nexts_.begin(), nexts_.end(), next);
230 if(itr == nexts_.end()){
231 throw CheckpointError(
"Next argument was not present in this checkpoint's nexts_ list. Cannot remove");
243 const std::vector<Checkpoint*>&
getNexts() const noexcept {
return nexts_; }
267 std::vector<Checkpoint*> nexts_;
292#define SPARTA_CHECKPOINT_BODY \
293 namespace sparta{ namespace serialization { namespace checkpoint { \
294 const Checkpoint::chkpt_id_t Checkpoint::MIN_CHECKPOINT; \
295 const Checkpoint::chkpt_id_t Checkpoint::UNIDENTIFIED_CHECKPOINT; \
File that contains checkpoint exception types.
A simple time-based, event precedence based scheduler.
Set of macros for Sparta assertions. Caught by the framework.
Exception class for all of Sparta.
Contains a set of contiguous line of architectural data which can be referred to by any architected o...
uint64_t Tick
Typedef for our unit of time.
Indicates that there was an issue operating on checkpoints within the SPARTA framework.
Single checkpoint object interface with a tick number and an ID unique to the owning Checkpointer ins...
Checkpoint()=delete
Not default constructable.
Checkpoint * getPrev() const noexcept
Returns the previous checkpoint. If this checkpoint is a snapshot, it has no previous checkpoint.
virtual std::string getDeletedRepr() const
Gets the representation of this deleted checkpoint as part of a checkpoint chain (if that checkpointe...
virtual std::string stringize() const
Returns a string describing this object.
Checkpoint(const Checkpoint &)=delete
Not copy constructable.
const std::vector< Checkpoint * > & getNexts() const noexcept
Returns next checkpoint following *this. May be an empty vector if there are no later checkpoints fol...
chkpt_id_t getID() const noexcept
Returns the ID of this checkpoint.
tick_t getTick() const noexcept
Returns the tick number at which this checkpoint was taken.
sparta::Scheduler::Tick tick_t
tick_t Tick type to which checkpoints will refer
virtual void load(const std::vector< ArchData * > &dats)=0
Attempts to restore this checkpoint state to the simulation state (ArchData) objects given to this Ch...
static const chkpt_id_t MIN_CHECKPOINT
Indicates the smallest valid checkpoint id.
void addNext(Checkpoint *next)
Adds another next checkpoint following *this.
void setID_(chkpt_id_t id)
Sets the checkpoint ID.
const Checkpoint & operator=(const Checkpoint &)=delete
Non-assignable.
void setPrev(Checkpoint *prev) noexcept
Sets the previous checkpoint of this checkpoint to prev.
virtual uint64_t getTotalMemoryUse() const noexcept=0
Returns memory usage by this checkpoint including any framework data structures.
Checkpoint(chkpt_id_t id, tick_t tick, Checkpoint *prev)
virtual void dumpData(std::ostream &o) const =0
Writes all checkpoint raw data to an ostream.
uint64_t chkpt_id_t
tick_t Tick type to which checkpoints will refer
static const chkpt_id_t UNIDENTIFIED_CHECKPOINT
Indicates unidentified checkpoint (could mean 'invalid' or 'any') depending on context.
void removeNext(Checkpoint *next)
Removes a checkpoint following *this because it was deleted.
virtual uint64_t getContentMemoryUse() const noexcept=0
Returns memory usage by this checkpoint solely for the checkpointed content.
virtual ~Checkpoint()
Destructor.
std::ostream & operator<<(std::ostream &o, const SimulationInfo &info)
ostream insertion operator for SimulationInfo