diff --git a/src/dev/ParallelChecker.hpp b/src/dev/ParallelChecker.hpp index 08b6de99159ed84019529459b5e21799003f99fc..e37729292e46212dec5257fa5681e83a2e591f57 100644 --- a/src/dev/ParallelChecker.hpp +++ b/src/dev/ParallelChecker.hpp @@ -13,6 +13,7 @@ #include <utils/Filesystem.hpp> #include <utils/Messenger.hpp> #include <utils/SourceLocation.hpp> +#include <utils/checkpointing/ResumingManager.hpp> #include <fstream> @@ -1248,6 +1249,22 @@ class ParallelChecker return *m_instance; } + size_t + tag() const + { + return m_tag; + } + + void + setTag(size_t tag) + { + if (ResumingManager::getInstance().isResuming()) { + m_tag = tag; + } else { + throw UnexpectedError("Cannot modify parallel checker tag if not resuming"); + } + } + Mode mode() const { @@ -1257,7 +1274,7 @@ class ParallelChecker void setMode(const Mode& mode) { - if (m_tag != 0) { + if ((m_tag != 0) and not ResumingManager::getInstance().isResuming()) { throw UnexpectedError("Cannot modify parallel checker mode if it was already used"); } diff --git a/src/utils/checkpointing/Checkpoint.cpp b/src/utils/checkpointing/Checkpoint.cpp index 245871c0dad26b78f92f846416b9f63f1c4d9add..70166a86175bd5621bc545112db7ac17e28e668a 100644 --- a/src/utils/checkpointing/Checkpoint.cpp +++ b/src/utils/checkpointing/Checkpoint.cpp @@ -21,6 +21,7 @@ #ifdef PUGS_HAS_HDF5 #include <algebra/LinearSolverOptions.hpp> +#include <dev/ParallelChecker.hpp> #include <language/utils/ASTNodeDataTypeTraits.hpp> #include <language/utils/CheckpointResumeRepository.hpp> #include <language/utils/DataHandler.hpp> @@ -29,6 +30,7 @@ #include <utils/RandomEngine.hpp> #include <utils/checkpointing/LinearSolverOptionsHFType.hpp> +#include <utils/checkpointing/ParallelCheckerHFType.hpp> void checkpoint() @@ -83,6 +85,11 @@ checkpoint() execution_info_group.createAttribute("cumulative_total_cpu_time", ExecutionStatManager::getInstance().getCumulativeTotalCPUTime()); } + { + HighFive::Group parallel_checker_group = checkpoint.createGroup("singleton/parallel_checker"); + parallel_checker_group.createAttribute("tag", ParallelChecker::instance().tag()); + parallel_checker_group.createAttribute("mode", ParallelChecker::instance().mode()); + } { HighFive::Group linear_solver_options_default_group = checkpoint.createGroup("singleton/linear_solver_options_default"); diff --git a/src/utils/checkpointing/ParallelCheckerHFType.hpp b/src/utils/checkpointing/ParallelCheckerHFType.hpp new file mode 100644 index 0000000000000000000000000000000000000000..27cd6412ba1641964c5019275c8032a455860cd1 --- /dev/null +++ b/src/utils/checkpointing/ParallelCheckerHFType.hpp @@ -0,0 +1,16 @@ +#ifndef PARALLEL_CHECKER_HF_TYPE_HPP +#define PARALLEL_CHECKER_HF_TYPE_HPP + +#include <dev/ParallelChecker.hpp> +#include <utils/checkpointing/CheckpointUtils.hpp> + +HighFive::EnumType<ParallelChecker::Mode> PUGS_INLINE +create_enum_ParallelChecker_mode() +{ + return {{"automatic", ParallelChecker::Mode::automatic}, + {"read", ParallelChecker::Mode::read}, + {"write", ParallelChecker::Mode::write}}; +} +HIGHFIVE_REGISTER_TYPE(ParallelChecker::Mode, create_enum_ParallelChecker_mode) + +#endif // PARALLEL_CHECKER_HF_TYPE_HPP diff --git a/src/utils/checkpointing/Resume.cpp b/src/utils/checkpointing/Resume.cpp index 27f8e3db1f8bcf6ed742eae8371f2e6c5248d905..757458fc45fbed692b015c6407dff89cca752196 100644 --- a/src/utils/checkpointing/Resume.cpp +++ b/src/utils/checkpointing/Resume.cpp @@ -26,6 +26,7 @@ #include <utils/checkpointing/ResumingManager.hpp> #include <utils/checkpointing/LinearSolverOptionsHFType.hpp> +#include <utils/checkpointing/ParallelCheckerHFType.hpp> #include <language/utils/CheckpointResumeRepository.hpp> @@ -69,6 +70,12 @@ resume() ExecutionStatManager::getInstance().setPreviousCumulativeElapseTime(cumulative_elapse_time); ExecutionStatManager::getInstance().setPreviousCumulativeTotalCPUTime(cumulative_total_cpu_time); } + { + HighFive::Group random_seed_group = checkpoint.getGroup("singleton/parallel_checker"); + // Ordering is important! Must set mode before changing the tag (changing mode is not allowed if tag!=0) + ParallelChecker::instance().setMode(random_seed_group.getAttribute("mode").read<ParallelChecker::Mode>()); + ParallelChecker::instance().setTag(random_seed_group.getAttribute("tag").read<size_t>()); + } { HighFive::Group linear_solver_options_default_group = checkpoint.getGroup("singleton/linear_solver_options_default");