From 87b9da2df4d4dc0028566a7803ee55159343d735 Mon Sep 17 00:00:00 2001 From: Curtis Dunham Date: Wed, 2 Sep 2015 15:23:30 -0500 Subject: sim: tag-based checkpoint versioning This commit addresses gem5 checkpoints' linear versioning bottleneck. Since development is distributed across many private trees, there exists a sort of 'race' for checkpoint version numbers: internally a checkpoint version may be used but then resynchronizing with the external tree causes a conflict on that version. This change replaces the linear version number with a set of unique strings called tags. Now the only conflicts that can arise are of tag names, where collisions are much easier to avoid. The checkpoint upgrader (util/cpt_upgrader.py) upgrades the version representation, as one would expect. Each tag version implements its upgrader code in a python file in the util/cpt_upgraders directory rather than adding a function to the upgrader script itself. The version tags are stored in the 'Globals' section rather than 'root' (as the version was previously) because 'Globals' gets unserialized first and can provide a warning before any other unserialization errors can occur. --- src/sim/serialize.cc | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'src/sim/serialize.cc') diff --git a/src/sim/serialize.cc b/src/sim/serialize.cc index 0904b1375..f9a945b95 100644 --- a/src/sim/serialize.cc +++ b/src/sim/serialize.cc @@ -496,16 +496,73 @@ class Globals : public Serializable /// The one and only instance of the Globals class. Globals globals; +/// The version tags for this build of the simulator, to be stored in the +/// Globals section during serialization and compared upon unserialization. +extern std::set version_tags; + void Globals::serialize(CheckpointOut &cp) const { paramOut(cp, "curTick", curTick()); + SERIALIZE_CONTAINER(version_tags); } void Globals::unserialize(CheckpointIn &cp) { paramIn(cp, "curTick", unserializedCurTick); + + const std::string §ion(Serializable::currentSection()); + std::string str; + if (!cp.find(section, "version_tags", str)) { + warn("**********************************************************\n"); + warn("!!!! Checkpoint uses an old versioning scheme. !!!!\n"); + warn("Run the checkpoint upgrader (util/cpt_upgrader.py) on your " + "checkpoint\n"); + warn("**********************************************************\n"); + return; + } + + std::set cpt_tags; + arrayParamIn(cp, "version_tags", cpt_tags); // UNSERIALIZE_CONTAINER + + bool err = false; + for (const auto& t : version_tags) { + if (cpt_tags.find(t) == cpt_tags.end()) { + // checkpoint is missing tag that this binary has + if (!err) { + warn("*****************************************************\n"); + warn("!!!! Checkpoint is missing the following version tags:\n"); + err = true; + } + warn(" %s\n", t); + } + } + if (err) { + warn("You might experience some issues when restoring and should run " + "the checkpoint upgrader (util/cpt_upgrader.py) on your " + "checkpoint\n"); + warn("**********************************************************\n"); + } + + err = false; + for (const auto& t : cpt_tags) { + if (version_tags.find(t) == version_tags.end()) { + // gem5 binary is missing tag that this checkpoint has + if (!err) { + warn("*****************************************************\n"); + warn("!!!! gem5 is missing the following version tags:\n"); + err = true; + } + warn(" %s\n", t); + } + } + if (err) { + warn("Running a checkpoint with incompatible version tags is not " + "supported. While it might work, you may experience incorrect " + "behavior or crashes.\n"); + warn("**********************************************************\n"); + } } Serializable::Serializable() -- cgit v1.2.3