@@ -109,11 +109,8 @@ void WriteDataset::call(ADIOS2File &ba, detail::BufferedPut &bp)
109
109
std::nullopt,
110
110
ba.variables ());
111
111
112
- // @todo cache this
113
- auto is_bp5 = ba.m_impl ->realEngineType () == " bp5" ||
114
- auxiliary::lowerCase (engine.Type ()) == " bp5writer" ;
115
112
auto do_defer =
116
- is_bp5 ? adios2::Mode::Sync : adios2::Mode::Deferred;
113
+ ba. m_is_bp5 ? adios2::Mode::Sync : adios2::Mode::Deferred;
117
114
engine.Put (var, ptr, do_defer);
118
115
}
119
116
else if constexpr (std::is_same_v<
@@ -185,10 +182,8 @@ struct RunUniquePtrPut
185
182
bufferedPut.name ,
186
183
std::nullopt,
187
184
ba.variables ());
188
- // @todo cache this
189
- auto is_bp5 = ba.m_impl ->realEngineType () == " bp5" ||
190
- auxiliary::lowerCase (engine.Type ()) == " bp5writer" ;
191
- auto do_defer = is_bp5 ? adios2::Mode::Sync : adios2::Mode::Deferred;
185
+ auto do_defer =
186
+ ba.m_is_bp5 ? adios2::Mode::Sync : adios2::Mode::Deferred;
192
187
engine.Put (var, ptr, do_defer);
193
188
}
194
189
@@ -985,6 +980,14 @@ adios2::Engine &ADIOS2File::getEngine()
985
980
{
986
981
throw std::runtime_error (" [ADIOS2] Failed opening Engine." );
987
982
}
983
+
984
+ m_is_bp5 = m_impl->realEngineType () == " bp5" ||
985
+ /* this second check should be sufficient, but we leave the
986
+ first check in as a safeguard against renamings in
987
+ ADIOS2. Also do a lowerCase transform since the docstring
988
+ of `Engine::Type()` claims that the return value is in
989
+ lowercase, but for BP5 this does not seem true. */
990
+ auxiliary::lowerCase (m_engine->Type ()) == " bp5writer" ;
988
991
}
989
992
return m_engine.value ();
990
993
}
@@ -1105,13 +1108,7 @@ void ADIOS2File::flush_impl(ADIOS2FlushParams flushParams, bool writeLatePuts)
1105
1108
{
1106
1109
case FlushTarget::Disk:
1107
1110
case FlushTarget::Disk_Override:
1108
- if (m_impl->realEngineType () == " bp5" ||
1109
- /* this second check should be sufficient, but we leave the
1110
- first check in as a safeguard against renamings in
1111
- ADIOS2. Also do a lowerCase transform since the docstring
1112
- of `Engine::Type()` claims that the return value is in
1113
- lowercase, but for BP5 this does not seem true. */
1114
- auxiliary::lowerCase (engine.Type ()) == " bp5writer" )
1111
+ if (m_is_bp5)
1115
1112
{
1116
1113
target = CleanedFlushTarget::Disk;
1117
1114
}
@@ -1145,10 +1142,8 @@ void ADIOS2File::flush_impl(ADIOS2FlushParams flushParams, bool writeLatePuts)
1145
1142
m_uniquePtrPuts.clear ();
1146
1143
m_updateSpans.clear ();
1147
1144
break ;
1148
- case CleanedFlushTarget::Buffer: { // @todo cache this
1149
- auto is_bp5 = m_impl->realEngineType () == " bp5" ||
1150
- auxiliary::lowerCase (engine.Type ()) == " bp5writer" ;
1151
- if (!is_bp5)
1145
+ case CleanedFlushTarget::Buffer: {
1146
+ if (!m_is_bp5)
1152
1147
{
1153
1148
engine.PerformPuts ();
1154
1149
}
@@ -1261,16 +1256,6 @@ AdvanceStatus ADIOS2File::advance(AdvanceMode mode)
1261
1256
adios2::StepStatus adiosStatus{};
1262
1257
auto &engine = getEngine ();
1263
1258
1264
- auto check_bp5 = [&]() -> bool {
1265
- std::string engineType = engine.Type ();
1266
- std::transform (
1267
- engineType.begin (),
1268
- engineType.end (),
1269
- engineType.begin (),
1270
- [](unsigned char c) { return std::tolower (c); });
1271
- return engineType == " bp5writer" ;
1272
- };
1273
-
1274
1259
if (engine.CurrentStep () == 0 )
1275
1260
{
1276
1261
int max_steps_from_env =
@@ -1288,13 +1273,13 @@ AdvanceStatus ADIOS2File::advance(AdvanceMode mode)
1288
1273
1289
1274
// Check some conditions on which to now cancel operation due to
1290
1275
// unwieldy metadata sizes in BP5 with group encoding
1291
- if (this ->m_impl ->m_handler ->m_encoding ==
1276
+ if (m_is_bp5 &&
1277
+ this ->m_impl ->m_handler ->m_encoding ==
1292
1278
IterationEncoding::groupBased &&
1293
1279
this ->m_max_steps_bp5 .has_value () &&
1294
1280
engine.CurrentStep () >= *this ->m_max_steps_bp5 &&
1295
1281
(this ->m_mode == adios2::Mode::Write ||
1296
- this ->m_mode == adios2::Mode::Append) &&
1297
- check_bp5 ())
1282
+ this ->m_mode == adios2::Mode::Append))
1298
1283
{
1299
1284
throw error::OperationUnsupportedInBackend (
1300
1285
" ADIOS2" ,
0 commit comments