Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
anagainaru committed Dec 29, 2022
1 parent 233a170 commit ef22740
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
8 changes: 7 additions & 1 deletion bindings/CXX11/adios2/cxx11/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@
#include "Engine.tcc"

#include "adios2/core/Engine.h"

#include "adios2/helper/adiosFunctions.h"

namespace adios2
{

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");
}

Engine::operator bool() const noexcept
{
if (m_Engine == nullptr)
Expand Down
17 changes: 7 additions & 10 deletions bindings/CXX11/adios2/cxx11/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#include "adios2/common/ADIOSMacros.h"
#include "adios2/common/ADIOSTypes.h"
#include "adios2/helper/adiosFunctions.h"

namespace adios2
{
Expand All @@ -39,6 +38,8 @@ class Engine
friend class IO;
friend class QueryWorker;

void CheckMemorySpace(MemorySpace variableMem, MemorySpace bufferMem);

public:
/**
* Empty (default) constructor, use it as a placeholder for future
Expand Down Expand Up @@ -218,17 +219,13 @@ class Engine
void Put(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();
auto bufferView = static_cast<AdiosView<U>>(data);
#ifdef ADIOS2_HAVE_GPU_SUPPORT
if (variable.m_MemSpace != MemorySpace::Detect &&
variable.m_MemSpace != mem_space)
helper::Throw<std::runtime_error>(
"CXX-Bindings", "Engine", "Put",
"Memory space mismatch between the variable and the "
"Kokkos::View");
auto bufferMem = bufferView.memory_space();
auto variableMem = variable.GetMemorySpace();
CheckMemorySpace(variableMem, bufferMem);
#endif
Put(variable, adios_data.data(), launch);
Put(variable, bufferView.data(), launch);
}

/** Perform all Put calls in Deferred mode up to this point. Specifically,
Expand Down
6 changes: 6 additions & 0 deletions bindings/CXX11/adios2/cxx11/Variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ namespace adios2
} \
\
template <> \
MemorySpace Variable<T>::GetMemorySpace() \
{ \
return m_Variable->m_MemSpace; \
} \
\
template <> \
void Variable<T>::SetShape(const Dims &shape) \
{ \
helper::CheckForNullptr(m_Variable, \
Expand Down
6 changes: 6 additions & 0 deletions bindings/CXX11/adios2/cxx11/Variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ class Variable
*/
void SetMemorySpace(const MemorySpace mem);

/**
* Get the memory space that was set by the application
* @return the memory space stored in the Variable object
*/
MemorySpace GetMemorySpace();

/**
* Set new shape, care must be taken when reading back the variable for
* different steps. Only applies to Global arrays.
Expand Down

0 comments on commit ef22740

Please sign in to comment.