Skip to content

Commit 05183cb

Browse files
author
Raghuveer Devulapalli
authored
Merge pull request #80 from r-devulap/fp16
Bug fix in avx512_qselect_fp16
2 parents 4d9b15b + b6fb602 commit 05183cb

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/avx512-common-qsort.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ static void qsort_(type_t *arr, int64_t left, int64_t right, int64_t max_iters)
826826
* Resort to std::sort if quicksort isnt making any progress
827827
*/
828828
if (max_iters <= 0) {
829-
std::sort(arr + left, arr + right + 1);
829+
std::sort(arr + left, arr + right + 1, comparison_func<vtype>);
830830
return;
831831
}
832832
/*
@@ -862,7 +862,7 @@ static void qselect_(type_t *arr,
862862
* Resort to std::sort if quicksort isnt making any progress
863863
*/
864864
if (max_iters <= 0) {
865-
std::sort(arr + left, arr + right + 1);
865+
std::sort(arr + left, arr + right + 1, comparison_func<vtype>);
866866
return;
867867
}
868868
/*

tests/test-qselect.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ class avx512_select : public ::testing::Test {
55
};
66
TYPED_TEST_SUITE_P(avx512_select);
77

8+
#ifdef __FLT16_MAX__
9+
TEST(avx512_select, test_simple)
10+
{
11+
if (__builtin_cpu_supports("avx512vbmi2")) {
12+
std::vector<_Float16> arr{1.0, -1.0};
13+
avx512_qselect_fp16(reinterpret_cast<uint16_t*>(arr.data()), 0, arr.size());
14+
ASSERT_EQ(arr[0], -1.0);
15+
}
16+
else {
17+
GTEST_SKIP() << "Skipping this test, it requires avx512vbmi2";
18+
}
19+
}
20+
#endif
21+
822
TYPED_TEST_P(avx512_select, test_random)
923
{
1024
if (__builtin_cpu_supports("avx512bw")) {

0 commit comments

Comments
 (0)