Skip to content

Commit

Permalink
Merge pull request #2079 from brian-kelley/HIPManagedETI
Browse files Browse the repository at this point in the history
Add HIPManagedSpace support
  • Loading branch information
lucbv authored Jan 8, 2024
2 parents 93d4cda + 5868e99 commit d5c2924
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 10 deletions.
1 change: 1 addition & 0 deletions cmake/KokkosKernels_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
/* Whether to build kernels for execution space Kokkos::HIP */
#cmakedefine KOKKOSKERNELS_INST_EXECSPACE_HIP
#cmakedefine KOKKOSKERNELS_INST_MEMSPACE_HIPSPACE
#cmakedefine KOKKOSKERNELS_INST_MEMSPACE_HIPMANAGEDSPACE
/* Whether to build kernels for execution space Kokkos::Experimental::SYCL */
#cmakedefine KOKKOSKERNELS_INST_EXECSPACE_SYCL
#cmakedefine KOKKOSKERNELS_INST_MEMSPACE_SYCLSPACE
Expand Down
13 changes: 12 additions & 1 deletion cmake/kokkoskernels_eti_devices.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ SET(MEM_SPACES
MEMSPACE_CUDASPACE
MEMSPACE_CUDAUVMSPACE
MEMSPACE_HIPSPACE
MEMSPACE_HIPMANAGEDSPACE
MEMSPACE_SYCLSPACE
MEMSPACE_SYCLSHAREDSPACE
MEMSPACE_OPENMPTARGET
Expand All @@ -32,6 +33,7 @@ SET(MEM_SPACES
SET(MEMSPACE_CUDASPACE_CPP_TYPE Kokkos::CudaSpace)
SET(MEMSPACE_CUDAUVMSPACE_CPP_TYPE Kokkos::CudaUVMSpace)
SET(MEMSPACE_HIPSPACE_CPP_TYPE Kokkos::HIPSpace)
SET(MEMSPACE_HIPMANAGEDSPACE_CPP_TYPE Kokkos::HIPManagedSpace)
SET(MEMSPACE_SYCLSPACE_CPP_TYPE Kokkos::Experimental::SYCLDeviceUSMSpace)
SET(MEMSPACE_SYCLSHAREDSPACE_CPP_TYPE Kokkos::Experimental::SYCLSharedUSMSpace)
SET(MEMSPACE_OPENMPTARGETSPACE_CPP_TYPE Kokkos::Experimental::OpenMPTargetSpace)
Expand Down Expand Up @@ -85,10 +87,19 @@ IF(KOKKOS_ENABLE_HIP)
BOOL
"Whether to pre instantiate kernels for the memory space Kokkos::HIPSpace. Disabling this when Kokkos_ENABLE_HIP is enabled may increase build times. Default: ON if Kokkos is HIP-enabled, OFF otherwise."
)
KOKKOSKERNELS_ADD_OPTION(
INST_MEMSPACE_HIPMANAGEDSPACE
OFF
BOOL
"Whether to pre instantiate kernels for the memory space Kokkos::HIPManagedSpace. Disabling this when Kokkos_ENABLE_HIP is enabled may increase build times. Default: OFF."
)

IF(KOKKOSKERNELS_INST_EXECSPACE_HIP AND KOKKOSKERNELS_INST_MEMSPACE_HIPSPACE)
LIST(APPEND DEVICE_LIST "<HIP,HIPSpace>")
ENDIF()
IF(KOKKOSKERNELS_INST_EXECSPACE_HIP AND KOKKOSKERNELS_INST_MEMSPACE_HIPMANAGEDSPACE)
LIST(APPEND DEVICE_LIST "<HIP,HIPManagedSpace>")
ENDIF()

IF( Trilinos_ENABLE_COMPLEX_DOUBLE AND ((NOT DEFINED CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS) OR (NOT CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS)) )
MESSAGE( WARNING "The CMake option CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS is either undefined or OFF. Please set CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS:BOOL=ON when building with HIP and complex double enabled.")
Expand Down Expand Up @@ -197,7 +208,7 @@ KOKKOSKERNELS_ADD_OPTION(
)

SET(EXECSPACE_CUDA_VALID_MEM_SPACES CUDASPACE CUDAUVMSPACE)
SET(EXECSPACE_HIP_VALID_MEM_SPACES HIPSPACE)
SET(EXECSPACE_HIP_VALID_MEM_SPACES HIPSPACE HIPMANAGEDSPACE)
SET(EXECSPACE_SYCL_VALID_MEM_SPACES SYCLSPACE SYCLSHAREDSPACE)
SET(EXECSPACE_OPENMPTARGET_VALID_MEM_SPACES OPENMPTARGETSPACE)
SET(EXECSPACE_SERIAL_VALID_MEM_SPACES HBWSPACE HOSTSPACE)
Expand Down
11 changes: 11 additions & 0 deletions common/src/KokkosKernels_ExecSpaceUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,21 @@ inline void kk_get_free_total_memory<Kokkos::HIPSpace>(size_t& free_mem,
total_mem /= n_streams;
}
template <>
inline void kk_get_free_total_memory<Kokkos::HIPManagedSpace>(size_t& free_mem,
size_t& total_mem,
int n_streams) {
kk_get_free_total_memory<Kokkos::HIPSpace>(free_mem, total_mem, n_streams);
}
template <>
inline void kk_get_free_total_memory<Kokkos::HIPSpace>(size_t& free_mem,
size_t& total_mem) {
kk_get_free_total_memory<Kokkos::HIPSpace>(free_mem, total_mem, 1);
}
template <>
inline void kk_get_free_total_memory<Kokkos::HIPManagedSpace>(
size_t& free_mem, size_t& total_mem) {
kk_get_free_total_memory<Kokkos::HIPSpace>(free_mem, total_mem, 1);
}
#endif

// FIXME_SYCL Use compiler extension instead of low level interface when
Expand Down
19 changes: 15 additions & 4 deletions graph/unit_test/Test_Graph_graph_color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,15 @@ void test_coloring(lno_t numRows, size_type nnz, lno_t bandwidth,
COLORING_DEFAULT, COLORING_SERIAL, COLORING_VB, COLORING_VBBIT,
COLORING_VBCS};

#ifdef KOKKOS_ENABLE_CUDA
// FIXME: VBD sometimes fails on CUDA and HIP
#if defined(KOKKOS_ENABLE_CUDA)
if (!std::is_same<typename device::execution_space, Kokkos::Cuda>::value) {
coloring_algorithms.push_back(COLORING_VBD);
}
#elif defined(KOKKOS_ENABLE_HIP)
if (!std::is_same<typename device::execution_space, Kokkos::HIP>::value) {
coloring_algorithms.push_back(COLORING_VBD);
}
#else
coloring_algorithms.push_back(COLORING_VBD);
#endif
Expand Down Expand Up @@ -174,9 +179,15 @@ void test_coloring(lno_t numRows, size_type nnz, lno_t bandwidth,
}
}
}
EXPECT_TRUE((num_conflict == conf));

EXPECT_TRUE((num_conflict == 0));
EXPECT_TRUE((num_conflict == conf))
<< "Coloring algo " << (int)coloring_algorithm
<< ": kk_is_d1_coloring_valid returned incorrect number of conflicts ("
<< num_conflict << ", should be " << conf << ")";

EXPECT_TRUE((num_conflict == 0))
<< "Coloring algo " << (int)coloring_algorithm
<< ": D1 coloring produced invalid coloring (" << num_conflict
<< " conflicts)";
}
// device::execution_space::finalize();
}
Expand Down
6 changes: 2 additions & 4 deletions sparse/impl/KokkosSparse_sptrsv_solve_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,6 @@ struct LowerTriLvlSchedTP2SolverFunctor {
// Helper functors for Lower-triangular solve with SpMV
template <class TriSolveHandle, class LHSType, class NGBLType>
struct SparseTriSupernodalSpMVFunctor {
// using execution_space = typename LHSType::execution_space;
// using memory_space = typename execution_space::memory_space;
using execution_space = typename TriSolveHandle::HandleExecSpace;
using memory_space = typename TriSolveHandle::HandleTempMemorySpace;

Expand Down Expand Up @@ -2913,7 +2911,7 @@ void lower_tri_solve(ExecutionSpace &space, TriSolveHandle &thandle,

#if defined(KOKKOSKERNELS_ENABLE_SUPERNODAL_SPTRSV)
using namespace KokkosSparse::Experimental;
using memory_space = typename ExecutionSpace::memory_space;
using memory_space = typename TriSolveHandle::HandleTempMemorySpace;
using device_t = Kokkos::Device<ExecutionSpace, memory_space>;
using integer_view_t = typename TriSolveHandle::integer_view_t;
using integer_view_host_t = typename TriSolveHandle::integer_view_host_t;
Expand Down Expand Up @@ -3311,7 +3309,7 @@ void upper_tri_solve(ExecutionSpace &space, TriSolveHandle &thandle,
#if defined(KOKKOS_ENABLE_CUDA) && defined(KOKKOSPSTRSV_SOLVE_IMPL_PROFILE)
cudaProfilerStop();
#endif
using memory_space = typename ExecutionSpace::memory_space;
using memory_space = typename TriSolveHandle::HandleTempMemorySpace;
using device_t = Kokkos::Device<ExecutionSpace, memory_space>;
typedef typename TriSolveHandle::size_type size_type;
typedef typename TriSolveHandle::nnz_lno_view_t NGBLType;
Expand Down
13 changes: 12 additions & 1 deletion test_common/Test_HIP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,18 @@ class hip : public ::testing::Test {
static void TearDownTestCase() {}
};

using HIPSpaceDevice = Kokkos::Device<Kokkos::HIP, Kokkos::HIPSpace>;
using HIPManagedSpaceDevice =
Kokkos::Device<Kokkos::HIP, Kokkos::HIPManagedSpace>;

#define TestCategory hip
#define TestDevice Kokkos::HIP

// Prefer <HIP, HIPSpace> for any testing where only one exec space is used
#if defined(KOKKOSKERNELS_INST_MEMSPACE_HIPMANAGEDSPACE) && \
!defined(KOKKOSKERNELS_INST_MEMSPACE_HIPSPACE)
#define TestDevice HIPManagedSpaceDevice
#else
#define TestDevice HIPSpaceDevice
#endif

#endif // TEST_HIP_HPP

0 comments on commit d5c2924

Please sign in to comment.