Adding CMake tweaks to turn off thrust algorithms if thrust is not detected.

This commit is contained in:
Sean Miller 2022-12-12 11:53:30 -06:00 committed by Thomas Gibson
parent 5a72275ed8
commit e6f63a807d
5 changed files with 20 additions and 2 deletions

@ -357,6 +357,18 @@ if(VTKm_ENABLE_KOKKOS AND NOT TARGET vtkm_kokkos)
add_library(vtkm_kokkos_hip INTERFACE)
set_property(TARGET vtkm_kokkos_hip PROPERTY EXPORT_NAME kokkos_hip)
install(TARGETS vtkm_kokkos_hip EXPORT ${VTKm_EXPORT_NAME})
# Make sure rocthrust is available if requested
# If it is not available, warn the user and continue with thrust disabled
if(${VTKm_ENABLE_KOKKOS_THRUST})
find_package(rocthrust)
if(${rocthrust_FOUND})
message(STATUS "Kokkos HIP enabled with rocthrust support")
else()
set(VTKm_ENABLE_KOKKOS_THRUST OFF CACHE BOOL "Enable thrust within Kokkos algorithms" FORCE)
message(WARNING "Kokkos HIP enabled, but rocthrust not found. Install rocthrust for improved performance.")
endif()
endif()
endif()
add_library(vtkm_kokkos INTERFACE IMPORTED GLOBAL)

@ -90,6 +90,7 @@ endmacro ()
# Configurable Options
vtkm_option(VTKm_ENABLE_CUDA "Enable Cuda support" OFF)
vtkm_option(VTKm_ENABLE_KOKKOS "Enable Kokkos support" OFF)
vtkm_option(VTKm_ENABLE_KOKKOS_THRUST "Enable Kokkos thrust support (only valid with CUDA and HIP)" ON)
vtkm_option(VTKm_ENABLE_OPENMP "Enable OpenMP support" OFF)
vtkm_option(VTKm_ENABLE_TBB "Enable TBB support" OFF)
vtkm_option(VTKm_ENABLE_RENDERING "Enable rendering library" ON)

@ -38,7 +38,7 @@ VTKM_THIRDPARTY_POST_INCLUDE
#define VTKM_VOLATILE volatile
#endif
#if defined(VTKM_KOKKOS_HIP) || defined(VTKM_KOKKOS_CUDA)
#if defined(VTKM_ENABLE_KOKKOS_THRUST)
#include <thrust/device_ptr.h>
#include <thrust/sort.h>
#endif
@ -778,7 +778,7 @@ public:
protected:
// Kokkos currently (11/10/2022) does not support a sort_by_key operator
// so instead we are using thrust if and only if HIP or CUDA are the backends for Kokkos
#if defined(VTKM_KOKKOS_HIP) || defined(VTKM_KOKKOS_CUDA)
#if defined(VTKM_ENABLE_KOKKOS_THRUST)
template <typename T, typename U, typename BinaryCompare>
VTKM_CONT static std::enable_if_t<(std::is_same<BinaryCompare, vtkm::SortLess>::value ||

@ -21,6 +21,7 @@ set(VTKM_USE_64BIT_IDS ${VTKm_USE_64BIT_IDS})
set(VTKM_ENABLE_CUDA ${VTKm_ENABLE_CUDA})
set(VTKM_ENABLE_KOKKOS ${VTKm_ENABLE_KOKKOS})
set(VTKM_ENABLE_KOKKOS_THRUST ${VTKm_ENABLE_KOKKOS_THRUST})
set(VTKM_ENABLE_OPENMP ${VTKm_ENABLE_OPENMP})
set(VTKM_ENABLE_TBB ${VTKm_ENABLE_TBB})

@ -300,6 +300,10 @@
#ifndef VTKM_KOKKOS_HIP
#cmakedefine VTKM_KOKKOS_HIP
#endif
// Mark if Kokkos algorithms should use thrust
#if defined(VTKM_KOKKOS_HIP) || defined(VTKM_KOKKOS_CUDA)
#cmakedefine VTKM_ENABLE_KOKKOS_THRUST
#endif
//Mark if we are building with MPI enabled.
#cmakedefine VTKM_ENABLE_MPI