46 #include "debug/Drain.hh" 66 "Trying to drain a drained system\n");
69 "Drain counter must be zero at the start of a drain cycle\n");
78 DPRINTF(Drain,
"Failed to drain %s\n", temp->
name());
84 DPRINTF(Drain,
"Drain done.\n");
88 DPRINTF(Drain,
"Need another drain cycle. %u/%u objects not ready.\n",
98 "Trying to resume a system that is already running\n");
101 "Resuming a system that isn't fully drained, this is untested and " 102 "likely to break\n");
105 "Resuming a system that is already trying to resume. This should " 109 "Resume called in the middle of a drain cycle. %u objects " 110 "left to drain.\n",
_count);
125 obj->dmDrainResume();
137 "preCheckpointRestore() called on a system that isn't in the " 140 DPRINTF(Drain,
"Applying pre-restore fixes to %u objects.\n",
180 if (obj->drainState() !=
state)
198 _drainState(_drainManager.
state())
224 "Trying to resume an object that hasn't been drained\n");
void preCheckpointRestore()
Run state fixups before a checkpoint restore operation.
DrainManager & _drainManager
Convenience reference to the drain manager.
DrainState
Object drain/handover states.
DrainState state() const
Get the simulators global drain state.
Buffers drained, ready for serialization/handover.
size_t drainableCount() const
Thread-safe helper function to get the number of Drainable objects in a system.
Interface for objects that might require draining before checkpointing.
void dmDrainResume()
DrainManager interface to request a resume operation.
virtual DrainState drain()=0
Notify an object that it needs to drain its state.
std::atomic_uint _count
Number of objects still draining.
DrainState dmDrain()
DrainManager interface to request a drain operation.
This class coordinates draining of a System.
#define warn_if(cond,...)
Conditional warning macro that checks the supplied condition and only prints a warning if the conditi...
std::vector< Drainable * > _allDrainable
Set of all drainable objects.
void unregisterDrainable(Drainable *obj)
static DrainManager _instance
Singleton instance of the drain manager.
Draining buffers pending serialization/handover.
virtual const std::string name() const
bool tryDrain()
Try to drain the system.
std::mutex globalLock
Lock protecting the set of drainable objects.
void exitSimLoop(const std::string &message, int exit_code, Tick when, Tick repeat, bool serialize)
Schedule an event to exit the simulation loop (returning to Python) at the end of the current cycle (...
bool allInState(DrainState state) const
Helper function to check if all Drainable objects are in a specific state.
void registerDrainable(Drainable *obj)
static DrainManager & instance()
Get the singleton DrainManager instance.
virtual void drainResume()
Resume execution after a successful drain.
void resume()
Resume normal simulation in a Drained system.
DrainState _state
Global simulator drain state.
void signalDrainDone()
Notify the DrainManager that a Drainable object has finished draining.
DrainState _drainState
Current drain state of the object.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Abstract superclass for simulation objects.