ICheckpointableModelComponent is an IModelComponent that can save and restore its complete simulation state. More...
#include <hydrocouple.h>
Public Member Functions | |
| virtual | ~ICheckpointableModelComponent ()=default |
| ~ICheckpointableModelComponent destructor. | |
| virtual bool | saveState (std::string &token, std::string &message)=0 |
| Saves the component's complete state. | |
| virtual bool | restoreState (const std::string &token, std::string &message)=0 |
| Restores state previously saved by saveState(). | |
| virtual bool | releaseState (const std::string &token, std::string &message)=0 |
| Releases a state saved by saveState() that will not be restored. | |
Public Member Functions inherited from HydroCouple::IModelComponent | |
| virtual | ~IModelComponent ()=default |
| IModelComponent::~IModelComponent destructor. | |
| virtual IModelComponentInfo * | componentInfo () const =0 |
| Contains the metadata about this IModelComponent instance. | |
| virtual ComponentStatus | status () const =0 |
| Defines current status of the IModelComponent. | |
| virtual std::vector< IArgument * > | arguments () const =0 |
| Arguments needed to let the component do its work. | |
| virtual std::vector< IInput * > | inputs () const =0 |
| The list of consumer items for which a component can receive values. | |
| virtual std::vector< IOutput * > | outputs () const =0 |
| The list of IOutputs for which a component can produce results. | |
| virtual std::vector< IComponentDataItem * > | results () const =0 |
| List of the model's output results. | |
| virtual std::vector< IComponentDataItem * > | states () const =0 |
| The data items that make up the state carried from one update() to the next. | |
| virtual void | initialize ()=0 |
| Initializes the current IModelComponent. | |
| virtual std::vector< std::string > | validate ()=0 |
| Validates the populated instance of the IModelComponent. | |
| virtual void | prepare ()=0 |
| Prepares the IModelComponent for calls to the update() method. | |
| virtual void | update (const std::vector< IOutput * > &requiredOutputs={})=0 |
| This method is called to let the component update itself, thus reaching its next state. | |
| virtual void | finish ()=0 |
| finish() must be invoked as the last of any methods in the IModelComponent interface. | |
| virtual const IWorkflowComponent * | workflow () const =0 |
| Gets the workflow that this component is part of. | |
| virtual void | setWorkflow (const IWorkflowComponent *workflow)=0 |
| Sets the workflow that this component is part of. | |
| virtual std::set< Capability > | capabilities () const =0 |
| The set of optional capabilities this component supports. | |
| virtual std::vector< ErrorEntry > | errors (bool clearAfterRead=false)=0 |
| Drains this component's diagnostic queue. | |
| virtual std::string | referenceDirectory () const =0 |
| Gets the reference directory for this component instance. | |
| virtual void | setReferenceDirectory (const std::string &referenceDirectory)=0 |
| setReferenceDirectory Sets the reference directory for this component instance. | |
Public Member Functions inherited from HydroCouple::IIdentity | |
| virtual | ~IIdentity ()=default |
| IIdentity::~IIdentity is a virtual destructor. | |
| virtual const std::string & | id () const =0 |
| Gets a unique identifier for the entity. | |
Public Member Functions inherited from HydroCouple::IDescription | |
| virtual | ~IDescription ()=default |
| IDescription::~IDescription is a virtual destructor. | |
| virtual const std::string & | caption () const =0 |
| Gets caption for the entity. | |
| virtual void | setCaption (const std::string &caption)=0 |
| Sets caption for the entity. | |
| virtual const std::string & | description () const =0 |
| Gets additional descriptive information for the entity. | |
| virtual void | setDescription (const std::string &description)=0 |
| Gets additional descriptive information for the entity. | |
Public Member Functions inherited from HydroCouple::IPropertyChanged | |
| virtual | ~IPropertyChanged ()=default |
| IPropertyChanged::~IPropertyChanged is a virtual destructor. | |
Public Member Functions inherited from HydroCouple::ISignal< std::string > | |
| virtual | ~ISignal ()=default |
| ISignal::~ISignal is a virtual destructor. | |
| virtual void | connect (const std::shared_ptr< ISlot< Args... > > &slot)=0 |
| connect is used to connect a slot to the signal. | |
| virtual void | disconnect (const std::shared_ptr< ISlot< Args... > > &slot)=0 |
| disconnect is used to disconnect a slot from the signal. | |
| virtual void | blockSignals (bool block)=0 |
| blockSignals is used to block signals from being emitted. | |
Public Member Functions inherited from HydroCouple::ISignal< const std::shared_ptr< IComponentStatusChangeEventArgs > & > | |
| virtual | ~ISignal ()=default |
| ISignal::~ISignal is a virtual destructor. | |
| virtual void | connect (const std::shared_ptr< ISlot< Args... > > &slot)=0 |
| connect is used to connect a slot to the signal. | |
| virtual void | disconnect (const std::shared_ptr< ISlot< Args... > > &slot)=0 |
| disconnect is used to disconnect a slot from the signal. | |
| virtual void | blockSignals (bool block)=0 |
| blockSignals is used to block signals from being emitted. | |
Additional Inherited Members | |
Public Types inherited from HydroCouple::IModelComponent | |
| enum class | ComponentStatus : uint8_t { Created = 0 , Initializing = 1 , Initialized = 2 , Validating = 3 , Valid = 4 , WaitingForData = 5 , Invalid = 6 , Preparing = 7 , Updating = 8 , Updated = 9 , Checkpointing = 10 , Done = 11 , Finishing = 12 , Finished = 13 , Failed = 14 } |
| HydroCouple::ComponentStatus is an enumerator that describes the status of a component over the course of its lifetime. More... | |
Protected Member Functions inherited from HydroCouple::ISignal< std::string > | |
| virtual void | emit (Args... args)=0 |
| emit is used to emit the signal. | |
Protected Member Functions inherited from HydroCouple::ISignal< const std::shared_ptr< IComponentStatusChangeEventArgs > & > | |
| virtual void | emit (Args... args)=0 |
| emit is used to emit the signal. | |
ICheckpointableModelComponent is an IModelComponent that can save and restore its complete simulation state.
Checkpoint/restart is required for preemptible cloud execution and walltime-limited HPC runs. During saveState()/restoreState() the component's status is HydroCouple::Checkpointing. Components supporting this interface advertise Capability::Checkpointing.
Lifecycle. Both saveState() and restoreState() are legal when status() is HydroCouple::Updated or HydroCouple::Done. saveState() returns the component to the status it was entered from. A successful restoreState() always lands in HydroCouple::Updated — even from Done — because the restored state is, in general, not the final one. A failed call lands in HydroCouple::Failed. A restart in a fresh process therefore runs initialize(), validate(), prepare() and then restoreState(): the checkpoint replaces the prepared state, it does not replace preparation.
What a checkpoint captures is at least every item in IModelComponent::states() plus whatever private solver state update() depends on.
|
virtualdefault |
~ICheckpointableModelComponent destructor.
|
nodiscardpure virtual |
Releases a state saved by saveState() that will not be restored.
Whatever saveState() set aside for token – a file under referenceDirectory(), a buffer, a remote object – may be reclaimed. An orchestrator that keeps checkpoints for replay (reverse-mode differentiation among them) saves far more states than it ever restores and calls this for each one it drops, so a component whose token names storage must honour it or leak that storage for the length of the run. A component whose token IS the state has nothing to free and returns true. After this call the token is dead: restoring or releasing it again is an error the component may refuse.
| [in] | token | is an opaque identifier returned by saveState(). |
| [out] | message | describes the failure when the return value is false. |
|
nodiscardpure virtual |
Restores state previously saved by saveState().
Legal when status() is HydroCouple::Updated or HydroCouple::Done; on success the status is HydroCouple::Updated and the component behaves as if it had computed its way to the checkpointed simulation state.
| [in] | token | is the opaque identifier returned by saveState(). |
| [out] | message | describes the failure when the return value is false. |
|
nodiscardpure virtual |
Saves the component's complete state.
The component persists its state to storage of its choosing (typically under referenceDirectory()) and returns an opaque token with which the state can be restored later, possibly by a different process on a different machine. Legal when status() is HydroCouple::Updated or HydroCouple::Done; on return the status is what it was before the call (or Failed).
| [out] | token | is an opaque identifier for the saved state. |
| [out] | message | describes the failure when the return value is false. |