From b0f3be2b9555bb6221f30e36a4b5923d2141fb58 Mon Sep 17 00:00:00 2001 From: Matthew Sterrett Date: Fri, 17 May 2024 11:41:16 -0700 Subject: [PATCH] Fixed formatting and removed previous testing code --- src/xss-common-argsort.h | 62 ++++++++++++++++++++------------------- src/xss-network-qsort.hpp | 19 ++++-------- 2 files changed, 38 insertions(+), 43 deletions(-) diff --git a/src/xss-common-argsort.h b/src/xss-common-argsort.h index 6b651aa1..cf02b302 100644 --- a/src/xss-common-argsort.h +++ b/src/xss-common-argsort.h @@ -469,10 +469,10 @@ X86_SIMD_SORT_INLINE type_t get_pivot_64bit(type_t *arr, template X86_SIMD_SORT_INLINE void argsort_(type_t *arr, - arrsize_t *arg, - arrsize_t left, - arrsize_t right, - arrsize_t max_iters) + arrsize_t *arg, + arrsize_t left, + arrsize_t right, + arrsize_t max_iters) { /* * Resort to std::sort if quicksort isnt making any progress @@ -498,17 +498,16 @@ X86_SIMD_SORT_INLINE void argsort_(type_t *arr, argsort_( arr, arg, left, pivot_index - 1, max_iters - 1); if (pivot != biggest) - argsort_( - arr, arg, pivot_index, right, max_iters - 1); + argsort_(arr, arg, pivot_index, right, max_iters - 1); } template X86_SIMD_SORT_INLINE void argselect_(type_t *arr, - arrsize_t *arg, - arrsize_t pos, - arrsize_t left, - arrsize_t right, - arrsize_t max_iters) + arrsize_t *arg, + arrsize_t pos, + arrsize_t left, + arrsize_t right, + arrsize_t max_iters) { /* * Resort to std::sort if quicksort isnt making any progress @@ -545,10 +544,10 @@ template typename half_vector> X86_SIMD_SORT_INLINE void xss_argsort(T *arr, - arrsize_t *arg, - arrsize_t arrsize, - bool hasnan = false, - bool descending = false) + arrsize_t *arg, + arrsize_t arrsize, + bool hasnan = false, + bool descending = false) { /* TODO optimization: on 32-bit, use full_vector for 32-bit dtype */ using vectype = typename std::conditional(arr, arg, arrsize, hasnan, descending); + xss_argsort( + arr, arg, arrsize, hasnan, descending); } template X86_SIMD_SORT_INLINE void avx2_argsort(T *arr, - arrsize_t *arg, - arrsize_t arrsize, - bool hasnan = false, - bool descending = false) + arrsize_t *arg, + arrsize_t arrsize, + bool hasnan = false, + bool descending = false) { - xss_argsort(arr, arg, arrsize, hasnan, descending); + xss_argsort( + arr, arg, arrsize, hasnan, descending); } /* argselect methods for 32-bit and 64-bit dtypes */ @@ -605,10 +606,10 @@ template typename half_vector> X86_SIMD_SORT_INLINE void xss_argselect(T *arr, - arrsize_t *arg, - arrsize_t k, - arrsize_t arrsize, - bool hasnan = false) + arrsize_t *arg, + arrsize_t k, + arrsize_t arrsize, + bool hasnan = false) { /* TODO optimization: on 32-bit, use full_vector for 32-bit dtype */ using vectype = typename std::conditional X86_SIMD_SORT_INLINE void avx512_argselect(T *arr, - arrsize_t *arg, - arrsize_t k, - arrsize_t arrsize, - bool hasnan = false) + arrsize_t *arg, + arrsize_t k, + arrsize_t arrsize, + bool hasnan = false) { xss_argselect(arr, arg, k, arrsize, hasnan); } @@ -650,7 +651,8 @@ X86_SIMD_SORT_INLINE void avx2_argselect(T *arr, arrsize_t arrsize, bool hasnan = false) { - xss_argselect(arr, arg, k, arrsize, hasnan); + xss_argselect( + arr, arg, k, arrsize, hasnan); } #endif // XSS_COMMON_ARGSORT diff --git a/src/xss-network-qsort.hpp b/src/xss-network-qsort.hpp index 28e1d717..0c1d1d8a 100644 --- a/src/xss-network-qsort.hpp +++ b/src/xss-network-qsort.hpp @@ -159,20 +159,13 @@ template X86_SIMD_SORT_FINLINE void sort_vectors(reg_t *vecs) { - if constexpr (numVecs == 1){ - vecs[0] = vtype::sort_vec(vecs[0]); - if (comparator::leftmost(0, 1) == 1){ - vecs[0] = vtype::reverse(vecs[0]); - } - }else{ - /* Run the initial sorting network to sort the columns of the [numVecs x - * num_lanes] matrix - */ - bitonic_sort_n_vec(vecs); + /* Run the initial sorting network to sort the columns of the [numVecs x + * num_lanes] matrix + */ + bitonic_sort_n_vec(vecs); - // Merge the vectors using bitonic merging networks - merge_n_vec(vecs); - } + // Merge the vectors using bitonic merging networks + merge_n_vec(vecs); } template