Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tpetra: Adding cmake support for making Tpetra allocate in shared space #12622

Merged
merged 3 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/tpetra/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,24 @@ ELSE () # NOT Tpetra_INST_SYCL
ENDIF ()
ENDIF () # Tpetra_INST_SYCL

############################################################
# Shared/Managed Memory Default Allocation
############################################################
# Normally we allocate Tpetra objects to the basic space by default,
# but some apps might want to allocate memory to the "shared" host/device
# space. This might be CudaUVMSpace, HIPManagedSpace or SYCLSharedUSMSpace.
# These options allow us to do that sort of thing, changing
# core/compat/Tpetra_KokkosCompat_ClassicNodeAPI_Wrapper.hpp
TRIBITS_ADD_OPTION_AND_DEFINE(
Tpetra_ALLOCATE_IN_SHARED_SPACE
HAVE_TPETRA_SHARED_ALLOCS
"Have Tpetra allocate memory in shared/managed space by default"
OFF
)
IF(Tpetra_ALLOCATE_IN_SHARED_SPACE)
MESSAGE(STATUS "- Tpetra: Allocating the shared/managed space by default.")
ENDIF()


############################################################
# Device-aware MPI Support
Expand Down
2 changes: 2 additions & 0 deletions packages/tpetra/core/cmake/TpetraCore_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@
#endif


#cmakedefine HAVE_TPETRA_SHARED_ALLOCS

#cmakedefine HAVE_TPETRA_EXPERIMENTAL

@TPETRA_DEPRECATED_DECLARATIONS@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,26 @@ class KokkosDeviceWrapperNode {
};

#ifdef KOKKOS_ENABLE_SYCL
#ifdef HAVE_TPETRA_SHARED_ALLOCS
typedef KokkosDeviceWrapperNode<::Kokkos::Experimental::SYCL, ::Kokkos::Experimental::SYCLSharedUSMSpace> KokkosSYCLWrapperNode;
#else
typedef KokkosDeviceWrapperNode<::Kokkos::Experimental::SYCL, ::Kokkos::Experimental::SYCLDeviceUSMSpace> KokkosSYCLWrapperNode;
#endif
#endif

#ifdef KOKKOS_ENABLE_HIP
// NOTE: KokkosKernels does not currently support HIPManagedSpace, but
// if it did, we'd add HAVE_TPETRA_MANAGED_ALLOCS here
csiefer2 marked this conversation as resolved.
Show resolved Hide resolved
typedef KokkosDeviceWrapperNode<::Kokkos::HIP, ::Kokkos::HIPSpace> KokkosHIPWrapperNode;
#endif

#ifdef KOKKOS_ENABLE_CUDA
#ifdef HAVE_TPETRA_SHARED_ALLOCS
typedef KokkosDeviceWrapperNode<::Kokkos::Cuda,::Kokkos::CudaUVMSpace> KokkosCudaWrapperNode;
#else
typedef KokkosDeviceWrapperNode<::Kokkos::Cuda> KokkosCudaWrapperNode;
#endif
#endif

#ifdef KOKKOS_ENABLE_OPENMP
typedef KokkosDeviceWrapperNode<::Kokkos::OpenMP> KokkosOpenMPWrapperNode;
Expand Down