Skip to content

Commit fbbdb43

Browse files
committed
Fixed SPR issues
1 parent 693ffd7 commit fbbdb43

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

lib/x86simdsort-spr.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ using x86simdsort::sort_order;
77
namespace xss {
88
namespace avx512 {
99
template <>
10-
void qsort(_Float16 *arr,
11-
size_t size,
12-
bool hasnan,
13-
sort_order order = sort_order::sort_ascending)
10+
void qsort(_Float16 *arr, size_t size, bool hasnan, sort_order order)
1411
{
1512
avx512_qsort(arr, size, hasnan, order);
1613
}
@@ -19,7 +16,7 @@ namespace avx512 {
1916
size_t k,
2017
size_t arrsize,
2118
bool hasnan,
22-
sort_order order = sort_order::sort_ascending)
19+
sort_order order)
2320
{
2421
avx512_qselect(arr, k, arrsize, hasnan, order);
2522
}
@@ -28,7 +25,7 @@ namespace avx512 {
2825
size_t k,
2926
size_t arrsize,
3027
bool hasnan,
31-
sort_order order = sort_order::sort_ascending)
28+
sort_order order)
3229
{
3330
avx512_partial_qsort(arr, k, arrsize, hasnan, order);
3431
}

src/avx512fp16-16bit-qsort.hpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ X86_SIMD_SORT_INLINE_ONLY void replace_inf_with_nan(_Float16 *arr,
203203
/* Specialized template function for _Float16 qsort_*/
204204
template <>
205205
X86_SIMD_SORT_INLINE_ONLY void
206-
avx512_qsort(_Float16 *arr, arrsize_t arrsize, bool hasnan, bool descending)
206+
avx512_qsort(_Float16 *arr, arrsize_t arrsize, bool hasnan, sort_order order)
207207
{
208208
using vtype = zmm_vector<_Float16>;
209209

@@ -212,15 +212,16 @@ avx512_qsort(_Float16 *arr, arrsize_t arrsize, bool hasnan, bool descending)
212212
if (UNLIKELY(hasnan)) {
213213
nan_count = replace_nan_with_inf<vtype, _Float16>(arr, arrsize);
214214
}
215-
if (descending) {
215+
if (order == sort_order::sort_descending) {
216216
qsort_<vtype, DescendingComparator<vtype>, _Float16>(
217217
arr, 0, arrsize - 1, 2 * (arrsize_t)log2(arrsize));
218218
}
219219
else {
220220
qsort_<vtype, AscendingComparator<vtype>, _Float16>(
221221
arr, 0, arrsize - 1, 2 * (arrsize_t)log2(arrsize));
222222
}
223-
replace_inf_with_nan(arr, arrsize, nan_count, descending);
223+
replace_inf_with_nan(
224+
arr, arrsize, nan_count, order == sort_order::sort_descending);
224225
}
225226
}
226227

@@ -229,11 +230,11 @@ X86_SIMD_SORT_INLINE_ONLY void avx512_qselect(_Float16 *arr,
229230
arrsize_t k,
230231
arrsize_t arrsize,
231232
bool hasnan,
232-
bool descending)
233+
sort_order order)
233234
{
234235
using vtype = zmm_vector<_Float16>;
235236

236-
if (descending) {
237+
if (order == sort_order::sort_descending) {
237238
arrsize_t index_first_elem = 0;
238239
if (UNLIKELY(hasnan)) {
239240
index_first_elem = move_nans_to_start_of_array(arr, arrsize);
@@ -271,9 +272,9 @@ X86_SIMD_SORT_INLINE_ONLY void avx512_partial_qsort(_Float16 *arr,
271272
arrsize_t k,
272273
arrsize_t arrsize,
273274
bool hasnan,
274-
bool descending)
275+
sort_order order)
275276
{
276-
avx512_qselect(arr, k - 1, arrsize, hasnan, descending);
277-
avx512_qsort(arr, k - 1, hasnan, descending);
277+
avx512_qselect(arr, k - 1, arrsize, hasnan, order);
278+
avx512_qsort(arr, k - 1, hasnan, order);
278279
}
279280
#endif // AVX512FP16_QSORT_16BIT

0 commit comments

Comments
 (0)