@@ -109,11 +109,8 @@ void WriteDataset::call(ADIOS2File &ba, detail::BufferedPut &bp)
109109 std::nullopt ,
110110 ba.variables ());
111111
112- // @todo cache this
113- auto is_bp5 = ba.m_impl ->realEngineType () == " bp5" ||
114- auxiliary::lowerCase (engine.Type ()) == " bp5writer" ;
115112 auto do_defer =
116- is_bp5 ? adios2::Mode::Sync : adios2::Mode::Deferred;
113+ ba. m_is_bp5 ? adios2::Mode::Sync : adios2::Mode::Deferred;
117114 engine.Put (var, ptr, do_defer);
118115 }
119116 else if constexpr (std::is_same_v<
@@ -185,10 +182,8 @@ struct RunUniquePtrPut
185182 bufferedPut.name ,
186183 std::nullopt ,
187184 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;
192187 engine.Put (var, ptr, do_defer);
193188 }
194189
@@ -987,6 +982,14 @@ adios2::Engine &ADIOS2File::getEngine()
987982 {
988983 throw std::runtime_error (" [ADIOS2] Failed opening Engine." );
989984 }
985+
986+ m_is_bp5 = m_impl->realEngineType () == " bp5" ||
987+ /* this second check should be sufficient, but we leave the
988+ first check in as a safeguard against renamings in
989+ ADIOS2. Also do a lowerCase transform since the docstring
990+ of `Engine::Type()` claims that the return value is in
991+ lowercase, but for BP5 this does not seem true. */
992+ auxiliary::lowerCase (m_engine->Type ()) == " bp5writer" ;
990993 }
991994 return m_engine.value ();
992995}
@@ -1107,13 +1110,7 @@ void ADIOS2File::flush_impl(ADIOS2FlushParams flushParams, bool writeLatePuts)
11071110 {
11081111 case FlushTarget::Disk:
11091112 case FlushTarget::Disk_Override:
1110- if (m_impl->realEngineType () == " bp5" ||
1111- /* this second check should be sufficient, but we leave the
1112- first check in as a safeguard against renamings in
1113- ADIOS2. Also do a lowerCase transform since the docstring
1114- of `Engine::Type()` claims that the return value is in
1115- lowercase, but for BP5 this does not seem true. */
1116- auxiliary::lowerCase (engine.Type ()) == " bp5writer" )
1113+ if (m_is_bp5)
11171114 {
11181115 target = CleanedFlushTarget::Disk;
11191116 }
@@ -1147,10 +1144,8 @@ void ADIOS2File::flush_impl(ADIOS2FlushParams flushParams, bool writeLatePuts)
11471144 m_uniquePtrPuts.clear ();
11481145 m_updateSpans.clear ();
11491146 break ;
1150- case CleanedFlushTarget::Buffer: { // @todo cache this
1151- auto is_bp5 = m_impl->realEngineType () == " bp5" ||
1152- auxiliary::lowerCase (engine.Type ()) == " bp5writer" ;
1153- if (!is_bp5)
1147+ case CleanedFlushTarget::Buffer: {
1148+ if (!m_is_bp5)
11541149 {
11551150 engine.PerformPuts ();
11561151 }
@@ -1263,16 +1258,6 @@ AdvanceStatus ADIOS2File::advance(AdvanceMode mode)
12631258 adios2::StepStatus adiosStatus{};
12641259 auto &engine = getEngine ();
12651260
1266- auto check_bp5 = [&]() -> bool {
1267- std::string engineType = engine.Type ();
1268- std::transform (
1269- engineType.begin (),
1270- engineType.end (),
1271- engineType.begin (),
1272- [](unsigned char c) { return std::tolower (c); });
1273- return engineType == " bp5writer" ;
1274- };
1275-
12761261 if (engine.CurrentStep () == 0 )
12771262 {
12781263 int max_steps_from_env =
@@ -1290,13 +1275,13 @@ AdvanceStatus ADIOS2File::advance(AdvanceMode mode)
12901275
12911276 // Check some conditions on which to now cancel operation due to
12921277 // unwieldy metadata sizes in BP5 with group encoding
1293- if (this ->m_impl ->m_handler ->m_encoding ==
1278+ if (m_is_bp5 &&
1279+ this ->m_impl ->m_handler ->m_encoding ==
12941280 IterationEncoding::groupBased &&
12951281 this ->m_max_steps_bp5 .has_value () &&
12961282 engine.CurrentStep () >= *this ->m_max_steps_bp5 &&
12971283 (this ->m_mode == adios2::Mode::Write ||
1298- this ->m_mode == adios2::Mode::Append) &&
1299- check_bp5 ())
1284+ this ->m_mode == adios2::Mode::Append))
13001285 {
13011286 throw error::OperationUnsupportedInBackend (
13021287 " ADIOS2" ,
0 commit comments