Skip to content

Commit

Permalink
Fixed formatting and removed previous testing code
Browse files Browse the repository at this point in the history
  • Loading branch information
sterrettm2 committed May 17, 2024
1 parent 3e6089c commit b0f3be2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 43 deletions.
62 changes: 32 additions & 30 deletions src/xss-common-argsort.h
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,10 @@ X86_SIMD_SORT_INLINE type_t get_pivot_64bit(type_t *arr,

template <typename vtype, typename argtype, typename type_t>
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
Expand All @@ -498,17 +498,16 @@ X86_SIMD_SORT_INLINE void argsort_(type_t *arr,
argsort_<vtype, argtype>(
arr, arg, left, pivot_index - 1, max_iters - 1);
if (pivot != biggest)
argsort_<vtype, argtype>(
arr, arg, pivot_index, right, max_iters - 1);
argsort_<vtype, argtype>(arr, arg, pivot_index, right, max_iters - 1);
}

template <typename vtype, typename argtype, typename type_t>
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
Expand Down Expand Up @@ -545,10 +544,10 @@ template <typename T,
template <typename...>
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<sizeof(T) == sizeof(int32_t),
Expand Down Expand Up @@ -585,17 +584,19 @@ X86_SIMD_SORT_INLINE void avx512_argsort(T *arr,
bool hasnan = false,
bool descending = false)
{
xss_argsort<T, zmm_vector, ymm_vector>(arr, arg, arrsize, hasnan, descending);
xss_argsort<T, zmm_vector, ymm_vector>(
arr, arg, arrsize, hasnan, descending);
}

template <typename T>
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<T, avx2_vector, avx2_half_vector>(arr, arg, arrsize, hasnan, descending);
xss_argsort<T, avx2_vector, avx2_half_vector>(
arr, arg, arrsize, hasnan, descending);
}

/* argselect methods for 32-bit and 64-bit dtypes */
Expand All @@ -605,10 +606,10 @@ template <typename T,
template <typename...>
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<sizeof(T) == sizeof(int32_t),
Expand All @@ -635,10 +636,10 @@ X86_SIMD_SORT_INLINE void xss_argselect(T *arr,

template <typename T>
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<T, zmm_vector, ymm_vector>(arr, arg, k, arrsize, hasnan);
}
Expand All @@ -650,7 +651,8 @@ X86_SIMD_SORT_INLINE void avx2_argselect(T *arr,
arrsize_t arrsize,
bool hasnan = false)
{
xss_argselect<T, avx2_vector, avx2_half_vector>(arr, arg, k, arrsize, hasnan);
xss_argselect<T, avx2_vector, avx2_half_vector>(
arr, arg, k, arrsize, hasnan);
}

#endif // XSS_COMMON_ARGSORT
19 changes: 6 additions & 13 deletions src/xss-network-qsort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,13 @@ template <typename vtype,
typename reg_t = typename vtype::reg_t>
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<vtype, comparator, numVecs>(vecs);
/* Run the initial sorting network to sort the columns of the [numVecs x
* num_lanes] matrix
*/
bitonic_sort_n_vec<vtype, comparator, numVecs>(vecs);

// Merge the vectors using bitonic merging networks
merge_n_vec<vtype, comparator, numVecs>(vecs);
}
// Merge the vectors using bitonic merging networks
merge_n_vec<vtype, comparator, numVecs>(vecs);
}

template <typename vtype,
Expand Down

0 comments on commit b0f3be2

Please sign in to comment.