Skip to content

Commit def88c3

Browse files
Use schema-based versioning in ADIOS2 backend (#941)
* Use schema-based versioning in ADIOS2 backend Also automatically recognize the schema used by a written file * Only support explicitly listed schema versions * Update documentation * Undo unnecessary whitespace changes * Remove change that is now a PR of its own See #944 * Rename __is_boolean__ to __openPMD_internal/is_boolean Only in new layout
1 parent 6191d98 commit def88c3

6 files changed

Lines changed: 205 additions & 107 deletions

File tree

.github/workflows/unix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ jobs:
134134
../share/openPMD/download_samples.sh && chmod u-w samples/git-sample/*.h5
135135
cmake -S .. -B . -DopenPMD_USE_PYTHON=OFF -DopenPMD_USE_MPI=ON -DopenPMD_USE_HDF5=ON -DopenPMD_USE_ADIOS1=OFF -DopenPMD_USE_ADIOS2=ON -DopenPMD_USE_INVASIVE_TESTS=ON
136136
cmake --build . --parallel 2
137-
export OPENPMD_NEW_ATTRIBUTE_LAYOUT=1
137+
export OPENPMD2_ADIOS2_SCHEMA=20210209
138138
ctest --output-on-failure
139139
140140
# TODO

docs/source/backends/adios2.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ environment variable default description
5151
``OPENPMD_ADIOS2_HAVE_METADATA_FILE`` ``1`` Online creation of the adios journal file (``1``: yes, ``0``: no).
5252
``OPENPMD_ADIOS2_NUM_SUBSTREAMS`` ``0`` Number of files to be created, 0 indicates maximum number possible.
5353
``OPENPMD_ADIOS2_ENGINE`` ``File`` `ADIOS2 engine <https://adios2.readthedocs.io/en/latest/engines/engines.html>`_
54-
``OPENPMD_NEW_ATTRIBUTE_LAYOUT`` ``0`` Experimental: new attribute layout (see below)
54+
``OPENPMD2_ADIOS2_SCHEMA`` ``0`` ADIOS2 schema version (see below)
5555
``OPENPMD_BP_BACKEND`` ``ADIOS2`` Chose preferred ``.bp`` file backend if ``ADIOS1`` and ``ADIOS2`` are available.
5656
===================================== ========== ================================================================================
5757

@@ -79,8 +79,8 @@ A good number for substreams is usually the number of contributing nodes divided
7979
For fine-tuning at extreme scale or for exotic systems, please refer to the ADIOS2 manual and talk to your filesystem admins and the ADIOS2 authors.
8080
Be aware that extreme-scale I/O is a research topic after all.
8181

82-
Experimental new attribute layout
83-
---------------------------------
82+
Experimental new ADIOS2 schema
83+
------------------------------
8484

8585
We are experimenting with a breaking change to our layout of openPMD datasets in ADIOS2.
8686
It is likely that we will in future use ADIOS attributes only for a handful of internal flags.
@@ -96,11 +96,10 @@ We hope that this will bring several advantages:
9696

9797
The new layout may be activated **for experimental purposes** in two ways:
9898

99-
* Via the JSON parameter ``adios2.new_attribute_layout = true``.
100-
* Via the environment variable ``export OPENPMD_NEW_ATTRIBUTE_LAYOUT=1``.
99+
* Via the JSON parameter ``adios2.schema = 20210209``.
100+
* Via the environment variable ``export OPENPMD2_ADIOS2_SCHEMA=20210209``.
101101

102-
The classical and the new layout are absolutely incompatible with one another.
103-
The ADIOS2 backend will **not** (yet) automatically recognize the layout that has been used by a writer when reading a dataset.
102+
The ADIOS2 backend will automatically recognize the layout that has been used by a writer when reading a dataset.
104103

105104
Selected References
106105
-------------------

include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,26 @@ namespace detail
8080
} // namespace detail
8181

8282

83+
namespace ADIOS2Schema
84+
{
85+
using schema_t = uint64_t;
86+
/*
87+
* Original ADIOS schema.
88+
*/
89+
constexpr schema_t schema_0000_00_00 = 00000000;
90+
/*
91+
* This introduces attribute layout via scalar ADIOS variables.
92+
*/
93+
constexpr schema_t schema_2021_02_09 = 20210209;
94+
95+
enum class SupportedSchema : char
96+
{
97+
s_0000_00_00,
98+
s_2021_02_09
99+
};
100+
}
101+
using SupportedSchema = ADIOS2Schema::SupportedSchema;
102+
83103
class ADIOS2IOHandlerImpl
84104
: public AbstractIOHandlerImplCommon< ADIOS2FilePosition >
85105
{
@@ -203,14 +223,40 @@ class ADIOS2IOHandlerImpl
203223
* The ADIOS2 engine type, to be passed to adios2::IO::SetEngine
204224
*/
205225
std::string m_engineType;
226+
ADIOS2Schema::schema_t m_schema = ADIOS2Schema::schema_0000_00_00;
206227

207228
enum class AttributeLayout : char
208229
{
209230
ByAdiosAttributes,
210231
ByAdiosVariables
211232
};
212233

213-
AttributeLayout m_attributeLayout = AttributeLayout::ByAdiosAttributes;
234+
inline SupportedSchema schema() const
235+
{
236+
switch( m_schema )
237+
{
238+
case ADIOS2Schema::schema_0000_00_00:
239+
return SupportedSchema::s_0000_00_00;
240+
case ADIOS2Schema::schema_2021_02_09:
241+
return SupportedSchema::s_2021_02_09;
242+
default:
243+
throw std::runtime_error(
244+
"[ADIOS2] Encountered unsupported schema version: " +
245+
std::to_string( m_schema ) );
246+
}
247+
}
248+
249+
inline AttributeLayout attributeLayout() const
250+
{
251+
switch( schema() )
252+
{
253+
case SupportedSchema::s_0000_00_00:
254+
return AttributeLayout::ByAdiosAttributes;
255+
case SupportedSchema::s_2021_02_09:
256+
return AttributeLayout::ByAdiosVariables;
257+
}
258+
throw std::runtime_error( "Unreachable!" );
259+
}
214260

215261
struct ParameterizedOperator
216262
{
@@ -357,6 +403,11 @@ namespace ADIOS2Defaults
357403
constexpr const_str str_params = "parameters";
358404
constexpr const_str str_usesteps = "usesteps";
359405
constexpr const_str str_usesstepsAttribute = "__openPMD_internal/useSteps";
406+
constexpr const_str str_adios2Schema =
407+
"__openPMD_internal/openPMD2_adios2_schema";
408+
constexpr const_str str_isBooleanOldLayout = "__is_boolean__";
409+
constexpr const_str str_isBooleanNewLayout =
410+
"__openPMD_internal/is_boolean";
360411
} // namespace ADIOS2Defaults
361412

362413
namespace detail
@@ -995,8 +1046,6 @@ namespace detail
9951046
detail::DatasetReader const m_readDataset;
9961047
detail::AttributeReader const m_attributeReader;
9971048
PreloadAdiosAttributes preloadAttributes;
998-
using AttributeLayout = ADIOS2IOHandlerImpl::AttributeLayout;
999-
AttributeLayout m_attributeLayout = AttributeLayout::ByAdiosAttributes;
10001049

10011050
/*
10021051
* We call an attribute committed if the step during which it was
@@ -1106,6 +1155,7 @@ namespace detail
11061155
invalidateVariablesMap();
11071156

11081157
private:
1158+
ADIOS2IOHandlerImpl * m_impl;
11091159
auxiliary::Option< adios2::Engine > m_engine; //! ADIOS engine
11101160
/**
11111161
* The ADIOS2 engine type, to be passed to adios2::IO::SetEngine
@@ -1230,10 +1280,20 @@ namespace detail
12301280
*/
12311281
bool finalized = false;
12321282

1283+
inline SupportedSchema schema() const
1284+
{
1285+
return m_impl->schema();
1286+
}
1287+
12331288
void
12341289
configure_IO( ADIOS2IOHandlerImpl & impl );
1235-
};
12361290

1291+
using AttributeLayout = ADIOS2IOHandlerImpl::AttributeLayout;
1292+
inline AttributeLayout attributeLayout() const
1293+
{
1294+
return m_impl->attributeLayout();
1295+
}
1296+
};
12371297

12381298
} // namespace detail
12391299
#endif // openPMD_HAVE_ADIOS2

0 commit comments

Comments
 (0)