33 * * SPDX-License-Identifier: BSD-3-Clause
44 * *******************************************/
55
6- #include " avx512-16bit-qsort.hpp"
7- #include " avx512-32bit-qsort.hpp"
8- #include " avx512-64bit-keyvaluesort.hpp"
9- #include " avx512-64bit-qsort.hpp"
10- #include " cpuinfo.h"
6+ #include " avx512-common-keyvaluesort.h"
117#include " rand_array.h"
128#include < gtest/gtest.h>
139#include < vector>
1410
15- template <typename T>
16- class avx512_sort : public ::testing::Test {
17- };
18- TYPED_TEST_SUITE_P (avx512_sort);
19-
20- TYPED_TEST_P (avx512_sort, test_arrsizes)
21- {
22- if (cpu_has_avx512bw ()) {
23- if ((sizeof (TypeParam) == 2 ) && (!cpu_has_avx512_vbmi2 ())) {
24- GTEST_SKIP () << " Skipping this test, it requires avx512_vbmi2" ;
25- }
26- std::vector<int64_t > arrsizes;
27- for (int64_t ii = 0 ; ii < 1024 ; ++ii) {
28- arrsizes.push_back ((TypeParam)ii);
29- }
30- std::vector<TypeParam> arr;
31- std::vector<TypeParam> sortedarr;
32- for (size_t ii = 0 ; ii < arrsizes.size (); ++ii) {
33- /* Random array */
34- arr = get_uniform_rand_array<TypeParam>(arrsizes[ii]);
35- sortedarr = arr;
36- /* Sort with std::sort for comparison */
37- std::sort (sortedarr.begin (), sortedarr.end ());
38- avx512_qsort<TypeParam>(arr.data (), arr.size ());
39- ASSERT_EQ (sortedarr, arr);
40- arr.clear ();
41- sortedarr.clear ();
42- }
43- }
44- else {
45- GTEST_SKIP () << " Skipping this test, it requires avx512bw" ;
46- }
47- }
48-
49- REGISTER_TYPED_TEST_SUITE_P (avx512_sort, test_arrsizes);
50-
51- using Types = testing::Types<uint16_t ,
52- int16_t ,
53- float ,
54- double ,
55- uint32_t ,
56- int32_t ,
57- uint64_t ,
58- int64_t >;
59- INSTANTIATE_TYPED_TEST_SUITE_P (TestPrefix, avx512_sort, Types);
60-
6111template <typename K, typename V = uint64_t >
6212struct sorted_t {
6313 K key;
6414 K value;
6515};
16+
6617template <typename K, typename V = uint64_t >
6718bool compare (sorted_t <K, V> a, sorted_t <K, V> b)
6819{
@@ -87,7 +38,8 @@ TYPED_TEST_P(TestKeyValueSort, KeyValueSort)
8738
8839 for (size_t ii = 0 ; ii < keysizes.size (); ++ii) {
8940 /* Random array */
90- keys = get_uniform_rand_array_key<TypeParam>(keysizes[ii]);
41+ keys =
42+ get_uniform_rand_array_with_uniquevalues<TypeParam>(keysizes[ii]);
9143 values = get_uniform_rand_array<uint64_t >(keysizes[ii]);
9244 for (size_t i = 0 ; i < keys.size (); i++) {
9345 sorted_t <TypeParam, uint64_t > tmp_s;
@@ -113,4 +65,4 @@ TYPED_TEST_P(TestKeyValueSort, KeyValueSort)
11365REGISTER_TYPED_TEST_SUITE_P (TestKeyValueSort, KeyValueSort);
11466
11567using TypesKv = testing::Types<double , uint64_t , int64_t >;
116- INSTANTIATE_TYPED_TEST_SUITE_P (TestPrefixKv, TestKeyValueSort, TypesKv);
68+ INSTANTIATE_TYPED_TEST_SUITE_P (TestPrefixKv, TestKeyValueSort, TypesKv);
0 commit comments