Skip to content

Commit

Permalink
Don't check closed iterations if they are dirty
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Mar 6, 2024
1 parent c2e0e83 commit bc7fca8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 60 deletions.
10 changes: 10 additions & 0 deletions src/Iteration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,16 @@ void Iteration::setStepStatus(StepStatus status)

bool Iteration::dirtyRecursive() const
{
switch (get().m_closed)
{
case internal::CloseStatus::ParseAccessDeferred:
case internal::CloseStatus::ClosedInBackend:
return false;
case internal::CloseStatus::Open:
case internal::CloseStatus::ClosedInFrontend:
case internal::CloseStatus::ClosedTemporarily:
break;
}
if (dirty())
{
return true;
Expand Down
10 changes: 5 additions & 5 deletions test/ParallelIOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,9 +741,9 @@ void close_iteration_test(std::string const &file_ending)
E_x.storeChunk(data, {mpi_rank, 0}, {1, 4});
it1.close(/* flush = */ true);

// illegally access iteration after closing
E_x.storeChunk(data, {mpi_rank, 0}, {1, 4});
REQUIRE_THROWS(write.flush());
// // illegally access iteration after closing
// E_x.storeChunk(data, {mpi_rank, 0}, {1, 4});
// REQUIRE_THROWS(write.flush());

Check notice

Code scanning / CodeQL

Commented-out code Note test

This comment appears to contain commented-out code.
}

{
Expand All @@ -756,8 +756,8 @@ void close_iteration_test(std::string const &file_ending)
{
REQUIRE(data[i % 4] == chunk.get()[i]);
}
auto read_again = E_x_read.loadChunk<int>({0, 0}, {mpi_size, 4});
REQUIRE_THROWS(read.flush());
// auto read_again = E_x_read.loadChunk<int>({0, 0}, {mpi_size, 4});
// REQUIRE_THROWS(read.flush());

Check notice

Code scanning / CodeQL

Commented-out code Note test

This comment appears to contain commented-out code.
}
}

Expand Down
60 changes: 5 additions & 55 deletions test/SerialIOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,9 @@ void close_iteration_test(std::string const &file_ending)
E_x.storeChunk(data, {0, 0}, {2, 2});
it1.close(/* flush = */ true);

// illegally access iteration after closing
E_x.storeChunk(data, {0, 0}, {2, 2});
REQUIRE_THROWS(write.flush());
// // illegally access iteration after closing
// E_x.storeChunk(data, {0, 0}, {2, 2});
// REQUIRE_THROWS(write.flush());

Check notice

Code scanning / CodeQL

Commented-out code Note test

This comment appears to contain commented-out code.
}

{
Expand All @@ -465,8 +465,8 @@ void close_iteration_test(std::string const &file_ending)
{
REQUIRE(data[i] == chunk.get()[i]);
}
auto read_again = E_x_read.loadChunk<int>({0, 0}, {2, 2});
REQUIRE_THROWS(read.flush());
// auto read_again = E_x_read.loadChunk<int>({0, 0}, {2, 2});
// REQUIRE_THROWS(read.flush());

Check notice

Code scanning / CodeQL

Commented-out code Note test

This comment appears to contain commented-out code.
}

{
Expand Down Expand Up @@ -734,56 +734,6 @@ TEST_CASE("close_and_copy_attributable_test", "[serial]")
}
}

#if openPMD_HAVE_ADIOS2
TEST_CASE("close_iteration_throws_test", "[serial]")
{
/*
* Iterations should not be accessed any more after closing.
* Test that the openPMD API detects that case and throws.
*/
{
Series series("../samples/close_iteration_throws_1.bp", Access::CREATE);
auto it0 = series.iterations[0];
auto E_x = it0.meshes["E"]["x"];
E_x.resetDataset({Datatype::INT, {5}});
std::vector<int> data{0, 1, 2, 3, 4};
E_x.storeChunk(data, {0}, {5});
it0.close();

auto B_y = it0.meshes["B"]["y"];
B_y.resetDataset({Datatype::INT, {5}});
B_y.storeChunk(data, {0}, {5});
REQUIRE_THROWS(series.flush());
}
{
Series series("../samples/close_iteration_throws_2.bp", Access::CREATE);
auto it0 = series.iterations[0];
auto E_x = it0.meshes["E"]["x"];
E_x.resetDataset({Datatype::INT, {5}});
std::vector<int> data{0, 1, 2, 3, 4};
E_x.storeChunk(data, {0}, {5});
it0.close();

auto e_position_x = it0.particles["e"]["position"]["x"];
e_position_x.resetDataset({Datatype::INT, {5}});
e_position_x.storeChunk(data, {0}, {5});
REQUIRE_THROWS(series.flush());
}
{
Series series("../samples/close_iteration_throws_3.bp", Access::CREATE);
auto it0 = series.iterations[0];
auto E_x = it0.meshes["E"]["x"];
E_x.resetDataset({Datatype::INT, {5}});
std::vector<int> data{0, 1, 2, 3, 4};
E_x.storeChunk(data, {0}, {5});
it0.close();

it0.setTimeUnitSI(2.0);
REQUIRE_THROWS(series.flush());
}
}
#endif

inline void empty_dataset_test(std::string const &file_ending)
{
{
Expand Down

0 comments on commit bc7fca8

Please sign in to comment.