Unverified Commit 2bedf5c9 authored by pnorbert's avatar pnorbert Committed by GitHub
Browse files

Merge pull request #3126 from pnorbert/nullengine

Removed the virtual NULL engine from the C++/C/Python API... 
parents 57d328b4 624750dd
Loading
Loading
Loading
Loading
+0 −72
Original line number Diff line number Diff line
@@ -197,12 +197,6 @@ adios2_error adios2_begin_step(adios2_engine *engine,
        adios2::core::Engine *engineCpp =
            reinterpret_cast<adios2::core::Engine *>(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<const adios2::core::Engine *>(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<const adios2::core::Engine *>(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<adios2::core::Engine *>(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<adios2::core::Engine *>(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<adios2::core::Engine *>(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<adios2::core::Engine *>(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<adios2::core::Engine *>(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<adios2::core::Engine *>(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<adios2::core::Engine *>(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<adios2::core::Engine *>(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<adios2::core::Engine *>(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<adios2::core::Engine *>(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<adios2::core::Engine *>(engine);

        if (engineCpp->m_EngineType == "NULL")
        {
            return adios2_error_none;
        }

        engineCpp->Close(transport_index);

        // erase Engine object from IO
+0 −52
Original line number Diff line number Diff line
@@ -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();
}

+0 −71
Original line number Diff line number Diff line
@@ -69,11 +69,6 @@ typename Variable<T>::Span Engine::Put(Variable<T> variable,
    adios2::helper::CheckForNullptr(m_Engine,
                                    "for Engine in call to Engine::Array");

    if (m_Engine->m_EngineType == "NULL")
    {
        return typename Variable<T>::Span(nullptr);
    }

    adios2::helper::CheckForNullptr(variable.m_Variable,
                                    "for variable in call to Engine::Array");

@@ -91,11 +86,6 @@ typename Variable<T>::Span Engine::Put(Variable<T> variable)
    adios2::helper::CheckForNullptr(m_Engine,
                                    "for Engine in call to Engine::Array");

    if (m_Engine->m_EngineType == "NULL")
    {
        return typename Variable<T>::Span(nullptr);
    }

    adios2::helper::CheckForNullptr(variable.m_Variable,
                                    "for variable in call to Engine::Array");

@@ -111,10 +101,6 @@ void Engine::Put(Variable<T> variable, const T *data, const Mode launch)
{
    using IOType = typename TypeInfo<T>::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<const IOType *>(data),
@@ -127,10 +113,6 @@ void Engine::Put(const std::string &variableName, const T *data,
{
    using IOType = typename TypeInfo<T>::IOType;
    adios2::helper::CheckForNullptr(m_Engine, "in call to Engine::Put");
    if (m_Engine->m_EngineType == "NULL")
    {
        return;
    }
    m_Engine->Put(variableName, reinterpret_cast<const IOType *>(data), launch);
}

@@ -139,10 +121,6 @@ void Engine::Put(Variable<T> variable, const T &datum, const Mode launch)
{
    using IOType = typename TypeInfo<T>::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<const IOType &>(datum),
@@ -155,10 +133,6 @@ void Engine::Put(const std::string &variableName, const T &datum,
{
    using IOType = typename TypeInfo<T>::IOType;
    adios2::helper::CheckForNullptr(m_Engine, "in call to Engine::Put");
    if (m_Engine->m_EngineType == "NULL")
    {
        return;
    }
    m_Engine->Put(variableName, reinterpret_cast<const IOType &>(datum),
                  launch);
}
@@ -168,10 +142,6 @@ void Engine::Get(Variable<T> variable, T *data, const Mode launch)
{
    using IOType = typename TypeInfo<T>::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<IOType *>(data),
@@ -183,10 +153,6 @@ void Engine::Get(const std::string &variableName, T *data, const Mode launch)
{
    using IOType = typename TypeInfo<T>::IOType;
    adios2::helper::CheckForNullptr(m_Engine, "in call to Engine::Get");
    if (m_Engine->m_EngineType == "NULL")
    {
        return;
    }
    m_Engine->Get(variableName, reinterpret_cast<IOType *>(data), launch);
}

@@ -195,10 +161,6 @@ void Engine::Get(Variable<T> variable, T &datum, const Mode /*launch*/)
{
    using IOType = typename TypeInfo<T>::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<IOType &>(datum));
@@ -210,10 +172,6 @@ void Engine::Get(const std::string &variableName, T &datum,
{
    using IOType = typename TypeInfo<T>::IOType;
    adios2::helper::CheckForNullptr(m_Engine, "in call to Engine::Get");
    if (m_Engine->m_EngineType == "NULL")
    {
        return;
    }
    m_Engine->Get(variableName, reinterpret_cast<IOType &>(datum));
}

@@ -223,10 +181,6 @@ void Engine::Get(Variable<T> variable, std::vector<T> &dataV, const Mode launch)
    using IOType = typename TypeInfo<T>::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<T> &dataV,
    using IOType = typename TypeInfo<T>::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<std::vector<IOType> &>(dataV),
                  launch);
}
@@ -253,10 +203,6 @@ void Engine::Get(Variable<T> variable, typename Variable<T>::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<typename Variable<T>::Info::CoreInfo *>(
@@ -269,10 +215,6 @@ void Engine::Get(const std::string &variableName,
{
    using IOType = typename TypeInfo<T>::IOType;
    adios2::helper::CheckForNullptr(m_Engine, "in call to Engine::Get");
    if (m_Engine->m_EngineType == "NULL")
    {
        return;
    }
    info.m_Info = reinterpret_cast<typename Variable<T>::Info::CoreInfo *>(
        m_Engine->Get<IOType>(variableName, launch));
}
@@ -299,10 +241,6 @@ Engine::AllStepsBlocksInfo(const Variable<T> variable) const
    using IOType = typename TypeInfo<T>::IOType;
    adios2::helper::CheckForNullptr(
        m_Engine, "for Engine in call to Engine::AllStepsBlocksInfo");
    if (m_Engine->m_EngineType == "NULL")
    {
        return std::map<size_t, std::vector<typename Variable<T>::Info>>();
    }

    adios2::helper::CheckForNullptr(
        variable.m_Variable,
@@ -348,10 +286,6 @@ Engine::BlocksInfo(const Variable<T> variable, const size_t step) const
    using IOType = typename TypeInfo<T>::IOType;
    adios2::helper::CheckForNullptr(m_Engine,
                                    "for Engine in call to Engine::BlocksInfo");
    if (m_Engine->m_EngineType == "NULL")
    {
        return std::vector<typename Variable<T>::Info>();
    }

    adios2::helper::CheckForNullptr(
        variable.m_Variable, "for variable in call to Engine::BlocksInfo");
@@ -378,11 +312,6 @@ std::vector<size_t> Engine::GetAbsoluteSteps(const Variable<T> variable) const
    using IOType = typename TypeInfo<T>::IOType;
    adios2::helper::CheckForNullptr(
        m_Engine, "for Engine in call to Engine::GetAbsoluteSteps");
    if (m_Engine->m_EngineType == "NULL")
    {
        return std::vector<size_t>();
    }

    adios2::helper::CheckForNullptr(
        variable.m_Variable,
        "for variable in call to Engine::GetAbsoluteSteps");
+0 −56
Original line number Diff line number Diff line
@@ -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();
}

+39 −2
Original line number Diff line number Diff line
@@ -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

    <adios-config>
        <io name="Output">
            <engine type="Null">
            </engine>
        </io>
    </adios-config>

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

    <adios-config>
        <io name="Output">
            <engine type="BP5">
            </engine>
            <transport type="Null">
            </transport>
        </io>
    </adios-config>
 No newline at end of file
Loading