Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 97e6714

Browse files
committed
Disable avx512_qselect on 32-bit systems
1 parent 3ce866b commit 97e6714

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

numpy/core/src/npysort/selection.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,17 @@ inline bool quickselect_dispatch(T* v, npy_intp num, npy_intp kth)
3636
/*
3737
* Only defined for int16_t, uint16_t, float16, int32_t, uint32_t, float32,
3838
* int64_t, uint64_t, double
39+
* TODO: Enable quickselect for 32-bit. np.argpartition is only vectorized
40+
* for 64-bit when npy_intp is 8 bytes, which means np.partition and
41+
* np.argpartition will produces different results on 32-bit systems.
42+
* Several tests in test_multiarray.py rely on these results being
43+
* identical. We should get rid of this constraint and re-write
44+
* these tests once we enable this for 32-bit.
3945
*/
4046
if constexpr (
4147
(std::is_integral_v<T> || std::is_floating_point_v<T> || std::is_same_v<T, np::Half>) &&
42-
(sizeof(T) == sizeof(uint16_t) || sizeof(T) == sizeof(uint32_t) || sizeof(T) == sizeof(uint64_t))) {
48+
(sizeof(T) == sizeof(uint16_t) || sizeof(T) == sizeof(uint32_t) || sizeof(T) == sizeof(uint64_t)) &&
49+
sizeof(npy_intp) == sizeof(int64_t)) {
4350
using TF = typename np::meta::FixedWidth<T>::Type;
4451
void (*dispfunc)(TF*, npy_intp, npy_intp) = nullptr;
4552
if constexpr (sizeof(T) == sizeof(uint16_t)) {

numpy/core/src/npysort/simd_qsort.dispatch.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// 'baseline' option isn't specified within targets.
77

88
#include "simd_qsort.hpp"
9+
#ifndef __CYGWIN__
910

1011
#if defined(NPY_HAVE_AVX512_SKX)
1112
#include "x86-simd-sort/src/avx512-32bit-qsort.hpp"
@@ -16,7 +17,6 @@
1617
namespace np { namespace qsort_simd {
1718

1819
#if defined(NPY_HAVE_AVX512_SKX)
19-
#ifndef __CYGWIN__
2020
template<> void NPY_CPU_DISPATCH_CURFX(ArgQSelect)(int32_t *arr, npy_intp* arg, npy_intp num, npy_intp kth)
2121
{
2222
avx512_argselect(arr, reinterpret_cast<int64_t*>(arg), kth, num);
@@ -113,7 +113,8 @@ template<> void NPY_CPU_DISPATCH_CURFX(ArgQSort)(double *arr, npy_intp *arg, npy
113113
{
114114
avx512_argsort(arr, reinterpret_cast<int64_t*>(arg), size);
115115
}
116-
#endif // __CYGWIN__
117116
#endif // NPY_HAVE_AVX512_SKX
118117

119118
}} // namespace np::simd
119+
120+
#endif // __CYGWIN__

numpy/core/src/npysort/simd_qsort_16bit.dispatch.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// 'baseline' option isn't specified within targets.
77

88
#include "simd_qsort.hpp"
9+
#ifndef __CYGWIN__
910

1011
#if defined(NPY_HAVE_AVX512_SPR)
1112
#include "x86-simd-sort/src/avx512fp16-16bit-qsort.hpp"
@@ -15,13 +16,12 @@
1516
*/
1617
void avx512_qsort_uint16(uint16_t*, intptr_t);
1718
void avx512_qsort_int16(int16_t*, intptr_t);
18-
void avx512_qselect_uint16(uint16_t*, npy_intp, npy_intp)
19-
void avx512_qselect_int16(int16_t*, npy_intp, npy_intp)
19+
void avx512_qselect_uint16(uint16_t*, npy_intp, npy_intp);
20+
void avx512_qselect_int16(int16_t*, npy_intp, npy_intp);
2021

2122
#elif defined(NPY_HAVE_AVX512_ICL)
2223
#include "x86-simd-sort/src/avx512-16bit-qsort.hpp"
2324
/* Wrapper function defintions here: */
24-
#ifndef __CYGWIN__
2525
void avx512_qsort_uint16(uint16_t* arr, intptr_t size)
2626
{
2727
avx512_qsort(arr, size);
@@ -38,7 +38,6 @@ void avx512_qselect_int16(int16_t* arr, npy_intp kth, npy_intp size)
3838
{
3939
avx512_qselect(arr, kth, size, true);
4040
}
41-
#endif // __CYGWIN__
4241
#endif
4342

4443
namespace np { namespace qsort_simd {
@@ -47,7 +46,6 @@ namespace np { namespace qsort_simd {
4746
* QSelect dispatch functions:
4847
*/
4948
#if defined(NPY_HAVE_AVX512_ICL) || defined(NPY_HAVE_AVX512_SPR)
50-
#ifndef __CYGWIN__
5149
template<> void NPY_CPU_DISPATCH_CURFX(QSelect)(Half *arr, npy_intp num, npy_intp kth)
5250
{
5351
#if defined(NPY_HAVE_AVX512_SPR)
@@ -102,7 +100,8 @@ template<> void NPY_CPU_DISPATCH_CURFX(QSort)(int16_t *arr, intptr_t size)
102100
avx512_qsort(arr, size);
103101
#endif
104102
}
105-
#endif // __CYGWIN__
106103
#endif // NPY_HAVE_AVX512_ICL || SPR
107104

108105
}} // namespace np::qsort_simd
106+
107+
#endif // __CYGWIN__

0 commit comments

Comments
 (0)