8000 ENH: Vectorize np.sort and np.partition with AVX2 by r-devulap · Pull Request #25045 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: Vectorize np.sort and np.partition with AVX2 #25045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Include highway/x86-simd-sort at compile time
  • Loading branch information
Raghuveer Devulapalli committed Nov 30, 2023
commit a3ca84b0575f46845a566567bf01cdc08fbb2e49
4 changes: 2 additions & 2 deletions numpy/_core/src/npysort/highway_qsort.dispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* $maxopt $keep_baseline
* asimd
*/
// policy $keep_baseline is used to avoid skip building avx512_skx
// policy $keep_baseline is used to avoid skip building asimd
// when its part of baseline features (--cpu-baseline), since
// 'baseline' option isn't specified within targets.

Expand Down Expand Up @@ -43,6 +43,6 @@ template<> void NPY_CPU_DISPATCH_CURFX(QSort)(double *arr, intptr_t size)
}
#endif // NPY_HAVE_ASIMD

}} // namespace np::simd
}} // namespace np::qsort_simd

#endif // __CYGWIN__
13 changes: 5 additions & 8 deletions numpy/_core/src/npysort/quicksort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,13 @@ inline bool quicksort_dispatch(T *start, npy_intp num)
}
else if (sizeof(T) == sizeof(uint32_t) || sizeof(T) == sizeof(uint64_t)) {
#ifndef NPY_DISABLE_OPTIMIZATION
#include "x86_simd_qsort.dispatch.h"
#endif
NPY_CPU_DISPATCH_CALL_XB(dispfunc = np::qsort_simd::template QSort, <TF>);
// If not dispatched for avx-512 or avx2:
if (dispfunc == nullptr) {
#ifndef NPY_DISABLE_OPTIMIZATION
#if defined(NPY_CPU_AMD64) || defined(NPY_CPU_X86) // x86 32-bit and 64-bit
#include "x86_simd_qsort.dispatch.h"
#else
#include "highway_qsort.dispatch.h"
#endif
NPY_CPU_DISPATCH_CALL_XB(dispfunc = np::qsort_simd::template QSort, <TF>);
}
#endif
NPY_CPU_DISPATCH_CALL_XB(dispfunc = np::qsort_simd::template QSort, <TF>);
}
if (dispfunc) {
(*dispfunc)(reinterpret_cast<TF*>(start), static_cast<intptr_t>(num));
Expand Down
2 changes: 1 addition & 1 deletion numpy/_core/src/npysort/x86_simd_qsort.dispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,6 @@ template<> void NPY_CPU_DISPATCH_CURFX(QSort)(double *arr, npy_intp num)
}
#endif // NPY_HAVE_AVX512_SKX || NPY_HAVE_AVX2

}} // namespace np::simd
}} // namespace np::qsort_simd

#endif // __CYGWIN__
0