Skip to content

Commit

Permalink
Remove use_annotated_operator (#736)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpadioleau authored Jan 2, 2025
1 parent f666e23 commit 9a715db
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 53 deletions.
3 changes: 1 addition & 2 deletions include/ddc/ddc_to_kokkos_execution_policy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ auto ddc_to_kokkos_execution_policy(
ExecSpace const& execution_space,
DiscreteDomain<DDims...> const& domain)
{
using work_tag = std::
conditional_t<need_annotated_operator<ExecSpace>(), use_annotated_operator, void>;
using work_tag = void;
using index_type = Kokkos::IndexType<DiscreteElementType>;
if constexpr (sizeof...(DDims) == 0) {
return Kokkos::RangePolicy<ExecSpace, work_tag, index_type>(execution_space, 0, 1);
Expand Down
16 changes: 0 additions & 16 deletions include/ddc/detail/kokkos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,20 +192,4 @@ KOKKOS_FUNCTION auto build_mdspan(
DDC_IF_NVCC_THEN_POP
}

struct use_annotated_operator
{
};

template <class ExecSpace>
constexpr bool need_annotated_operator() noexcept
{
#if defined(KOKKOS_ENABLE_CUDA)
return std::is_same_v<ExecSpace, Kokkos::Cuda>;
#elif defined(KOKKOS_ENABLE_HIP)
return std::is_same_v<ExecSpace, Kokkos::HIP>;
#else
return false;
#endif
}

} // namespace ddc::detail
18 changes: 2 additions & 16 deletions include/ddc/parallel_for_each.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,13 @@ class ForEachKokkosLambdaAdapter
explicit ForEachKokkosLambdaAdapter(F const& f) : m_f(f) {}

template <std::size_t N = sizeof...(DDims), std::enable_if_t<(N == 0), bool> = true>
void operator()([[maybe_unused]] index_type<void> unused_id) const
KOKKOS_FUNCTION void operator()([[maybe_unused]] index_type<void> unused_id) const
{
m_f(DiscreteElement<>());
}

template <std::size_t N = sizeof...(DDims), std::enable_if_t<(N == 0), bool> = true>
KOKKOS_FUNCTION void operator()(
use_annotated_operator,
[[maybe_unused]] index_type<void> unused_id) const
{
m_f(DiscreteElement<>());
}

template <std::size_t N = sizeof...(DDims), std::enable_if_t<(N > 0), bool> = true>
void operator()(index_type<DDims>... ids) const
{
m_f(DiscreteElement<DDims...>(ids...));
}

template <std::size_t N = sizeof...(DDims), std::enable_if_t<(N > 0), bool> = true>
KOKKOS_FUNCTION void operator()(use_annotated_operator, index_type<DDims>... ids) const
KOKKOS_FUNCTION void operator()(index_type<DDims>... ids) const
{
m_f(DiscreteElement<DDims...>(ids...));
}
Expand Down
20 changes: 1 addition & 19 deletions include/ddc/parallel_transform_reduce.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,8 @@ class TransformReducerKokkosLambdaAdapter
{
}

template <std::size_t N = sizeof...(DDims), std::enable_if_t<(N == 0), bool> = true>
void operator()([[maybe_unused]] index_type<void> unused_id, typename Reducer::value_type& a)
const
{
a = reducer(a, functor(DiscreteElement<>()));
}

template <std::size_t N = sizeof...(DDims), std::enable_if_t<(N == 0), bool> = true>
KOKKOS_FUNCTION void operator()(
use_annotated_operator,
[[maybe_unused]] index_type<void> unused_id,
typename Reducer::value_type& a) const

Expand All @@ -121,17 +113,7 @@ class TransformReducerKokkosLambdaAdapter
}

template <std::size_t N = sizeof...(DDims), std::enable_if_t<(N > 0), bool> = true>
void operator()(index_type<DDims>... ids, typename Reducer::value_type& a) const
{
a = reducer(a, functor(DiscreteElement<DDims...>(ids...)));
}


template <std::size_t N = sizeof...(DDims), std::enable_if_t<(N > 0), bool> = true>
KOKKOS_FUNCTION void operator()(
use_annotated_operator,
index_type<DDims>... ids,
typename Reducer::value_type& a) const
KOKKOS_FUNCTION void operator()(index_type<DDims>... ids, typename Reducer::value_type& a) const
{
a = reducer(a, functor(DiscreteElement<DDims...>(ids...)));
}
Expand Down

0 comments on commit 9a715db

Please sign in to comment.