Skip to content

Commit bea91a4

Browse files
Followup: Bug fixes for random-access in variable encoding (#1730)
* Remove leftover line from warning message Cannot actually distinguish modifiable attributes from non-modifiable ones in ADIOS2. * readDataset: use step selection from time of enqueuing asdf * Add test * Add link to ADIOS2 issue ornladios/ADIOS2#4474
1 parent 4e399ea commit bea91a4

File tree

4 files changed

+59
-2
lines changed

4 files changed

+59
-2
lines changed

include/openPMD/IO/ADIOS/ADIOS2File.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ struct BufferedGet : BufferedAction
6767
{
6868
std::string name;
6969
Parameter<Operation::READ_DATASET> param;
70+
std::optional<size_t> stepSelection;
7071

7172
void run(ADIOS2File &) override;
7273
};

src/IO/ADIOS/ADIOS2File.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void BufferedGet::run(ADIOS2File &ba)
146146
ba.m_IO,
147147
ba.getEngine(),
148148
ba.m_file,
149-
ba.stepSelection());
149+
this->stepSelection);
150150
}
151151

152152
void BufferedPut::run(ADIOS2File &ba)

src/IO/ADIOS/ADIOS2IOHandler.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,9 @@ void ADIOS2IOHandlerImpl::readDataset(
10791079
detail::BufferedGet bg;
10801080
bg.name = nameOfVariable(writable);
10811081
bg.param = parameters;
1082+
// need to store the current step selection for deferred reads as the step
1083+
// selection might change again before flushing
1084+
bg.stepSelection = ba.stepSelection();
10821085
ba.enqueue(std::move(bg));
10831086
m_dirty.emplace(std::move(file));
10841087
}
@@ -1521,7 +1524,6 @@ Random-access for variable-encoding in ADIOS2 is currently
15211524
experimental. Support for modifiable attributes is currently not implemented
15221525
yet, meaning that attributes such as /data/time will show useless values.
15231526
Use Access::READ_LINEAR to retrieve those values if needed.
1524-
The following modifiable attributes have been found:
15251527
)";
15261528
};
15271529
if (!modifiable_flag)

test/SerialIOTest.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5901,6 +5901,31 @@ void variableBasedSeries(std::string const &file)
59015901
REQUIRE(
59025902
readSeries.getAttribute("some_global").get<std::string>() ==
59035903
"attribute");
5904+
if (access == Access::READ_RANDOM_ACCESS)
5905+
{
5906+
std::vector<std::shared_ptr<int>> load_E_x(
5907+
readSeries.snapshots().size());
5908+
// std::vector<std::shared_ptr<int>> load_E_y(
5909+
// readSeries.snapshots().size());
5910+
5911+
for (auto &[idx, iteration] : readSeries.snapshots())
5912+
{
5913+
iteration.open();
5914+
load_E_x[idx] = iteration.meshes["E"]["x"].loadChunk<int>();
5915+
// TODO: Changing dimensionality seems to not work in ADIOS2
5916+
// with ReadRandomAccess
5917+
// https://github.com/ornladios/ADIOS2/issues/4474
5918+
// load_E_y[idx] = iteration.meshes["E"]["y"].loadChunk<int>();
5919+
}
5920+
readSeries.flush();
5921+
for (size_t i = 0; i < load_E_x.size(); ++i)
5922+
{
5923+
for (size_t j = 0; j < extent; ++j)
5924+
{
5925+
REQUIRE(load_E_x[i].get()[j] == int(i));
5926+
}
5927+
}
5928+
}
59045929
for (auto iteration : readSeries.readIterations())
59055930
{
59065931
if (access == Access::READ_LINEAR)
@@ -5999,6 +6024,35 @@ void variableBasedSeries(std::string const &file)
59996024
iteration.iterationIndex);
60006025
}
60016026
REQUIRE(last_iteration_index == (is_adios2 ? 9 : 0));
6027+
if (access == Access::READ_RANDOM_ACCESS)
6028+
{
6029+
// should be able to reopen Iterations closed previously
6030+
// should be able to read multiple Iterations at once
6031+
6032+
std::vector<std::shared_ptr<int>> load_E_x(
6033+
readSeries.snapshots().size());
6034+
6035+
// std::vector<std::shared_ptr<int>> load_E_y(
6036+
// readSeries.snapshots().size());
6037+
6038+
for (auto &[idx, iteration] : readSeries.snapshots())
6039+
{
6040+
iteration.open();
6041+
load_E_x[idx] = iteration.meshes["E"]["x"].loadChunk<int>();
6042+
// Changing dimensionality seems to not work in ADIOS2
6043+
// with ReadRandomAccess
6044+
// https://github.com/ornladios/ADIOS2/issues/4474
6045+
// load_E_y[idx] = iteration.meshes["E"]["y"].loadChunk<int>();
6046+
}
6047+
readSeries.flush();
6048+
for (size_t i = 0; i < load_E_x.size(); ++i)
6049+
{
6050+
for (size_t j = 0; j < extent; ++j)
6051+
{
6052+
REQUIRE(load_E_x[i].get()[j] == int(i));
6053+
}
6054+
}
6055+
}
60026056
};
60036057

60046058
std::string jsonConfig = R"(

0 commit comments

Comments
 (0)