Skip to content

Commit

Permalink
use exespace to check rather than mem space
Browse files Browse the repository at this point in the history
  • Loading branch information
fnrizzi committed Jun 26, 2023
1 parent 543accd commit 2a1c79b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
7 changes: 1 addition & 6 deletions algorithms/src/sorting/Kokkos_SortPublicAPI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,7 @@ void sort([[maybe_unused]] const ExecutionSpace& exec,
return;
}

if constexpr (SpaceAccessibility<HostSpace, MemSpace>::accessible
#if defined(KOKKOS_ENABLE_CUDA)
&& !std::is_same_v<MemSpace, Kokkos::CudaUVMSpace>
#endif
)
{
if constexpr (Impl::better_off_calling_std_sort_v<ExecutionSpace>){
auto first = ::Kokkos::Experimental::begin(view);
auto last = ::Kokkos::Experimental::end(view);
std::sort(first, last);
Expand Down
28 changes: 28 additions & 0 deletions algorithms/src/sorting/impl/Kokkos_SortImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,34 @@
namespace Kokkos {
namespace Impl {

template <class ExecutionSpace>
struct better_off_calling_std_sort : std::false_type {};

#if defined KOKKOS_ENABLE_SERIAL
template <>
struct better_off_calling_std_sort<Kokkos::Serial> : std::true_type {};
#endif

#if defined KOKKOS_ENABLE_OPENMP
template <>
struct better_off_calling_std_sort<Kokkos::OpenMP> : std::true_type {};
#endif

#if defined KOKKOS_ENABLE_THREADS
template <>
struct better_off_calling_std_sort<Kokkos::Threads> : std::true_type {};
#endif

#if defined KOKKOS_ENABLE_HPX
template <>
struct better_off_calling_std_sort<Kokkos::Experimental::HPX> : std::true_type {
};
#endif

template <class T>
inline constexpr bool better_off_calling_std_sort_v =
better_off_calling_std_sort<T>::value;

template <class ViewType>
struct min_max_functor {
using minmax_scalar =
Expand Down

0 comments on commit 2a1c79b

Please sign in to comment.