@@ -1291,7 +1291,7 @@ namespace
12911291
12921292 if (type == determineDatatype<rep>())
12931293 {
1294- auto meta = IO.InquireAttribute <rep>(metaAttr);
1294+ auto meta = IO.template InquireAttribute <rep>(metaAttr);
12951295 if (meta.Data ().size () == 1 && meta.Data ()[0 ] == 1 )
12961296 {
12971297 std::forward<Functor>(fun)(
@@ -1427,6 +1427,59 @@ namespace
14271427 static constexpr char const *errorMsg = " ReadAttributeAllsteps" ;
14281428 };
14291429
1430+ struct ReadAttributeAllstepsFullPreparsing
1431+ {
1432+ struct GetAttribute
1433+ {
1434+ detail::PreloadAdiosAttributes const &p;
1435+ template <typename AdiosType>
1436+ [[nodiscard]] auto call (std::string const &name) const
1437+ -> detail::AttributeWithShapeAndResource<AdiosType>
1438+ {
1439+ return p.getAttribute <AdiosType>(name);
1440+ }
1441+ };
1442+
1443+ template <typename T>
1444+ static void call (
1445+ std::vector<detail::PreloadAdiosAttributes> const &preload,
1446+ adios2::IO &IO,
1447+ std::string const &name,
1448+ Parameter<Operation::READ_ATT_ALLSTEPS>::result_type
1449+ &put_result_here)
1450+ {
1451+ std::vector<T> res;
1452+ res.reserve (preload.size ());
1453+ for (auto const &p : preload)
1454+ {
1455+ genericReadAttribute<T>(
1456+ [&res](auto &&val) {
1457+ using type = std::remove_reference_t <decltype (val)>;
1458+ if constexpr (std::is_same_v<type, bool >)
1459+ {
1460+ throw error::ReadError (
1461+ error::AffectedObject::Attribute,
1462+ error::Reason::UnexpectedContent,
1463+ " ADIOS2" ,
1464+ " [ReadAttributeAllsteps] No support for "
1465+ " Boolean attributes." );
1466+ }
1467+ else
1468+ {
1469+ res.emplace_back (static_cast <decltype (val)>(val));
1470+ }
1471+ },
1472+ IO,
1473+ name,
1474+ GetAttribute{p});
1475+ }
1476+ put_result_here = std::move (res);
1477+ }
1478+
1479+ static constexpr char const *errorMsg =
1480+ " ReadAttributeAllstepsFullPreparsing" ;
1481+ };
1482+
14301483#if openPMD_HAVE_MPI
14311484 struct DistributeToAllRanks
14321485 {
@@ -1561,13 +1614,61 @@ Use Access::READ_LINEAR to retrieve those values if needed.
15611614 }
15621615} // namespace
15631616
1617+ #define OPENPMD_PREPARSE_EVERYTHING 1
1618+
15641619void ADIOS2IOHandlerImpl::readAttributeAllsteps (
15651620 Writable *writable, Parameter<Operation::READ_ATT_ALLSTEPS> ¶m)
15661621{
15671622 auto file = refreshFileFromParent (writable, /* preferParentFile = */ false );
15681623 auto pos = setAndGetFilePosition (writable);
15691624 auto name = nameOfAttribute (writable, param.name );
15701625
1626+ #if OPENPMD_PREPARSE_EVERYTHING
1627+ detail::ADIOS2File &ba = getFileData (file, IfFileNotOpen::ThrowError);
1628+ #if openPMD_HAVE_MPI
1629+ auto adios = [&]() {
1630+ if (m_communicator.has_value ())
1631+ {
1632+ return adios2::ADIOS (*m_communicator);
1633+ }
1634+ else
1635+ {
1636+ return adios2::ADIOS{};
1637+ }
1638+ }();
1639+ #else
1640+ adios2::ADIOS adios;
1641+ #endif
1642+ auto IO = adios.DeclareIO (" PreparseSnapshots" );
1643+ // @todo check engine type
1644+ IO.SetEngine (realEngineType ());
1645+ IO.SetParameter (" StreamReader" , " ON" ); // this be for BP4
1646+ auto engine = IO.Open (fullPath (*file), adios2::Mode::Read);
1647+ std::vector<detail::PreloadAdiosAttributes> preload;
1648+ preload.reserve (engine.Steps ());
1649+ adios2::StepStatus status;
1650+ while ((status = engine.BeginStep ()) == adios2::StepStatus::OK)
1651+ {
1652+ auto &new_entry = preload.emplace_back ();
1653+ new_entry.preloadAttributes (IO);
1654+ engine.EndStep ();
1655+ }
1656+ if (status != adios2::StepStatus::EndOfStream)
1657+ {
1658+ throw std::runtime_error (
1659+ " [ADIOS2IOHandlerImpl::readAttributeAllsteps] Unexpected step "
1660+ " status while beginning a step." );
1661+ }
1662+ engine.Close ();
1663+ auto &attributes = ba.attributes ();
1664+ switchType<ReadAttributeAllstepsFullPreparsing>(
1665+ preload.at (0 ).attributeType (param.name ),
1666+ preload,
1667+ IO,
1668+ param.name ,
1669+ *param.resource );
1670+ attributes.m_data = std::move (preload);
1671+ #else
15711672 auto read_from_file_in_serial = [&]() {
15721673 adios2::ADIOS adios;
15731674 auto IO = adios.DeclareIO (" PreparseSnapshots" );
@@ -1603,6 +1704,7 @@ void ADIOS2IOHandlerImpl::readAttributeAllsteps(
16031704#else
16041705 read_from_file_in_serial ();
16051706#endif
1707+ #endif
16061708}
16071709
16081710void ADIOS2IOHandlerImpl::listPaths (
0 commit comments