@@ -203,7 +203,7 @@ X86_SIMD_SORT_INLINE_ONLY void replace_inf_with_nan(_Float16 *arr,
203203/* Specialized template function for _Float16 qsort_*/
204204template <>
205205X86_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