From 54e988b20df3aa972ec824b27936e900f0e92e94 Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Wed, 24 Aug 2022 12:41:00 -0700 Subject: [PATCH 1/5] #5382: Deprecate overloads of Kokkos::sort() taking parameter 'bool always_use_kokkos_sort' --- algorithms/src/Kokkos_Sort.hpp | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/algorithms/src/Kokkos_Sort.hpp b/algorithms/src/Kokkos_Sort.hpp index 7eaa5442f68..b0317c07d66 100644 --- a/algorithms/src/Kokkos_Sort.hpp +++ b/algorithms/src/Kokkos_Sort.hpp @@ -586,11 +586,7 @@ struct min_max_functor { template std::enable_if_t::value> sort( - const ExecutionSpace& exec, ViewType const& view, - bool const always_use_kokkos_sort = false) { - if (!always_use_kokkos_sort) { - if (Impl::try_std_sort(view, exec)) return; - } + const ExecutionSpace& exec, ViewType const& view) { using CompType = BinOp1D; Kokkos::MinMaxScalar result; @@ -628,12 +624,38 @@ std::enable_if_t::value> sort( bin_sort.sort(exec, view); } +#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3 +template +KOKKOS_DEPRECATED_WITH_COMMENT( + "Use the overload not taking bool always_use_kokkos_sort") +std::enable_if_t::value> sort( + const ExecutionSpace& exec, ViewType const& view, + bool const always_use_kokkos_sort) { + if (!always_use_kokkos_sort && Impl::try_std_sort(view, exec)) { + return; + } else { + sort(exec, view); + } +} +#endif + template +void sort(ViewType const& view) { + typename ViewType::execution_space exec; + sort(exec, view); + exec.fence("Kokkos::Sort: fence after sorting"); +} + +#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3 +template +KOKKOS_DEPRECATED_WITH_COMMENT( + "Use the overload not taking bool always_use_kokkos_sort") void sort(ViewType const& view, bool const always_use_kokkos_sort = false) { typename ViewType::execution_space exec; sort(exec, view, always_use_kokkos_sort); exec.fence("Kokkos::Sort: fence after sorting"); } +#endif template std::enable_if_t::value> sort( From 066b3aafb8cd060136ca70dc8bfd3408f7f81000 Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Wed, 24 Aug 2022 14:40:03 -0700 Subject: [PATCH 2/5] Update CHANGELOG.md accordingly --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8901c10d37..76c45b3de6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -105,6 +105,7 @@ - Deprecate `Kokkos::common_view_alloc_prop` [\#5059](https://github.com/kokkos/kokkos/pull/5059) - Deprecate `Kokkos::is_reducer_type` [\#4957](https://github.com/kokkos/kokkos/pull/4957) - Deprecate `OffsetView` constructors taking `index_list_type` [\#4810](https://github.com/kokkos/kokkos/pull/4810) +- Deprecate overloads of `Kokkos::sort` taking a parameter `bool always_use_kokkos_sort` [\#5382](https://github.com/kokkos/kokkos/issues/5382) - Warn about `parallel_reduce` cases that call `join()` with volatile-qualified arguments [\#5215](https://github.com/kokkos/kokkos/pull/5215) ### Bug Fixes: From a458fd2e02a3dbee534f79c0cef75d362f3809db Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Wed, 24 Aug 2022 17:49:23 -0700 Subject: [PATCH 3/5] Fix test to match code change --- algorithms/unit_tests/TestSort.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/algorithms/unit_tests/TestSort.hpp b/algorithms/unit_tests/TestSort.hpp index 9108731c158..a4747d5afaa 100644 --- a/algorithms/unit_tests/TestSort.hpp +++ b/algorithms/unit_tests/TestSort.hpp @@ -396,7 +396,7 @@ void test_sort_integer_overflow() { Kokkos::Experimental::finite_min::value}; auto vd = Kokkos::create_mirror_view_and_copy( ExecutionSpace(), Kokkos::View(a)); - Kokkos::sort(vd, /*force using Kokkos bin sort*/ true); + Kokkos::sort(vd); auto vh = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), vd); EXPECT_TRUE(std::is_sorted(vh.data(), vh.data() + 2)) << "view (" << vh[0] << ", " << vh[1] << ") is not sorted"; From e4a717f8bc1053d27a1f70c235f8b2c8dac89feb Mon Sep 17 00:00:00 2001 From: Christian Trott Date: Thu, 25 Aug 2022 11:41:09 -0600 Subject: [PATCH 4/5] Update algorithms/src/Kokkos_Sort.hpp Co-authored-by: Daniel Arndt --- algorithms/src/Kokkos_Sort.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/algorithms/src/Kokkos_Sort.hpp b/algorithms/src/Kokkos_Sort.hpp index b0317c07d66..ad0c2d47b6d 100644 --- a/algorithms/src/Kokkos_Sort.hpp +++ b/algorithms/src/Kokkos_Sort.hpp @@ -650,7 +650,7 @@ void sort(ViewType const& view) { template KOKKOS_DEPRECATED_WITH_COMMENT( "Use the overload not taking bool always_use_kokkos_sort") -void sort(ViewType const& view, bool const always_use_kokkos_sort = false) { +void sort(ViewType const& view, bool const always_use_kokkos_sort) { typename ViewType::execution_space exec; sort(exec, view, always_use_kokkos_sort); exec.fence("Kokkos::Sort: fence after sorting"); From bfd1e0d3a3ecd06ec6805c694538a5d4b0613f1d Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Thu, 25 Aug 2022 10:56:45 -0700 Subject: [PATCH 5/5] Guard deprecated code path in unit test --- algorithms/unit_tests/TestSort.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/algorithms/unit_tests/TestSort.hpp b/algorithms/unit_tests/TestSort.hpp index a4747d5afaa..120a04bdb53 100644 --- a/algorithms/unit_tests/TestSort.hpp +++ b/algorithms/unit_tests/TestSort.hpp @@ -137,7 +137,12 @@ void test_1D_sort_impl(unsigned int n, bool force_kokkos) { // Test sorting array with all numbers equal ExecutionSpace exec; Kokkos::deep_copy(exec, keys, KeyType(1)); +#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3 Kokkos::sort(exec, keys, force_kokkos); +#else + (void)force_kokkos; // suppress warnings about unused variable + Kokkos::sort(exec, keys); +#endif Kokkos::Random_XorShift64_Pool g(1931); Kokkos::fill_random(keys, g, @@ -151,7 +156,11 @@ void test_1D_sort_impl(unsigned int n, bool force_kokkos) { Kokkos::parallel_reduce(Kokkos::RangePolicy(exec, 0, n), sum(keys), sum_before); +#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3 Kokkos::sort(exec, keys, force_kokkos); +#else + Kokkos::sort(exec, keys); +#endif Kokkos::parallel_reduce(Kokkos::RangePolicy(exec, 0, n), sum(keys), sum_after); @@ -407,7 +416,9 @@ void test_sort_integer_overflow() { template void test_1D_sort(unsigned int N) { test_1D_sort_impl(N * N * N, true); +#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3 test_1D_sort_impl(N * N * N, false); +#endif } template