Skip to content

Commit

Permalink
Set default flush target to buffer when using this option
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Jun 20, 2023
1 parent b1f4f67 commit 3dd6191
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/source/backends/adios2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ environment variable default description
``OPENPMD_ADIOS2_ENGINE`` ``File`` `ADIOS2 engine <https://adios2.readthedocs.io/en/latest/engines/engines.html>`_
``OPENPMD2_ADIOS2_SCHEMA`` ``0`` ADIOS2 schema version (see below)
``OPENPMD_ADIOS2_STATS_LEVEL`` ``0`` whether to generate statistics for variables in ADIOS2. (``1``: yes, ``0``: no).
``OPENPMD_ADIOS2_ASYNC_WRITE`` ``0`` ADIOS2 BP5 engine: 1 means setting "AsyncWrite" in ADIOS2 to "on"
``OPENPMD_ADIOS2_ASYNC_WRITE`` ``0`` ADIOS2 BP5 engine: 1 means setting "AsyncWrite" in ADIOS2 to "on". Flushes will go to the buffer by default (see ``preferred_flush_target``).
``OPENPMD_ADIOS2_BP5_BufferChunkMB`` ``0`` ADIOS2 BP5 engine: applies when using either EveryoneWrites or EveryoneWritesSerial aggregation
``OPENPMD_ADIOS2_BP5_MaxShmMB`` ``0`` ADIOS2 BP5 engine: applies when using TwoLevelShm aggregation
``OPENPMD_ADIOS2_BP5_NumSubFiles`` ``0`` ADIOS2 BP5 engine: num of subfiles
Expand Down Expand Up @@ -268,7 +268,7 @@ Rather than by reallocation as in BP4, this is done by appending a new chunk, le
.. figure:: https://user-images.githubusercontent.com/14241876/181477384-ce4ea8ab-3bde-4210-991b-2e627dfcc7c9.png
:alt: Memory usage of BP5 when flushing to the engine buffer

The default is to flush to disk, but the default ``preferred_flush_target`` can also be specified via JSON/TOML at the ``Series`` level.
The default is to flush to disk (except when specifying ``OPENPMD_ADIOS2_ASYNC_WRITE=1``), but the default ``preferred_flush_target`` can also be specified via JSON/TOML at the ``Series`` level.



Expand Down
10 changes: 7 additions & 3 deletions src/IO/ADIOS/ADIOS2IOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2863,6 +2863,7 @@ namespace detail
// set engine parameters
std::set<std::string> alreadyConfigured;
std::optional<bool> userSpecifiedUsesteps;
bool wasTheFlushTargetSpecifiedViaJSON = false;
auto engineConfig = impl.config(ADIOS2Defaults::str_engine);
if (!engineConfig.json().is_null())
{
Expand Down Expand Up @@ -2909,9 +2910,8 @@ namespace detail
"Flush target must be either 'disk' or 'buffer', but "
"was non-literal type.");
}
overrideFlushTarget(
m_impl->m_flushTarget,
flushTargetFromString(target.value()));
m_impl->m_flushTarget = flushTargetFromString(target.value());
wasTheFlushTargetSpecifiedViaJSON = true;
}
}

Expand Down Expand Up @@ -3001,6 +3001,10 @@ namespace detail
notYetConfigured("AsyncWrite"))
{
m_IO.SetParameter("AsyncWrite", "On");
if (!wasTheFlushTargetSpecifiedViaJSON)
{
m_impl->m_flushTarget = FlushTarget::Buffer;
}
}
else
{
Expand Down
6 changes: 5 additions & 1 deletion test/SerialIOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4328,7 +4328,11 @@ BufferChunkSize = 2147483646 # 2^31 - 2
)";

adios2_bp5_flush(
cfg3, /* flushDuringStep = */ FlushDuringStep::Default_Yes);
cfg3,
/* flushDuringStep = */
auxiliary::getEnvNum("OPENPMD_ADIOS2_ASYNC_WRITE", 0) == 0
? FlushDuringStep::Default_Yes
: FlushDuringStep::Default_No);

std::string cfg4 = R"(
[adios2]
Expand Down

0 comments on commit 3dd6191

Please sign in to comment.