From b3f9f7825b6d039e6f5245ec0accd2f754a3be85 Mon Sep 17 00:00:00 2001 From: Francesco Rizzi Date: Thu, 25 May 2023 11:33:52 -0400 Subject: [PATCH] sorting: add to binsort support for strided views and reorg tests (#6081) * binsort: support strided views, reorg tests [skip ci] * should be working for cuda * cleanup sorting and random tests * cleanup and reorg tests for random and sort * fixes for CI, remove unused guards * update * fix integer type and makefile * fix tests to use hpp, and fix template for windows * formatting * fix typo * rename * use assert_true (sorry DLG for the CI troubles) * fix for nvhpc * address comments * remove wrong closing bracket --- algorithms/src/Kokkos_Sort.hpp | 16 +- algorithms/unit_tests/CMakeLists.txt | 81 +++-- algorithms/unit_tests/Makefile | 8 +- algorithms/unit_tests/TestBinSortA.hpp | 280 ++++++++++++++++++ algorithms/unit_tests/TestBinSortB.hpp | 262 ++++++++++++++++ algorithms/unit_tests/TestNestedSort.hpp | 22 +- algorithms/unit_tests/TestOpenMP_Sort1D.cpp | 39 --- algorithms/unit_tests/TestOpenMP_Sort3D.cpp | 37 --- .../unit_tests/TestOpenMP_SortDynamicView.cpp | 37 --- algorithms/unit_tests/TestRandom.hpp | 41 +-- algorithms/unit_tests/TestRandomCommon.hpp | 32 -- algorithms/unit_tests/TestSort.hpp | 271 ++--------------- algorithms/unit_tests/TestSortCommon.hpp | 39 --- 13 files changed, 656 insertions(+), 509 deletions(-) create mode 100644 algorithms/unit_tests/TestBinSortA.hpp create mode 100644 algorithms/unit_tests/TestBinSortB.hpp delete mode 100644 algorithms/unit_tests/TestOpenMP_Sort1D.cpp delete mode 100644 algorithms/unit_tests/TestOpenMP_Sort3D.cpp delete mode 100644 algorithms/unit_tests/TestOpenMP_SortDynamicView.cpp delete mode 100644 algorithms/unit_tests/TestRandomCommon.hpp delete mode 100644 algorithms/unit_tests/TestSortCommon.hpp diff --git a/algorithms/src/Kokkos_Sort.hpp b/algorithms/src/Kokkos_Sort.hpp index e99a64d000..10f9ad6462 100644 --- a/algorithms/src/Kokkos_Sort.hpp +++ b/algorithms/src/Kokkos_Sort.hpp @@ -146,8 +146,12 @@ class BinSort { Kokkos::is_view::value, Kokkos::View >, + typename SrcViewType::device_type +#if !defined(KOKKOS_COMPILER_NVHPC) // FIXME_NVHPC + , + Kokkos::MemoryTraits +#endif + >, typename SrcViewType::const_type>; using perm_view_type = typename PermuteViewType::const_type; @@ -348,11 +352,6 @@ class BinSort { "The provided execution space must be able to access the memory space " "of the View argument!"); - using scratch_view_type = - Kokkos::View; - const size_t len = range_end - range_begin; const size_t values_len = values_range_end - values_range_begin; if (len != values_len) { @@ -360,6 +359,9 @@ class BinSort { "BinSort::sort: values range length != permutation vector length"); } + using scratch_view_type = + Kokkos::View; scratch_view_type sorted_values( view_alloc(exec, WithoutInitializing, "Kokkos::SortImpl::BinSortFunctor::sorted_values"), diff --git a/algorithms/unit_tests/CMakeLists.txt b/algorithms/unit_tests/CMakeLists.txt index 2d81e70179..92d9f072c1 100644 --- a/algorithms/unit_tests/CMakeLists.txt +++ b/algorithms/unit_tests/CMakeLists.txt @@ -16,35 +16,45 @@ foreach(Tag Threads;Serial;OpenMP;Cuda;HPX;HIP;SYCL;OpenMPTarget) set(dir ${CMAKE_CURRENT_BINARY_DIR}/${dir}) file(MAKE_DIRECTORY ${dir}) - # ------------------------- - # Sort1d,3d, Random - # ------------------------- - set(SOURCES_A) - if(Tag STREQUAL "OpenMP") - LIST(APPEND SOURCES_A - TestOpenMP_Sort1D.cpp - TestOpenMP_Sort3D.cpp - TestOpenMP_SortDynamicView.cpp - ) - endif() - + # ------------------------------------------ + # Sort + # ------------------------------------------ # Each of these inputs is an .hpp file. # Generate a .cpp file for each one that runs it on the current backend (Tag), # and add this .cpp file to the sources for UnitTest_RandomAndSort. - foreach(SOURCES_A_Input - TestRandomCommon - TestSortCommon - TestNestedSort - ) - set(file ${dir}/${SOURCES_A_Input}.cpp) + set(ALGO_SORT_SOURCES) + foreach(SOURCE_Input + TestSort + TestBinSortA + TestBinSortB + TestNestedSort + ) + set(file ${dir}/${SOURCE_Input}.cpp) # Write to a temporary intermediate file and call configure_file to avoid # updating timestamps triggering unnecessary rebuilds on subsequent cmake runs. file(WRITE ${dir}/dummy.cpp "#include \n" - "#include <${SOURCES_A_Input}.hpp>\n" + "#include <${SOURCE_Input}.hpp>\n" + ) + configure_file(${dir}/dummy.cpp ${file}) + list(APPEND ALGO_SORT_SOURCES ${file}) + endforeach() + + # ------------------------------------------ + # Random + # ------------------------------------------ + # do as above + set(ALGO_RANDOM_SOURCES) + foreach(SOURCE_Input + TestRandom + ) + set(file ${dir}/${SOURCE_Input}.cpp) + file(WRITE ${dir}/dummy.cpp + "#include \n" + "#include <${SOURCE_Input}.hpp>\n" ) configure_file(${dir}/dummy.cpp ${file}) - list(APPEND SOURCES_A ${file}) + list(APPEND ALGO_RANDOM_SOURCES ${file}) endforeach() # ------------------------------------------ @@ -145,6 +155,26 @@ foreach(Tag Threads;Serial;OpenMP;Cuda;HPX;HIP;SYCL;OpenMPTarget) endif() endforeach() +# FIXME_OPENMPTARGET This test causes internal compiler errors as of 09/01/22 +# when compiling for Intel's Xe-HP GPUs. +# FRIZZI: 04/26/2023: not sure if the compilation error is still applicable +# but we conservatively leave this guard on +if(NOT (KOKKOS_ENABLE_OPENMPTARGET AND KOKKOS_CXX_COMPILER_ID STREQUAL IntelLLVM)) + KOKKOS_ADD_EXECUTABLE_AND_TEST( + UnitTest_Sort + SOURCES + UnitTestMain.cpp + ${ALGO_SORT_SOURCES} + ) + + KOKKOS_ADD_EXECUTABLE_AND_TEST( + UnitTest_Random + SOURCES + UnitTestMain.cpp + ${ALGO_RANDOM_SOURCES} + ) +endif() + # FIXME_OPENMPTARGET These tests cause internal compiler errors as of 09/01/22 # when compiling for Intel's Xe-HP GPUs. if(KOKKOS_ENABLE_OPENMPTARGET AND KOKKOS_CXX_COMPILER_ID STREQUAL IntelLLVM) @@ -160,17 +190,6 @@ if(KOKKOS_ENABLE_OPENMPTARGET AND KOKKOS_CXX_COMPILER_ID STREQUAL IntelLLVM) ) endif() -# FIXME_OPENMPTARGET This test causes internal compiler errors as of 09/01/22 -# when compiling for Intel's Xe-HP GPUs. -if(NOT (KOKKOS_ENABLE_OPENMPTARGET AND KOKKOS_CXX_COMPILER_ID STREQUAL IntelLLVM)) - KOKKOS_ADD_EXECUTABLE_AND_TEST( - AlgorithmsUnitTest_RandomAndSort - SOURCES - UnitTestMain.cpp - ${SOURCES_A} - ) -endif() - foreach(ID A;B;C;D;E) KOKKOS_ADD_EXECUTABLE_AND_TEST( AlgorithmsUnitTest_StdSet_${ID} diff --git a/algorithms/unit_tests/Makefile b/algorithms/unit_tests/Makefile index e961e7ba2c..9e0f1d60a0 100644 --- a/algorithms/unit_tests/Makefile +++ b/algorithms/unit_tests/Makefile @@ -27,10 +27,8 @@ TARGETS = tmp := $(foreach device, $(KOKKOS_DEVICELIST), \ $(if $(filter Test$(device).cpp, $(shell ls Test$(device).cpp 2>/dev/null)),,\ - $(shell echo "\#include " > Test$(device).cpp); \ - $(shell echo "\#include " >> Test$(device).cpp); \ - $(shell echo "\#include " >> Test$(device).cpp); \ - ) \ + $(shell echo "\#include " > Test$(device).cpp); \ + ) \ ) ifeq ($(KOKKOS_INTERNAL_USE_CUDA), 1) @@ -52,7 +50,7 @@ ifeq ($(KOKKOS_INTERNAL_USE_THREADS), 1) endif ifeq ($(KOKKOS_INTERNAL_USE_OPENMP), 1) - OBJ_OPENMP = TestOpenMP.o TestOpenMP_Sort1D.o TestOpenMP_Sort3D.o TestOpenMP_SortDynamicView.o UnitTestMain.o gtest-all.o + OBJ_OPENMP = TestOpenMP.o UnitTestMain.o gtest-all.o TARGETS += KokkosAlgorithms_UnitTest_OpenMP TEST_TARGETS += test-openmp endif diff --git a/algorithms/unit_tests/TestBinSortA.hpp b/algorithms/unit_tests/TestBinSortA.hpp new file mode 100644 index 0000000000..46f6486cdc --- /dev/null +++ b/algorithms/unit_tests/TestBinSortA.hpp @@ -0,0 +1,280 @@ +//@HEADER +// ************************************************************************ +// +// Kokkos v. 4.0 +// Copyright (2022) National Technology & Engineering +// Solutions of Sandia, LLC (NTESS). +// +// Under the terms of Contract DE-NA0003525 with NTESS, +// the U.S. Government retains certain rights in this software. +// +// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. +// See https://kokkos.org/LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//@HEADER + +#ifndef KOKKOS_ALGORITHMS_UNITTESTS_TEST_BINSORTA_HPP +#define KOKKOS_ALGORITHMS_UNITTESTS_TEST_BINSORTA_HPP + +#include +#include +#include +#include +#include + +namespace Test { +namespace BinSortSetA { + +template +struct bin3d_is_sorted_struct { + using value_type = unsigned int; + using execution_space = ExecutionSpace; + + Kokkos::View keys; + + int max_bins; + Scalar min; + Scalar max; + + bin3d_is_sorted_struct(Kokkos::View keys_, + int max_bins_, Scalar min_, Scalar max_) + : keys(keys_), max_bins(max_bins_), min(min_), max(max_) {} + KOKKOS_INLINE_FUNCTION + void operator()(int i, unsigned int& count) const { + int ix1 = int((keys(i, 0) - min) / max * max_bins); + int iy1 = int((keys(i, 1) - min) / max * max_bins); + int iz1 = int((keys(i, 2) - min) / max * max_bins); + int ix2 = int((keys(i + 1, 0) - min) / max * max_bins); + int iy2 = int((keys(i + 1, 1) - min) / max * max_bins); + int iz2 = int((keys(i + 1, 2) - min) / max * max_bins); + + if (ix1 > ix2) + count++; + else if (ix1 == ix2) { + if (iy1 > iy2) + count++; + else if ((iy1 == iy2) && (iz1 > iz2)) + count++; + } + } +}; + +template +struct sum3D { + using value_type = double; + using execution_space = ExecutionSpace; + + Kokkos::View keys; + + sum3D(Kokkos::View keys_) : keys(keys_) {} + KOKKOS_INLINE_FUNCTION + void operator()(int i, double& count) const { + count += keys(i, 0); + count += keys(i, 1); + count += keys(i, 2); + } +}; + +template +void test_3D_sort_impl(unsigned int n) { + using KeyViewType = Kokkos::View; + + KeyViewType keys("Keys", n * n * n); + + Kokkos::Random_XorShift64_Pool g(1931); + Kokkos::fill_random(keys, g, 100.0); + + double sum_before = 0.0; + double sum_after = 0.0; + unsigned int sort_fails = 0; + + ExecutionSpace exec; + Kokkos::parallel_reduce( + Kokkos::RangePolicy(exec, 0, keys.extent(0)), + sum3D(keys), sum_before); + + int bin_1d = 1; + while (bin_1d * bin_1d * bin_1d * 4 < (int)keys.extent(0)) bin_1d *= 2; + int bin_max[3] = {bin_1d, bin_1d, bin_1d}; + typename KeyViewType::value_type min[3] = {0, 0, 0}; + typename KeyViewType::value_type max[3] = {100, 100, 100}; + + using BinOp = Kokkos::BinOp3D; + BinOp bin_op(bin_max, min, max); + Kokkos::BinSort Sorter(keys, bin_op, false); + Sorter.create_permute_vector(exec); + Sorter.sort(exec, keys); + + Kokkos::parallel_reduce( + Kokkos::RangePolicy(exec, 0, keys.extent(0)), + sum3D(keys), sum_after); + Kokkos::parallel_reduce( + Kokkos::RangePolicy(exec, 0, keys.extent(0) - 1), + bin3d_is_sorted_struct(keys, bin_1d, min[0], + max[0]), + sort_fails); + + double ratio = sum_before / sum_after; + double epsilon = 1e-10; + unsigned int equal_sum = + (ratio > (1.0 - epsilon)) && (ratio < (1.0 + epsilon)) ? 1 : 0; + + if (sort_fails) + printf("3D Sort Sum: %f %f Fails: %u\n", sum_before, sum_after, sort_fails); + + ASSERT_EQ(sort_fails, 0u); + ASSERT_EQ(equal_sum, 1u); +} + +template +void test_issue_1160_impl() { + Kokkos::View element_("element", 10); + Kokkos::View x_("x", 10); + Kokkos::View v_("y", 10); + + auto h_element = Kokkos::create_mirror_view(element_); + auto h_x = Kokkos::create_mirror_view(x_); + auto h_v = Kokkos::create_mirror_view(v_); + + h_element(0) = 9; + h_element(1) = 8; + h_element(2) = 7; + h_element(3) = 6; + h_element(4) = 5; + h_element(5) = 4; + h_element(6) = 3; + h_element(7) = 2; + h_element(8) = 1; + h_element(9) = 0; + + for (int i = 0; i < 10; ++i) { + h_v.access(i, 0) = h_x.access(i, 0) = double(h_element(i)); + } + ExecutionSpace exec; + Kokkos::deep_copy(exec, element_, h_element); + Kokkos::deep_copy(exec, x_, h_x); + Kokkos::deep_copy(exec, v_, h_v); + + using KeyViewType = decltype(element_); + using BinOp = Kokkos::BinOp1D; + + int begin = 3; + int end = 8; + auto max = h_element(begin); + auto min = h_element(end - 1); + BinOp binner(end - begin, min, max); + + Kokkos::BinSort Sorter(element_, begin, end, binner, + false); + Sorter.create_permute_vector(exec); + Sorter.sort(exec, element_, begin, end); + + Sorter.sort(exec, x_, begin, end); + Sorter.sort(exec, v_, begin, end); + + Kokkos::deep_copy(exec, h_element, element_); + Kokkos::deep_copy(exec, h_x, x_); + Kokkos::deep_copy(exec, h_v, v_); + exec.fence(); + + ASSERT_EQ(h_element(0), 9); + ASSERT_EQ(h_element(1), 8); + ASSERT_EQ(h_element(2), 7); + ASSERT_EQ(h_element(3), 2); + ASSERT_EQ(h_element(4), 3); + ASSERT_EQ(h_element(5), 4); + ASSERT_EQ(h_element(6), 5); + ASSERT_EQ(h_element(7), 6); + ASSERT_EQ(h_element(8), 1); + ASSERT_EQ(h_element(9), 0); + + for (int i = 0; i < 10; ++i) { + ASSERT_EQ(h_element(i), int(h_x.access(i, 0))); + ASSERT_EQ(h_element(i), int(h_v.access(i, 0))); + } +} + +template +void test_sort_integer_overflow() { + // FIXME: this test is meant to test something for BinSort, + // but actually uses the kokkos::sort API with the assumption + // that underneath it calls binsort. I don't think this is correct, + // because if the kokkos::sort API chages impl, this test is not testing + // what it meants to test... so need to change this to actually use BinSort + // directly. + + // array with two extrema in reverse order to expose integer overflow bug in + // bin calculation + T a[2] = {Kokkos::Experimental::finite_max::value, + Kokkos::Experimental::finite_min::value}; + auto vd = Kokkos::create_mirror_view_and_copy( + ExecutionSpace(), Kokkos::View(a)); + 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"; +} + +} // namespace BinSortSetA + +TEST(TEST_CATEGORY, BinSortGenericTests) { + using ExecutionSpace = TEST_EXECSPACE; + using key_type = unsigned; + constexpr int N = 171; + +#if defined(KOKKOS_ENABLE_CUDA) && \ + defined(KOKKOS_COMPILER_NVHPC) // FIXME_NVHPC + if (!std::is_same_v) +#endif + BinSortSetA::test_3D_sort_impl(N); + +#if defined(KOKKOS_ENABLE_CUDA) && \ + defined(KOKKOS_COMPILER_NVHPC) // FIXME_NVHPC + if (!std::is_same_v) +#endif + BinSortSetA::test_issue_1160_impl(); + + BinSortSetA::test_sort_integer_overflow(); + BinSortSetA::test_sort_integer_overflow(); + BinSortSetA::test_sort_integer_overflow(); +} + +TEST(TEST_CATEGORY, BinSortEmptyView) { + using ExecutionSpace = TEST_EXECSPACE; + + // the bounds and extents used below are totally arbitrary + // and, in theory, should have no impact + + using KeyViewType = Kokkos::View; + KeyViewType kv("kv", 20); + + using BinOp_t = Kokkos::BinOp1D; + BinOp_t binOp(5, 0, 10); + Kokkos::BinSort Sorter(ExecutionSpace{}, kv, binOp); + + // does not matter if we use int or something else + Kokkos::View v("v", 0); + + // test all exposed public sort methods + ASSERT_NO_THROW(Sorter.sort(ExecutionSpace(), v, 0, 0)); + ASSERT_NO_THROW(Sorter.sort(v, 0, 0)); + ASSERT_NO_THROW(Sorter.sort(ExecutionSpace(), v)); + ASSERT_NO_THROW(Sorter.sort(v)); +} + +TEST(TEST_CATEGORY, BinSortEmptyKeysView) { + using ExecutionSpace = TEST_EXECSPACE; + + using KeyViewType = Kokkos::View; + KeyViewType kv("kv", 0); + + using BinOp_t = Kokkos::BinOp1D; + BinOp_t binOp(5, 0, 10); + Kokkos::BinSort Sorter(ExecutionSpace{}, kv, binOp); + + ASSERT_NO_THROW(Sorter.create_permute_vector(ExecutionSpace{})); +} + +} // namespace Test +#endif diff --git a/algorithms/unit_tests/TestBinSortB.hpp b/algorithms/unit_tests/TestBinSortB.hpp new file mode 100644 index 0000000000..0707411f59 --- /dev/null +++ b/algorithms/unit_tests/TestBinSortB.hpp @@ -0,0 +1,262 @@ +//@HEADER +// ************************************************************************ +// +// Kokkos v. 4.0 +// Copyright (2022) National Technology & Engineering +// Solutions of Sandia, LLC (NTESS). +// +// Under the terms of Contract DE-NA0003525 with NTESS, +// the U.S. Government retains certain rights in this software. +// +// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. +// See https://kokkos.org/LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//@HEADER + +#ifndef KOKKOS_ALGORITHMS_UNITTESTS_TEST_BINSORTB_HPP +#define KOKKOS_ALGORITHMS_UNITTESTS_TEST_BINSORTB_HPP + +#include +#include +#include +#include +#include +#include +#include +#include //needed for iota + +namespace Test { +namespace BinSortSetB { + +template +struct CopyFunctorRank2 { + ViewTypeFrom m_view_from; + ViewTypeTo m_view_to; + + CopyFunctorRank2() = delete; + + CopyFunctorRank2(const ViewTypeFrom view_from, const ViewTypeTo view_to) + : m_view_from(view_from), m_view_to(view_to) {} + + KOKKOS_INLINE_FUNCTION + void operator()(int k) const { + const auto i = k / m_view_from.extent(1); + const auto j = k % m_view_from.extent(1); + m_view_to(i, j) = m_view_from(i, j); + } +}; + +template +auto create_deep_copyable_compatible_view_with_same_extent( + Kokkos::View view) { + using view_type = Kokkos::View; + using view_value_type = typename view_type::value_type; + using view_exespace = typename view_type::execution_space; + const std::size_t ext0 = view.extent(0); + using view_deep_copyable_t = Kokkos::View; + return view_deep_copyable_t{"view_dc", ext0}; +} + +template +auto create_deep_copyable_compatible_view_with_same_extent( + Kokkos::View view) { + using view_type = Kokkos::View; + using view_value_type = typename view_type::value_type; + using view_exespace = typename view_type::execution_space; + using view_deep_copyable_t = Kokkos::View; + const std::size_t ext0 = view.extent(0); + const std::size_t ext1 = view.extent(1); + return view_deep_copyable_t{"view_dc", ext0, ext1}; +} + +template +auto create_deep_copyable_compatible_clone(ViewType view) { + static_assert(ViewType::rank <= 2); + + auto view_dc = create_deep_copyable_compatible_view_with_same_extent(view); + using view_dc_t = decltype(view_dc); + if constexpr (ViewType::rank == 1) { + Test::stdalgos::CopyFunctor F1(view, view_dc); + Kokkos::parallel_for("copy", view.extent(0), F1); + } else { + static_assert(ViewType::rank == 2, "Only rank 1 or 2 supported."); + CopyFunctorRank2 F1(view, view_dc); + Kokkos::parallel_for("copy", view.extent(0) * view.extent(1), F1); + } + return view_dc; +} + +template +auto create_host_space_copy(ViewType view) { + auto view_dc = create_deep_copyable_compatible_clone(view); + return create_mirror_view_and_copy(Kokkos::HostSpace(), view_dc); +} + +template +auto create_rank1_dev_and_host_views_of_keys(const ExecutionSpace& exec, + int N) { + namespace KE = Kokkos::Experimental; + Kokkos::DefaultHostExecutionSpace defaultHostExeSpace; + + using KeyViewType = Kokkos::View; + KeyViewType keys("keys", N); + auto keys_h = Kokkos::create_mirror_view(keys); + std::iota(KE::begin(keys_h), KE::end(keys_h), KeyType(0)); + KE::reverse(defaultHostExeSpace, keys_h); + // keys now is = [N-1,N-2,...,2,1,0], shuffle it for avoid trivial case + std::random_device rd; + std::mt19937 g(rd()); + std::shuffle(KE::begin(keys_h), KE::end(keys_h), g); + Kokkos::deep_copy(exec, keys, keys_h); + + return std::make_pair(keys, keys_h); +} + +template = 0> +auto create_strided_view(std::size_t numRows, std::size_t /*numCols*/) { + Kokkos::LayoutStride layout{numRows, 2}; + using v_t = Kokkos::View; + v_t v("v", layout); + return v; +} + +template = 0> +auto create_strided_view(std::size_t numRows, std::size_t numCols) { + Kokkos::LayoutStride layout{numRows, 2, numCols, numRows * 2}; + using v_t = Kokkos::View; + v_t v("v", layout); + return v; +} + +template +void test_on_view_with_stride(std::size_t numRows, std::size_t indB, + std::size_t indE, std::size_t numCols = 1) { + ExecutionSpace exec; + Kokkos::DefaultHostExecutionSpace defaultHostExeSpace; + namespace KE = Kokkos::Experimental; + + // 1. generate 1D view of keys + auto [keys, keys_h] = + create_rank1_dev_and_host_views_of_keys(exec, numRows); + using KeyViewType = decltype(keys); + + // need this map key->row to use later for checking + std::unordered_map keyToRowBeforeSort; + for (std::size_t i = 0; i < numRows; ++i) { + keyToRowBeforeSort[keys_h(i)] = i; + } + + // 2. create binOp + using BinOp = Kokkos::BinOp1D; + auto itB = KE::cbegin(keys_h) + indB; + auto itE = itB + indE - indB; + auto it = KE::minmax_element(defaultHostExeSpace, itB, itE); + // seems like the behavior is odd when we use # buckets = # keys + // so use +5 for using more buckets than keys. + // This is something to investigate. + BinOp binner(indE - indB + 5, *it.first, *it.second); + + // 3. create sorter + Kokkos::BinSort sorter(keys, indB, indE, binner, false); + sorter.create_permute_vector(exec); + sorter.sort(exec, keys, indB, indE); + Kokkos::deep_copy(exec, keys_h, keys); + + auto v = create_strided_view( + numRows, numCols); + + Kokkos::Random_XorShift64_Pool pool(73931); + Kokkos::fill_random(v, pool, ValueType(545)); + auto v_before_sort_h = create_host_space_copy(v); + sorter.sort(exec, v, indB, indE); + auto v_after_sort_h = create_host_space_copy(v); + + for (size_t i = 0; i < v.extent(0); ++i) { + // if i within [indB,indE), the sorting was done + // so we need to do proper checking since rows have changed + if (i >= size_t(indB) && i < size_t(indE)) { + const KeyType key = keys_h(i); + if constexpr (ValuesViewRank == 1) { + ASSERT_TRUE(v_before_sort_h(keyToRowBeforeSort.at(key)) == + v_after_sort_h(i)); + } else { + for (size_t j = 0; j < v.extent(1); ++j) { + ASSERT_TRUE(v_before_sort_h(keyToRowBeforeSort.at(key), j) == + v_after_sort_h(i, j)); + } + } + } + // outside the target bounds, then the i-th row remains unchanged + else { + if constexpr (ValuesViewRank == 1) { + ASSERT_TRUE(v_before_sort_h(i) == v_after_sort_h(i)); + } else { + for (size_t j = 0; j < v.extent(1); ++j) { + ASSERT_TRUE(v_before_sort_h(i, j) == v_after_sort_h(i, j)); + } + } + } + } +} + +template +void run_for_rank1() { + constexpr int rank = 1; + + // trivial case + test_on_view_with_stride(1, 0, 1); + + // nontrivial cases + for (std::size_t N : {311, 710017}) { + // various cases for bounds + test_on_view_with_stride(N, 0, N); + test_on_view_with_stride(N, 3, N); + test_on_view_with_stride(N, 0, + N - 4); + test_on_view_with_stride(N, 4, + N - 3); + } +} + +template +void run_for_rank2() { + constexpr int rank = 2; + + // trivial case + test_on_view_with_stride(1, 0, 1, + 1); + + // nontrivial cases + for (std::size_t Nr : {11, 1157, 710017}) { + for (std::size_t Nc : {3, 51}) { + // various cases for bounds + test_on_view_with_stride( + Nr, 0, Nr, Nc); + test_on_view_with_stride( + Nr, 3, Nr, Nc); + test_on_view_with_stride( + Nr, 0, Nr - 4, Nc); + test_on_view_with_stride( + Nr, 4, Nr - 3, Nc); + } + } +} + +} // namespace BinSortSetB + +TEST(TEST_CATEGORY, BinSortUnsignedKeyLayoutStrideValues) { + using ExeSpace = TEST_EXECSPACE; + using key_type = unsigned; + BinSortSetB::run_for_rank1(); + BinSortSetB::run_for_rank1(); + + BinSortSetB::run_for_rank2(); + BinSortSetB::run_for_rank2(); +} + +} // namespace Test +#endif diff --git a/algorithms/unit_tests/TestNestedSort.hpp b/algorithms/unit_tests/TestNestedSort.hpp index 37ee211b42..1b7a3f48fc 100644 --- a/algorithms/unit_tests/TestNestedSort.hpp +++ b/algorithms/unit_tests/TestNestedSort.hpp @@ -17,14 +17,14 @@ #ifndef KOKKOS_ALGORITHMS_UNITTESTS_TEST_NESTED_SORT_HPP #define KOKKOS_ALGORITHMS_UNITTESTS_TEST_NESTED_SORT_HPP +#include #include #include #include #include namespace Test { - -namespace Impl { +namespace NestedSortImpl { // Comparator for sorting in descending order template @@ -383,24 +383,28 @@ void test_nested_sort_by_key(unsigned int N, KeyType minKey, KeyType maxKey, test_nested_sort_by_key_impl( N, N, false, true, minKey, maxKey, minVal, maxVal); } -} // namespace Impl +} // namespace NestedSortImpl TEST(TEST_CATEGORY, NestedSort) { - Impl::test_nested_sort(171, 0U, UINT_MAX); - Impl::test_nested_sort(42, -1e6f, 1e6f); - Impl::test_nested_sort(67, CHAR_MIN, CHAR_MAX); + using ExecutionSpace = TEST_EXECSPACE; + NestedSortImpl::test_nested_sort(171, 0U, UINT_MAX); + NestedSortImpl::test_nested_sort(42, -1e6f, 1e6f); + NestedSortImpl::test_nested_sort(67, CHAR_MIN, + CHAR_MAX); } TEST(TEST_CATEGORY, NestedSortByKey) { + using ExecutionSpace = TEST_EXECSPACE; + // Second/third template arguments are key and value respectively. // In sort_by_key_X functions, a key view and a value view are both permuted // to make the keys sorted. This means that the value type doesn't need to be // ordered, unlike key - Impl::test_nested_sort_by_key( + NestedSortImpl::test_nested_sort_by_key( 161, 0U, UINT_MAX, 0U, UINT_MAX); - Impl::test_nested_sort_by_key( + NestedSortImpl::test_nested_sort_by_key( 267, -1e6f, 1e6f, CHAR_MIN, CHAR_MAX); - Impl::test_nested_sort_by_key( + NestedSortImpl::test_nested_sort_by_key( 11, CHAR_MIN, CHAR_MAX, 2.718, 3.14); } diff --git a/algorithms/unit_tests/TestOpenMP_Sort1D.cpp b/algorithms/unit_tests/TestOpenMP_Sort1D.cpp deleted file mode 100644 index e06486618f..0000000000 --- a/algorithms/unit_tests/TestOpenMP_Sort1D.cpp +++ /dev/null @@ -1,39 +0,0 @@ -//@HEADER -// ************************************************************************ -// -// Kokkos v. 4.0 -// Copyright (2022) National Technology & Engineering -// Solutions of Sandia, LLC (NTESS). -// -// Under the terms of Contract DE-NA0003525 with NTESS, -// the U.S. Government retains certain rights in this software. -// -// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. -// See https://kokkos.org/LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//@HEADER - -#include -#ifdef KOKKOS_ENABLE_OPENMP - -#include -#include - -//---------------------------------------------------------------------------- -#include -#include -#include - -namespace Test { - -TEST(openmp, SortUnsigned1D) { - Impl::test_1D_sort(171); -} - -TEST(openmp, SortIssue1160) { Impl::test_issue_1160_sort(); } - -} // namespace Test -#else -void KOKKOS_ALGORITHMS_UNITTESTS_TESTOPENMP_PREVENT_LINK_ERROR() {} -#endif diff --git a/algorithms/unit_tests/TestOpenMP_Sort3D.cpp b/algorithms/unit_tests/TestOpenMP_Sort3D.cpp deleted file mode 100644 index cd6e8e8cbf..0000000000 --- a/algorithms/unit_tests/TestOpenMP_Sort3D.cpp +++ /dev/null @@ -1,37 +0,0 @@ -//@HEADER -// ************************************************************************ -// -// Kokkos v. 4.0 -// Copyright (2022) National Technology & Engineering -// Solutions of Sandia, LLC (NTESS). -// -// Under the terms of Contract DE-NA0003525 with NTESS, -// the U.S. Government retains certain rights in this software. -// -// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. -// See https://kokkos.org/LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//@HEADER - -#include -#ifdef KOKKOS_ENABLE_OPENMP - -#include -#include - -//---------------------------------------------------------------------------- -#include -#include -#include - -namespace Test { - -TEST(openmp, SortUnsigned3D) { - Impl::test_3D_sort(171); -} - -} // namespace Test -#else -void KOKKOS_ALGORITHMS_UNITTESTS_TESTOPENMP_PREVENT_LINK_ERROR() {} -#endif diff --git a/algorithms/unit_tests/TestOpenMP_SortDynamicView.cpp b/algorithms/unit_tests/TestOpenMP_SortDynamicView.cpp deleted file mode 100644 index 549d09f1f2..0000000000 --- a/algorithms/unit_tests/TestOpenMP_SortDynamicView.cpp +++ /dev/null @@ -1,37 +0,0 @@ -//@HEADER -// ************************************************************************ -// -// Kokkos v. 4.0 -// Copyright (2022) National Technology & Engineering -// Solutions of Sandia, LLC (NTESS). -// -// Under the terms of Contract DE-NA0003525 with NTESS, -// the U.S. Government retains certain rights in this software. -// -// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. -// See https://kokkos.org/LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//@HEADER - -#include -#ifdef KOKKOS_ENABLE_OPENMP - -#include -#include - -//---------------------------------------------------------------------------- -#include -#include -#include - -namespace Test { - -TEST(openmp, SortUnsignedDynamicView) { - Impl::test_dynamic_view_sort(171); -} - -} // namespace Test -#else -void KOKKOS_ALGORITHMS_UNITTESTS_TESTOPENMP_PREVENT_LINK_ERROR() {} -#endif diff --git a/algorithms/unit_tests/TestRandom.hpp b/algorithms/unit_tests/TestRandom.hpp index 607e94c784..e9dc3327a6 100644 --- a/algorithms/unit_tests/TestRandom.hpp +++ b/algorithms/unit_tests/TestRandom.hpp @@ -14,8 +14,8 @@ // //@HEADER -#ifndef KOKKOS_TEST_DUALVIEW_HPP -#define KOKKOS_TEST_DUALVIEW_HPP +#ifndef KOKKOS_ALGORITHMS_UNITTESTS_TEST_RANDOM_HPP +#define KOKKOS_ALGORITHMS_UNITTESTS_TEST_RANDOM_HPP #include #include @@ -29,8 +29,7 @@ #include namespace Test { - -namespace Impl { +namespace AlgoRandomImpl { // This test runs the random number generators and uses some statistic tests to // check the 'goodness' of the random numbers: @@ -469,42 +468,46 @@ struct TestDynRankView { ASSERT_LE(val.max_val, max); } }; -} // namespace Impl -template -void test_random_xorshift64() { +} // namespace AlgoRandomImpl + +TEST(TEST_CATEGORY, Random_XorShift64) { + using ExecutionSpace = TEST_EXECSPACE; + #if defined(KOKKOS_ENABLE_SYCL) || defined(KOKKOS_ENABLE_CUDA) || \ defined(KOKKOS_ENABLE_HIP) const int num_draws = 132141141; #else // SERIAL, HPX, OPENMP const int num_draws = 10240000; #endif - Impl::test_random>(num_draws); - Impl::test_random>( + num_draws); + AlgoRandomImpl::test_random>>( num_draws); - Impl::TestDynRankView>(10000) + AlgoRandomImpl::TestDynRankView< + ExecutionSpace, Kokkos::Random_XorShift64_Pool>(10000) .run(); } -template -void test_random_xorshift1024() { +TEST(TEST_CATEGORY, Random_XorShift1024_0) { + using ExecutionSpace = TEST_EXECSPACE; + #if defined(KOKKOS_ENABLE_SYCL) || defined(KOKKOS_ENABLE_CUDA) || \ defined(KOKKOS_ENABLE_HIP) const int num_draws = 52428813; #else // SERIAL, HPX, OPENMP const int num_draws = 10130144; #endif - Impl::test_random>( + AlgoRandomImpl::test_random>( num_draws); - Impl::test_random>>( num_draws); - Impl::TestDynRankView>(10000) + AlgoRandomImpl::TestDynRankView< + ExecutionSpace, Kokkos::Random_XorShift1024_Pool>(10000) .run(); } -} // namespace Test -#endif // KOKKOS_TEST_UNORDERED_MAP_HPP +} // namespace Test +#endif diff --git a/algorithms/unit_tests/TestRandomCommon.hpp b/algorithms/unit_tests/TestRandomCommon.hpp deleted file mode 100644 index c53d66f4d0..0000000000 --- a/algorithms/unit_tests/TestRandomCommon.hpp +++ /dev/null @@ -1,32 +0,0 @@ -//@HEADER -// ************************************************************************ -// -// Kokkos v. 4.0 -// Copyright (2022) National Technology & Engineering -// Solutions of Sandia, LLC (NTESS). -// -// Under the terms of Contract DE-NA0003525 with NTESS, -// the U.S. Government retains certain rights in this software. -// -// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. -// See https://kokkos.org/LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//@HEADER - -#ifndef KOKKOS_ALGORITHMS_UNITTESTS_TESTRANDOM_COMMON_HPP -#define KOKKOS_ALGORITHMS_UNITTESTS_TESTRANDOM_COMMON_HPP - -#include - -namespace Test { - -TEST(TEST_CATEGORY, Random_XorShift64) { - test_random_xorshift64(); -} -TEST(TEST_CATEGORY, Random_XorShift1024_0) { - test_random_xorshift1024(); -} -} // namespace Test - -#endif diff --git a/algorithms/unit_tests/TestSort.hpp b/algorithms/unit_tests/TestSort.hpp index 9ac606c535..968fb8950b 100644 --- a/algorithms/unit_tests/TestSort.hpp +++ b/algorithms/unit_tests/TestSort.hpp @@ -14,8 +14,8 @@ // //@HEADER -#ifndef KOKKOS_ALGORITHMS_UNITTESTS_TESTSORT_HPP -#define KOKKOS_ALGORITHMS_UNITTESTS_TESTSORT_HPP +#ifndef KOKKOS_ALGORITHMS_UNITTESTS_TEST_SORT_HPP +#define KOKKOS_ALGORITHMS_UNITTESTS_TEST_SORT_HPP #include #include @@ -24,8 +24,7 @@ #include namespace Test { - -namespace Impl { +namespace SortImpl { template struct is_sorted_struct { @@ -53,56 +52,6 @@ struct sum { void operator()(int i, double& count) const { count += keys(i); } }; -template -struct bin3d_is_sorted_struct { - using value_type = unsigned int; - using execution_space = ExecutionSpace; - - Kokkos::View keys; - - int max_bins; - Scalar min; - Scalar max; - - bin3d_is_sorted_struct(Kokkos::View keys_, - int max_bins_, Scalar min_, Scalar max_) - : keys(keys_), max_bins(max_bins_), min(min_), max(max_) {} - KOKKOS_INLINE_FUNCTION - void operator()(int i, unsigned int& count) const { - int ix1 = int((keys(i, 0) - min) / max * max_bins); - int iy1 = int((keys(i, 1) - min) / max * max_bins); - int iz1 = int((keys(i, 2) - min) / max * max_bins); - int ix2 = int((keys(i + 1, 0) - min) / max * max_bins); - int iy2 = int((keys(i + 1, 1) - min) / max * max_bins); - int iz2 = int((keys(i + 1, 2) - min) / max * max_bins); - - if (ix1 > ix2) - count++; - else if (ix1 == ix2) { - if (iy1 > iy2) - count++; - else if ((iy1 == iy2) && (iz1 > iz2)) - count++; - } - } -}; - -template -struct sum3D { - using value_type = double; - using execution_space = ExecutionSpace; - - Kokkos::View keys; - - sum3D(Kokkos::View keys_) : keys(keys_) {} - KOKKOS_INLINE_FUNCTION - void operator()(int i, double& count) const { - count += keys(i, 0); - count += keys(i, 1); - count += keys(i, 2); - } -}; - template void test_1D_sort_impl(unsigned int n) { using KeyViewType = Kokkos::View; @@ -142,57 +91,6 @@ void test_1D_sort_impl(unsigned int n) { ASSERT_EQ(equal_sum, 1u); } -template -void test_3D_sort_impl(unsigned int n) { - using KeyViewType = Kokkos::View; - - KeyViewType keys("Keys", n * n * n); - - Kokkos::Random_XorShift64_Pool g(1931); - Kokkos::fill_random(keys, g, 100.0); - - double sum_before = 0.0; - double sum_after = 0.0; - unsigned int sort_fails = 0; - - ExecutionSpace exec; - Kokkos::parallel_reduce( - Kokkos::RangePolicy(exec, 0, keys.extent(0)), - sum3D(keys), sum_before); - - int bin_1d = 1; - while (bin_1d * bin_1d * bin_1d * 4 < (int)keys.extent(0)) bin_1d *= 2; - int bin_max[3] = {bin_1d, bin_1d, bin_1d}; - typename KeyViewType::value_type min[3] = {0, 0, 0}; - typename KeyViewType::value_type max[3] = {100, 100, 100}; - - using BinOp = Kokkos::BinOp3D; - BinOp bin_op(bin_max, min, max); - Kokkos::BinSort Sorter(keys, bin_op, false); - Sorter.create_permute_vector(exec); - Sorter.sort(exec, keys); - - Kokkos::parallel_reduce( - Kokkos::RangePolicy(exec, 0, keys.extent(0)), - sum3D(keys), sum_after); - Kokkos::parallel_reduce( - Kokkos::RangePolicy(exec, 0, keys.extent(0) - 1), - bin3d_is_sorted_struct(keys, bin_1d, min[0], - max[0]), - sort_fails); - - double ratio = sum_before / sum_after; - double epsilon = 1e-10; - unsigned int equal_sum = - (ratio > (1.0 - epsilon)) && (ratio < (1.0 + epsilon)) ? 1 : 0; - - if (sort_fails) - printf("3D Sort Sum: %f %f Fails: %u\n", sum_before, sum_after, sort_fails); - - ASSERT_EQ(sort_fails, 0u); - ASSERT_EQ(equal_sum, 1u); -} - //---------------------------------------------------------------------------- template @@ -259,74 +157,6 @@ void test_dynamic_view_sort_impl(unsigned int n) { //---------------------------------------------------------------------------- -template -void test_issue_1160_impl() { - Kokkos::View element_("element", 10); - Kokkos::View x_("x", 10); - Kokkos::View v_("y", 10); - - auto h_element = Kokkos::create_mirror_view(element_); - auto h_x = Kokkos::create_mirror_view(x_); - auto h_v = Kokkos::create_mirror_view(v_); - - h_element(0) = 9; - h_element(1) = 8; - h_element(2) = 7; - h_element(3) = 6; - h_element(4) = 5; - h_element(5) = 4; - h_element(6) = 3; - h_element(7) = 2; - h_element(8) = 1; - h_element(9) = 0; - - for (int i = 0; i < 10; ++i) { - h_v.access(i, 0) = h_x.access(i, 0) = double(h_element(i)); - } - ExecutionSpace exec; - Kokkos::deep_copy(exec, element_, h_element); - Kokkos::deep_copy(exec, x_, h_x); - Kokkos::deep_copy(exec, v_, h_v); - - using KeyViewType = decltype(element_); - using BinOp = Kokkos::BinOp1D; - - int begin = 3; - int end = 8; - auto max = h_element(begin); - auto min = h_element(end - 1); - BinOp binner(end - begin, min, max); - - Kokkos::BinSort Sorter(element_, begin, end, binner, - false); - Sorter.create_permute_vector(exec); - Sorter.sort(exec, element_, begin, end); - - Sorter.sort(exec, x_, begin, end); - Sorter.sort(exec, v_, begin, end); - - Kokkos::deep_copy(exec, h_element, element_); - Kokkos::deep_copy(exec, h_x, x_); - Kokkos::deep_copy(exec, h_v, v_); - exec.fence(); - - ASSERT_EQ(h_element(0), 9); - ASSERT_EQ(h_element(1), 8); - ASSERT_EQ(h_element(2), 7); - ASSERT_EQ(h_element(3), 2); - ASSERT_EQ(h_element(4), 3); - ASSERT_EQ(h_element(5), 4); - ASSERT_EQ(h_element(6), 5); - ASSERT_EQ(h_element(7), 6); - ASSERT_EQ(h_element(8), 1); - ASSERT_EQ(h_element(9), 0); - - for (int i = 0; i < 10; ++i) { - ASSERT_EQ(h_element(i), int(h_x.access(i, 0))); - ASSERT_EQ(h_element(i), int(h_v.access(i, 0))); - } -} - template void test_issue_4978_impl() { Kokkos::View element_("element", 9); @@ -376,58 +206,26 @@ void test_sort_integer_overflow() { << "view (" << vh[0] << ", " << vh[1] << ") is not sorted"; } -//---------------------------------------------------------------------------- - -template -void test_1D_sort(unsigned int N) { - test_1D_sort_impl(N * N * N); -} - -template -void test_3D_sort(unsigned int N) { - test_3D_sort_impl(N); -} - -template -void test_dynamic_view_sort(unsigned int N) { - test_dynamic_view_sort_impl(N * N); -} +} // namespace SortImpl -template -void test_issue_1160_sort() { - test_issue_1160_impl(); -} +TEST(TEST_CATEGORY, SortUnsignedValueType) { + using ExecutionSpace = TEST_EXECSPACE; + using key_type = unsigned; + constexpr int N = 171; -template -void test_issue_4978_sort() { - test_issue_4978_impl(); -} + SortImpl::test_1D_sort_impl(N * N * N); -template -void test_sort(unsigned int N) { - test_1D_sort(N); -#if defined(KOKKOS_ENABLE_CUDA) && \ - defined(KOKKOS_COMPILER_NVHPC) // FIXME_NVHPC - if (!std::is_same_v) -#endif - test_3D_sort(N); -// FIXME_OPENMPTARGET: OpenMPTarget doesn't support DynamicView yet. #ifndef KOKKOS_ENABLE_OPENMPTARGET - test_dynamic_view_sort(N); -#endif -#if defined(KOKKOS_ENABLE_CUDA) && \ - defined(KOKKOS_COMPILER_NVHPC) // FIXME_NVHPC - if (!std::is_same_v) + // FIXME_OPENMPTARGET: OpenMPTarget doesn't support DynamicView yet. + SortImpl::test_dynamic_view_sort_impl(N * N); #endif - test_issue_1160_sort(); - test_issue_4978_sort(); - test_sort_integer_overflow(); - test_sort_integer_overflow(); - test_sort_integer_overflow(); + + SortImpl::test_issue_4978_impl(); } -template -void test_sort_empty_view() { +TEST(TEST_CATEGORY, SortEmptyView) { + using ExecutionSpace = TEST_EXECSPACE; + // does not matter if we use int or something else Kokkos::View v("v", 0); @@ -436,40 +234,5 @@ void test_sort_empty_view() { ASSERT_NO_THROW(Kokkos::sort(v)); } -template -void test_binsort_empty_view() { - // the bounds and extents used below are totally arbitrary - // and, in theory, should have no impact - - using KeyViewType = Kokkos::View; - KeyViewType kv("kv", 20); - - using BinOp_t = Kokkos::BinOp1D; - BinOp_t binOp(5, 0, 10); - Kokkos::BinSort Sorter(ExecutionSpace{}, kv, binOp); - - // does not matter if we use int or something else - Kokkos::View v("v", 0); - - // test all exposed public sort methods - ASSERT_NO_THROW(Sorter.sort(ExecutionSpace(), v, 0, 0)); - ASSERT_NO_THROW(Sorter.sort(v, 0, 0)); - ASSERT_NO_THROW(Sorter.sort(ExecutionSpace(), v)); - ASSERT_NO_THROW(Sorter.sort(v)); -} - -template -void test_binsort_empty_keys() { - using KeyViewType = Kokkos::View; - KeyViewType kv("kv", 0); - - using BinOp_t = Kokkos::BinOp1D; - BinOp_t binOp(5, 0, 10); - Kokkos::BinSort Sorter(ExecutionSpace{}, kv, binOp); - - ASSERT_NO_THROW(Sorter.create_permute_vector(ExecutionSpace{})); -} - -} // namespace Impl } // namespace Test -#endif /* KOKKOS_ALGORITHMS_UNITTESTS_TESTSORT_HPP */ +#endif diff --git a/algorithms/unit_tests/TestSortCommon.hpp b/algorithms/unit_tests/TestSortCommon.hpp deleted file mode 100644 index 628ce905ac..0000000000 --- a/algorithms/unit_tests/TestSortCommon.hpp +++ /dev/null @@ -1,39 +0,0 @@ -//@HEADER -// ************************************************************************ -// -// Kokkos v. 4.0 -// Copyright (2022) National Technology & Engineering -// Solutions of Sandia, LLC (NTESS). -// -// Under the terms of Contract DE-NA0003525 with NTESS, -// the U.S. Government retains certain rights in this software. -// -// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. -// See https://kokkos.org/LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//@HEADER - -#ifndef KOKKOS_ALGORITHMS_UNITTESTS_TESTSORT_COMMON_HPP -#define KOKKOS_ALGORITHMS_UNITTESTS_TESTSORT_COMMON_HPP - -#include - -namespace Test { -TEST(TEST_CATEGORY, SortUnsigned) { - Impl::test_sort(171); -} - -TEST(TEST_CATEGORY, SortEmptyView) { - Impl::test_sort_empty_view(); -} - -TEST(TEST_CATEGORY, BinSortEmptyView) { - Impl::test_binsort_empty_view(); -} - -TEST(TEST_CATEGORY, BinSortEmptyKeys) { - Impl::test_binsort_empty_keys(); -} -} // namespace Test -#endif