Skip to content

Commit

Permalink
Merge pull request #4346 from anagainaru/memSelLayout
Browse files Browse the repository at this point in the history
Update the memory selection layout when there is a layout mismatch
  • Loading branch information
anagainaru authored Oct 7, 2024
2 parents 2b40572 + 04aac83 commit 24c3860
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 0 additions & 4 deletions bindings/CXX11/adios2/cxx11/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,7 @@ class Engine
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
Put(variable, bufferView.data(), launch);
}
Expand Down Expand Up @@ -424,9 +422,7 @@ class Engine
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);
}
Expand Down
13 changes: 13 additions & 0 deletions source/adios2/core/VariableBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ void VariableBase::SetArrayLayout(const ArrayOrdering layout)
UpdateLayout(m_Shape);
UpdateLayout(m_Count);
UpdateLayout(m_Start);
UpdateLayout(m_MemoryStart);
UpdateLayout(m_MemoryCount);
return;
}
if (m_ArrayLayout != layout)
Expand Down Expand Up @@ -103,6 +105,9 @@ MemorySpace VariableBase::GetMemorySpace(const void *ptr)

void VariableBase::SetMemorySpace(const MemorySpace mem)
{
#if defined(ADIOS2_HAVE_KOKKOS) || defined(ADIOS2_HAVE_GPU_SUPPORT)
ArrayOrdering layout = m_BaseLayout;
#endif
#ifdef ADIOS2_HAVE_GPU_SUPPORT
if (m_MemSpace != MemorySpace::Detect && m_MemSpace != mem)
{
Expand All @@ -117,6 +122,14 @@ void VariableBase::SetMemorySpace(const MemorySpace mem)
ExistingMemSpace + " and cannot received a " +
NewMemSpace + " buffer");
}
if (mem == MemorySpace::GPU)
layout = ArrayOrdering::ColumnMajor;
#endif
#if defined(ADIOS2_HAVE_KOKKOS) || defined(ADIOS2_HAVE_GPU_SUPPORT)
// set the layout based on the buffer memory space
// skipping throwing an exception for a mismatch
if (m_ArrayLayout == ArrayOrdering::Auto)
SetArrayLayout(layout);
#endif
m_MemSpace = mem;
}
Expand Down

0 comments on commit 24c3860

Please sign in to comment.