Commit 01eec6ac authored by William F Godoy's avatar William F Godoy
Browse files

Unifiying memory copy call

Include memory selection and contiguous selection
Need a more robust way to copy between same types and from any type to
char
Implementing Intersection Start Count
Working on 1D solution
parent b441a32b
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -38,6 +38,14 @@ namespace adios2
    }                                                                          \
                                                                               \
    template <>                                                                \
    void Variable<T>::SetMemorySelection(const Box<Dims> &selection)           \
    {                                                                          \
        helper::CheckForNullptr(m_Variable,                                    \
                                "in call to Variable<T>::SetMemorySelection"); \
        m_Variable->SetMemorySelection(selection);                             \
    }                                                                          \
                                                                               \
    template <>                                                                \
    void Variable<T>::SetStepSelection(const Box<size_t> &stepSelection)       \
    {                                                                          \
        helper::CheckForNullptr(m_Variable,                                    \
+8 −0
Original line number Diff line number Diff line
@@ -59,6 +59,14 @@ public:
     */
    void SetSelection(const adios2::Box<adios2::Dims> &selection);

    /**
     * Sets the description of the pointer or vector memory given at Put and Get
     * for non-contiguous memory writes and reads. Most commonly used in I/O of
     * non ghost-cells into a larger array containing ghost cells.
     * @param selection input {start, count} of memory to be given at Put or Get
     */
    void SetMemorySelection(const adios2::Box<adios2::Dims> &selection);

    /**
     * Sets a step selection modifying current startStep, countStep
     * countStep is the number of steps from startStep point
+19 −0
Original line number Diff line number Diff line
@@ -184,6 +184,25 @@ void Engine::CommonChecks(Variable<T> &variable, const T *data,
        helper::CheckForNullptr(
            data, "for data argument in non-zero count block, " + hint);
    }

    if (!variable.m_MemoryStart.empty() && !variable.m_MemoryCount.empty())
    {
        const Box<Dims> selectionBox =
            helper::StartEndBox(variable.m_Start, variable.m_Count);
        const Box<Dims> memoryBox =
            helper::StartEndBox(variable.m_MemoryStart, variable.m_MemoryCount);

        const Box<Dims> intersectionBox =
            helper::IntersectionBox(selectionBox, memoryBox);
        if (intersectionBox.first != selectionBox.first ||
            intersectionBox.second != selectionBox.second)
        {
            throw std::invalid_argument(
                "ERROR: variable start and count do not fall inside "
                "SetMemorySelection start and count for variable " +
                variable.m_Name + ", " + hint);
        }
    }
}

} // end namespace core
+2 −0
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ namespace core
        info.Shape = m_Shape;                                                  \
        info.Start = m_Start;                                                  \
        info.Count = m_Count;                                                  \
        info.MemoryStart = m_MemoryStart;                                      \
        info.MemoryCount = m_MemoryCount;                                      \
        info.StepsStart = stepsStart;                                          \
        info.StepsCount = stepsCount;                                          \
        info.Data = const_cast<T *>(data);                                     \
+2 −0
Original line number Diff line number Diff line
@@ -58,6 +58,8 @@ public:
        T Value = T();
        bool IsValue = false;
        std::vector<Operation> Operations;
        Dims MemoryStart;
        Dims MemoryCount;

        /** Contains (seek) read information for available [step][blockID],
         *  used in Read mode only,
Loading