Commit 13cfa658 authored by William F Godoy's avatar William F Godoy
Browse files

Passing Write Read 1D tests

TODO:
Muldimensional tests
Min Max for non-contiguous memory

Working on 2D MemoryStart

Retrieved memory count
parent 1252c4f0
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -38,11 +38,11 @@ namespace adios2
    }                                                                          \
                                                                               \
    template <>                                                                \
    void Variable<T>::SetMemoryStart(const Dims &memoryStart)                  \
    void Variable<T>::SetMemorySelection(const Box<Dims> &memorySelection)     \
    {                                                                          \
        helper::CheckForNullptr(m_Variable,                                    \
                                "in call to Variable<T>::SetMemoryStart");     \
        m_Variable->SetMemoryStart(memoryStart);                               \
                                "in call to Variable<T>::SetMemorySelection"); \
        m_Variable->SetMemorySelection(memorySelection);                       \
    }                                                                          \
                                                                               \
    template <>                                                                \
+16 −8
Original line number Diff line number Diff line
@@ -60,16 +60,24 @@ public:
    void SetSelection(const adios2::Box<adios2::Dims> &selection);

    /**
     * Set the local start (offset) point to the memory pointer passed at Put.
     * Set the local start (offset) point to the memory pointer passed at Put
     * and the memory local dimensions (count). Used for non-contiguous memory
     * writes and reads (e.g. multidimensional ghost-cells).
     * Currently not working for calls to Get.
     * Used for non-contiguous memory writes and reads (e.g. multidimensional
     * ghost-cells).
     * @param memoryStart relative local offset to the memory pointer passed at
     * Put.
     * e.g. if variable start = {0,0} and there is 1 ghost cell per dimension,
     * @param memorySelection {memoryStart, memoryCount}
     * <pre>
     * 		memoryStart: relative local offset of variable.start to the
     * contiguous memory pointer passed at Put from which data starts. e.g. if
     * variable.Start() = {rank*Ny,0} and there is 1 ghost cell per dimension,
     * then memoryStart = {1,1}
     *
     * 		memoryCount: local dimensions for the contiguous memory pointer
     * passed at Put, e.g. if there is 1 ghost cell per dimension and
     * variable.Count() = {Ny,Nx}, then memoryCount = {Ny+2,Nx+2}
     *
     * </pre>
     */
    void SetMemoryStart(const adios2::Dims &memoryStart);
    void SetMemorySelection(const adios2::Box<adios2::Dims> &memorySelection);

    /**
     * Sets a step selection modifying current startStep, countStep
+1 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ namespace core
        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);                                     \
+1 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ public:
        bool IsValue = false;
        std::vector<Operation> Operations;
        Dims MemoryStart;
        Dims MemoryCount;

        /** Contains (seek) read information for available [step][blockID],
         *  used in Read mode only,
+38 −7
Original line number Diff line number Diff line
@@ -130,8 +130,11 @@ void VariableBase::SetSelection(const Box<Dims> &boxDims)
    m_Count = count;
}

void VariableBase::SetMemoryStart(const Dims &memoryStart)
void VariableBase::SetMemorySelection(const Box<Dims> &memorySelection)
{
    const Dims &memoryStart = memorySelection.first;
    const Dims &memoryCount = memorySelection.second;

    if (m_DebugMode)
    {
        if (m_SingleValue)
@@ -139,20 +142,48 @@ void VariableBase::SetMemoryStart(const Dims &memoryStart)
            throw std::invalid_argument("ERROR: memory start is not valid "
                                        "for single value variable " +
                                        m_Name +
                                        ", in call to SetMemoryStart\n");
                                        ", in call to SetMemorySelection\n");
        }

        if (m_Shape.size() != memoryStart.size())
        if (m_Start.size() != memoryStart.size())
        {
            throw std::invalid_argument("ERROR: memoryStart size must be "
                                        "the same as variable " +
                                        m_Name + " Shape size " +
                                        std::to_string(m_Shape.size()) +
                                        ", in call to SetMemoryStart\n");
                                        m_Name + " start size " +
                                        std::to_string(m_Start.size()) +
                                        ", in call to SetMemorySelection\n");
        }

        if (m_Count.size() != memoryCount.size())
        {
            throw std::invalid_argument("ERROR: memoryCount size must be "
                                        "the same as variable " +
                                        m_Name + " count size " +
                                        std::to_string(m_Count.size()) +
                                        ", in call to SetMemorySelection\n");
        }

        // TODO might have to remove for reading
        for (size_t i = 0; i < memoryCount.size(); ++i)
        {
            if (memoryCount[i] < m_Count[i])
            {
                const std::string indexStr = std::to_string(i);
                const std::string memoryCountStr =
                    std::to_string(memoryCount[i]);
                const std::string countStr = std::to_string(m_Count[i]);

                throw std::invalid_argument(
                    "ERROR: memoyCount[" + indexStr + "]= " + memoryCountStr +
                    " can not be smaller than variable count[" + indexStr +
                    "]= " + countStr + " for variable " + m_Name +
                    ", in call to SetMemorySelection\n");
            }
        }
    }

    m_MemoryStart = memoryStart;
    m_MemoryStart = memorySelection.first;
    m_MemoryCount = memorySelection.second;
}

size_t VariableBase::GetAvailableStepsStart() const
Loading