Skip to content

Commit

Permalink
Remove variadic range policy constructor (kokkos#6845)
Browse files Browse the repository at this point in the history
* Removed variadic ctor from RangePolicy, as well as extra
set(...) methods.

* In RangePolicy:
Deprecated set(ChunkSize)
In the ctor that takes a ChunkSize, set the chunk size via
set_chunk_size instead of via member initializers (to be more consistent
with other code)

* Removed superfluous "inline" from two of the RangePolicy constructors
  • Loading branch information
nliber committed Mar 1, 2024
1 parent 04a5334 commit 8b8de2c
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions core/src/Kokkos_ExecPolicy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,12 @@ class RangePolicy : public Impl::PolicyTraits<Properties...> {
: RangePolicy(typename traits::execution_space(), work_begin, work_end) {}

/** \brief Total range */
template <typename IndexType1, typename IndexType2, typename... Args,
template <typename IndexType1, typename IndexType2,
std::enable_if_t<(std::is_convertible_v<IndexType1, member_type> &&
std::is_convertible_v<IndexType2, member_type>),
bool> = false>
inline RangePolicy(const typename traits::execution_space& work_space,
const IndexType1 work_begin, const IndexType2 work_end,
Args... args)
const IndexType1 work_begin, const IndexType2 work_end)
: m_space(work_space),
m_begin(work_begin),
m_end(work_end),
Expand All @@ -139,36 +138,44 @@ class RangePolicy : public Impl::PolicyTraits<Properties...> {
check_conversion_safety(work_end);
check_bounds_validity();
set_auto_chunk_size();
set(args...);
}

template <typename IndexType1, typename IndexType2,
std::enable_if_t<(std::is_convertible_v<IndexType1, member_type> &&
std::is_convertible_v<IndexType2, member_type>),
bool> = false>
RangePolicy(const typename traits::execution_space& work_space,
const IndexType1 work_begin, const IndexType2 work_end,
const ChunkSize chunk_size)
: m_space(work_space),
m_begin(work_begin),
m_end(work_end),
m_granularity(0),
m_granularity_mask(0) {
check_conversion_safety(work_begin);
check_conversion_safety(work_end);
check_bounds_validity();
set_chunk_size(chunk_size.value);
}

/** \brief Total range */
template <typename IndexType1, typename IndexType2, typename... Args,
std::enable_if_t<(std::is_convertible_v<IndexType1, member_type> &&
std::is_convertible_v<IndexType2, member_type>),
bool> = false>
inline RangePolicy(const IndexType1 work_begin, const IndexType2 work_end,
Args... args)
RangePolicy(const IndexType1 work_begin, const IndexType2 work_end,
const ChunkSize chunk_size)
: RangePolicy(typename traits::execution_space(), work_begin, work_end,
args...) {}

private:
inline void set() {}
chunk_size) {}

public:
template <class... Args>
inline void set(Args...) {
static_assert(
0 == sizeof...(Args),
"Kokkos::RangePolicy: unhandled constructor arguments encountered.");
}

template <class... Args>
inline void set(const ChunkSize& chunksize, Args... args) {
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
KOKKOS_DEPRECATED_WITH_COMMENT("Use set_chunk_size instead")
inline void set(ChunkSize chunksize) {
m_granularity = chunksize.value;
m_granularity_mask = m_granularity - 1;
set(args...);
}
#endif

public:
/** \brief return chunk_size */
Expand Down

0 comments on commit 8b8de2c

Please sign in to comment.