diff --git a/CMakeLists.txt b/CMakeLists.txt index dc706eaa17..200c1093d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,7 +225,7 @@ endif() set(ADIOS2_CONFIG_OPTS - BP5 DataMan DataSpaces HDF5 HDF5_VOL MHS SST CUDA Fortran MPI Python Blosc Blosc2 BZip2 LIBPRESSIO MGARD PNG SZ ZFP DAOS IME O_DIRECT Sodium Catalyst SysVShMem ZeroMQ Profiling Endian_Reverse + BP5 DataMan DataSpaces HDF5 HDF5_VOL MHS SST CUDA Fortran MPI Python Blosc Blosc2 BZip2 LIBPRESSIO MGARD PNG SZ ZFP DAOS IME O_DIRECT Sodium Catalyst SysVShMem ZeroMQ Profiling Endian_Reverse GPU_Support ) GenerateADIOSHeaderConfig(${ADIOS2_CONFIG_OPTS}) diff --git a/cmake/DetectOptions.cmake b/cmake/DetectOptions.cmake index fa8324c431..625b1da781 100644 --- a/cmake/DetectOptions.cmake +++ b/cmake/DetectOptions.cmake @@ -193,6 +193,7 @@ endif() if(CMAKE_CUDA_COMPILER AND CUDAToolkit_FOUND) enable_language(CUDA) set(ADIOS2_HAVE_CUDA TRUE) + set(ADIOS2_HAVE_GPU_Support TRUE) endif() # Fortran diff --git a/source/adios2/common/ADIOSTypes.h b/source/adios2/common/ADIOSTypes.h index ed98643e0f..36f5fbeb3f 100644 --- a/source/adios2/common/ADIOSTypes.h +++ b/source/adios2/common/ADIOSTypes.h @@ -35,10 +35,12 @@ namespace adios2 /** Memory space for the user provided buffers */ enum class MemorySpace { +#ifdef ADIOS2_HAVE_GPU_SUPPORT Detect, ///< Detect the memory space automatically - Host, ///< Host memory space (default) +#endif + Host, ///< Host memory space #ifdef ADIOS2_HAVE_CUDA - CUDA ///< CUDA memory spaces + CUDA ///< CUDA memory spaces #endif }; diff --git a/source/adios2/core/VariableBase.cpp b/source/adios2/core/VariableBase.cpp index 3822507049..3f516cb4e3 100644 --- a/source/adios2/core/VariableBase.cpp +++ b/source/adios2/core/VariableBase.cpp @@ -50,13 +50,14 @@ size_t VariableBase::TotalSize() const noexcept MemorySpace VariableBase::DetectMemorySpace(const void *ptr) { +#ifdef ADIOS2_HAVE_GPU_SUPPORT if (m_MemSpaceRequested != MemorySpace::Detect) { m_MemSpaceDetected = m_MemSpaceRequested; return m_MemSpaceRequested; } +#endif - // if the user requested MemorySpace::Detect #ifdef ADIOS2_HAVE_CUDA cudaPointerAttributes attr; cudaPointerGetAttributes(&attr, ptr); @@ -72,16 +73,21 @@ MemorySpace VariableBase::DetectMemorySpace(const void *ptr) MemorySpace VariableBase::GetMemorySpace(const void *ptr) { +#ifdef ADIOS2_HAVE_GPU_SUPPORT if (m_MemSpaceDetected == MemorySpace::Detect) m_MemSpaceDetected = DetectMemorySpace(ptr); return m_MemSpaceDetected; +#endif + return MemorySpace::Host; } void VariableBase::SetMemorySpace(const MemorySpace mem) { m_MemSpaceRequested = mem; // reset the detected memory space +#ifdef ADIOS2_HAVE_GPU_SUPPORT m_MemSpaceDetected = MemorySpace::Detect; +#endif } void VariableBase::SetShape(const adios2::Dims &shape) diff --git a/source/adios2/core/VariableBase.h b/source/adios2/core/VariableBase.h index ac92482895..73d59f8366 100644 --- a/source/adios2/core/VariableBase.h +++ b/source/adios2/core/VariableBase.h @@ -51,12 +51,13 @@ class VariableBase * VariableStruct -> from constructor sizeof(struct) */ const size_t m_ElementSize; /* User requested memory space and the detected memory space */ -#ifdef ADIOS2_HAVE_CUDA +#ifdef ADIOS2_HAVE_GPU_SUPPORT MemorySpace m_MemSpaceRequested = MemorySpace::Detect; + MemorySpace m_MemSpaceDetected = MemorySpace::Detect; #else MemorySpace m_MemSpaceRequested = MemorySpace::Host; + MemorySpace m_MemSpaceDetected = MemorySpace::Host; #endif - MemorySpace m_MemSpaceDetected = MemorySpace::Detect; ShapeID m_ShapeID = ShapeID::Unknown; ///< see shape types in ADIOSTypes.h size_t m_BlockID = 0; ///< current block ID for local variables, global = 0