Skip to content

Commit 72e770e

Browse files
committed
Configure this via env variable
OPENPMD_BP5_GROUPENCODING_MAX_STEPS=1000
1 parent 1826c7c commit 72e770e

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

include/openPMD/IO/ADIOS/ADIOS2File.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "openPMD/IO/IOTask.hpp"
2626
#include "openPMD/IO/InvalidatableFile.hpp"
2727
#include "openPMD/config.hpp"
28+
#include <optional>
2829

2930
#if openPMD_HAVE_ADIOS2
3031
#include <adios2.h>
@@ -428,6 +429,7 @@ class ADIOS2File
428429
*/
429430
size_t m_currentStep = 0;
430431
bool useStepSelection = false;
432+
std::optional<size_t> m_max_steps_bp5 = std::make_optional<size_t>(1000);
431433

432434
/*
433435
* ADIOS2 does not give direct access to its internal attribute and

src/IO/ADIOS/ADIOS2File.cpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,17 +1251,37 @@ AdvanceStatus ADIOS2File::advance(AdvanceMode mode)
12511251
return engineType == "bp5writer";
12521252
};
12531253

1254+
if (this->m_currentStep == 0)
1255+
{
1256+
int max_steps_from_env =
1257+
auxiliary::getEnvNum("OPENPMD_BP5_GROUPENCODING_MAX_STEPS", -1);
1258+
if (max_steps_from_env == 0)
1259+
{
1260+
m_max_steps_bp5 = std::nullopt;
1261+
}
1262+
else if (max_steps_from_env != -1)
1263+
{
1264+
m_max_steps_bp5 =
1265+
std::make_optional<size_t>(size_t(max_steps_from_env));
1266+
}
1267+
}
1268+
12541269
// Check some conditions on which to now cancel operation due to
12551270
// unwieldy metadata sizes in BP5 with group encoding
12561271
if (this->m_impl->m_handler->m_encoding ==
12571272
IterationEncoding::groupBased &&
1258-
this->m_currentStep >= 1000 &&
1273+
this->m_max_steps_bp5.has_value() &&
1274+
this->m_currentStep >= *this->m_max_steps_bp5 &&
12591275
(this->m_mode == adios2::Mode::Write ||
12601276
this->m_mode == adios2::Mode::Append) &&
12611277
check_bp5())
12621278
{
1263-
throw error::OperationUnsupportedInBackend("ADIOS2", R"(
1264-
Trying to create group-based output with more than 1000 steps in BP5 engine.
1279+
throw error::OperationUnsupportedInBackend(
1280+
"ADIOS2",
1281+
R"(
1282+
Trying to create group-based output with more than )" +
1283+
std::to_string(*this->m_max_steps_bp5) +
1284+
R"( steps in BP5 engine.
12651285
As this engine is not adequate for group encoding, this will create immense
12661286
metadata sizes. For more context, check:
12671287
@@ -1278,7 +1298,11 @@ Please consider using either of the following instead:
12781298
* (experimental) variable encoding (e.g. by `Series::setIterationEncoding()`
12791299
or by the JSON config {"iteration_encoding": "variable_based"}).
12801300
Note that there is at this point no complete read support for variable-encoded
1281-
outputs.)");
1301+
outputs.
1302+
1303+
Use the environment variable OPENPMD_BP5_GROUPENCODING_MAX_STEPS to adjust the
1304+
number of allowed steps. Set the value as 0 to disable this check.
1305+
Be aware of the performance implications described above.)");
12821306
}
12831307

12841308
if (streamStatus != StreamStatus::DuringStep)

0 commit comments

Comments
 (0)