diff --git a/include/openPMD/IO/ADIOS/ADIOS2File.hpp b/include/openPMD/IO/ADIOS/ADIOS2File.hpp index 9d6820bb59..6a15a45b90 100644 --- a/include/openPMD/IO/ADIOS/ADIOS2File.hpp +++ b/include/openPMD/IO/ADIOS/ADIOS2File.hpp @@ -44,7 +44,7 @@ class ADIOS2IOHandlerImpl; #if openPMD_HAVE_ADIOS2 namespace openPMD::detail { -class BufferedActions; +class ADIOS2File; /* * IO-heavy action to be executed upon flushing. @@ -60,7 +60,7 @@ struct BufferedAction BufferedAction &operator=(BufferedAction const &other) = delete; BufferedAction &operator=(BufferedAction &&other) = default; - virtual void run(BufferedActions &) = 0; + virtual void run(ADIOS2File &) = 0; }; struct BufferedGet : BufferedAction @@ -68,7 +68,7 @@ struct BufferedGet : BufferedAction std::string name; Parameter param; - void run(BufferedActions &) override; + void run(ADIOS2File &) override; }; struct DatasetReader @@ -89,13 +89,13 @@ struct BufferedPut : BufferedAction std::string name; Parameter param; - void run(BufferedActions &) override; + void run(ADIOS2File &) override; }; struct WriteDataset { template - static void call(BufferedActions &ba, BufferedPut &bp); + static void call(ADIOS2File &ba, BufferedPut &bp); template static void call(Params &&...); @@ -109,7 +109,7 @@ struct BufferedUniquePtrPut UniquePtrWithLambda data; Datatype dtype = Datatype::UNDEFINED; - void run(BufferedActions &); + void run(ADIOS2File &); }; struct I_UpdateSpan @@ -133,7 +133,7 @@ struct UpdateSpan : I_UpdateSpan * (1) the file's IO and Engine objects * (2) the file's deferred IO-heavy actions */ -class BufferedActions +class ADIOS2File { friend struct BufferedGet; friend struct BufferedPut; @@ -144,7 +144,7 @@ class BufferedActions using FlushTarget = adios_defs::FlushTarget; public: - BufferedActions(BufferedActions const &) = delete; + ADIOS2File(ADIOS2File const &) = delete; /** * The full path to the file created on disk, including the @@ -177,7 +177,7 @@ class BufferedActions adios2::IO m_IO; /** * The default queue for deferred actions. - * Drained upon BufferedActions::flush(). + * Drained upon ADIOS2File::flush(). */ std::vector> m_buffer; /** @@ -219,7 +219,7 @@ class BufferedActions * iteration. If the following boolean is true, old attributes will be * removed upon CLOSE_GROUP. * Should not be set to true in persistent backends. - * Will be automatically set by BufferedActions::configure_IO depending + * Will be automatically set by ADIOS2File::configure_IO depending * on chosen ADIOS2 engine and can not be explicitly overridden by user. */ bool optimizeAttributesStreaming = false; @@ -229,9 +229,9 @@ class BufferedActions using AttributeMap_t = std::map; - BufferedActions(ADIOS2IOHandlerImpl &impl, InvalidatableFile file); + ADIOS2File(ADIOS2IOHandlerImpl &impl, InvalidatableFile file); - ~BufferedActions(); + ~ADIOS2File(); /** * Implementation of destructor, will only run once. @@ -295,7 +295,7 @@ class BufferedActions */ void flush_impl( ADIOS2FlushParams flushParams, - std::function const + std::function const &performPutGets, bool writeLatePuts, bool flushUnconditionally); @@ -346,13 +346,13 @@ class BufferedActions /* * streamStatus is NoStream for file-based ADIOS engines. - * This is relevant for the method BufferedActions::requireActiveStep, + * This is relevant for the method ADIOS2File::requireActiveStep, * where a step is only opened if the status is OutsideOfStep, but not * if NoStream. The rationale behind this is that parsing a Series * works differently for file-based and for stream-based engines: * * stream-based: Iterations are parsed as they arrive. For parsing an * iteration, the iteration must be awaited. - * BufferedActions::requireActiveStep takes care of this. + * ADIOS2File::requireActiveStep takes care of this. * * file-based: The Series is parsed up front. If no step has been * opened yet, ADIOS2 gives access to all variables and attributes * from all steps. Upon opening a step, only the variables from that @@ -461,7 +461,7 @@ class BufferedActions }; template -void BufferedActions::flush(Args &&...args) +void ADIOS2File::flush(Args &&...args) { try { diff --git a/include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp b/include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp index d0c6aaf1a1..66c8c7a466 100644 --- a/include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp +++ b/include/openPMD/IO/ADIOS/ADIOS2IOHandler.hpp @@ -79,7 +79,7 @@ namespace detail template struct DatasetTypes; struct WriteDataset; - class BufferedActions; + class ADIOS2File; struct BufferedPut; struct BufferedGet; struct BufferedAttributeRead; @@ -105,7 +105,7 @@ class ADIOS2IOHandlerImpl template friend struct detail::DatasetTypes; friend struct detail::WriteDataset; - friend class detail::BufferedActions; + friend class detail::ADIOS2File; friend struct detail::BufferedAttributeRead; friend struct detail::RunUniquePtrPut; @@ -331,9 +331,7 @@ class ADIOS2IOHandlerImpl * IO and Engine object. * Not to be accessed directly, use getFileData(). */ - std::unordered_map< - InvalidatableFile, - std::unique_ptr> + std::unordered_map> m_fileData; std::map m_operators; @@ -381,7 +379,7 @@ class ADIOS2IOHandlerImpl ThrowError }; - detail::BufferedActions & + detail::ADIOS2File & getFileData(InvalidatableFile const &file, IfFileNotOpen); void dropFileData(InvalidatableFile const &file); diff --git a/include/openPMD/IO/AbstractIOHandler.hpp b/include/openPMD/IO/AbstractIOHandler.hpp index 71a0587b0f..ba53e861d5 100644 --- a/include/openPMD/IO/AbstractIOHandler.hpp +++ b/include/openPMD/IO/AbstractIOHandler.hpp @@ -171,7 +171,7 @@ namespace internal namespace detail { - struct BufferedActions; + class ADIOS2File; } /** Interface for communicating between logical and physically persistent data. @@ -186,7 +186,7 @@ class AbstractIOHandler { friend class Series; friend class ADIOS2IOHandlerImpl; - friend struct detail::BufferedActions; + friend class detail::ADIOS2File; private: IterationEncoding m_encoding = IterationEncoding::groupBased; diff --git a/include/openPMD/backend/Writable.hpp b/include/openPMD/backend/Writable.hpp index 28554d0cf9..68daa94778 100644 --- a/include/openPMD/backend/Writable.hpp +++ b/include/openPMD/backend/Writable.hpp @@ -52,7 +52,7 @@ namespace internal } // namespace internal namespace detail { - struct BufferedActions; + class ADIOS2File; } /** @brief Layer to mirror structure of logical data and persistent data in @@ -83,7 +83,7 @@ class Writable final friend class Record; friend class AbstractIOHandlerImpl; friend class ADIOS2IOHandlerImpl; - friend struct detail::BufferedActions; + friend class detail::ADIOS2File; friend class HDF5IOHandlerImpl; friend class ParallelHDF5IOHandlerImpl; template diff --git a/src/IO/ADIOS/ADIOS2File.cpp b/src/IO/ADIOS/ADIOS2File.cpp index 9783cb8f6a..345116019f 100644 --- a/src/IO/ADIOS/ADIOS2File.cpp +++ b/src/IO/ADIOS/ADIOS2File.cpp @@ -70,7 +70,7 @@ template inline constexpr bool always_false_v = false; template -void WriteDataset::call(BufferedActions &ba, detail::BufferedPut &bp) +void WriteDataset::call(ADIOS2File &ba, detail::BufferedPut &bp) { VERIFY_ALWAYS( access::write(ba.m_impl->m_handler->m_backendAccess), @@ -124,13 +124,13 @@ void WriteDataset::call(Params &&...) throw std::runtime_error("[ADIOS2] WRITE_DATASET: Invalid datatype."); } -void BufferedGet::run(BufferedActions &ba) +void BufferedGet::run(ADIOS2File &ba) { switchAdios2VariableType( param.dtype, ba.m_impl, *this, ba.m_IO, ba.getEngine(), ba.m_file); } -void BufferedPut::run(BufferedActions &ba) +void BufferedPut::run(ADIOS2File &ba) { switchAdios2VariableType(param.dtype, ba, *this); } @@ -138,7 +138,7 @@ void BufferedPut::run(BufferedActions &ba) struct RunUniquePtrPut { template - static void call(BufferedUniquePtrPut &bufferedPut, BufferedActions &ba) + static void call(BufferedUniquePtrPut &bufferedPut, ADIOS2File &ba) { auto ptr = static_cast(bufferedPut.data.get()); adios2::Variable var = ba.m_impl->verifyDataset( @@ -149,13 +149,12 @@ struct RunUniquePtrPut static constexpr char const *errorMsg = "RunUniquePtrPut"; }; -void BufferedUniquePtrPut::run(BufferedActions &ba) +void BufferedUniquePtrPut::run(ADIOS2File &ba) { switchAdios2VariableType(dtype, *this, ba); } -BufferedActions::BufferedActions( - ADIOS2IOHandlerImpl &impl, InvalidatableFile file) +ADIOS2File::ADIOS2File(ADIOS2IOHandlerImpl &impl, InvalidatableFile file) : m_file(impl.fullPath(std::move(file))) , m_ADIOS(impl.m_ADIOS) , m_impl(&impl) @@ -179,23 +178,23 @@ BufferedActions::BufferedActions( } } -auto BufferedActions::useGroupTable() const -> UseGroupTable +auto ADIOS2File::useGroupTable() const -> UseGroupTable { return m_impl->useGroupTable(); } -void BufferedActions::create_IO() +void ADIOS2File::create_IO() { m_IOName = std::to_string(m_impl->nameCounter++); m_IO = m_impl->m_ADIOS.DeclareIO("IO_" + m_IOName); } -BufferedActions::~BufferedActions() +ADIOS2File::~ADIOS2File() { finalize(); } -void BufferedActions::finalize() +void ADIOS2File::finalize() { if (finalized) { @@ -318,7 +317,7 @@ namespace } } // namespace -size_t BufferedActions::currentStep() +size_t ADIOS2File::currentStep() { if (nonpersistentEngine(m_engineType)) { @@ -330,7 +329,7 @@ size_t BufferedActions::currentStep() } } -void BufferedActions::configure_IO_Read() +void ADIOS2File::configure_IO_Read() { bool upfrontParsing = supportsUpfrontParsing( m_impl->m_handler->m_backendAccess, m_engineType); @@ -402,7 +401,7 @@ void BufferedActions::configure_IO_Read() } } -void BufferedActions::configure_IO_Write() +void ADIOS2File::configure_IO_Write() { optimizeAttributesStreaming = // Also, it should only be done when truly streaming, not @@ -413,7 +412,7 @@ void BufferedActions::configure_IO_Write() streamStatus = StreamStatus::OutsideOfStep; } -void BufferedActions::configure_IO() +void ADIOS2File::configure_IO() { // step/variable-based iteration encoding requires use of group tables // but the group table feature is available only in ADIOS2 >= v2.9 @@ -710,7 +709,7 @@ void BufferedActions::configure_IO() getEngine(); } -auto BufferedActions::detectGroupTable() -> UseGroupTable +auto ADIOS2File::detectGroupTable() -> UseGroupTable { auto const &attributes = availableAttributes(); auto lower_bound = @@ -727,7 +726,7 @@ auto BufferedActions::detectGroupTable() -> UseGroupTable } } -adios2::Engine &BufferedActions::getEngine() +adios2::Engine &ADIOS2File::getEngine() { if (!m_engine) { @@ -929,10 +928,9 @@ adios2::Engine &BufferedActions::getEngine() return m_engine.value(); } -void BufferedActions::flush_impl( +void ADIOS2File::flush_impl( ADIOS2FlushParams flushParams, - std::function const - &performPutGets, + std::function const &performPutGets, bool writeLatePuts, bool flushUnconditionally) { @@ -1026,8 +1024,7 @@ void BufferedActions::flush_impl( } } -void BufferedActions::flush_impl( - ADIOS2FlushParams flushParams, bool writeLatePuts) +void ADIOS2File::flush_impl(ADIOS2FlushParams flushParams, bool writeLatePuts) { auto decideFlushAPICall = [this, flushTarget = flushParams.flushTarget](adios2::Engine &engine) { @@ -1080,7 +1077,7 @@ void BufferedActions::flush_impl( flush_impl( flushParams, [decideFlushAPICall = std::move(decideFlushAPICall)]( - BufferedActions &ba, adios2::Engine &eng) { + ADIOS2File &ba, adios2::Engine &eng) { if (writeOnly(ba.m_mode)) { decideFlushAPICall(eng); @@ -1094,12 +1091,12 @@ void BufferedActions::flush_impl( /* flushUnconditionally = */ false); } -AdvanceStatus BufferedActions::advance(AdvanceMode mode) +AdvanceStatus ADIOS2File::advance(AdvanceMode mode) { if (streamStatus == StreamStatus::Undecided) { throw error::Internal( - "[BufferedActions::advance()] StreamStatus Undecided before " + "[ADIOS2File::advance()] StreamStatus Undecided before " "beginning/ending a step?"); } // sic! no else @@ -1118,7 +1115,7 @@ AdvanceStatus BufferedActions::advance(AdvanceMode mode) * Advance mode write: * Close the current step, defer opening the new step * until one is actually needed: - * (1) The engine is accessed in BufferedActions::flush + * (1) The engine is accessed in ADIOS2File::flush * (2) A new step is opened before the currently active step * has seen an access. See the following lines: open the * step just to skip it again. @@ -1143,7 +1140,7 @@ AdvanceStatus BufferedActions::advance(AdvanceMode mode) flush( ADIOS2FlushParams{FlushLevel::UserFlush}, - [](BufferedActions &, adios2::Engine &eng) { eng.EndStep(); }, + [](ADIOS2File &, adios2::Engine &eng) { eng.EndStep(); }, /* writeLatePuts = */ true, /* flushUnconditionally = */ true); uncommittedAttributes.clear(); @@ -1189,18 +1186,18 @@ AdvanceStatus BufferedActions::advance(AdvanceMode mode) " chosen by the front-end."); } -void BufferedActions::drop() +void ADIOS2File::drop() { m_buffer.clear(); } static std::vector availableAttributesOrVariablesPrefixed( std::string const &prefix, - BufferedActions::AttributeMap_t const &(BufferedActions::*getBasicMap)(), - BufferedActions &ba) + ADIOS2File::AttributeMap_t const &(ADIOS2File::*getBasicMap)(), + ADIOS2File &ba) { std::string var = auxiliary::ends_with(prefix, '/') ? prefix : prefix + '/'; - BufferedActions::AttributeMap_t const &attributes = (ba.*getBasicMap)(); + ADIOS2File::AttributeMap_t const &attributes = (ba.*getBasicMap)(); std::vector ret; for (auto it = attributes.lower_bound(prefix); it != attributes.end(); ++it) { @@ -1217,25 +1214,25 @@ static std::vector availableAttributesOrVariablesPrefixed( } std::vector -BufferedActions::availableAttributesPrefixed(std::string const &prefix) +ADIOS2File::availableAttributesPrefixed(std::string const &prefix) { return availableAttributesOrVariablesPrefixed( - prefix, &BufferedActions::availableAttributes, *this); + prefix, &ADIOS2File::availableAttributes, *this); } std::vector -BufferedActions::availableVariablesPrefixed(std::string const &prefix) +ADIOS2File::availableVariablesPrefixed(std::string const &prefix) { return availableAttributesOrVariablesPrefixed( - prefix, &BufferedActions::availableVariables, *this); + prefix, &ADIOS2File::availableVariables, *this); } -void BufferedActions::invalidateAttributesMap() +void ADIOS2File::invalidateAttributesMap() { m_availableAttributes = std::optional(); } -BufferedActions::AttributeMap_t const &BufferedActions::availableAttributes() +ADIOS2File::AttributeMap_t const &ADIOS2File::availableAttributes() { if (m_availableAttributes) { @@ -1248,12 +1245,12 @@ BufferedActions::AttributeMap_t const &BufferedActions::availableAttributes() } } -void BufferedActions::invalidateVariablesMap() +void ADIOS2File::invalidateVariablesMap() { m_availableVariables = std::optional(); } -BufferedActions::AttributeMap_t const &BufferedActions::availableVariables() +ADIOS2File::AttributeMap_t const &ADIOS2File::availableVariables() { if (m_availableVariables) { @@ -1266,7 +1263,7 @@ BufferedActions::AttributeMap_t const &BufferedActions::availableVariables() } } -void BufferedActions::markActive(Writable *writable) +void ADIOS2File::markActive(Writable *writable) { switch (useGroupTable()) { diff --git a/src/IO/ADIOS/ADIOS2IOHandler.cpp b/src/IO/ADIOS/ADIOS2IOHandler.cpp index 5f4c068dd3..03fec76d90 100644 --- a/src/IO/ADIOS/ADIOS2IOHandler.cpp +++ b/src/IO/ADIOS/ADIOS2IOHandler.cpp @@ -144,7 +144,7 @@ ADIOS2IOHandlerImpl::~ADIOS2IOHandlerImpl() * This means that destruction order is nondeterministic. * Let's determinize it (necessary if computing in parallel). */ - using file_t = std::unique_ptr; + using file_t = std::unique_ptr; std::vector sorted; sorted.reserve(m_fileData.size()); for (auto &pair : m_fileData) @@ -460,7 +460,7 @@ ADIOS2IOHandlerImpl::flush(internal::ParsedFlushParams &flushParams) { auto res = AbstractIOHandlerImpl::flush(); - detail::BufferedActions::ADIOS2FlushParams adios2FlushParams{ + detail::ADIOS2File::ADIOS2FlushParams adios2FlushParams{ flushParams.flushLevel, m_flushTarget}; if (flushParams.backendConfig.json().contains("adios2")) { @@ -876,9 +876,7 @@ void ADIOS2IOHandlerImpl::closeFile( */ it->second->flush( FlushLevel::UserFlush, - [](detail::BufferedActions &ba, adios2::Engine &) { - ba.finalize(); - }, + [](detail::ADIOS2File &ba, adios2::Engine &) { ba.finalize(); }, /* writeLatePuts = */ true, /* flushUnconditionally = */ false); m_fileData.erase(it); @@ -967,7 +965,7 @@ void ADIOS2IOHandlerImpl::writeDataset( "[ADIOS2] Cannot write data in read-only mode."); setAndGetFilePosition(writable); auto file = refreshFileFromParent(writable, /* preferParentFile = */ false); - detail::BufferedActions &ba = getFileData(file, IfFileNotOpen::ThrowError); + detail::ADIOS2File &ba = getFileData(file, IfFileNotOpen::ThrowError); detail::BufferedPut bp; bp.name = nameOfVariable(writable); bp.param = std::move(parameters); @@ -1018,7 +1016,7 @@ void ADIOS2IOHandlerImpl::readDataset( { setAndGetFilePosition(writable); auto file = refreshFileFromParent(writable, /* preferParentFile = */ false); - detail::BufferedActions &ba = getFileData(file, IfFileNotOpen::ThrowError); + detail::ADIOS2File &ba = getFileData(file, IfFileNotOpen::ThrowError); detail::BufferedGet bg; bg.name = nameOfVariable(writable); bg.param = parameters; @@ -1034,7 +1032,7 @@ namespace detail static void call( ADIOS2IOHandlerImpl *impl, Parameter ¶ms, - detail::BufferedActions &ba, + detail::ADIOS2File &ba, std::string const &varName) { auto &IO = ba.m_IO; @@ -1109,7 +1107,7 @@ void ADIOS2IOHandlerImpl::getBufferView( } setAndGetFilePosition(writable); auto file = refreshFileFromParent(writable, /* preferParentFile = */ false); - detail::BufferedActions &ba = getFileData(file, IfFileNotOpen::ThrowError); + detail::ADIOS2File &ba = getFileData(file, IfFileNotOpen::ThrowError); std::string name = nameOfVariable(writable); switch (m_useSpanBasedPutByDefault) @@ -1162,7 +1160,7 @@ void ADIOS2IOHandlerImpl::readAttribute( { auto file = refreshFileFromParent(writable, /* preferParentFile = */ false); auto pos = setAndGetFilePosition(writable); - detail::BufferedActions &ba = getFileData(file, IfFileNotOpen::ThrowError); + detail::ADIOS2File &ba = getFileData(file, IfFileNotOpen::ThrowError); auto name = nameOfAttribute(writable, parameters.name); auto type = detail::attributeInfo(ba.m_IO, name, /* verbose = */ true); @@ -1253,7 +1251,7 @@ void ADIOS2IOHandlerImpl::listPaths( std::vector attrs = fileData.availableAttributesPrefixed(tablePrefix); if (fileData.streamStatus == - detail::BufferedActions::StreamStatus::DuringStep) + detail::ADIOS2File::StreamStatus::DuringStep) { auto currentStep = fileData.currentStep(); for (auto const &attrName : attrs) @@ -1425,12 +1423,12 @@ void ADIOS2IOHandlerImpl::availableChunks( { setAndGetFilePosition(writable); auto file = refreshFileFromParent(writable, /* preferParentFile = */ false); - detail::BufferedActions &ba = getFileData(file, IfFileNotOpen::ThrowError); + detail::ADIOS2File &ba = getFileData(file, IfFileNotOpen::ThrowError); std::string varName = nameOfVariable(writable); auto engine = ba.getEngine(); // make sure that data are present auto datatype = detail::fromADIOS2Type(ba.m_IO.VariableType(varName)); - bool allSteps = ba.streamStatus == - detail::BufferedActions::StreamStatus::ReadWithoutStream; + bool allSteps = + ba.streamStatus == detail::ADIOS2File::StreamStatus::ReadWithoutStream; switchAdios2VariableType( datatype, parameters, @@ -1562,7 +1560,7 @@ GroupOrDataset ADIOS2IOHandlerImpl::groupOrDataset(Writable *writable) return setAndGetFilePosition(writable)->gd; } -detail::BufferedActions &ADIOS2IOHandlerImpl::getFileData( +detail::ADIOS2File &ADIOS2IOHandlerImpl::getFileData( InvalidatableFile const &file, IfFileNotOpen flag) { VERIFY_ALWAYS( @@ -1577,7 +1575,7 @@ detail::BufferedActions &ADIOS2IOHandlerImpl::getFileData( case IfFileNotOpen::OpenImplicitly: { auto res = m_fileData.emplace( - file, std::make_unique(*this, file)); + file, std::make_unique(*this, file)); return *res.first->second; } case IfFileNotOpen::ThrowError: