Unverified Commit 48e7e4ec authored by William F Godoy's avatar William F Godoy Committed by GitHub
Browse files

Merge pull request #1003 from williamfgc/mem_sel

Memory Selection, aka removing ghost cells at write, support
parents 7a33e0ca b7d0a989
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -107,6 +107,37 @@ adios2_error adios2_set_selection(adios2_variable *variable, const size_t ndims,
    }
}

adios2_error adios2_set_memory_selection(adios2_variable *variable,
                                         const size_t ndims,
                                         const size_t *memory_start,
                                         const size_t *memory_count)
{
    try
    {
        adios2::helper::CheckForNullptr(variable,
                                        "for adios2_variable, in call to "
                                        "adios2_set_memory_selection");
        adios2::helper::CheckForNullptr(memory_start,
                                        "for start, in call to "
                                        "adios2_set_memory_selection");
        adios2::helper::CheckForNullptr(memory_count,
                                        "for count, in call to "
                                        "adios2_set_memory_selection");
        adios2::core::VariableBase *variableBase =
            reinterpret_cast<adios2::core::VariableBase *>(variable);

        const adios2::Dims memoryStartV(memory_start, memory_start + ndims);
        const adios2::Dims memoryCountV(memory_count, memory_count + ndims);
        variableBase->SetMemorySelection({memoryStartV, memoryCountV});
        return adios2_error_none;
    }
    catch (...)
    {
        return static_cast<adios2_error>(
            adios2::helper::ExceptionToError("adios2_set_memory_selection"));
    }
}

adios2_error adios2_set_step_selection(adios2_variable *variable,
                                       const size_t step_start,
                                       const size_t step_count)
+21 −0
Original line number Diff line number Diff line
@@ -30,6 +30,27 @@ extern "C" {
adios2_error adios2_set_selection(adios2_variable *variable, const size_t ndims,
                                  const size_t *start, const size_t *count);

/**
 * 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.
 * @param variable handler for which new memory selection will be applied to
 * @param ndims number of dimensions for memory_start and memory_count
 * @param memory_start 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 memory_start = {1,1}
 * @param memory_count local dimensions for the contiguous memory pointer
 * passed at adios2_put, e.g. if there is 1 ghost cell per dimension and
 * variable count = {Ny,Nx}, then memory_count = {Ny+2,Nx+2}
 * @return adios2_error 0: success, see enum adios2_error for errors
 */
adios2_error adios2_set_memory_selection(adios2_variable *variable,
                                         const size_t ndims,
                                         const size_t *memory_start,
                                         const size_t *memory_count);

/**
 * Set new step selection using step_start and step_count. Used mostly for
 * reading from file-based engines (e.g. bpfile, hdf5)
+8 −0
Original line number Diff line number Diff line
@@ -38,6 +38,14 @@ namespace adios2
    }                                                                          \
                                                                               \
    template <>                                                                \
    void Variable<T>::SetMemorySelection(const Box<Dims> &memorySelection)     \
    {                                                                          \
        helper::CheckForNullptr(m_Variable,                                    \
                                "in call to Variable<T>::SetMemorySelection"); \
        m_Variable->SetMemorySelection(memorySelection);                       \
    }                                                                          \
                                                                               \
    template <>                                                                \
    void Variable<T>::SetStepSelection(const Box<size_t> &stepSelection)       \
    {                                                                          \
        helper::CheckForNullptr(m_Variable,                                    \
+18 −0
Original line number Diff line number Diff line
@@ -59,6 +59,24 @@ public:
     */
    void SetSelection(const adios2::Box<adios2::Dims> &selection);

    /**
     * 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.
     * @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 SetMemorySelection(const adios2::Box<adios2::Dims> &memorySelection);

    /**
     * Sets a step selection modifying current startStep, countStep
     * countStep is the number of steps from startStep point
+3 −1
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ set(MODULES
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_io_mod.f90 
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_io_define_variable_mod.f90
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_io_define_attribute_mod.f90
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_variable_mod.f90
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_engine_mod.f90 
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_engine_begin_step_mod.f90
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_engine_put_mod.f90 
@@ -34,6 +33,9 @@ set(MODULES
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_file_mod.f90
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_fwrite_mod.f90
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_fread_mod.f90
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_variable_mod.f90
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_variable_min_mod.f90
     ${CMAKE_CURRENT_SOURCE_DIR}/modules/adios2_variable_max_mod.f90
)

add_library(adios2_f ${MODULES} ${F2C})
Loading