Skip to content

Commit

Permalink
Test and fixes for READ_LINEAR mode
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Jun 12, 2024
1 parent 18fc184 commit 668e0e5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
25 changes: 20 additions & 5 deletions include/openPMD/IO/AbstractIOHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,28 @@ class AbstractIOHandler
{
/*
* In file-based iteration encoding, the APPEND mode is handled entirely
* by the frontend, the backend should just treat it as CREATE mode
* by the frontend, the backend should just treat it as CREATE mode.
* Similar for READ_LINEAR which should be treated as READ_RANDOM_ACCESS
* in the backend.
*/
if (encoding == IterationEncoding::fileBased &&
m_backendAccess == Access::APPEND)
if (encoding == IterationEncoding::fileBased)
{
// do we really want to have those as const members..?
*const_cast<Access *>(&m_backendAccess) = Access::CREATE;
switch (m_backendAccess)
{

case Access::READ_LINEAR:
// do we really want to have those as const members..?
*const_cast<Access *>(&m_backendAccess) =
Access::READ_RANDOM_ACCESS;
break;
case Access::APPEND:
*const_cast<Access *>(&m_backendAccess) = Access::CREATE;
break;
case Access::READ_RANDOM_ACCESS:
case Access::READ_WRITE:
case Access::CREATE:
break;
}
}

m_encoding = encoding;
Expand Down
7 changes: 7 additions & 0 deletions src/Series.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1548,6 +1548,13 @@ void Series::readFileBased()
Parameter<Operation::OPEN_FILE> fOpen;
Parameter<Operation::READ_ATT> aRead;

// Tell the backend that we are parsing file-based iteration encoding.
// This especially means that READ_RANDOM_ACCESS will be used instead of
// READ_LINEAR, as READ_LINEAR is implemented in the frontend for file-based
// encoding. Don't set the iteration encoding in the frontend yet, will be
// set after reading the iteration encoding attribute from the opened file.
IOHandler()->setIterationEncoding(IterationEncoding::fileBased);

if (!auxiliary::directory_exists(IOHandler()->directory))
throw error::ReadError(
error::AffectedObject::File,
Expand Down
4 changes: 1 addition & 3 deletions test/SerialIOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4461,9 +4461,7 @@ TEST_CASE("adios2_flush_via_step")
#if openPMD_HAS_ADIOS_2_10_1
for (auto access : {Access::READ_RANDOM_ACCESS, Access::READ_LINEAR})
{
Series read(
"../samples/adios2_flush_via_step/simData_%T.bp5",
Access::READ_RANDOM_ACCESS);
Series read("../samples/adios2_flush_via_step/simData_%T.%E", access);
std::vector<float> load_data(100);
data.resize(100);
for (auto iteration : read.readIterations())
Expand Down

0 comments on commit 668e0e5

Please sign in to comment.