Skip to content

Commit e668e86

Browse files
Adios2 warn groupbased encoding (#1498)
* Warning: group-based iteration encoding in ADIOS2 * Remove adios2.usesteps, set it always to true This uncovered loads of bugs * Remove requireActiveStep * Remove StreamStatus::Parsing * Remove usesteps = true/false from tests * Fix CI error * Testing: ADIOS2 < v2.9 compatibility * Less misleading warning message * Unify struct/class * Transition a bit more leniently (part 1) * Transition a bit more leniently (part 2) * Remove usesteps option from documentation * Cleanup and fixes * Fix tests * Fix the warning text
1 parent b131cd2 commit e668e86

12 files changed

Lines changed: 237 additions & 349 deletions

File tree

CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,16 +1360,18 @@ if(openPMD_BUILD_TESTING)
13601360
${MPI_TEST_EXE} ${Python_EXECUTABLE} \
13611361
${openPMD_RUNTIME_OUTPUT_DIRECTORY}/openpmd-pipe \
13621362
--infile ../samples/git-sample/data00000100.h5 \
1363-
--outfile ../samples/git-sample/single_iteration.bp && \
1363+
--outfile \
1364+
../samples/git-sample/single_iteration_%T.bp && \
13641365
\
13651366
${MPI_TEST_EXE} ${Python_EXECUTABLE} \
13661367
${openPMD_RUNTIME_OUTPUT_DIRECTORY}/openpmd-pipe \
13671368
--infile ../samples/git-sample/thetaMode/data%T.h5 \
1368-
--outfile ../samples/git-sample/thetaMode/data.bp && \
1369+
--outfile \
1370+
../samples/git-sample/thetaMode/data_%T.bp && \
13691371
\
13701372
${Python_EXECUTABLE} \
13711373
${openPMD_RUNTIME_OUTPUT_DIRECTORY}/openpmd-pipe \
1372-
--infile ../samples/git-sample/thetaMode/data.bp \
1374+
--infile ../samples/git-sample/thetaMode/data_%T.bp \
13731375
--outfile ../samples/git-sample/thetaMode/data%T.json \
13741376
"
13751377
WORKING_DIRECTORY ${openPMD_RUNTIME_OUTPUT_DIRECTORY}
@@ -1378,17 +1380,17 @@ if(openPMD_BUILD_TESTING)
13781380
add_test(NAME CLI.pipe.py
13791381
COMMAND sh -c
13801382
"${Python_EXECUTABLE} \
1381-
${openPMD_RUNTIME_OUTPUT_DIRECTORY}/openpmd-pipe \
1383+
${openPMD_RUNTIME_OUTPUT_DIRECTORY}/openpmd-pipe \
13821384
--infile ../samples/git-sample/data%T.h5 \
13831385
--outfile ../samples/git-sample/data%T.bp && \
13841386
\
13851387
${Python_EXECUTABLE} \
1386-
${openPMD_RUNTIME_OUTPUT_DIRECTORY}/openpmd-pipe \
1388+
${openPMD_RUNTIME_OUTPUT_DIRECTORY}/openpmd-pipe \
13871389
--infile ../samples/git-sample/thetaMode/data%T.h5 \
13881390
--outfile ../samples/git-sample/thetaMode/data%T.bp && \
13891391
\
13901392
${Python_EXECUTABLE} \
1391-
${openPMD_RUNTIME_OUTPUT_DIRECTORY}/openpmd-pipe \
1393+
${openPMD_RUNTIME_OUTPUT_DIRECTORY}/openpmd-pipe \
13921394
--infile ../samples/git-sample/thetaMode/data%T.bp \
13931395
--outfile ../samples/git-sample/thetaMode/data%T.json \
13941396
"

docs/source/backends/adios2.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ In order to activate steps, it is imperative to use the :ref:`Streaming API <usa
5656

5757
ADIOS2 release 2.6.0 contained a bug (fixed in ADIOS 2.7.0, see `PR #2348 <https://github.com/ornladios/ADIOS2/pull/2348>`_) that disallows random-accessing steps in file-based engines.
5858
With this ADIOS2 release, files written with steps may only be read using the streaming API.
59-
In order to keep compatibility with older codes reading ADIOS2 files, step-based processing must currently be opted in to via use of the :ref:`JSON parameter<backendconfig>` ``adios2.engine.usesteps = true`` when using a file-based engine such as BP3 or BP4 (usesteps).
6059

6160
Upon reading a file, the ADIOS2 backend will automatically recognize whether it has been written with or without steps, ignoring the JSON option mentioned above.
6261
Steps are mandatory for streaming-based engines and trying to switch them off will result in a runtime error.
@@ -183,7 +182,6 @@ This feature can be activated via the JSON/TOML key ``adios2.use_group_table = t
183182
It is fully backward-compatible with the old layout of openPMD in ADIOS2 and mostly forward-compatible (except the support for steps).
184183

185184
The variable-based encoding of openPMD automatically activates the group table feature.
186-
The group table feature automatically activates the use of ADIOS2 steps (which until version 0.15 was an opt-in feature via ``adios2.engine.usesteps = true``).
187185

188186
Memory usage
189187
------------

docs/source/details/backendconfig.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ Explanation of the single keys:
121121
* ``adios2.engine.parameters``: An associative array of string-formatted engine parameters, passed directly through to ``adios2::IO::SetParameters``.
122122
Please refer to the `official ADIOS2 documentation <https://adios2.readthedocs.io/en/latest/engines/engines.html>`_ for the available engine parameters.
123123
The openPMD-api does not interpret these values and instead simply forwards them to ADIOS2.
124-
* ``adios2.engine.usesteps``: Described more closely in the documentation for the :ref:`ADIOS2 backend<backends-adios2>` (usesteps).
125124
* ``adios2.engine.preferred_flush_target`` Only relevant for BP5 engine, possible values are ``"disk"`` and ``"buffer"`` (default: ``"disk"``).
126125

127126
* If ``"disk"``, data will be moved to disk on every flush.

include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,6 @@ class ADIOS2IOHandlerImpl
225225
#if openPMD_HAVE_MPI
226226
std::optional<MPI_Comm> m_communicator;
227227
#endif
228-
/*
229-
* If the iteration encoding is variableBased, we default to using a group
230-
* table, since it is the only reliable way to recover currently active
231-
* groups.
232-
*/
233-
IterationEncoding m_iterationEncoding = IterationEncoding::groupBased;
234228
/**
235229
* The ADIOS2 engine type, to be passed to adios2::IO::SetEngine
236230
*/
@@ -439,6 +433,8 @@ namespace ADIOS2Defaults
439433
"__openPMD_internal/openPMD2_adios2_schema";
440434
constexpr const_str str_isBoolean = "__is_boolean__";
441435
constexpr const_str str_activeTablePrefix = "__openPMD_groups";
436+
constexpr const_str str_groupBasedWarning =
437+
"__openPMD_internal/warning_bugprone_groupbased_encoding";
442438
} // namespace ADIOS2Defaults
443439

444440
namespace detail
@@ -914,7 +910,6 @@ namespace detail
914910
UseGroupTable detectGroupTable();
915911

916912
adios2::Engine &getEngine();
917-
adios2::Engine &requireActiveStep();
918913

919914
template <typename BA>
920915
void enqueue(BA &&ba);
@@ -976,15 +971,9 @@ namespace detail
976971
* @brief Begin or end an ADIOS step.
977972
*
978973
* @param mode Whether to begin or end a step.
979-
* @param calledExplicitly True if called due to a public API call.
980-
* False if called from requireActiveStep.
981-
* Some engines (BP5) require that every interaction happens within
982-
* an active step, meaning that we need to call advance()
983-
* implicitly at times. When doing that, do not tag the dataset
984-
* with __openPMD_internal/useSteps (yet).
985974
* @return AdvanceStatus
986975
*/
987-
AdvanceStatus advance(AdvanceMode mode, bool calledExplicitly);
976+
AdvanceStatus advance(AdvanceMode mode);
988977

989978
/*
990979
* Delete all buffered actions without running them.
@@ -1069,34 +1058,7 @@ namespace detail
10691058
* without steps. This is not a workaround since not using steps,
10701059
* while inefficient in ADIOS2, is something that we support.
10711060
*/
1072-
NoStream,
1073-
/**
1074-
* Rationale behind this state:
1075-
* When user code opens a Series, series.iterations should contain
1076-
* all available iterations.
1077-
* If accessing a file without opening a step, ADIOS2 will grant
1078-
* access to variables and attributes from all steps, allowing us
1079-
* to parse the complete dump.
1080-
* This state indicates that no step should be opened for parsing
1081-
* purposes (which is necessary in streaming engines, hence they
1082-
* are initialized with the OutsideOfStep state).
1083-
* A step should only be opened if an explicit ADVANCE task arrives
1084-
* at the backend.
1085-
*
1086-
* @todo If the streaming API is used on files, parsing the whole
1087-
* Series up front is unnecessary work.
1088-
* Our frontend does not yet allow to distinguish whether
1089-
* parsing the whole series will be necessary since parsing
1090-
* happens upon construction time of Series,
1091-
* but the classical and the streaming API are both activated
1092-
* afterwards from the created Series object.
1093-
* Hence, improving this requires refactoring in our
1094-
* user-facing API. Ideas:
1095-
* (1) Delayed lazy parsing of iterations upon accessing
1096-
* (would bring other benefits also).
1097-
* (2) Introduce a restricted class StreamingSeries.
1098-
*/
1099-
Parsing,
1061+
ReadWithoutStream,
11001062
/**
11011063
* The stream status of a file-based engine will be decided upon
11021064
* opening the engine if in read mode. Up until then, this right
@@ -1157,8 +1119,8 @@ namespace detail
11571119
void create_IO();
11581120

11591121
void configure_IO(ADIOS2IOHandlerImpl &impl);
1160-
void configure_IO_Read(std::optional<bool> userSpecifiedUsesteps);
1161-
void configure_IO_Write(std::optional<bool> userSpecifiedUsesteps);
1122+
void configure_IO_Read();
1123+
void configure_IO_Write();
11621124
};
11631125

11641126
} // namespace detail

include/openPMD/IO/AbstractIOHandler.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "openPMD/IO/Access.hpp"
2424
#include "openPMD/IO/Format.hpp"
2525
#include "openPMD/IO/IOTask.hpp"
26+
#include "openPMD/IterationEncoding.hpp"
2627
#include "openPMD/config.hpp"
2728

2829
#if openPMD_HAVE_MPI
@@ -168,6 +169,11 @@ namespace internal
168169
}
169170
} // namespace internal
170171

172+
namespace detail
173+
{
174+
struct BufferedActions;
175+
}
176+
171177
/** Interface for communicating between logical and physically persistent data.
172178
*
173179
* Input and output operations are channeled through a task queue that is
@@ -179,8 +185,12 @@ namespace internal
179185
class AbstractIOHandler
180186
{
181187
friend class Series;
188+
friend class ADIOS2IOHandlerImpl;
189+
friend struct detail::BufferedActions;
182190

183191
private:
192+
IterationEncoding m_encoding = IterationEncoding::groupBased;
193+
184194
void setIterationEncoding(IterationEncoding encoding)
185195
{
186196
/*
@@ -193,6 +203,8 @@ class AbstractIOHandler
193203
// do we really want to have those as const members..?
194204
*const_cast<Access *>(&m_backendAccess) = Access::CREATE;
195205
}
206+
207+
m_encoding = encoding;
196208
}
197209

198210
public:

include/openPMD/IO/IOTask.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ struct OPENPMDAPI_EXPORT Parameter<Operation::CREATE_FILE>
125125
}
126126

127127
std::string name = "";
128-
IterationEncoding encoding = IterationEncoding::groupBased;
129128
};
130129

131130
template <>
@@ -172,12 +171,6 @@ struct OPENPMDAPI_EXPORT Parameter<Operation::OPEN_FILE>
172171
}
173172

174173
std::string name = "";
175-
/*
176-
* The backends might need to ensure availability of certain features
177-
* for some iteration encodings, e.g. availability of ADIOS steps for
178-
* variableBased encoding.
179-
*/
180-
IterationEncoding encoding = IterationEncoding::groupBased;
181174
using ParsePreference = internal::ParsePreference;
182175
std::shared_ptr<ParsePreference> out_parsePreference =
183176
std::make_shared<ParsePreference>(ParsePreference::UpFront);

0 commit comments

Comments
 (0)