From 624750dd6146f0783b82715d396a9136305553b7 Mon Sep 17 00:00:00 2001 From: Norbert Podhorszki Date: Wed, 23 Mar 2022 14:51:59 -0400 Subject: [PATCH] Removed the virtual NULL engine from the C++/C/Python API. Renamed NullCoreWriter to NullWriter. Added a NullReader engine but this is still useless. "Null" and "NullCore" names both will use these new class. Updated docs on Null engine. --- bindings/C/adios2/c/adios2_c_engine.cpp | 72 ----- bindings/CXX11/adios2/cxx11/Engine.cpp | 52 ---- bindings/CXX11/adios2/cxx11/Engine.tcc | 71 ----- bindings/Python/py11Engine.cpp | 56 ---- docs/user_guide/source/engines/null.rst | 41 ++- source/adios2/CMakeLists.txt | 5 +- source/adios2/core/IO.cpp | 8 +- source/adios2/engine/null/NullEngine.cpp | 31 --- source/adios2/engine/null/NullEngine.h | 41 --- source/adios2/engine/null/NullReader.cpp | 119 +++++++++ source/adios2/engine/null/NullReader.h | 66 +++++ source/adios2/engine/null/NullReader.tcc | 43 +++ source/adios2/engine/null/NullWriter.cpp | 118 ++++++++ .../NullCoreWriter.h => null/NullWriter.h} | 20 +- .../NullWriter.tcc} | 20 +- .../adios2/engine/nullcore/NullCoreWriter.cpp | 118 -------- .../adios2/bindings/C/TestNullWriteRead.cpp | 9 +- .../adios2/bindings/python/TestNullEngine.py | 13 +- .../adios2/engine/null/TestNullWriteRead.cpp | 75 +----- .../engine/nullcore/TestNullCoreWrite.cpp | 252 ------------------ 20 files changed, 432 insertions(+), 798 deletions(-) delete mode 100644 source/adios2/engine/null/NullEngine.cpp delete mode 100644 source/adios2/engine/null/NullEngine.h create mode 100644 source/adios2/engine/null/NullReader.cpp create mode 100644 source/adios2/engine/null/NullReader.h create mode 100644 source/adios2/engine/null/NullReader.tcc create mode 100644 source/adios2/engine/null/NullWriter.cpp rename source/adios2/engine/{nullcore/NullCoreWriter.h => null/NullWriter.h} (77%) rename source/adios2/engine/{nullcore/NullCoreWriter.tcc => null/NullWriter.tcc} (60%) delete mode 100644 source/adios2/engine/nullcore/NullCoreWriter.cpp diff --git a/bindings/C/adios2/c/adios2_c_engine.cpp b/bindings/C/adios2/c/adios2_c_engine.cpp index 999d6db159..d3be30149a 100644 --- a/bindings/C/adios2/c/adios2_c_engine.cpp +++ b/bindings/C/adios2/c/adios2_c_engine.cpp @@ -197,12 +197,6 @@ adios2_error adios2_begin_step(adios2_engine *engine, adios2::core::Engine *engineCpp = reinterpret_cast(engine); - if (engineCpp->m_EngineType == "NULL") - { - *status = adios2_step_status_end_of_stream; - return adios2_error_none; - } - const adios2::StepStatus statusCpp = engineCpp->BeginStep( ToStepMode(mode, "in call to adios2_begin_step"), timeout_seconds); @@ -228,12 +222,6 @@ adios2_error adios2_current_step(size_t *current_step, const adios2::core::Engine *engineCpp = reinterpret_cast(engine); - if (engineCpp->m_EngineType == "NULL") - { - *current_step = adios2::MaxSizeT; - return adios2_error_none; - } - *current_step = engineCpp->CurrentStep(); return adios2_error_none; } @@ -254,12 +242,6 @@ adios2_error adios2_steps(size_t *steps, const adios2_engine *engine) const adios2::core::Engine *engineCpp = reinterpret_cast(engine); - if (engineCpp->m_EngineType == "NULL") - { - *steps = 0; - return adios2_error_none; - } - *steps = engineCpp->Steps(); return adios2_error_none; } @@ -281,11 +263,6 @@ adios2_error adios2_put(adios2_engine *engine, adios2_variable *variable, adios2::core::Engine *engineCpp = reinterpret_cast(engine); - if (engineCpp->m_EngineType == "NULL") - { - return adios2_error_none; - } - adios2::helper::CheckForNullptr( variable, "for adios2_variable, in call to adios2_put"); @@ -339,11 +316,6 @@ adios2_error adios2_put_by_name(adios2_engine *engine, adios2::core::Engine *engineCpp = reinterpret_cast(engine); - if (engineCpp->m_EngineType == "NULL") - { - return adios2_error_none; - } - adios2::helper::CheckForNullptr( variable_name, "for const char* variable_name, in call to adios2_put_by_name"); @@ -391,11 +363,6 @@ adios2_error adios2_perform_puts(adios2_engine *engine) adios2::core::Engine *engineCpp = reinterpret_cast(engine); - if (engineCpp->m_EngineType == "NULL") - { - return adios2_error_none; - } - engineCpp->PerformPuts(); return adios2_error_none; } @@ -416,11 +383,6 @@ adios2_error adios2_perform_data_write(adios2_engine *engine) adios2::core::Engine *engineCpp = reinterpret_cast(engine); - if (engineCpp->m_EngineType == "NULL") - { - return adios2_error_none; - } - engineCpp->PerformDataWrite(); return adios2_error_none; } @@ -442,11 +404,6 @@ adios2_error adios2_get(adios2_engine *engine, adios2_variable *variable, adios2::core::Engine *engineCpp = reinterpret_cast(engine); - if (engineCpp->m_EngineType == "NULL") - { - return adios2_error_none; - } - adios2::helper::CheckForNullptr(variable, "for adios2_variable, in call " "to adios2_get"); @@ -501,11 +458,6 @@ adios2_error adios2_get_by_name(adios2_engine *engine, adios2::core::Engine *engineCpp = reinterpret_cast(engine); - if (engineCpp->m_EngineType == "NULL") - { - return adios2_error_none; - } - adios2::helper::CheckForNullptr( variable_name, "for const char* variable_name, in call to " "adios2_get_by_name"); @@ -552,11 +504,6 @@ adios2_error adios2_perform_gets(adios2_engine *engine) adios2::core::Engine *engineCpp = reinterpret_cast(engine); - if (engineCpp->m_EngineType == "NULL") - { - return adios2_error_none; - } - engineCpp->PerformGets(); return adios2_error_none; } @@ -577,11 +524,6 @@ adios2_error adios2_end_step(adios2_engine *engine) adios2::core::Engine *engineCpp = reinterpret_cast(engine); - if (engineCpp->m_EngineType == "NULL") - { - return adios2_error_none; - } - engineCpp->EndStep(); return adios2_error_none; } @@ -608,11 +550,6 @@ adios2_error adios2_flush_by_index(adios2_engine *engine, adios2::core::Engine *engineCpp = reinterpret_cast(engine); - if (engineCpp->m_EngineType == "NULL") - { - return adios2_error_none; - } - engineCpp->Flush(transport_index); return adios2_error_none; @@ -690,10 +627,6 @@ adios2_varinfo *adios2_inquire_blockinfo(adios2_engine *engine, adios2::core::Engine *engineCpp = reinterpret_cast(engine); - if (engineCpp->m_EngineType == "NULL") - { - return NULL; - } adios2::helper::CheckForNullptr(variable, "for adios2_variable, in call " "to adios2_get"); @@ -873,11 +806,6 @@ adios2_error adios2_close_by_index(adios2_engine *engine, adios2::core::Engine *engineCpp = reinterpret_cast(engine); - if (engineCpp->m_EngineType == "NULL") - { - return adios2_error_none; - } - engineCpp->Close(transport_index); // erase Engine object from IO diff --git a/bindings/CXX11/adios2/cxx11/Engine.cpp b/bindings/CXX11/adios2/cxx11/Engine.cpp index 147b4507d4..c766bb8b49 100644 --- a/bindings/CXX11/adios2/cxx11/Engine.cpp +++ b/bindings/CXX11/adios2/cxx11/Engine.cpp @@ -49,10 +49,6 @@ Mode Engine::OpenMode() const StepStatus Engine::BeginStep() { helper::CheckForNullptr(m_Engine, "in call to Engine::BeginStep"); - if (m_Engine->m_EngineType == "NULL") - { - return StepStatus::EndOfStream; - } return m_Engine->BeginStep(); } @@ -60,50 +56,30 @@ StepStatus Engine::BeginStep(const StepMode mode, const float timeoutSeconds) { helper::CheckForNullptr( m_Engine, "in call to Engine::BeginStep(const StepMode, const float)"); - if (m_Engine->m_EngineType == "NULL") - { - return StepStatus::EndOfStream; - } return m_Engine->BeginStep(mode, timeoutSeconds); } size_t Engine::CurrentStep() const { helper::CheckForNullptr(m_Engine, "in call to Engine::CurrentStep"); - if (m_Engine->m_EngineType == "NULL") - { - return MaxSizeT; - } return m_Engine->CurrentStep(); } void Engine::PerformPuts() { helper::CheckForNullptr(m_Engine, "in call to Engine::PerformPuts"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } m_Engine->PerformPuts(); } void Engine::PerformDataWrite() { helper::CheckForNullptr(m_Engine, "in call to Engine::PerformDataWrite"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } m_Engine->PerformDataWrite(); } void Engine::PerformGets() { helper::CheckForNullptr(m_Engine, "in call to Engine::PerformGets"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } m_Engine->PerformGets(); } @@ -111,10 +87,6 @@ void Engine::LockWriterDefinitions() { helper::CheckForNullptr(m_Engine, "in call to Engine::LockWriterDefinitions"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } m_Engine->LockWriterDefinitions(); } @@ -122,40 +94,24 @@ void Engine::LockReaderSelections() { helper::CheckForNullptr(m_Engine, "in call to Engine::LockReaderSelections"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } m_Engine->LockReaderSelections(); } void Engine::EndStep() { helper::CheckForNullptr(m_Engine, "in call to Engine::EndStep"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } m_Engine->EndStep(); } void Engine::Flush(const int transportIndex) { helper::CheckForNullptr(m_Engine, "in call to Engine::Flush"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } m_Engine->Flush(transportIndex); } void Engine::Close(const int transportIndex) { helper::CheckForNullptr(m_Engine, "in call to Engine::Close"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } m_Engine->Close(transportIndex); // erase Engine object from IO @@ -168,10 +124,6 @@ void Engine::Close(const int transportIndex) size_t Engine::Steps() const { helper::CheckForNullptr(m_Engine, "in call to Engine::Steps"); - if (m_Engine->m_EngineType == "NULL") - { - return 0; - } return m_Engine->Steps(); } @@ -223,10 +175,6 @@ size_t Engine::DebugGetDataBufferSize() const { helper::CheckForNullptr(m_Engine, "in call to Engine::DebugGetDataBufferSize"); - if (m_Engine->m_EngineType == "NULL") - { - return 0; - } return m_Engine->DebugGetDataBufferSize(); } diff --git a/bindings/CXX11/adios2/cxx11/Engine.tcc b/bindings/CXX11/adios2/cxx11/Engine.tcc index 93c6d2e48c..e7bcebd917 100644 --- a/bindings/CXX11/adios2/cxx11/Engine.tcc +++ b/bindings/CXX11/adios2/cxx11/Engine.tcc @@ -69,11 +69,6 @@ typename Variable::Span Engine::Put(Variable variable, adios2::helper::CheckForNullptr(m_Engine, "for Engine in call to Engine::Array"); - if (m_Engine->m_EngineType == "NULL") - { - return typename Variable::Span(nullptr); - } - adios2::helper::CheckForNullptr(variable.m_Variable, "for variable in call to Engine::Array"); @@ -91,11 +86,6 @@ typename Variable::Span Engine::Put(Variable variable) adios2::helper::CheckForNullptr(m_Engine, "for Engine in call to Engine::Array"); - if (m_Engine->m_EngineType == "NULL") - { - return typename Variable::Span(nullptr); - } - adios2::helper::CheckForNullptr(variable.m_Variable, "for variable in call to Engine::Array"); @@ -111,10 +101,6 @@ void Engine::Put(Variable variable, const T *data, const Mode launch) { using IOType = typename TypeInfo::IOType; adios2::helper::CheckForNullptr(m_Engine, "in call to Engine::Put"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } adios2::helper::CheckForNullptr(variable.m_Variable, "for variable in call to Engine::Put"); m_Engine->Put(*variable.m_Variable, reinterpret_cast(data), @@ -127,10 +113,6 @@ void Engine::Put(const std::string &variableName, const T *data, { using IOType = typename TypeInfo::IOType; adios2::helper::CheckForNullptr(m_Engine, "in call to Engine::Put"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } m_Engine->Put(variableName, reinterpret_cast(data), launch); } @@ -139,10 +121,6 @@ void Engine::Put(Variable variable, const T &datum, const Mode launch) { using IOType = typename TypeInfo::IOType; adios2::helper::CheckForNullptr(m_Engine, "in call to Engine::Put"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } adios2::helper::CheckForNullptr(variable.m_Variable, "for variable in call to Engine::Put"); m_Engine->Put(*variable.m_Variable, reinterpret_cast(datum), @@ -155,10 +133,6 @@ void Engine::Put(const std::string &variableName, const T &datum, { using IOType = typename TypeInfo::IOType; adios2::helper::CheckForNullptr(m_Engine, "in call to Engine::Put"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } m_Engine->Put(variableName, reinterpret_cast(datum), launch); } @@ -168,10 +142,6 @@ void Engine::Get(Variable variable, T *data, const Mode launch) { using IOType = typename TypeInfo::IOType; adios2::helper::CheckForNullptr(m_Engine, "in call to Engine::Get"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } adios2::helper::CheckForNullptr(variable.m_Variable, "for variable in call to Engine::Get"); m_Engine->Get(*variable.m_Variable, reinterpret_cast(data), @@ -183,10 +153,6 @@ void Engine::Get(const std::string &variableName, T *data, const Mode launch) { using IOType = typename TypeInfo::IOType; adios2::helper::CheckForNullptr(m_Engine, "in call to Engine::Get"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } m_Engine->Get(variableName, reinterpret_cast(data), launch); } @@ -195,10 +161,6 @@ void Engine::Get(Variable variable, T &datum, const Mode /*launch*/) { using IOType = typename TypeInfo::IOType; adios2::helper::CheckForNullptr(m_Engine, "in call to Engine::Get"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } adios2::helper::CheckForNullptr(variable.m_Variable, "for variable in call to Engine::Get"); m_Engine->Get(*variable.m_Variable, reinterpret_cast(datum)); @@ -210,10 +172,6 @@ void Engine::Get(const std::string &variableName, T &datum, { using IOType = typename TypeInfo::IOType; adios2::helper::CheckForNullptr(m_Engine, "in call to Engine::Get"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } m_Engine->Get(variableName, reinterpret_cast(datum)); } @@ -223,10 +181,6 @@ void Engine::Get(Variable variable, std::vector &dataV, const Mode launch) using IOType = typename TypeInfo::IOType; adios2::helper::CheckForNullptr( m_Engine, "in call to Engine::Get with std::vector argument"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } adios2::helper::CheckForNullptr(variable.m_Variable, "for variable in call to Engine::Get"); m_Engine->Get(*variable.m_Variable, @@ -240,10 +194,6 @@ void Engine::Get(const std::string &variableName, std::vector &dataV, using IOType = typename TypeInfo::IOType; adios2::helper::CheckForNullptr( m_Engine, "in call to Engine::Get with std::vector argument"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } m_Engine->Get(variableName, reinterpret_cast &>(dataV), launch); } @@ -253,10 +203,6 @@ void Engine::Get(Variable variable, typename Variable::Info &info, const Mode launch) { adios2::helper::CheckForNullptr(m_Engine, "in call to Engine::Get"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } adios2::helper::CheckForNullptr(variable.m_Variable, "for variable in call to Engine::Get"); info.m_Info = reinterpret_cast::Info::CoreInfo *>( @@ -269,10 +215,6 @@ void Engine::Get(const std::string &variableName, { using IOType = typename TypeInfo::IOType; adios2::helper::CheckForNullptr(m_Engine, "in call to Engine::Get"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } info.m_Info = reinterpret_cast::Info::CoreInfo *>( m_Engine->Get(variableName, launch)); } @@ -299,10 +241,6 @@ Engine::AllStepsBlocksInfo(const Variable variable) const using IOType = typename TypeInfo::IOType; adios2::helper::CheckForNullptr( m_Engine, "for Engine in call to Engine::AllStepsBlocksInfo"); - if (m_Engine->m_EngineType == "NULL") - { - return std::map::Info>>(); - } adios2::helper::CheckForNullptr( variable.m_Variable, @@ -348,10 +286,6 @@ Engine::BlocksInfo(const Variable variable, const size_t step) const using IOType = typename TypeInfo::IOType; adios2::helper::CheckForNullptr(m_Engine, "for Engine in call to Engine::BlocksInfo"); - if (m_Engine->m_EngineType == "NULL") - { - return std::vector::Info>(); - } adios2::helper::CheckForNullptr( variable.m_Variable, "for variable in call to Engine::BlocksInfo"); @@ -378,11 +312,6 @@ std::vector Engine::GetAbsoluteSteps(const Variable variable) const using IOType = typename TypeInfo::IOType; adios2::helper::CheckForNullptr( m_Engine, "for Engine in call to Engine::GetAbsoluteSteps"); - if (m_Engine->m_EngineType == "NULL") - { - return std::vector(); - } - adios2::helper::CheckForNullptr( variable.m_Variable, "for variable in call to Engine::GetAbsoluteSteps"); diff --git a/bindings/Python/py11Engine.cpp b/bindings/Python/py11Engine.cpp index 14e6cbb055..a7df316d8f 100644 --- a/bindings/Python/py11Engine.cpp +++ b/bindings/Python/py11Engine.cpp @@ -38,20 +38,12 @@ Engine::operator bool() const noexcept StepStatus Engine::BeginStep(const StepMode mode, const float timeoutSeconds) { helper::CheckForNullptr(m_Engine, "in call to Engine::BeginStep"); - if (m_Engine->m_EngineType == "NULL") - { - return StepStatus::EndOfStream; - } return m_Engine->BeginStep(mode, timeoutSeconds); } StepStatus Engine::BeginStep() { helper::CheckForNullptr(m_Engine, "in call to Engine::BeginStep"); - if (m_Engine->m_EngineType == "NULL") - { - return StepStatus::EndOfStream; - } return m_Engine->BeginStep(); } @@ -59,11 +51,6 @@ void Engine::Put(Variable variable, const pybind11::array &array, const Mode launch) { helper::CheckForNullptr(m_Engine, "in call to Engine::Put numpy array"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } - helper::CheckForNullptr(variable.m_VariableBase, "for variable, in call to Engine::Put numpy array"); @@ -96,11 +83,6 @@ void Engine::Put(Variable variable, const std::string &string) { helper::CheckForNullptr(m_Engine, "for engine, in call to Engine::Put string"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } - helper::CheckForNullptr(variable.m_VariableBase, "for variable, in call to Engine::Put string"); @@ -120,20 +102,12 @@ void Engine::Put(Variable variable, const std::string &string) void Engine::PerformPuts() { helper::CheckForNullptr(m_Engine, "in call to PerformPuts"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } m_Engine->PerformPuts(); } void Engine::PerformDataWrite() { helper::CheckForNullptr(m_Engine, "in call to PerformDataWrite"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } m_Engine->PerformDataWrite(); } @@ -141,11 +115,6 @@ void Engine::Get(Variable variable, pybind11::array &array, const Mode launch) { helper::CheckForNullptr(m_Engine, "for engine, in call to Engine::Get a numpy array"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } - helper::CheckForNullptr( variable.m_VariableBase, "for variable, in call to Engine::Get a numpy array"); @@ -182,11 +151,6 @@ std::string Engine::Get(Variable variable, const Mode launch) std::string string; helper::CheckForNullptr(m_Engine, "for engine, in call to Engine::Get a numpy array"); - if (m_Engine->m_EngineType == "NULL") - { - return ""; - } - helper::CheckForNullptr(variable.m_VariableBase, "for variable, in call to Engine::Get a string"); @@ -210,40 +174,24 @@ std::string Engine::Get(Variable variable, const Mode launch) void Engine::PerformGets() { helper::CheckForNullptr(m_Engine, "in call to Engine::PerformGets"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } m_Engine->PerformGets(); } void Engine::EndStep() { helper::CheckForNullptr(m_Engine, "for engine, in call to Engine::EndStep"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } m_Engine->EndStep(); } void Engine::Flush(const int transportIndex) { helper::CheckForNullptr(m_Engine, "for engine, in call to Engine::Flush"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } m_Engine->Flush(transportIndex); } void Engine::Close(const int transportIndex) { helper::CheckForNullptr(m_Engine, "for engine, in call to Engine::Close"); - if (m_Engine->m_EngineType == "NULL") - { - return; - } m_Engine->Close(transportIndex); // erase Engine object from IO @@ -257,10 +205,6 @@ size_t Engine::CurrentStep() const { helper::CheckForNullptr(m_Engine, "for engine, in call to Engine::CurrentStep"); - if (m_Engine->m_EngineType == "NULL") - { - return MaxSizeT; - } return m_Engine->CurrentStep(); } diff --git a/docs/user_guide/source/engines/null.rst b/docs/user_guide/source/engines/null.rst index 7b1156595d..9d2d661aa0 100644 --- a/docs/user_guide/source/engines/null.rst +++ b/docs/user_guide/source/engines/null.rst @@ -2,6 +2,43 @@ Null **** -The ``Null`` Engine by-passes any heavy I/O operations that other Engines might potentially execute, for example, memory allocations, buffering, transport data movement. Calls to the Null engine would effectively return immediately without doing any effective operations. +The ``Null`` Engine performs no internal work and no I/O. It was created for testing applications that have ADIOS2 output in it by turning off the I/O easily. The runtime difference between a run with the Null engine and another engine tells us the IO overhead of that particular output with that particular engine. -The overall goal is to provide a mechanism to isolate an application behavior without the ADIOS 2 footprint. Use this engine to have an idea of the overhead cost of using a certain ADIOS 2 Engine (similar to writing to `/dev/null`) in an application. +.. code-block:: c++ + + adios2::IO io = adios.DeclareIO("Output"); + io.SetEngine("Null"); + +or using the XML config file: + +.. code-block:: xml + + + + + + + + +Although there is a reading engine as well, which will not fail, any variable/attribute inquiry returns `nullptr` and any subsequent Get() calls will throw an exception in C++/Python or return an error in C/Fortran. + +Note that there is also a `Null transport` that can be used by a BP engine instead of the default `File transport`. In that case, the BP engine will perform all internal work including buffering and aggregation but no data will be output at all. A run like this can be used to assess the overhead of the internal work of the BP engine. + +.. code-block:: c++ + + adios2::IO io = adios.DeclareIO("Output"); + io.SetEngine("BP5"); + io.AddTransport("Null", {}); + +or using the XML config file + +.. code-block:: xml + + + + + + + + + \ No newline at end of file diff --git a/source/adios2/CMakeLists.txt b/source/adios2/CMakeLists.txt index 7a88e97850..43cc0e97aa 100644 --- a/source/adios2/CMakeLists.txt +++ b/source/adios2/CMakeLists.txt @@ -54,9 +54,8 @@ add_library(adios2_core engine/inline/InlineReader.cpp engine/inline/InlineReader.tcc engine/inline/InlineWriter.cpp engine/inline/InlineWriter.tcc - engine/null/NullEngine.cpp - - engine/nullcore/NullCoreWriter.cpp engine/nullcore/NullCoreWriter.tcc + engine/null/NullWriter.cpp engine/null/NullWriter.tcc + engine/null/NullReader.cpp engine/null/NullReader.tcc engine/plugin/PluginEngine.cpp engine/plugin/PluginEngineInterface.cpp operator/plugin/PluginOperator.cpp operator/plugin/PluginOperatorInterface.cpp diff --git a/source/adios2/core/IO.cpp b/source/adios2/core/IO.cpp index d4d832149e..11b30f3804 100644 --- a/source/adios2/core/IO.cpp +++ b/source/adios2/core/IO.cpp @@ -30,8 +30,8 @@ #include "adios2/engine/inline/InlineWriter.h" #include "adios2/engine/mhs/MhsReader.h" #include "adios2/engine/mhs/MhsWriter.h" -#include "adios2/engine/null/NullEngine.h" -#include "adios2/engine/nullcore/NullCoreWriter.h" +#include "adios2/engine/null/NullReader.h" +#include "adios2/engine/null/NullWriter.h" #include "adios2/engine/plugin/PluginEngine.h" #include "adios2/engine/skeleton/SkeletonReader.h" #include "adios2/engine/skeleton/SkeletonWriter.h" @@ -126,10 +126,10 @@ std::unordered_map Factory = { {IO::MakeEngine, IO::MakeEngine}}, {"null", - {IO::MakeEngine, IO::MakeEngine}}, + {IO::MakeEngine, IO::MakeEngine}}, {"nullcore", {IO::NoEngine("ERROR: nullcore engine does not support read mode"), - IO::MakeEngine}}, + IO::MakeEngine}}, {"plugin", {IO::MakeEngine, IO::MakeEngine}}, diff --git a/source/adios2/engine/null/NullEngine.cpp b/source/adios2/engine/null/NullEngine.cpp deleted file mode 100644 index 80be7dc656..0000000000 --- a/source/adios2/engine/null/NullEngine.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * NullEngine.cpp : Null engine does nothing, used for benchmarking - * - * Created on: Mar 11, 2019 - * Author: William F Godoy godoywf@ornl.gov - */ - -#include "NullEngine.h" - -namespace adios2 -{ -namespace core -{ -namespace engine -{ - -NullEngine::NullEngine(IO &io, const std::string &name, const Mode mode, - helper::Comm comm) -: Engine("NULL", io, name, mode, std::move(comm)) -{ -} - -// PRIVATE -void NullEngine::DoClose(const int /*transportIndex*/) {} - -} // end namespace engine -} // end namespace core -} // end namespace adios2 diff --git a/source/adios2/engine/null/NullEngine.h b/source/adios2/engine/null/NullEngine.h deleted file mode 100644 index 6cd54c7812..0000000000 --- a/source/adios2/engine/null/NullEngine.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Distributed under the OSI-approved Apache License, Version 2.0. See - * accompanying file Copyright.txt for details. - * - * NullEngine.h : Null engine does nothing, used for benchmarking - * - * Created on: Mar 11, 2019 - * Author: William F Godoy godoywf@ornl.gov - */ - -#ifndef ADIOS2_ENGINE_NULL_NULLENGINE_H_ -#define ADIOS2_ENGINE_NULL_NULLENGINE_H_ - -#include "adios2/common/ADIOSConfig.h" -#include "adios2/core/Engine.h" -#include "adios2/helper/adiosComm.h" - -namespace adios2 -{ -namespace core -{ -namespace engine -{ - -class NullEngine : public Engine -{ -public: - NullEngine(IO &adios, const std::string &name, const Mode mode, - helper::Comm comm); - - ~NullEngine() = default; - -private: - void DoClose(const int transportIndex = -1); -}; - -} // end namespace engine -} // end namespace core -} // end namespace adios2 - -#endif /* ADIOS2_ENGINE_NULL_NULLREADER_H_ */ diff --git a/source/adios2/engine/null/NullReader.cpp b/source/adios2/engine/null/NullReader.cpp new file mode 100644 index 0000000000..9d0cec1999 --- /dev/null +++ b/source/adios2/engine/null/NullReader.cpp @@ -0,0 +1,119 @@ +#include "NullReader.h" +#include "NullReader.tcc" + +#include "adios2/helper/adiosLog.h" + +namespace adios2 +{ +namespace core +{ +namespace engine +{ + +struct NullReader::NullReaderImpl +{ + int64_t CurrentStep = -1; + bool IsInStep = false; + bool IsOpen = true; +}; + +NullReader::NullReader(IO &io, const std::string &name, const Mode mode, + helper::Comm comm) +: Engine("NullReader", io, name, mode, std::move(comm)), + Impl(new NullReader::NullReaderImpl) +{ +} + +NullReader::~NullReader() = default; + +StepStatus NullReader::BeginStep(StepMode mode, const float timeoutSeconds) +{ + if (!Impl->IsOpen) + { + helper::Throw( + "Engine", "NullReader", "BeginStep", + "NullReader::BeginStep: Engine already closed"); + } + + if (Impl->IsInStep) + { + helper::Throw( + "Engine", "NullReader", "BeginStep", + "NullReader::BeginStep: Step already active"); + } + + Impl->IsInStep = true; + ++Impl->CurrentStep; + return StepStatus::EndOfStream; +} + +size_t NullReader::CurrentStep() const +{ + if (!Impl->IsOpen) + { + helper::Throw( + "Engine", "NullReader", "CurrentStep", + "NullReader::CurrentStep: Engine already closed"); + } + + return static_cast(Impl->CurrentStep); +} + +void NullReader::EndStep() +{ + if (!Impl->IsOpen) + { + helper::Throw( + "Engine", "NullReader", "EndStep", + "NullReader::EndStep: Engine already closed"); + } + + if (!Impl->IsInStep) + { + helper::Throw( + "Engine", "NullReader", "EndStep", + "NullReader::EndStep: No active step"); + } + + Impl->IsInStep = false; +} + +void NullReader::PerformGets() +{ + if (!Impl->IsOpen) + { + helper::Throw( + "Engine", "NullReader", "PerformGets", + "NullReader::PerformPuts: Engine already closed"); + } + + return; +} + +void NullReader::DoClose(const int) +{ + if (!Impl->IsOpen) + { + helper::Throw("Engine", "NullReader", "DoClose", + "already closed"); + } + + Impl->IsOpen = false; +} + +#define declare_type(T) \ + void NullReader::DoGetSync(Variable &variable, T *data) \ + { \ + GetSyncCommon(variable, data); \ + } \ + void NullReader::DoGetDeferred(Variable &variable, T *data) \ + { \ + GetDeferredCommon(variable, data); \ + } + +ADIOS2_FOREACH_STDTYPE_1ARG(declare_type) +#undef declare_type + +} // end namespace engine +} // end namespace core +} // end namespace adios2 diff --git a/source/adios2/engine/null/NullReader.h b/source/adios2/engine/null/NullReader.h new file mode 100644 index 0000000000..25b82566d8 --- /dev/null +++ b/source/adios2/engine/null/NullReader.h @@ -0,0 +1,66 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * NullReader.h + * + * Created on: 23 March 2022 + * Author: Norbert Podhorszki pnorbert@ornl.gov + */ + +#ifndef ADIOS2_ENGINE_NULL2_NULLREADER_H_ +#define ADIOS2_ENGINE_NULL2_NULLREADER_H_ + +#include + +#include "adios2/common/ADIOSConfig.h" +#include "adios2/core/Engine.h" +#include "adios2/helper/adiosComm.h" + +namespace adios2 +{ +namespace core +{ +namespace engine +{ + +class NullReader : public core::Engine +{ + +public: + NullReader(IO &io, const std::string &name, const Mode mode, + helper::Comm comm); + + virtual ~NullReader(); + + StepStatus BeginStep(StepMode mode, + const float timeoutSeconds = -1.0) override; + size_t CurrentStep() const override; + void EndStep() override; + void PerformGets() override; + +protected: +#define declare_type(T) \ + void DoGetSync(Variable &, T *) override; \ + void DoGetDeferred(Variable &, T *) override; + ADIOS2_FOREACH_STDTYPE_1ARG(declare_type) +#undef declare_type + + void DoClose(const int transportIndex) override; + + template + void GetSyncCommon(Variable &variable, T *data); + + template + void GetDeferredCommon(Variable &variable, T *data); + +private: + struct NullReaderImpl; + std::unique_ptr Impl; +}; + +} // end namespace engine +} // end namespace core +} // end namespace adios2 + +#endif /* ADIOS2_ENGINE_NULL2_NULLREADER_H_ */ diff --git a/source/adios2/engine/null/NullReader.tcc b/source/adios2/engine/null/NullReader.tcc new file mode 100644 index 0000000000..e1399e73a6 --- /dev/null +++ b/source/adios2/engine/null/NullReader.tcc @@ -0,0 +1,43 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * NullReader.tcc + * + */ +#ifndef ADIOS2_ENGINE_NULLREADER_TCC_ +#define ADIOS2_ENGINE_NULLREADER_TCC_ + +#include "NullReader.h" + +namespace adios2 +{ +namespace core +{ +namespace engine +{ + +template <> +inline void NullReader::GetSyncCommon(Variable &variable, + std::string *data) +{ + variable.m_Data = data; +} + +template +inline void NullReader::GetSyncCommon(Variable &variable, T *data) +{ + variable.m_Data = data; +} + +template +void NullReader::GetDeferredCommon(Variable &variable, T *data) +{ + variable.m_Data = data; +} + +} // end namespace engine +} // end namespace core +} // end namespace adios2 + +#endif /* ADIOS2_ENGINE_NULLREADER_TCC_ */ diff --git a/source/adios2/engine/null/NullWriter.cpp b/source/adios2/engine/null/NullWriter.cpp new file mode 100644 index 0000000000..649cd4628e --- /dev/null +++ b/source/adios2/engine/null/NullWriter.cpp @@ -0,0 +1,118 @@ +#include "NullWriter.h" +#include "NullWriter.tcc" + +#include "adios2/helper/adiosLog.h" + +namespace adios2 +{ +namespace core +{ +namespace engine +{ + +struct NullWriter::NullWriterImpl +{ + size_t CurrentStep = 0; + bool IsInStep = false; + bool IsOpen = true; +}; + +NullWriter::NullWriter(IO &io, const std::string &name, const Mode mode, + helper::Comm comm) +: Engine("NullWriter", io, name, mode, std::move(comm)), + Impl(new NullWriter::NullWriterImpl) +{ +} + +NullWriter::~NullWriter() = default; + +StepStatus NullWriter::BeginStep(StepMode mode, const float timeoutSeconds) +{ + if (!Impl->IsOpen) + { + helper::Throw( + "Engine", "NullWriter", "BeginStep", + "NullWriter::BeginStep: Engine already closed"); + } + + if (Impl->IsInStep) + { + helper::Throw( + "Engine", "NullWriter", "BeginStep", + "NullWriter::BeginStep: Step already active"); + } + + Impl->IsInStep = true; + ++Impl->CurrentStep; + return StepStatus::OK; +} + +size_t NullWriter::CurrentStep() const +{ + if (!Impl->IsOpen) + { + helper::Throw( + "Engine", "NullWriter", "CurrentStep", + "NullWriter::CurrentStep: Engine already closed"); + } + + return Impl->CurrentStep; +} + +void NullWriter::EndStep() +{ + if (!Impl->IsOpen) + { + helper::Throw( + "Engine", "NullWriter", "EndStep", + "NullWriter::EndStep: Engine already closed"); + } + + if (!Impl->IsInStep) + { + helper::Throw( + "Engine", "NullWriter", "EndStep", + "NullWriter::EndStep: No active step"); + } + + Impl->IsInStep = false; +} + +void NullWriter::PerformPuts() +{ + if (!Impl->IsOpen) + { + helper::Throw( + "Engine", "NullWriter", "PerformPuts", + "NullWriter::PerformPuts: Engine already closed"); + } + + return; +} + +void NullWriter::Flush(const int) +{ + if (!Impl->IsOpen) + { + helper::Throw( + "Engine", "NullWriter", "Flush", + "NullWriter::Flush: Engine already closed"); + } + + return; +} + +void NullWriter::DoClose(const int) +{ + if (!Impl->IsOpen) + { + helper::Throw("Engine", "NullWriter", "DoClose", + "already closed"); + } + + Impl->IsOpen = false; +} + +} // end namespace engine +} // end namespace core +} // end namespace adios2 diff --git a/source/adios2/engine/nullcore/NullCoreWriter.h b/source/adios2/engine/null/NullWriter.h similarity index 77% rename from source/adios2/engine/nullcore/NullCoreWriter.h rename to source/adios2/engine/null/NullWriter.h index 2b08889099..7ff1d1e163 100644 --- a/source/adios2/engine/nullcore/NullCoreWriter.h +++ b/source/adios2/engine/null/NullWriter.h @@ -2,14 +2,14 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * NullCoreWriter.h + * NullWriter.h * * Created on: 16 Apr 19 * Author: Chuck Atkins chuck.atkins@kitware.com */ -#ifndef ADIOS2_ENGINE_NULL2_NULLCOREWRITER_H_ -#define ADIOS2_ENGINE_NULL2_NULLCOREWRITER_H_ +#ifndef ADIOS2_ENGINE_NULL2_NULLWRITER_H_ +#define ADIOS2_ENGINE_NULL2_NULLWRITER_H_ #include @@ -24,14 +24,14 @@ namespace core namespace engine { -class NullCoreWriter : public core::Engine +class NullWriter : public core::Engine { public: - NullCoreWriter(IO &io, const std::string &name, const Mode mode, - helper::Comm comm); + NullWriter(IO &io, const std::string &name, const Mode mode, + helper::Comm comm); - virtual ~NullCoreWriter(); + virtual ~NullWriter(); StepStatus BeginStep(StepMode mode, const float timeoutSeconds = -1.0) override; @@ -58,12 +58,12 @@ class NullCoreWriter : public core::Engine void DoClose(const int transportIndex) override; private: - struct NullCoreWriterImpl; - std::unique_ptr Impl; + struct NullWriterImpl; + std::unique_ptr Impl; }; } // end namespace engine } // end namespace core } // end namespace adios2 -#endif /* ADIOS2_ENGINE_NULL2_NULLCOREWRITER_H_ */ +#endif /* ADIOS2_ENGINE_NULL2_NULLWRITER_H_ */ diff --git a/source/adios2/engine/nullcore/NullCoreWriter.tcc b/source/adios2/engine/null/NullWriter.tcc similarity index 60% rename from source/adios2/engine/nullcore/NullCoreWriter.tcc rename to source/adios2/engine/null/NullWriter.tcc index 081a0872a0..d0023248ca 100644 --- a/source/adios2/engine/nullcore/NullCoreWriter.tcc +++ b/source/adios2/engine/null/NullWriter.tcc @@ -2,15 +2,15 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * NullCoreWriter.tcc + * NullWriter.tcc * * Created on: 16 Apr 19 * Author: Chuck Atkins chuck.atkins@kitware.com */ -#ifndef ADIOS2_ENGINE_NULLCOREWRITER_TCC_ -#define ADIOS2_ENGINE_NULLCOREWRITER_TCC_ +#ifndef ADIOS2_ENGINE_NULLWRITER_TCC_ +#define ADIOS2_ENGINE_NULLWRITER_TCC_ -#include "NullCoreWriter.h" +#include "NullWriter.h" namespace adios2 { @@ -20,9 +20,9 @@ namespace engine { #define instantiate_type(T) \ - void NullCoreWriter::DoPut(Variable &variable, \ - typename Variable::Span &span, \ - const bool initialize, const T &value) \ + void NullWriter::DoPut(Variable &variable, \ + typename Variable::Span &span, \ + const bool initialize, const T &value) \ { \ } @@ -30,8 +30,8 @@ ADIOS2_FOREACH_PRIMITIVE_STDTYPE_1ARG(instantiate_type) #undef instantiate_type #define instantiate_type(T) \ - void NullCoreWriter::DoPutSync(Variable &, const T *) {} \ - void NullCoreWriter::DoPutDeferred(Variable &, const T *) {} + void NullWriter::DoPutSync(Variable &, const T *) {} \ + void NullWriter::DoPutDeferred(Variable &, const T *) {} ADIOS2_FOREACH_STDTYPE_1ARG(instantiate_type) #undef instantiate_type @@ -40,4 +40,4 @@ ADIOS2_FOREACH_STDTYPE_1ARG(instantiate_type) } // end namespace core } // end namespace adios2 -#endif /* ADIOS2_ENGINE_NULL2_NULLCOREWRITER_TCC_ */ +#endif /* ADIOS2_ENGINE_NULL2_NULLWRITER_TCC_ */ diff --git a/source/adios2/engine/nullcore/NullCoreWriter.cpp b/source/adios2/engine/nullcore/NullCoreWriter.cpp deleted file mode 100644 index eb9953d80c..0000000000 --- a/source/adios2/engine/nullcore/NullCoreWriter.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#include "NullCoreWriter.h" -#include "NullCoreWriter.tcc" - -#include "adios2/helper/adiosLog.h" - -namespace adios2 -{ -namespace core -{ -namespace engine -{ - -struct NullCoreWriter::NullCoreWriterImpl -{ - size_t CurrentStep = 0; - bool IsInStep = false; - bool IsOpen = true; -}; - -NullCoreWriter::NullCoreWriter(IO &io, const std::string &name, const Mode mode, - helper::Comm comm) -: Engine("NullCoreWriter", io, name, mode, std::move(comm)), - Impl(new NullCoreWriter::NullCoreWriterImpl) -{ -} - -NullCoreWriter::~NullCoreWriter() = default; - -StepStatus NullCoreWriter::BeginStep(StepMode mode, const float timeoutSeconds) -{ - if (!Impl->IsOpen) - { - helper::Throw( - "Engine", "NullCoreWriter", "BeginStep", - "NullCoreWriter::BeginStep: Engine already closed"); - } - - if (Impl->IsInStep) - { - helper::Throw( - "Engine", "NullCoreWriter", "BeginStep", - "NullCoreWriter::BeginStep: Step already active"); - } - - Impl->IsInStep = true; - ++Impl->CurrentStep; - return StepStatus::OK; -} - -size_t NullCoreWriter::CurrentStep() const -{ - if (!Impl->IsOpen) - { - helper::Throw( - "Engine", "NullCoreWriter", "CurrentStep", - "NullCoreWriter::CurrentStep: Engine already closed"); - } - - return Impl->CurrentStep; -} - -void NullCoreWriter::EndStep() -{ - if (!Impl->IsOpen) - { - helper::Throw( - "Engine", "NullCoreWriter", "EndStep", - "NullCoreWriter::EndStep: Engine already closed"); - } - - if (!Impl->IsInStep) - { - helper::Throw( - "Engine", "NullCoreWriter", "EndStep", - "NullCoreWriter::EndStep: No active step"); - } - - Impl->IsInStep = false; -} - -void NullCoreWriter::PerformPuts() -{ - if (!Impl->IsOpen) - { - helper::Throw( - "Engine", "NullCoreWriter", "PerformPuts", - "NullCoreWriter::PerformPuts: Engine already closed"); - } - - return; -} - -void NullCoreWriter::Flush(const int) -{ - if (!Impl->IsOpen) - { - helper::Throw( - "Engine", "NullCoreWriter", "Flush", - "NullCoreWriter::Flush: Engine already closed"); - } - - return; -} - -void NullCoreWriter::DoClose(const int) -{ - if (!Impl->IsOpen) - { - helper::Throw("Engine", "NullCoreWriter", "DoClose", - "already closed"); - } - - Impl->IsOpen = false; -} - -} // end namespace engine -} // end namespace core -} // end namespace adios2 diff --git a/testing/adios2/bindings/C/TestNullWriteRead.cpp b/testing/adios2/bindings/C/TestNullWriteRead.cpp index 702bc98fa9..48f2773909 100644 --- a/testing/adios2/bindings/C/TestNullWriteRead.cpp +++ b/testing/adios2/bindings/C/TestNullWriteRead.cpp @@ -53,6 +53,7 @@ TEST_F(NullWriteReadTests_C_API, NullWriteRead1D8) const std::vector shape{static_cast(Nx * mpiSize)}; const std::vector start{static_cast(Nx * mpiRank)}; const std::vector count{Nx}; + std::vector data(Nx, 1.0); adios2_variable *var = adios2_define_variable( io, "r64", adios2_type_double, 1, shape.data(), start.data(), @@ -68,7 +69,7 @@ TEST_F(NullWriteReadTests_C_API, NullWriteRead1D8) { adios2_begin_step(nullWriter, adios2_step_mode_append, -1., &status); - adios2_put(nullWriter, var, nullptr, adios2_mode_deferred); + adios2_put(nullWriter, var, data.data(), adios2_mode_deferred); adios2_perform_puts(nullWriter); adios2_end_step(nullWriter); } @@ -98,9 +99,11 @@ TEST_F(NullWriteReadTests_C_API, NullWriteRead1D8) EXPECT_EQ(var, nullptr); adios2_current_step(¤tStep, nullReader); - EXPECT_EQ(currentStep, std::numeric_limits::max()); + EXPECT_EQ(currentStep, t); - adios2_get(nullReader, var, nullptr, adios2_mode_deferred); + auto ret = + adios2_get(nullReader, var, nullptr, adios2_mode_deferred); + EXPECT_EQ(ret, 1); adios2_perform_gets(nullReader); adios2_end_step(nullReader); } diff --git a/testing/adios2/bindings/python/TestNullEngine.py b/testing/adios2/bindings/python/TestNullEngine.py index d6afb93000..c4281e9812 100644 --- a/testing/adios2/bindings/python/TestNullEngine.py +++ b/testing/adios2/bindings/python/TestNullEngine.py @@ -26,7 +26,7 @@ start = [rank * Nx, 0] shape = [size * Nx, Ny] -temperatures = np.zeros(count, dtype=np.int) +temperatures = np.zeros(count, dtype=np.int32) for i in range(0, Nx): for j in range(0, Ny): @@ -42,10 +42,10 @@ nullWriter = ioWrite.Open('NULL_py.bp', adios2.Mode.Write) -assert(nullWriter.Type() == "NULL") +assert(nullWriter.Type() == "NullWriter") status = nullWriter.BeginStep() -assert(status == adios2.StepStatus.EndOfStream) +assert(status == adios2.StepStatus.OK) nullWriter.Put(varTemperature, temperatures) nullWriter.PerformPuts() @@ -58,9 +58,9 @@ ioRead.SetEngine("null") nullReader = ioRead.Open('NULL_py.bp', adios2.Mode.Read, MPI.COMM_SELF) -assert(nullReader.Type() == "NULL") +assert(nullReader.Type() == "NullReader") -inTemperatures = np.zeros(1, dtype=np.int) +inTemperatures = np.zeros(1, dtype=np.int32) status = nullReader.BeginStep() assert(status == adios2.StepStatus.EndOfStream) @@ -70,7 +70,8 @@ if(var_inTemperature is True): raise ValueError('var_inTemperature is not False') -nullReader.Get(var_inTemperature, inTemperatures) +# nullReader.Get(var_inTemperature, inTemperatures) + nullReader.PerformGets() nullReader.EndStep() nullReader.Close() diff --git a/testing/adios2/engine/null/TestNullWriteRead.cpp b/testing/adios2/engine/null/TestNullWriteRead.cpp index 45ab8d7e80..424f265b0a 100644 --- a/testing/adios2/engine/null/TestNullWriteRead.cpp +++ b/testing/adios2/engine/null/TestNullWriteRead.cpp @@ -148,17 +148,6 @@ TEST_F(NullWriteReadTests, NullWriteRead1D8) std::string IString; std::vector I8; - std::vector I16; - std::vector I32; - std::vector I64; - std::vector U8; - std::vector U16; - std::vector U32; - std::vector U64; - std::vector R32; - std::vector R64; - - EXPECT_EQ(I8.empty(), true); for (size_t t = 0; t < NSteps; ++t) { @@ -166,73 +155,25 @@ TEST_F(NullWriteReadTests, NullWriteRead1D8) EXPECT_EQ(status, adios2::StepStatus::EndOfStream); const size_t currentStep = nullReader.CurrentStep(); - EXPECT_EQ(currentStep, adios2::MaxSizeT); + EXPECT_EQ(currentStep, t); + + auto vars = io.AvailableVariables(); + EXPECT_TRUE(vars.empty()); auto var_iString = io.InquireVariable("iString"); EXPECT_FALSE(var_iString); auto var_i8 = io.InquireVariable("i8"); - auto var_i8_info = nullReader.BlocksInfo(var_i8, currentStep); EXPECT_FALSE(var_i8); - EXPECT_EQ(var_i8_info.empty(), true); - - auto var_i16 = io.InquireVariable("i16"); - auto var_i16_info = nullReader.BlocksInfo(var_i8, currentStep); - EXPECT_FALSE(var_i16); - EXPECT_EQ(var_i16_info.empty(), true); - - auto var_i32 = io.InquireVariable("i32"); - EXPECT_FALSE(var_i32); - - auto var_i64 = io.InquireVariable("i64"); - EXPECT_FALSE(var_i64); - - auto var_u8 = io.InquireVariable("u8"); - EXPECT_FALSE(var_u8); - - auto var_u16 = io.InquireVariable("u16"); - EXPECT_FALSE(var_u16); - auto var_u32 = io.InquireVariable("u32"); - EXPECT_FALSE(var_u32); - - auto var_u64 = io.InquireVariable("u64"); - EXPECT_FALSE(var_u64); + EXPECT_THROW(nullReader.Get(var_iString, IString), + std::invalid_argument); - auto var_r32 = io.InquireVariable("r32"); - EXPECT_FALSE(var_r32); - - auto var_r64 = io.InquireVariable("r64"); - EXPECT_FALSE(var_r64); - - nullReader.Get(var_iString, IString); - - nullReader.Get(var_i8, I8.data()); - nullReader.Get(var_i16, I16.data()); - nullReader.Get(var_i32, I32.data()); - nullReader.Get(var_i64, I64.data()); - - nullReader.Get(var_u8, U8.data()); - nullReader.Get(var_u16, U16.data()); - nullReader.Get(var_u32, U32.data()); - nullReader.Get(var_u64, U64.data()); - - nullReader.Get(var_r32, R32.data()); - nullReader.Get(var_r64, R64.data()); + EXPECT_THROW(nullReader.Get(var_i8, I8.data()), + std::invalid_argument); nullReader.PerformGets(); nullReader.EndStep(); - - EXPECT_TRUE(I8.empty()); - EXPECT_TRUE(I16.empty()); - EXPECT_TRUE(I32.empty()); - EXPECT_TRUE(I64.empty()); - EXPECT_TRUE(U8.empty()); - EXPECT_TRUE(U16.empty()); - EXPECT_TRUE(U32.empty()); - EXPECT_TRUE(U64.empty()); - EXPECT_TRUE(R32.empty()); - EXPECT_TRUE(R64.empty()); } nullReader.Close(); } diff --git a/testing/adios2/engine/nullcore/TestNullCoreWrite.cpp b/testing/adios2/engine/nullcore/TestNullCoreWrite.cpp index bd4b835660..389d94ebe6 100644 --- a/testing/adios2/engine/nullcore/TestNullCoreWrite.cpp +++ b/testing/adios2/engine/nullcore/TestNullCoreWrite.cpp @@ -153,258 +153,6 @@ TEST_F(NullCoreWriteTest, ADIOS2NullCoreWrite1D8) } } -// ADIOS2 BP write, native ADIOS1 read -TEST_F(NullCoreWriteTest, ADIOS2NullCoreWrite2D2x4) -{ - int mpiRank = 0, mpiSize = 1; - // Number of rows - const std::size_t Nx = 4; - - // Number of rows - const std::size_t Ny = 2; - - // Number of steps - const std::size_t NSteps = 3; - -#if ADIOS2_USE_MPI - MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank); - MPI_Comm_size(MPI_COMM_WORLD, &mpiSize); -#endif - - // Write test data using ADIOS2 - { -#if ADIOS2_USE_MPI - adios2::ADIOS adios(MPI_COMM_WORLD); -#else - adios2::ADIOS adios; -#endif - adios2::IO io = adios.DeclareIO("TestIO"); - - // Declare 2D variables (Ny * (NumOfProcesses * Nx)) - // The local process' part (start, count) can be defined now or later - // before Write(). - { - adios2::Dims shape{static_cast(Ny), - static_cast(Nx * mpiSize)}; - adios2::Dims start{static_cast(0), - static_cast(mpiRank * Nx)}; - adios2::Dims count{static_cast(Ny), - static_cast(Nx)}; - auto var_i8 = io.DefineVariable("i8", shape, start, count); - EXPECT_TRUE(var_i8); - auto var_i16 = - io.DefineVariable("i16", shape, start, count); - EXPECT_TRUE(var_i16); - auto var_i32 = - io.DefineVariable("i32", shape, start, count); - EXPECT_TRUE(var_i32); - auto var_i64 = - io.DefineVariable("i64", shape, start, count); - EXPECT_TRUE(var_i64); - auto var_u8 = io.DefineVariable("u8", shape, start, count); - EXPECT_TRUE(var_u8); - auto var_u16 = - io.DefineVariable("u16", shape, start, count); - EXPECT_TRUE(var_u16); - auto var_u32 = - io.DefineVariable("u32", shape, start, count); - EXPECT_TRUE(var_u32); - auto var_u64 = - io.DefineVariable("u64", shape, start, count); - EXPECT_TRUE(var_u64); - auto var_r32 = io.DefineVariable("r32", shape, start, count); - EXPECT_TRUE(var_r32); - auto var_r64 = - io.DefineVariable("r64", shape, start, count); - EXPECT_TRUE(var_r64); - } - - io.SetEngine("NullCore"); - - adios2::Engine engine = io.Open("foo", adios2::Mode::Write); - - for (size_t step = 0; step < NSteps; ++step) - { - // Generate test data for each process uniquely - SmallTestData currentTestData = generateNewSmallTestData( - m_TestData, static_cast(step), mpiRank, mpiSize); - - // Retrieve the variables that previously went out of scope - auto var_i8 = io.InquireVariable("i8"); - auto var_i16 = io.InquireVariable("i16"); - auto var_i32 = io.InquireVariable("i32"); - auto var_i64 = io.InquireVariable("i64"); - auto var_u8 = io.InquireVariable("u8"); - auto var_u16 = io.InquireVariable("u16"); - auto var_u32 = io.InquireVariable("u32"); - auto var_u64 = io.InquireVariable("u64"); - auto var_r32 = io.InquireVariable("r32"); - auto var_r64 = io.InquireVariable("r64"); - - // Make a 2D selection to describe the local dimensions of the - // variable we write and its offsets in the global spaces - adios2::Box sel( - {0, static_cast(mpiRank * Nx)}, {Ny, Nx}); - var_i8.SetSelection(sel); - var_i16.SetSelection(sel); - var_i32.SetSelection(sel); - var_i64.SetSelection(sel); - var_u8.SetSelection(sel); - var_u16.SetSelection(sel); - var_u32.SetSelection(sel); - var_u64.SetSelection(sel); - var_r32.SetSelection(sel); - var_r64.SetSelection(sel); - - // Write each one - // fill in the variable with values from starting index to - // starting index + count - engine.BeginStep(); - engine.Put(var_i8, currentTestData.I8.data()); - engine.Put(var_i16, currentTestData.I16.data()); - engine.Put(var_i32, currentTestData.I32.data()); - engine.Put(var_i64, currentTestData.I64.data()); - engine.Put(var_u8, currentTestData.U8.data()); - engine.Put(var_u16, currentTestData.U16.data()); - engine.Put(var_u32, currentTestData.U32.data()); - engine.Put(var_u64, currentTestData.U64.data()); - engine.Put(var_r32, currentTestData.R32.data()); - engine.Put(var_r64, currentTestData.R64.data()); - engine.EndStep(); - } - - // Close the file - engine.Close(); - } -} - -// ADIOS2 write, native ADIOS1 read -TEST_F(NullCoreWriteTest, ADIOS2NullCoreWrite2D4x2) -{ - // Each process would write a 4x2 array and all processes would - // form a 2D 4 * (NumberOfProcess * Nx) matrix where Nx is 2 here - std::string fname = "ADIOS2NullCoreWrite2D4x2Test.bp"; - - int mpiRank = 0, mpiSize = 1; - // Number of rows - const std::size_t Nx = 2; - // Number of cols - const std::size_t Ny = 4; - - // Number of steps - const std::size_t NSteps = 3; - -#if ADIOS2_USE_MPI - MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank); - MPI_Comm_size(MPI_COMM_WORLD, &mpiSize); -#endif - - // Write test data using ADIOS2 - { -#if ADIOS2_USE_MPI - adios2::ADIOS adios(MPI_COMM_WORLD); -#else - adios2::ADIOS adios; -#endif - adios2::IO io = adios.DeclareIO("TestIO"); - - // Declare 2D variables (4 * (NumberOfProcess * Nx)) - // The local process' part (start, count) can be defined now or later - // before Write(). - { - adios2::Dims shape{static_cast(Ny), - static_cast(mpiSize * Nx)}; - adios2::Dims start{static_cast(0), - static_cast(mpiRank * Nx)}; - adios2::Dims count{static_cast(Ny), - static_cast(Nx)}; - auto var_i8 = io.DefineVariable("i8", shape, start, count); - EXPECT_TRUE(var_i8); - auto var_i16 = - io.DefineVariable("i16", shape, start, count); - EXPECT_TRUE(var_i16); - auto var_i32 = - io.DefineVariable("i32", shape, start, count); - EXPECT_TRUE(var_i32); - auto var_i64 = - io.DefineVariable("i64", shape, start, count); - EXPECT_TRUE(var_i64); - auto var_u8 = io.DefineVariable("u8", shape, start, count); - EXPECT_TRUE(var_u8); - auto var_u16 = - io.DefineVariable("u16", shape, start, count); - EXPECT_TRUE(var_u16); - auto var_u32 = - io.DefineVariable("u32", shape, start, count); - EXPECT_TRUE(var_u32); - auto var_u64 = - io.DefineVariable("u64", shape, start, count); - EXPECT_TRUE(var_u64); - auto var_r32 = io.DefineVariable("r32", shape, start, count); - EXPECT_TRUE(var_r32); - auto var_r64 = - io.DefineVariable("r64", shape, start, count); - EXPECT_TRUE(var_r64); - } - - io.SetEngine("NullCore"); - adios2::Engine engine = io.Open(fname, adios2::Mode::Write); - - for (size_t step = 0; step < NSteps; ++step) - { - // Generate test data for each process uniquely - SmallTestData currentTestData = generateNewSmallTestData( - m_TestData, static_cast(step), mpiRank, mpiSize); - - // Retrieve the variables that previously went out of scope - auto var_i8 = io.InquireVariable("i8"); - auto var_i16 = io.InquireVariable("i16"); - auto var_i32 = io.InquireVariable("i32"); - auto var_i64 = io.InquireVariable("i64"); - auto var_u8 = io.InquireVariable("u8"); - auto var_u16 = io.InquireVariable("u16"); - auto var_u32 = io.InquireVariable("u32"); - auto var_u64 = io.InquireVariable("u64"); - auto var_r32 = io.InquireVariable("r32"); - auto var_r64 = io.InquireVariable("r64"); - - // Make a 2D selection to describe the local dimensions of the - // variable we write and its offsets in the global spaces - adios2::Box sel( - {0, static_cast(mpiRank * Nx)}, {Ny, Nx}); - var_i8.SetSelection(sel); - var_i16.SetSelection(sel); - var_i32.SetSelection(sel); - var_i64.SetSelection(sel); - var_u8.SetSelection(sel); - var_u16.SetSelection(sel); - var_u32.SetSelection(sel); - var_u64.SetSelection(sel); - var_r32.SetSelection(sel); - var_r64.SetSelection(sel); - - // Write each one - // fill in the variable with values from starting index to - // starting index + count - engine.BeginStep(); - engine.Put(var_i8, currentTestData.I8.data()); - engine.Put(var_i16, currentTestData.I16.data()); - engine.Put(var_i32, currentTestData.I32.data()); - engine.Put(var_i64, currentTestData.I64.data()); - engine.Put(var_u8, currentTestData.U8.data()); - engine.Put(var_u16, currentTestData.U16.data()); - engine.Put(var_u32, currentTestData.U32.data()); - engine.Put(var_u64, currentTestData.U64.data()); - engine.Put(var_r32, currentTestData.R32.data()); - engine.Put(var_r64, currentTestData.R64.data()); - engine.EndStep(); - } - - // Close the file - engine.Close(); - } -} - //****************************************************************************** // main //******************************************************************************