diff --git a/core/src/Kokkos_ExecPolicy.hpp b/core/src/Kokkos_ExecPolicy.hpp index d0051560398..5f251eeb26a 100644 --- a/core/src/Kokkos_ExecPolicy.hpp +++ b/core/src/Kokkos_ExecPolicy.hpp @@ -328,6 +328,21 @@ class RangePolicy : public Impl::PolicyTraits { }; }; +RangePolicy()->RangePolicy<>; + +RangePolicy(int64_t, int64_t)->RangePolicy<>; +RangePolicy(int64_t, int64_t, ChunkSize const&)->RangePolicy<>; + +RangePolicy(DefaultExecutionSpace const&, int64_t, int64_t)->RangePolicy<>; +RangePolicy(DefaultExecutionSpace const&, int64_t, int64_t, ChunkSize const&) + ->RangePolicy<>; + +template >> +RangePolicy(ES const&, int64_t, int64_t)->RangePolicy; + +template >> +RangePolicy(ES const&, int64_t, int64_t, ChunkSize const&)->RangePolicy; + } // namespace Kokkos //---------------------------------------------------------------------------- diff --git a/core/unit_test/TestRangePolicyCTAD.cpp b/core/unit_test/TestRangePolicyCTAD.cpp index 6a2c0f507be..20288e2b40a 100644 --- a/core/unit_test/TestRangePolicyCTAD.cpp +++ b/core/unit_test/TestRangePolicyCTAD.cpp @@ -17,76 +17,134 @@ #include #include "Kokkos_Core_fwd.hpp" -#if !defined(KOKKOS_COMPILER_NVCC) || KOKKOS_COMPILER_NVCC >= 1120 - namespace { -template -using PolicyMaker = decltype(::Kokkos::RangePolicy(std::declval()...)); - -template -inline constexpr bool IsSamePolicy = - std::is_same_v>; +struct TestRangePolicyCTAD { + struct SomeExecutionSpace { + using execution_space = SomeExecutionSpace; + using size_type = size_t; -#define KOKKOS_TEST_RANGE_POLICY(...) static_assert(IsSamePolicy<__VA_ARGS__>) + [[maybe_unused]] static int concurrency() { return 0; } + }; + static_assert(Kokkos::is_execution_space_v); -struct TestRangePolicyCTAD { struct ImplicitlyConvertibleToDefaultExecutionSpace { - operator Kokkos::DefaultExecutionSpace() const { + [[maybe_unused]] operator Kokkos::DefaultExecutionSpace() const { return Kokkos::DefaultExecutionSpace(); } }; static_assert(!Kokkos::is_execution_space_v< ImplicitlyConvertibleToDefaultExecutionSpace>); - using des = Kokkos::DefaultExecutionSpace; - using nes = ImplicitlyConvertibleToDefaultExecutionSpace; - using i64 = int64_t; - using i32 = int32_t; - using cs = Kokkos::ChunkSize; + [[maybe_unused]] static inline auto i64 = int64_t(); + [[maybe_unused]] static inline auto i32 = int32_t(); + [[maybe_unused]] static inline auto cs = Kokkos::ChunkSize(0); + [[maybe_unused]] static inline auto des = Kokkos::DefaultExecutionSpace(); + [[maybe_unused]] static inline auto nes = + ImplicitlyConvertibleToDefaultExecutionSpace(); + [[maybe_unused]] static inline auto ses = SomeExecutionSpace(); // RangePolicy() - // Guard against GGC 8.4 bug - // error: cannot deduce template arguments for ‘RangePolicy’ from () - // error: template argument 2 is invalid -#if !defined(KOKKOS_COMPILER_GNU) || (KOKKOS_COMPILER_GNU > 900) - KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<> /*, no argument */); -#endif + [[maybe_unused]] static inline auto rp = Kokkos::RangePolicy{}; + static_assert(std::is_same_v, decltype(rp)>); // RangePolicy(index_type, index_type) - KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, i64, i64); - KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, i64, i32); - KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, i32, i64); - KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, i32, i32); + [[maybe_unused]] static inline auto rpi64i64 = Kokkos::RangePolicy(i64, i64); + static_assert(std::is_same_v, decltype(rpi64i64)>); + + [[maybe_unused]] static inline auto rpi64i32 = Kokkos::RangePolicy(i64, i32); + static_assert(std::is_same_v, decltype(rpi64i32)>); + + [[maybe_unused]] static inline auto rpi32i64 = Kokkos::RangePolicy(i32, i64); + static_assert(std::is_same_v, decltype(rpi32i64)>); - // RangePolicy(index_type, index_type, Args...) + [[maybe_unused]] static inline auto rpi32i32 = Kokkos::RangePolicy(i32, i32); + static_assert(std::is_same_v, decltype(rpi32i32)>); - KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, i64, i64, cs); - KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, i64, i32, cs); - KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, i32, i64, cs); - KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, i32, i32, cs); + // RangePolicy(index_type, index_type, ChunkSize) + + [[maybe_unused]] static inline auto rpi64i64cs = + Kokkos::RangePolicy(i64, i64, cs); + static_assert(std::is_same_v, decltype(rpi64i64cs)>); + + [[maybe_unused]] static inline auto rpi64i32cs = + Kokkos::RangePolicy(i64, i32, cs); + static_assert(std::is_same_v, decltype(rpi64i32cs)>); + + [[maybe_unused]] static inline auto rpi32i64cs = + Kokkos::RangePolicy(i32, i64, cs); + static_assert(std::is_same_v, decltype(rpi32i64cs)>); + + [[maybe_unused]] static inline auto rpi32i32cs = + Kokkos::RangePolicy(i32, i32, cs); + static_assert(std::is_same_v, decltype(rpi32i32cs)>); // RangePolicy(execution_space, index_type, index_type) - KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, des, i64, i64); - KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, des, i32, i32); - KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, nes, i64, i64); - KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, nes, i32, i32); + [[maybe_unused]] static inline auto rpdesi64i64 = + Kokkos::RangePolicy(des, i64, i64); + static_assert(std::is_same_v, decltype(rpdesi64i64)>); + + [[maybe_unused]] static inline auto rpdesi32i32 = + Kokkos::RangePolicy(des, i32, i32); + static_assert(std::is_same_v, decltype(rpdesi32i32)>); + + [[maybe_unused]] static inline auto rpnesi64i64 = + Kokkos::RangePolicy(nes, i64, i64); + static_assert(std::is_same_v, decltype(rpnesi64i64)>); - // RangePolicy(execution_space, index_type, index_type, Args...) + [[maybe_unused]] static inline auto rpnesi32i32 = + Kokkos::RangePolicy(nes, i32, i32); + static_assert(std::is_same_v, decltype(rpnesi32i32)>); + + [[maybe_unused]] static inline auto rpsesi64i64 = + Kokkos::RangePolicy(ses, i64, i64); + static_assert(std::is_same_v, + decltype(rpsesi64i64)>); + + [[maybe_unused]] static inline auto rpsesi32i32 = + Kokkos::RangePolicy(ses, i32, i32); + static_assert(std::is_same_v, + decltype(rpsesi32i32)>); + + // RangePolicy(execution_space, index_type, index_type, ChunkSize) + + [[maybe_unused]] static inline auto rpdesi64i64cs = + Kokkos::RangePolicy(des, i64, i64, cs); + static_assert(std::is_same_v, decltype(rpdesi64i64cs)>); + + [[maybe_unused]] static inline auto rpdesi32i32cs = + Kokkos::RangePolicy(des, i32, i32, cs); + static_assert(std::is_same_v, decltype(rpdesi32i32cs)>); + + [[maybe_unused]] static inline auto rpnesi64i64cs = + Kokkos::RangePolicy(nes, i64, i64, cs); + static_assert(std::is_same_v, decltype(rpnesi64i64cs)>); + + [[maybe_unused]] static inline auto rpnesi32i32cs = + Kokkos::RangePolicy(nes, i32, i32, cs); + static_assert(std::is_same_v, decltype(rpnesi32i32cs)>); + + [[maybe_unused]] static inline auto rpsesi64i64cs = + Kokkos::RangePolicy(ses, i64, i64, cs); + static_assert(std::is_same_v, + decltype(rpsesi64i64cs)>); + + [[maybe_unused]] static inline auto rpsesi32i32cs = + Kokkos::RangePolicy(ses, i32, i32, cs); + static_assert(std::is_same_v, + decltype(rpsesi32i32cs)>); - KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, des, i64, i64, cs); - KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, des, i32, i32, cs); - KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, nes, i64, i64, cs); - KOKKOS_TEST_RANGE_POLICY(Kokkos::RangePolicy<>, nes, i32, i32, cs); }; // TestRangePolicyCTAD struct // To eliminate maybe_unused warning on some compilers -[[maybe_unused]] const Kokkos::DefaultExecutionSpace des = + +[[maybe_unused]] const Kokkos::DefaultExecutionSpace nestodes = TestRangePolicyCTAD::ImplicitlyConvertibleToDefaultExecutionSpace(); -} // namespace +[[maybe_unused]] const auto sesconcurrency = + TestRangePolicyCTAD::ses.concurrency(); -#endif +} // namespace