Skip to content
Snippets Groups Projects
Commit b4746f6d authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Remove deprecated checkpoints when not resuming from last checkpoint

This happens when manually changing the resuming checkpoint.

Let n be the number of the last checkpoint and i be the number of the
resuming checkpoint.

If i!=n, then the checkpoints i+1, i+2, ... and n are removed when one
writes the checkpoint i+1.
parent fbdc0153
No related branches found
No related tags found
1 merge request!199Integrate checkpointing
...@@ -51,6 +51,20 @@ checkpoint() ...@@ -51,6 +51,20 @@ checkpoint()
<< rang::fgB::yellow << ASTExecutionStack::getInstance().currentNode().begin().line << rang::fg::reset << rang::fgB::yellow << ASTExecutionStack::getInstance().currentNode().begin().line << rang::fg::reset
<< " [using " << rang::fgB::cyan << checkpoint_name << rang::fg::reset << "]\n"; << " [using " << rang::fgB::cyan << checkpoint_name << rang::fg::reset << "]\n";
if (checkpoint_number > 0) {
uint64_t resuming_checkpoint_number =
file.getGroup("resuming_checkpoint").getAttribute("checkpoint_number").read<uint64_t>();
uint64_t last_checkpoint_number =
file.getGroup("last_checkpoint").getAttribute("checkpoint_number").read<uint64_t>();
for (uint64_t i = resuming_checkpoint_number + 1; i <= last_checkpoint_number; ++i) {
std::string old_checkpoint_name = "checkpoint_" + std::to_string(i);
std::cout << " - removing deprecated " << rang::fgB::yellow << old_checkpoint_name << rang::fg::reset << '\n';
if (file.exist(old_checkpoint_name)) {
file.unlink(old_checkpoint_name);
}
}
}
HighFive::Group checkpoint = file.createGroup(checkpoint_name); HighFive::Group checkpoint = file.createGroup(checkpoint_name);
uint64_t checkpoint_id = uint64_t checkpoint_id =
...@@ -68,6 +82,9 @@ checkpoint() ...@@ -68,6 +82,9 @@ checkpoint()
checkpoint.createAttribute("id", checkpoint_id); checkpoint.createAttribute("id", checkpoint_id);
checkpoint.createAttribute("data.pgs", ASTExecutionStack::getInstance().fileContent()); checkpoint.createAttribute("data.pgs", ASTExecutionStack::getInstance().fileContent());
checkpoint.createAttribute("checkpoint_number", checkpoint_number);
++checkpoint_number;
{ {
HighFive::Group global_variables_group = checkpoint.createGroup("singleton/global_variables"); HighFive::Group global_variables_group = checkpoint.createGroup("singleton/global_variables");
global_variables_group.createAttribute("connectivity_id", GlobalVariableManager::instance().getConnectivityId()); global_variables_group.createAttribute("connectivity_id", GlobalVariableManager::instance().getConnectivityId());
...@@ -209,13 +226,6 @@ checkpoint() ...@@ -209,13 +226,6 @@ checkpoint()
file.unlink("resuming_checkpoint"); file.unlink("resuming_checkpoint");
} }
file.createHardLink("resuming_checkpoint", checkpoint); file.createHardLink("resuming_checkpoint", checkpoint);
if (file.hasAttribute("checkpoint_number")) {
file.deleteAttribute("checkpoint_number");
}
file.createAttribute("checkpoint_number", checkpoint_number);
++checkpoint_number;
} }
catch (HighFive::Exception& e) { catch (HighFive::Exception& e) {
throw NormalError(e.what()); throw NormalError(e.what());
......
...@@ -37,7 +37,7 @@ resume() ...@@ -37,7 +37,7 @@ resume()
ResumingManager& resuming_manager = ResumingManager::getInstance(); ResumingManager& resuming_manager = ResumingManager::getInstance();
resuming_manager.checkpointNumber() = file.getAttribute("checkpoint_number").read<uint64_t>() + 1; resuming_manager.checkpointNumber() = checkpoint.getAttribute("checkpoint_number").read<uint64_t>() + 1;
std::cout << " * " << rang::fgB::green << "Resuming " << rang::fg::reset << "execution at line " std::cout << " * " << rang::fgB::green << "Resuming " << rang::fg::reset << "execution at line "
<< rang::fgB::yellow << p_node->begin().line << rang::fg::reset << " [using " << rang::fgB::cyan << rang::fgB::yellow << p_node->begin().line << rang::fg::reset << " [using " << rang::fgB::cyan
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment