|
ADS-IDAC Engine 5.0.0
|
Complete state of a dynamic event tree run at a sequence boundary. More...
#include <DETCheckpoint.h>
Public Member Functions | |
| template<class Archive > | |
| void | serialize (Archive &ar, unsigned int) |
| Boost serialization of the archive layout. More... | |
| void | capture_branch_center (const BranchRecord &br) |
Serialize br (Boost binary archive) into branch_center_blob, replacing its previous content. More... | |
| void | restore_branch_center (BranchRecord &br) const |
Deserialize branch_center_blob into br. The blob must be uncompressed, as load() leaves it; a Boost archive exception propagates if the blob is empty or malformed. More... | |
| bool | config_matches (uint64_t current) const |
Does this checkpoint's configuration digest match current, the digest of the running process (g_sim.config_fingerprint)? More... | |
| void | save (const std::string &path) |
Write the checkpoint to path. More... | |
Static Public Member Functions | |
| static bool | version_supported (int v) |
Whether load() accepts a file with stored version v. More... | |
| static std::string | lz4_pack_string (const std::string &s) |
LZ4-compress s with the 4-byte size header of lz4_compress(). More... | |
| static std::string | lz4_unpack_string (const std::string &s) |
Inverse of lz4_pack_string(). Exits the process (lz4_decompress) if s does not decompress to its recorded size. More... | |
| static std::string | pack_rinfo (const RestartNodeInfo &ri) |
| Serialize one snapshot (Boost binary archive) and LZ4-compress it. More... | |
| static std::shared_ptr< RestartNodeInfo > | unpack_rinfo (const std::string &blob) |
| Inverse of pack_rinfo(). Deserialization pre-seeds the snapshot from the process-local shared masters (SharedConfig.h); with no master registered, its configuration members stay default-valued. More... | |
| static DETCheckpoint | load (const std::string &path) |
| Read a checkpoint file. More... | |
Public Attributes | |
| int | version = VERSION |
| Format version stored in the archive. More... | |
| int | sequences_completed = 0 |
| Sequences finished when the checkpoint was taken. More... | |
| int | sequence_counter = 0 |
| uint64_t | config_fingerprint = 0 |
| bool | compress_queue = false |
| bool | blobs_compressed = false |
| std::map< int, std::vector< char > > | source_blobs |
| source key -> restart blob More... | |
| std::map< int, int > | cid_source |
| int | max_branch_id = -1 |
| std::string | branch_center_blob |
| std::vector< std::string > | packed_rinfos |
| lz4(serialized rinfo), one per unique snapshot More... | |
| std::map< int, int > | restart_state_pack_ref |
| cid -> packed index (-1 = null entry) More... | |
| std::vector< int > | task_state_pack_ref |
| task position -> packed index (-1 = null) More... | |
| std::map< int, std::shared_ptr< RestartNodeInfo > > | restart_states |
| cid -> snapshot; read by serial resume More... | |
| std::map< int, std::string > | branch_record_blobs |
| cid -> serialized BranchRecord of the holding client; filled by the MPI writer only and used there to build branch_center_blob More... | |
| std::vector< PendingBranch > | pending_tasks |
| Unexplored branches. More... | |
| std::vector< std::shared_ptr< RestartNodeInfo > > | task_restart_states |
| Snapshot per pending task (null = none); read by MPI resume. More... | |
| std::vector< std::string > | task_branch_blobs |
| Always empty; resume dispatches branch_center_blob. More... | |
| std::vector< SequenceReport > | completed_reports |
| Reports of finished sequences (filled only when the visualization server is on) More... | |
Static Public Attributes | |
| static constexpr int | VERSION = 9 |
Complete state of a dynamic event tree run at a sequence boundary.
One Boost binary archive per file. The same format is written by the serial loop (ADSIDAC.cpp) and by the MPI server (Server::write_checkpoint) and can be resumed in either mode and with any rank count. Crew snapshots inside it are state-only: a resume rebuilds configuration from the project's input files, which is why the configuration fingerprint is checked. Not thread-safe; build, save and load from one thread.
Definition at line 45 of file DETCheckpoint.h.
|
inline |
Serialize br (Boost binary archive) into branch_center_blob, replacing its previous content.
Definition at line 151 of file DETCheckpoint.h.
References branch_center_blob.
Referenced by build_serial_checkpoint().
|
inline |
Does this checkpoint's configuration digest match current, the digest of the running process (g_sim.config_fingerprint)?
Definition at line 177 of file DETCheckpoint.h.
References config_fingerprint, and version.
|
inlinestatic |
Read a checkpoint file.
Exits the process with status 1 (message on stderr) if the file cannot be opened, the archive is corrupt or truncated, or its version is not supported; it never returns a partial object. In MPI only rank 0 calls it, and the exit is a plain std::exit(1), not MPI_Abort. On return the at-rest LZ4 layer is stripped (blobs_compressed == false), restart_states and task_restart_states are rebuilt with their shared_ptr aliasing, and the packed members are empty. When compress_queue is true, source_blobs still carry their queue-layer LZ4 encoding. Snapshot deserialization uses the shared masters of SharedConfig.h, so register them first. The configuration fingerprint is NOT checked here; callers use config_matches().
Definition at line 312 of file DETCheckpoint.h.
References blobs_compressed, branch_center_blob, branch_record_blobs, compress_queue, lz4_decompress(), lz4_unpack_string(), packed_rinfos, restart_state_pack_ref, restart_states, source_blobs, task_restart_states, task_state_pack_ref, unpack_rinfo(), VERSION, version, and version_supported().
Referenced by Server::dispatch_resume_tasks(), and main().
|
inlinestatic |
LZ4-compress s with the 4-byte size header of lz4_compress().
Definition at line 183 of file DETCheckpoint.h.
References lz4_compress().
Referenced by pack_rinfo(), and save().
|
inlinestatic |
Inverse of lz4_pack_string(). Exits the process (lz4_decompress) if s does not decompress to its recorded size.
Definition at line 189 of file DETCheckpoint.h.
References lz4_decompress().
Referenced by load(), and unpack_rinfo().
|
inlinestatic |
Serialize one snapshot (Boost binary archive) and LZ4-compress it.
Definition at line 195 of file DETCheckpoint.h.
References lz4_pack_string().
Referenced by save().
|
inline |
Deserialize branch_center_blob into br. The blob must be uncompressed, as load() leaves it; a Boost archive exception propagates if the blob is empty or malformed.
Definition at line 161 of file DETCheckpoint.h.
References branch_center_blob.
|
inline |
Write the checkpoint to path.
Writes <path>.tmp and renames it into place, so a process killed mid-save leaves any earlier file at path intact. MUTATES the object: source_blobs (unless compress_queue), branch_record_blobs and branch_center_blob are LZ4-compressed in place and blobs_compressed is set, so build a fresh object for every save. restart_states and task_restart_states stay usable. On failure (cannot open, short write, rename error) it prints "ERROR: ..." on stderr and returns without throwing or exiting (a short write also removes the temp file); success prints "[CHECKPOINT] Saved: ..." on stdout. There is no return value, so a caller cannot tell the two apart.
Definition at line 227 of file DETCheckpoint.h.
References blobs_compressed, branch_center_blob, branch_record_blobs, compress_queue, lz4_compress(), lz4_pack_string(), pack_rinfo(), packed_rinfos, pending_tasks, restart_state_pack_ref, restart_states, sequences_completed, source_blobs, task_restart_states, and task_state_pack_ref.
Referenced by Server::write_checkpoint().
|
inline |
Boost serialization of the archive layout.
load() accepts only files with version >= 9, and save() writes VERSION, so for every accepted archive each version >= N guard below is true and both version < 7 guards are false: the raw restart_states and task_restart_states containers are never archived, only their packed form. For a file with a lower stored version the guards select the fields that version carried; load() then rejects the file (or reports it corrupt if the archive cannot be parsed).
Definition at line 113 of file DETCheckpoint.h.
References blobs_compressed, branch_center_blob, branch_record_blobs, cid_source, completed_reports, compress_queue, config_fingerprint, max_branch_id, packed_rinfos, pending_tasks, restart_state_pack_ref, restart_states, sequence_counter, sequences_completed, source_blobs, task_branch_blobs, task_restart_states, task_state_pack_ref, and version.
|
inlinestatic |
Inverse of pack_rinfo(). Deserialization pre-seeds the snapshot from the process-local shared masters (SharedConfig.h); with no master registered, its configuration members stay default-valued.
Definition at line 206 of file DETCheckpoint.h.
References lz4_unpack_string().
Referenced by load().
|
inlinestatic |
Whether load() accepts a file with stored version v.
Definition at line 170 of file DETCheckpoint.h.
Referenced by load().
| bool DETCheckpoint::blobs_compressed = false |
At-rest compression flag. save() LZ4-compresses the blob payloads inside the archive (RELAP restart sources dominate checkpoint size) and load() strips the layer again, so consumers always see uncompressed bytes. Sources already compressed by –compress-queue keep their queue-layer bytes (owned by that flag) and are not compressed a second time.
Definition at line 67 of file DETCheckpoint.h.
Referenced by load(), save(), and serialize().
| std::string DETCheckpoint::branch_center_blob |
Serialized merged BranchRecord. Serial resume restores it as the global tree; MPI resume sends it with every dispatched task.
Definition at line 80 of file DETCheckpoint.h.
Referenced by capture_branch_center(), load(), restore_branch_center(), save(), serialize(), and Server::write_checkpoint().
| std::map<int, std::string> DETCheckpoint::branch_record_blobs |
cid -> serialized BranchRecord of the holding client; filled by the MPI writer only and used there to build branch_center_blob
Definition at line 94 of file DETCheckpoint.h.
Referenced by load(), save(), serialize(), and Server::write_checkpoint().
| std::map<int, int> DETCheckpoint::cid_source |
pending CID -> source key
Definition at line 72 of file DETCheckpoint.h.
Referenced by build_serial_checkpoint(), serialize(), and Server::write_checkpoint().
| std::vector<SequenceReport> DETCheckpoint::completed_reports |
Reports of finished sequences (filled only when the visualization server is on)
Definition at line 101 of file DETCheckpoint.h.
Referenced by serialize(), and Server::write_checkpoint().
| bool DETCheckpoint::compress_queue = false |
Whether the restart blobs carry the queue-layer LZ4 encoding of –compress-queue. A resume adopts this value, so the blobs are always decoded the way they were encoded. Serial checkpoints always store false.
Definition at line 61 of file DETCheckpoint.h.
Referenced by build_serial_checkpoint(), load(), save(), serialize(), and Server::write_checkpoint().
| uint64_t DETCheckpoint::config_fingerprint = 0 |
FNV-1a digest of the immutable configuration inputs (deck, Input/**, ZCtrlPar.txt) at write time. A resume compares it with its own digest and refuses on mismatch: the snapshots are state-only, so a resume rebuilds configuration from the project files, and different files would mean a different tree. 0 = not computed (see config_matches()).
Definition at line 57 of file DETCheckpoint.h.
Referenced by build_serial_checkpoint(), config_matches(), serialize(), and Server::write_checkpoint().
| int DETCheckpoint::max_branch_id = -1 |
Highest branch ID issued by the checkpointed run, exactly as issued. A resumed run derives a fresh ID epoch above it so its new IDs can never collide with identities that live on inside merged PE outputs. -1 = none.
Definition at line 76 of file DETCheckpoint.h.
Referenced by build_serial_checkpoint(), serialize(), and Server::write_checkpoint().
| std::vector<std::string> DETCheckpoint::packed_rinfos |
lz4(serialized rinfo), one per unique snapshot
Definition at line 88 of file DETCheckpoint.h.
Referenced by load(), save(), and serialize().
| std::vector<PendingBranch> DETCheckpoint::pending_tasks |
Unexplored branches.
Definition at line 97 of file DETCheckpoint.h.
Referenced by build_serial_checkpoint(), save(), serialize(), and Server::write_checkpoint().
| std::map<int, int> DETCheckpoint::restart_state_pack_ref |
cid -> packed index (-1 = null entry)
Definition at line 89 of file DETCheckpoint.h.
Referenced by load(), save(), and serialize().
| std::map<int, std::shared_ptr<RestartNodeInfo> > DETCheckpoint::restart_states |
cid -> snapshot; read by serial resume
Definition at line 93 of file DETCheckpoint.h.
Referenced by build_serial_checkpoint(), load(), save(), serialize(), and Server::write_checkpoint().
| int DETCheckpoint::sequence_counter = 0 |
Next global sequence ID to assign
Definition at line 51 of file DETCheckpoint.h.
Referenced by build_serial_checkpoint(), serialize(), and Server::write_checkpoint().
| int DETCheckpoint::sequences_completed = 0 |
Sequences finished when the checkpoint was taken.
Definition at line 50 of file DETCheckpoint.h.
Referenced by build_serial_checkpoint(), save(), serialize(), and Server::write_checkpoint().
| std::map<int, std::vector<char> > DETCheckpoint::source_blobs |
source key -> restart blob
Definition at line 71 of file DETCheckpoint.h.
Referenced by build_serial_checkpoint(), load(), save(), serialize(), and Server::write_checkpoint().
| std::vector<std::string> DETCheckpoint::task_branch_blobs |
Always empty; resume dispatches branch_center_blob.
Definition at line 99 of file DETCheckpoint.h.
Referenced by serialize().
| std::vector<std::shared_ptr<RestartNodeInfo> > DETCheckpoint::task_restart_states |
Snapshot per pending task (null = none); read by MPI resume.
Definition at line 98 of file DETCheckpoint.h.
Referenced by build_serial_checkpoint(), load(), save(), serialize(), and Server::write_checkpoint().
| std::vector<int> DETCheckpoint::task_state_pack_ref |
task position -> packed index (-1 = null)
Definition at line 90 of file DETCheckpoint.h.
Referenced by load(), save(), and serialize().
|
staticconstexpr |
Current file format version. save() always writes it; load() refuses any file whose stored version is lower (see version_supported()).
Definition at line 48 of file DETCheckpoint.h.
Referenced by load().
| int DETCheckpoint::version = VERSION |
Format version stored in the archive.
Definition at line 49 of file DETCheckpoint.h.
Referenced by config_matches(), load(), and serialize().