Unverified Commit 3bfcb936 authored by Bolea Sanchez, Vicente Adolfo's avatar Bolea Sanchez, Vicente Adolfo Committed by GitHub
Browse files

Merge pull request #4029 from vicentebolea/backport-master

Backport master commits
parents c9f76bf4 62b4405a
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
# KW's stuff
CMakeLists.txt @vicentebolea @caitlinross

# Caitlin's stuff
plugins/ @caitlinross

@@ -10,11 +7,11 @@ plugins/ @caitlinross
*.in @vicentebolea
*.json @vicentebolea
*.sh @vicentebolea
*.txt  @vicentebolea
*.yaml @vicentebolea
*.yml @vicentebolea
cmake/ @vicentebolea
scripts/ @vicentebolea
python/ @vicentebolea
.github/ @vicentebolea
.circleci/ @vicentebolea
source/adios2/toolkit/sst/dp/mpi_dp.c @vicentebolea
+0 −8
Original line number Diff line number Diff line
@@ -17,14 +17,6 @@
namespace adios2
{

#ifdef ADIOS2_HAVE_GPU_SUPPORT
void Engine::CheckMemorySpace(MemorySpace variableMem, MemorySpace bufferMem)
{
    if (variableMem != MemorySpace::Detect && variableMem != bufferMem)
        helper::Throw<std::runtime_error>("CXX-Bindings", "Engine", "Put", "Memory space mismatch");
}
#endif

Engine::operator bool() const noexcept
{
    if (m_Engine == nullptr)
+12 −12
Original line number Diff line number Diff line
@@ -38,10 +38,6 @@ class Engine
    friend class IO;
    friend class QueryWorker;

#ifdef ADIOS2_HAVE_GPU_SUPPORT
    void CheckMemorySpace(MemorySpace variableMem, MemorySpace bufferMem);
#endif

public:
    /**
     * Empty (default) constructor, use it as a placeholder for future
@@ -212,12 +208,12 @@ public:
    void Put(Variable<T> variable, U const &data, const Mode launch = Mode::Deferred)
    {
        auto bufferView = static_cast<AdiosView<U>>(data);
#if defined(ADIOS2_HAVE_KOKKOS) || defined(ADIOS2_HAVE_GPU_SUPPORT)
        auto bufferMem = bufferView.memory_space();
#ifdef ADIOS2_HAVE_GPU_SUPPORT
        auto variableMem = variable.GetMemorySpace();
        CheckMemorySpace(variableMem, bufferMem);
#endif
        auto bufferLayout = bufferView.layout();
        variable.SetMemorySpace(bufferMem);
        variable.SetArrayLayout(bufferLayout);
#endif
        Put(variable, bufferView.data(), launch);
    }

@@ -417,10 +413,14 @@ public:
              class = typename std::enable_if<std::is_convertible<U, AdiosView<U>>::value>::type>
    void Get(Variable<T> variable, U const &data, const Mode launch = Mode::Deferred)
    {
        auto adios_data = static_cast<AdiosView<U>>(data);
        auto mem_space = adios_data.memory_space();
        variable.SetMemorySpace(mem_space);
        Get(variable, adios_data.data(), launch);
        auto bufferView = static_cast<AdiosView<U>>(data);
#if defined(ADIOS2_HAVE_KOKKOS) || defined(ADIOS2_HAVE_GPU_SUPPORT)
        auto bufferMem = bufferView.memory_space();
        auto bufferLayout = bufferView.layout();
        variable.SetMemorySpace(bufferMem);
        variable.SetArrayLayout(bufferLayout);
#endif
        Get(variable, bufferView.data(), launch);
    }

    /** Perform all Get calls in Deferred mode up to this point */
+21 −0
Original line number Diff line number Diff line
@@ -28,6 +28,23 @@ struct memspace_kokkos_to_adios2
};
#endif

template <typename T>
struct layout_kokkos_to_adios2
{
    static constexpr adios2::ArrayOrdering value = adios2::ArrayOrdering::RowMajor;
};

template <>
struct layout_kokkos_to_adios2<Kokkos::LayoutLeft>
{
    static constexpr adios2::ArrayOrdering value = adios2::ArrayOrdering::ColumnMajor;
};

template <>
struct layout_kokkos_to_adios2<Kokkos::LayoutRight>
{
    static constexpr adios2::ArrayOrdering value = adios2::ArrayOrdering::RowMajor;
};
} // namespace detail

template <class T, class... Parameters>
@@ -36,6 +53,7 @@ class AdiosView<Kokkos::View<T, Parameters...>>
    using data_type = typename Kokkos::View<T, Parameters...>::value_type;
    data_type *pointer;
    adios2::MemorySpace mem_space;
    adios2::ArrayOrdering m_layout;

public:
    template <class... P>
@@ -44,11 +62,14 @@ public:
        pointer = v.data();
        mem_space =
            detail::memspace_kokkos_to_adios2<typename Kokkos::View<T, P...>::memory_space>::value;
        m_layout =
            detail::layout_kokkos_to_adios2<typename Kokkos::View<T, P...>::array_layout>::value;
    }

    data_type const *data() const { return pointer; }
    data_type *data() { return pointer; }
    adios2::MemorySpace memory_space() const { return mem_space; }
    adios2::ArrayOrdering layout() const { return m_layout; }
};

}
+22 −0
Original line number Diff line number Diff line
@@ -126,6 +126,20 @@ namespace adios2
    }                                                                                              \
                                                                                                   \
    template <>                                                                                    \
    Dims Variable<T>::Shape(const ArrayOrdering layout, const size_t step) const                   \
    {                                                                                              \
        helper::CheckForNullptr(m_Variable, "in call to Variable<T>::Shape");                      \
        return m_Variable->Shape(step, MemorySpace::Host, layout);                                 \
    }                                                                                              \
                                                                                                   \
    template <>                                                                                    \
    Dims Variable<T>::Shape(const MemorySpace memSpace, const size_t step) const                   \
    {                                                                                              \
        helper::CheckForNullptr(m_Variable, "in call to Variable<T>::Shape");                      \
        return m_Variable->Shape(step, memSpace);                                                  \
    }                                                                                              \
                                                                                                   \
    template <>                                                                                    \
    Dims Variable<T>::Start() const                                                                \
    {                                                                                              \
        helper::CheckForNullptr(m_Variable, "in call to Variable<T>::Start");                      \
@@ -266,6 +280,14 @@ ADIOS2_FOREACH_TYPE_1ARG(declare_template_instantiation)
ADIOS2_FOREACH_PRIMITIVE_TYPE_1ARG(declare_template_instantiation)
#undef declare_template_instantiation

#if defined(ADIOS2_HAVE_KOKKOS) || defined(ADIOS2_HAVE_GPU_SUPPORT)
#define declare_layout_template_instantiation(T)                                                   \
    template void Variable<T>::SetArrayLayout(const ArrayOrdering layout);                         \
    template ArrayOrdering Variable<T>::GetArrayLayout();
ADIOS2_FOREACH_TYPE_1ARG(declare_layout_template_instantiation)
#undef declare_layout_template_instantiation
#endif

#define declare_template_instantiation(T)                                                          \
    template std::vector<typename Variable<T>::Info> Variable<T>::ToBlocksInfoMin(                 \
        const MinVarInfo *coreVarInfo) const;
Loading