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

Remove use_annotated_operator #736

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading