From 9daf5cae0ad603e876503c3180905c4cb6c8b2f8 Mon Sep 17 00:00:00 2001 From: anagainaru Date: Sun, 15 Sep 2024 18:40:21 -0400 Subject: [PATCH 1/2] Update memory selection when there is a layout mismatch --- bindings/CXX11/adios2/cxx11/Engine.h | 4 ---- source/adios2/core/VariableBase.cpp | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bindings/CXX11/adios2/cxx11/Engine.h b/bindings/CXX11/adios2/cxx11/Engine.h index 26fd076a9f..4f7a3fae36 100644 --- a/bindings/CXX11/adios2/cxx11/Engine.h +++ b/bindings/CXX11/adios2/cxx11/Engine.h @@ -218,9 +218,7 @@ class Engine auto bufferView = static_cast>(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); } @@ -424,9 +422,7 @@ class Engine auto bufferView = static_cast>(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); } diff --git a/source/adios2/core/VariableBase.cpp b/source/adios2/core/VariableBase.cpp index 67758beeb5..f069be9d49 100644 --- a/source/adios2/core/VariableBase.cpp +++ b/source/adios2/core/VariableBase.cpp @@ -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) @@ -117,6 +119,8 @@ void VariableBase::SetMemorySpace(const MemorySpace mem) ExistingMemSpace + " and cannot received a " + NewMemSpace + " buffer"); } + if (mem == MemorySpace::GPU && m_ArrayLayout == ArrayOrdering::Auto) + SetArrayLayout(ArrayOrdering::ColumnMajor); #endif m_MemSpace = mem; } From 04aac833eaf72324928154e0709c821cbc40eb2b Mon Sep 17 00:00:00 2001 From: anagainaru Date: Mon, 23 Sep 2024 10:52:18 -0400 Subject: [PATCH 2/2] Set the layout when the memory space is set --- source/adios2/core/VariableBase.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/source/adios2/core/VariableBase.cpp b/source/adios2/core/VariableBase.cpp index f069be9d49..c3c9bfaa53 100644 --- a/source/adios2/core/VariableBase.cpp +++ b/source/adios2/core/VariableBase.cpp @@ -105,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) { @@ -119,8 +122,14 @@ void VariableBase::SetMemorySpace(const MemorySpace mem) ExistingMemSpace + " and cannot received a " + NewMemSpace + " buffer"); } - if (mem == MemorySpace::GPU && m_ArrayLayout == ArrayOrdering::Auto) - SetArrayLayout(ArrayOrdering::ColumnMajor); + 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; }