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

Add ResumingData and Resume checkpointing tests

parent 980596da
No related branches found
No related tags found
1 merge request!199Integrate checkpointing
......@@ -233,15 +233,19 @@ resume()
}
break;
}
// LCOV_EXCL_START
default: {
throw NotImplementedError(symbol_name + " of type " + dataTypeName(attribute.dataType().contentType()));
}
// LCOV_EXCL_STOP
}
break;
}
// LCOV_EXCL_START
default: {
throw NotImplementedError(symbol_name + " of type " + dataTypeName(attribute.dataType()));
}
// LCOV_EXCL_STOP
}
}
......@@ -286,9 +290,11 @@ resume()
checkpointing::ResumingData::destroy();
}
// LCOV_EXCL_START
catch (HighFive::Exception& e) {
throw NormalError(e.what());
}
// LCOV_EXCL_STOP
}
#else // PUGS_HAS_HDF5
......
......@@ -368,33 +368,41 @@ ResumingData::_getFunctionIds(const HighFive::Group& checkpoint, std::shared_ptr
for (auto symbol : p_symbol_table->symbolList()) {
if (symbol.attributes().dataType() == ASTNodeDataType::function_t) {
if (not function_group.exist(symbol.name())) {
// LCOV_EXCL_START
std::ostringstream error_msg;
error_msg << "cannot find function " << rang::fgB::yellow << symbol.name() << rang::fg::reset << " in "
<< rang::fgB::cyan << checkpoint.getFile().getName() << rang::fg::reset;
throw NormalError(error_msg.str());
} else {
throw UnexpectedError(error_msg.str());
// LCOV_EXCL_STOP
} else { // LCOV_EXCL_LINE
const HighFive::Group function = function_group.getGroup(symbol.name());
const size_t stored_function_id = function.getAttribute("id").read<size_t>();
const size_t function_id = std::get<size_t>(symbol.attributes().value());
if (symbol_table_id != function.getAttribute("symbol_table_id").read<size_t>()) {
// LCOV_EXCL_START
std::ostringstream error_msg;
error_msg << "symbol table of function " << rang::fgB::yellow << symbol.name() << rang::fg::reset
<< " does not match the one stored in " << rang::fgB::cyan << checkpoint.getFile().getName()
<< rang::fg::reset;
throw NormalError(error_msg.str());
throw UnexpectedError(error_msg.str());
// LCOV_EXCL_STOP
} else if (function_id != stored_function_id) {
// LCOV_EXCL_START
std::ostringstream error_msg;
error_msg << "id (" << function_id << ") of function " << rang::fgB::yellow << symbol.name()
<< rang::fg::reset << " does not match the one stored in " << rang::fgB::cyan
<< checkpoint.getFile().getName() << rang::fg::reset << "(" << stored_function_id << ")";
throw NormalError(error_msg.str());
} else {
throw UnexpectedError(error_msg.str());
// LCOV_EXCL_STOP
} else { // LCOV_EXCL_LINE
if (m_id_to_function_symbol_id_map.contains(function_id)) {
// LCOV_EXCL_START
std::ostringstream error_msg;
error_msg << "id (" << function_id << ") of function " << rang::fgB::yellow << symbol.name()
<< rang::fg::reset << " is duplicated";
throw UnexpectedError(error_msg.str());
}
// LCOV_EXCL_STOP
} // LCOV_EXCL_LINE
m_id_to_function_symbol_id_map[function_id] =
std::make_shared<FunctionSymbolId>(function_id, p_symbol_table);
}
......@@ -420,7 +428,9 @@ ResumingData::iConnectivity(const size_t connectivity_id) const
{
auto i_id_to_connectivity = m_id_to_iconnectivity_map.find(connectivity_id);
if (i_id_to_connectivity == m_id_to_iconnectivity_map.end()) {
// LCOV_EXCL_START
throw UnexpectedError("cannot find connectivity of id " + std::to_string(connectivity_id));
// LCOV_EXCL_STOP
} else {
return i_id_to_connectivity->second;
}
......@@ -431,7 +441,9 @@ ResumingData::meshVariant(const size_t mesh_id) const
{
auto i_id_to_mesh = m_id_to_mesh_variant_map.find(mesh_id);
if (i_id_to_mesh == m_id_to_mesh_variant_map.end()) {
// LCOV_EXCL_START
throw UnexpectedError("cannot find mesh of id " + std::to_string(mesh_id));
// LCOV_EXCL_STOP
} else {
return i_id_to_mesh->second;
}
......@@ -442,7 +454,9 @@ ResumingData::functionSymbolId(const size_t function_symbol_id) const
{
auto i_id_to_function_symbol_id = m_id_to_function_symbol_id_map.find(function_symbol_id);
if (i_id_to_function_symbol_id == m_id_to_function_symbol_id_map.end()) {
// LCOV_EXCL_START
throw UnexpectedError("cannot find function_symbol_id of id " + std::to_string(function_symbol_id));
// LCOV_EXCL_STOP
} else {
return i_id_to_function_symbol_id->second;
}
......
......@@ -9,13 +9,19 @@
#include <utils/Exceptions.hpp>
#include <utils/HighFivePugsUtils.hpp>
#include <utils/Messenger.hpp>
void
setResumeFrom(const std::string& filename, const uint64_t& checkpoint_number, std::ostream& os)
{
try {
HighFive::SilenceHDF5 m_silence_hdf5{true};
HighFive::File file(filename, HighFive::File::ReadWrite);
HighFive::FileAccessProps fapl;
fapl.add(HighFive::MPIOFileAccess{parallel::Messenger::getInstance().comm(), MPI_INFO_NULL});
fapl.add(HighFive::MPIOCollectiveMetadata{});
HighFive::File file(filename, HighFive::File::ReadWrite, fapl);
const std::string checkpoint_name = "checkpoint_" + std::to_string(checkpoint_number);
if (not file.exist(checkpoint_name)) {
......
......@@ -7,8 +7,7 @@ include_directories(${PUGS_SOURCE_DIR}/tests)
set(checkpointing_sequential_TESTS
# this one should enventually integrate parallel tests
test_checkpointing_Checkpoint_sequential.cpp
test_checkpointing_SetResumeFrom.cpp
test_checkpointing_Resume_sequential.cpp
)
add_executable (unit_tests
......@@ -171,6 +170,7 @@ add_executable (unit_tests
test_checkpointing_PrintScriptFrom.cpp
test_checkpointing_ResumingManager.cpp
test_checkpointing_ResumingUtils.cpp
test_checkpointing_SetResumeFrom.cpp
)
if(PUGS_HAS_HDF5)
......
......@@ -75,6 +75,9 @@ TEST_CASE("checkpointing_Checkpoint", "[utils/checkpointing]")
{
#ifdef PUGS_HAS_HDF5
ResumingManager::destroy();
ResumingManager::create();
std::string tmp_dirname;
{
{
......
......@@ -77,6 +77,9 @@ TEST_CASE("checkpointing_Checkpoint_sequential", "[utils/checkpointing]")
{
#ifdef PUGS_HAS_HDF5
ResumingManager::destroy();
ResumingManager::create();
std::string tmp_dirname;
{
{
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment