You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add backendConfig parameter to flush call
Parse string JSON config into nlohmann representation
* ADIOS2 implementation: preferred_flush_target parameter
* Testing
* Documentation
* Add override parameters, update tests and docs
Also, use fstat in tests rather than <filesystem>
* Flush attributes before PerformDataWrites()
* Don't write buffered attributes upon PerformDataWrites
There is no advantage from doing this, readers will only see the data
after EndStep anyway, but there's the disadvantage that attributes
cannot be overwritten within this step anymore
* Use images from PR thread
Copy file name to clipboardExpand all lines: docs/source/backends/adios2.rst
+92-5Lines changed: 92 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -130,12 +130,18 @@ This buffer is drained to storage only at specific times:
130
130
131
131
The usage pattern of openPMD, especially the choice of iteration encoding influences the memory use of ADIOS2.
132
132
The following graphs are created from a real-world application using openPMD (PIConGPU) using KDE Heaptrack.
133
-
Ignore the 30GB initialization phases.
133
+
134
+
BP4 file engine
135
+
***************
136
+
137
+
The internal data structure of BP4 is one large buffer that holds all data written by a process.
138
+
It is drained to the disk upon ending a step or closing the engine (in parallel applications, data will usually be aggregated at the node-level before this).
139
+
This approach enables a very high IO performance by requiring only very few, very large IO operations, at the cost of a high memory consumption and some common usage pitfalls as detailed below:
134
140
135
141
* **file-based iteration encoding:** A new ADIOS2 engine is opened for each iteration and closed upon ``Iteration::close()``.
Series series("simData.sst", Access::CREATE, adios2Config);
193
+
194
+
By default, the openPMD-api configures a queue limit of 2.
195
+
Depending on the value of the ADIOS2 parameter ``QueueFullPolicy``, the SST engine will either ``"Discard"`` steps or ``"Block"`` the writer upon reaching the queue limit.
196
+
197
+
BP5 file engine
198
+
***************
199
+
200
+
The BP5 file engine internally uses a linked list of equally-sized buffers.
201
+
The size of each buffer can be specified up to a maximum of 2GB with the `ADIOS2 parameter <https://adios2.readthedocs.io/en/latest/engines/engines.html#bp5>`_ ``BufferChunkSize``:
Series series("simData.bp5", Access::CREATE, adios2Config);
209
+
210
+
This approach implies a sligthly lower IO performance due to more frequent and smaller writes, but it lets users control memory usage better and avoids out-of-memory issues when configuring ADIOS2 incorrectly.
211
+
212
+
The buffer is drained upon closing a step or the engine, but draining to the filesystem can also be triggered manually.
213
+
In the openPMD-api, this can be done by specifying backend-specific parameters to the ``Series::flush()`` or ``Attributable::seriesFlush()`` calls:
:alt:Memory usage of BP5 when flushing directly to disk
223
+
224
+
.. note::
225
+
226
+
KDE Heaptrack tracks the **virtual memory** consumption.
227
+
While the BP4 engine uses ``std::vector<char>`` for its internal buffer, BP5 uses plain ``malloc()`` (hence the 2GB limit), which does not initialize memory.
228
+
Memory pages will only be allocated to physical memory upon writing.
229
+
In applications with small IO sizes on systems with virtual memory, the physical memory usage will stay well below 2GB even if specifying the BufferChunkSize as 2GB.
230
+
231
+
**=> Specifying the buffer chunk size as 2GB as shown above is a good idea in most cases.**
232
+
233
+
Alternatively, data can be flushed to the buffer.
234
+
Note that this involves data copies that can be avoided by either flushing directly to disk or by entirely avoiding to flush until ``Iteration::close()``:
Copy file name to clipboardExpand all lines: docs/source/details/backendconfig.rst
+14-1Lines changed: 14 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,10 @@ The configuration string may refer to the complete ``openPMD::Series`` or may ad
37
37
This reflects the fact that certain backend-specific parameters may refer to the whole Series (such as storage engines and their parameters) and others refer to actual datasets (such as compression).
38
38
Dataset-specific configurations are (currently) only available during dataset creation, but not when reading datasets.
39
39
40
-
A JSON/TOML configuration may either be specified as an inline string that can be parsed as a JSON/TOML object, or alternatively as a path to a JSON/TOML-formatted text file (only in the constructor of ``openPMD::Series``):
40
+
Additionally, some backends may provide different implementations to the ``Series::flush()`` and ``Attributable::flushSeries()`` calls.
41
+
JSON/TOML strings may be passed to these calls as optional parameters.
42
+
43
+
A JSON/TOML configuration may either be specified as an inline string that can be parsed as a JSON/TOML object, or alternatively as a path to a JSON/TOML-formatted text file (only in the constructor of ``openPMD::Series``, all other API calls that accept a JSON/TOML specification require in-line datasets):
41
44
42
45
* File paths are distinguished by prepending them with an at-sign ``@``.
43
46
JSON and TOML are then distinguished by the filename extension ``.json`` or ``.toml``.
@@ -119,6 +122,16 @@ Explanation of the single keys:
119
122
Please refer to the `official ADIOS2 documentation <https://adios2.readthedocs.io/en/latest/engines/engines.html>`_ for the available engine parameters.
120
123
The openPMD-api does not interpret these values and instead simply forwards them to ADIOS2.
121
124
* ``adios2.engine.usesteps``: Described more closely in the documentation for the :ref:`ADIOS2 backend<backends-adios2>` (usesteps).
125
+
* ``adios2.engine.preferred_flush_target`` Only relevant for BP5 engine, possible values are ``"disk"`` and ``"buffer"`` (default: ``"disk"``).
126
+
127
+
* If ``"disk"``, data will be moved to disk on every flush.
128
+
* If ``"buffer"``, then only upon ending an IO step or closing an engine.
129
+
130
+
This behavior can be overridden on a per-flush basis by specifying this JSON/TOML key as an optional parameter to the ``Series::flush()`` or ``Attributable::seriesFlush()`` methods.
131
+
132
+
Additionally, specifying ``"disk_override"`` or ``"buffer_override"`` will take precedence over options specified without the ``_override`` suffix, allowing to invert the normal precedence order.
133
+
This way, a data producing code can hardcode the preferred flush target per ``flush()`` call, but users can e.g. still entirely deactivate flushing to disk in the ``Series`` constructor by specifying ``preferred_flush_target = buffer_override``.
134
+
This is useful when applying the asynchronous IO capabilities of the BP5 engine.
122
135
* ``adios2.dataset.operators``: This key contains a list of ADIOS2 `operators <https://adios2.readthedocs.io/en/latest/components/components.html#operator>`_, used to enable compression or dataset transformations.
Copy file name to clipboardExpand all lines: docs/source/usage/workflow.rst
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,3 +63,12 @@ Attributes are (currently) unaffected by this:
63
63
64
64
* In writing, attributes are stored internally by value and can afterwards not be accessed by the user.
65
65
* In reading, attributes are parsed upon opening the Series / an iteration and are available to read right-away.
66
+
67
+
.. attention::
68
+
69
+
Note that the concrete implementation of ``Series::flush()`` and ``Attributable::seriesFlush()`` is backend-specific.
70
+
Using these calls does neither guarantee that data is moved to storage/transport nor that it can be accessed by independent readers at this point.
71
+
72
+
Some backends (e.g. the BP5 engine of ADIOS2) have multiple implementations for the openPMD-api-level guarantees of flush points.
73
+
For user-guided selection of such implementations, ``Series::flush`` and ``Attributable::seriesFlush()`` take an optional JSON/TOML string as a parameter.
74
+
See the section on :ref:`backend-specific configuration <backendconfig>` for details.
0 commit comments