Skip to content

Commit 4cf4064

Browse files
ADIOS2: more fine-grained control for file endings (#1218)
* Frontend implementation * Backend implementation * Fix config bug: JSON has higher priority than env vars * Testing Adapt tests to BP5 Don't use parentheses in attribute names Enable BP5 dtype tests Add test for AppendAfterSteps in BP5 * Documentation * CI debugging * Revert CI Debugging
1 parent 27e58a0 commit 4cf4064

File tree

15 files changed

+780
-138
lines changed

15 files changed

+780
-138
lines changed

docs/source/backends/adios2.rst

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,43 @@ For further information, check out the :ref:`installation guide <install>`,
1010
:ref:`build dependencies <development-dependencies>` and the :ref:`build options <development-buildoptions>`.
1111

1212

13-
I/O Method
14-
----------
13+
I/O Method and Engine Selection
14+
-------------------------------
1515

1616
ADIOS2 has several engines for alternative file formats and other kinds of backends, yet natively writes to ``.bp`` files.
17-
The openPMD API uses the BP4 engine as the default file engine and the SST engine for streaming support.
18-
We currently leverage the default ADIOS2 transport parameters, i.e. ``POSIX`` on Unix systems and ``FStream`` on Windows.
17+
The openPMD API uses the File meta engine as the default file engine and the SST engine for streaming support.
18+
19+
The ADIOS2 engine can be selected in different ways:
20+
21+
1. Automatic detection via the selected file ending
22+
2. Explicit selection of an engine by specifying the environment variable ``OPENPMD_ADIOS2_ENGINE`` (case-independent).
23+
This overrides the automatically detected engine.
24+
3. Explicit selection of an engine by specifying the JSON/TOML key ``adios2.engine.type`` as a case-independent string.
25+
This overrides both previous options.
26+
27+
Automatic engine detection supports the following extensions:
28+
29+
.. list-table::
30+
:header-rows: 1
31+
32+
* - Extension
33+
- Selected ADIOS2 Engine
34+
* - ``.bp``
35+
- ``"file"``
36+
* - ``.bp4``
37+
- ``"bp4"``
38+
* - ``.bp5``
39+
- ``"bp5"``
40+
* - ``.sst``
41+
- ``"sst"``
42+
* - ``.ssc``
43+
- ``"ssc"``
44+
45+
Specifying any of these extensions will automatically activate the ADIOS2 backend.
46+
The ADIOS2 backend will create file system paths exactly as they were specified and not change file extensions.
47+
Exceptions to this are the BP3 and SST engines which require their endings ``.bp`` and ``.sst`` respectively.
48+
49+
For file engines, we currently leverage the default ADIOS2 transport parameters, i.e. ``POSIX`` on Unix systems and ``FStream`` on Windows.
1950

2051
Steps
2152
-----

include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,16 @@ class ADIOS2IOHandlerImpl
132132
AbstractIOHandler *,
133133
MPI_Comm,
134134
json::TracingJSON config,
135-
std::string engineType);
135+
std::string engineType,
136+
std::string specifiedExtension);
136137

137138
#endif // openPMD_HAVE_MPI
138139

139140
explicit ADIOS2IOHandlerImpl(
140-
AbstractIOHandler *, json::TracingJSON config, std::string engineType);
141+
AbstractIOHandler *,
142+
json::TracingJSON config,
143+
std::string engineType,
144+
std::string specifiedExtension);
141145

142146
~ADIOS2IOHandlerImpl() override;
143147

@@ -231,6 +235,11 @@ class ADIOS2IOHandlerImpl
231235
* The ADIOS2 engine type, to be passed to adios2::IO::SetEngine
232236
*/
233237
std::string m_engineType;
238+
/*
239+
* The filename extension specified by the user.
240+
*/
241+
std::string m_userSpecifiedExtension;
242+
234243
ADIOS2Schema::schema_t m_schema = ADIOS2Schema::schema_0000_00_00;
235244

236245
enum class UseSpan : char
@@ -1320,15 +1329,17 @@ class ADIOS2IOHandler : public AbstractIOHandler
13201329
Access,
13211330
MPI_Comm,
13221331
json::TracingJSON options,
1323-
std::string engineType);
1332+
std::string engineType,
1333+
std::string specifiedExtension);
13241334

13251335
#endif
13261336

13271337
ADIOS2IOHandler(
13281338
std::string path,
13291339
Access,
13301340
json::TracingJSON options,
1331-
std::string engineType);
1341+
std::string engineType,
1342+
std::string specifiedExtension);
13321343

13331344
std::string backendName() const override
13341345
{

include/openPMD/IO/AbstractIOHandlerHelper.hpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ namespace openPMD
3535
* @param access Access mode describing desired operations and
3636
permissions of the desired handler.
3737
* @param format Format describing the IO backend of the desired handler.
38+
* @param originalExtension The filename extension as it was originally
39+
* specified by the user.
3840
* @param comm MPI communicator used for IO.
3941
* @param options JSON-formatted option string, to be interpreted by
4042
* the backend.
@@ -47,6 +49,7 @@ std::shared_ptr<AbstractIOHandler> createIOHandler(
4749
std::string path,
4850
Access access,
4951
Format format,
52+
std::string originalExtension,
5053
MPI_Comm comm,
5154
JSON options);
5255
#endif
@@ -58,6 +61,8 @@ std::shared_ptr<AbstractIOHandler> createIOHandler(
5861
* @param access Access describing desired operations and permissions
5962
* of the desired handler.
6063
* @param format Format describing the IO backend of the desired handler.
64+
* @param originalExtension The filename extension as it was originally
65+
* specified by the user.
6166
* @param options JSON-formatted option string, to be interpreted by
6267
* the backend.
6368
* @tparam JSON Substitute for nlohmann::json. Templated to avoid
@@ -66,9 +71,16 @@ std::shared_ptr<AbstractIOHandler> createIOHandler(
6671
*/
6772
template <typename JSON>
6873
std::shared_ptr<AbstractIOHandler> createIOHandler(
69-
std::string path, Access access, Format format, JSON options = JSON());
74+
std::string path,
75+
Access access,
76+
Format format,
77+
std::string originalExtension,
78+
JSON options = JSON());
7079

7180
// version without configuration to use in AuxiliaryTest
72-
std::shared_ptr<AbstractIOHandler>
73-
createIOHandler(std::string path, Access access, Format format);
81+
std::shared_ptr<AbstractIOHandler> createIOHandler(
82+
std::string path,
83+
Access access,
84+
Format format,
85+
std::string originalExtension);
7486
} // namespace openPMD

include/openPMD/IO/Format.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ enum class Format
3030
{
3131
HDF5,
3232
ADIOS1,
33-
ADIOS2,
33+
ADIOS2_BP,
34+
ADIOS2_BP4,
35+
ADIOS2_BP5,
3436
ADIOS2_SST,
3537
ADIOS2_SSC,
3638
JSON,

include/openPMD/Series.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ namespace internal
108108
* Filename after the expansion pattern without filename extension.
109109
*/
110110
std::string m_filenamePostfix;
111+
/**
112+
* Filename extension as specified by the user.
113+
* (Not necessarily the backend's default suffix)
114+
*/
115+
std::string m_filenameExtension;
111116
/**
112117
* The padding in file-based iteration encoding.
113118
* 0 if no padding is given (%T pattern).

src/Format.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Format determineFormat(std::string const &filename)
4545
);
4646

4747
if (bp_backend == "ADIOS2")
48-
return Format::ADIOS2;
48+
return Format::ADIOS2_BP;
4949
else if (bp_backend == "ADIOS1")
5050
return Format::ADIOS1;
5151
else
@@ -54,6 +54,10 @@ Format determineFormat(std::string const &filename)
5454
"neither ADIOS1 nor ADIOS2: " +
5555
bp_backend);
5656
}
57+
if (auxiliary::ends_with(filename, ".bp4"))
58+
return Format::ADIOS2_BP4;
59+
if (auxiliary::ends_with(filename, ".bp5"))
60+
return Format::ADIOS2_BP5;
5761
if (auxiliary::ends_with(filename, ".sst"))
5862
return Format::ADIOS2_SST;
5963
if (auxiliary::ends_with(filename, ".ssc"))
@@ -72,8 +76,12 @@ std::string suffix(Format f)
7276
case Format::HDF5:
7377
return ".h5";
7478
case Format::ADIOS1:
75-
case Format::ADIOS2:
79+
case Format::ADIOS2_BP:
7680
return ".bp";
81+
case Format::ADIOS2_BP4:
82+
return ".bp4";
83+
case Format::ADIOS2_BP5:
84+
return ".bp5";
7785
case Format::ADIOS2_SST:
7886
return ".sst";
7987
case Format::ADIOS2_SSC:

0 commit comments

Comments
 (0)