Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/openPMD/IO/ADIOS/ADIOS2File.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ struct BufferedGet : BufferedAction
{
std::string name;
Parameter<Operation::READ_DATASET> param;
std::optional<size_t> stepSelection;

void run(ADIOS2File &) override;
};
Expand Down
2 changes: 1 addition & 1 deletion src/IO/ADIOS/ADIOS2File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void BufferedGet::run(ADIOS2File &ba)
ba.m_IO,
ba.getEngine(),
ba.m_file,
ba.stepSelection());
this->stepSelection);
}

void BufferedPut::run(ADIOS2File &ba)
Expand Down
4 changes: 3 additions & 1 deletion src/IO/ADIOS/ADIOS2IOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,9 @@ void ADIOS2IOHandlerImpl::readDataset(
detail::BufferedGet bg;
bg.name = nameOfVariable(writable);
bg.param = parameters;
// need to store the current step selection for deferred reads as the step
// selection might change again before flushing
bg.stepSelection = ba.stepSelection();
ba.enqueue(std::move(bg));
m_dirty.emplace(std::move(file));
}
Expand Down Expand Up @@ -1521,7 +1524,6 @@ Random-access for variable-encoding in ADIOS2 is currently
experimental. Support for modifiable attributes is currently not implemented
yet, meaning that attributes such as /data/time will show useless values.
Use Access::READ_LINEAR to retrieve those values if needed.
The following modifiable attributes have been found:
)";
};
if (!modifiable_flag)
Expand Down
54 changes: 54 additions & 0 deletions test/SerialIOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5901,6 +5901,31 @@ void variableBasedSeries(std::string const &file)
REQUIRE(
readSeries.getAttribute("some_global").get<std::string>() ==
"attribute");
if (access == Access::READ_RANDOM_ACCESS)
{
std::vector<std::shared_ptr<int>> load_E_x(
readSeries.snapshots().size());
// std::vector<std::shared_ptr<int>> load_E_y(
// readSeries.snapshots().size());

for (auto &[idx, iteration] : readSeries.snapshots())
{
iteration.open();
load_E_x[idx] = iteration.meshes["E"]["x"].loadChunk<int>();
// TODO: Changing dimensionality seems to not work in ADIOS2
// with ReadRandomAccess
// https://github.com/ornladios/ADIOS2/issues/4474
// load_E_y[idx] = iteration.meshes["E"]["y"].loadChunk<int>();
}
readSeries.flush();
for (size_t i = 0; i < load_E_x.size(); ++i)
{
for (size_t j = 0; j < extent; ++j)
{
REQUIRE(load_E_x[i].get()[j] == int(i));
}
}
}
for (auto iteration : readSeries.readIterations())
{
if (access == Access::READ_LINEAR)
Expand Down Expand Up @@ -5999,6 +6024,35 @@ void variableBasedSeries(std::string const &file)
iteration.iterationIndex);
}
REQUIRE(last_iteration_index == (is_adios2 ? 9 : 0));
if (access == Access::READ_RANDOM_ACCESS)
{
// should be able to reopen Iterations closed previously
// should be able to read multiple Iterations at once

std::vector<std::shared_ptr<int>> load_E_x(
readSeries.snapshots().size());

// std::vector<std::shared_ptr<int>> load_E_y(
// readSeries.snapshots().size());

for (auto &[idx, iteration] : readSeries.snapshots())
{
iteration.open();
load_E_x[idx] = iteration.meshes["E"]["x"].loadChunk<int>();
// Changing dimensionality seems to not work in ADIOS2
// with ReadRandomAccess
// https://github.com/ornladios/ADIOS2/issues/4474
// load_E_y[idx] = iteration.meshes["E"]["y"].loadChunk<int>();
}
readSeries.flush();
for (size_t i = 0; i < load_E_x.size(); ++i)
{
for (size_t j = 0; j < extent; ++j)
{
REQUIRE(load_E_x[i].get()[j] == int(i));
}
}
}
};

std::string jsonConfig = R"(
Expand Down
Loading