Skip to content

Commit ee072b4

Browse files
author
Raghuveer Devulapalli
committed
Use uint64_t for arrsize_t on macOS 64-bit
1 parent a3f6753 commit ee072b4

File tree

2 files changed

+8
-33
lines changed

2 files changed

+8
-33
lines changed

src/xss-common-argsort.h

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -559,19 +559,10 @@ avx512_argsort(T *arr, arrsize_t *arg, arrsize_t arrsize, bool hasnan = false)
559559
ymm_vector<T>,
560560
zmm_vector<T>>::type;
561561

562-
/* Workaround for NumPy failed build on macOS x86_64: implicit instantiation of
563-
* undefined template 'zmm_vector<unsigned long>'*/
564-
#ifdef __APPLE__
565-
using argtype =
566-
typename std::conditional<sizeof(arrsize_t) == sizeof(int32_t),
567-
ymm_vector<uint32_t>,
568-
zmm_vector<uint64_t>>::type;
569-
#else
570562
using argtype =
571563
typename std::conditional<sizeof(arrsize_t) == sizeof(int32_t),
572564
ymm_vector<arrsize_t>,
573565
zmm_vector<arrsize_t>>::type;
574-
#endif
575566

576567
if (arrsize > 1) {
577568
if constexpr (std::is_floating_point_v<T>) {
@@ -605,18 +596,10 @@ avx2_argsort(T *arr, arrsize_t *arg, arrsize_t arrsize, bool hasnan = false)
605596
avx2_half_vector<T>,
606597
avx2_vector<T>>::type;
607598

608-
#ifdef __APPLE__
609-
using argtype =
610-
typename std::conditional<sizeof(arrsize_t) == sizeof(int32_t),
611-
avx2_half_vector<uint32_t>,
612-
avx2_vector<uint64_t>>::type;
613-
#else
614599
using argtype =
615600
typename std::conditional<sizeof(arrsize_t) == sizeof(int32_t),
616601
avx2_half_vector<arrsize_t>,
617602
avx2_vector<arrsize_t>>::type;
618-
#endif
619-
620603
if (arrsize > 1) {
621604
if constexpr (std::is_floating_point_v<T>) {
622605
if ((hasnan) && (array_has_nan<vectype>(arr, arrsize))) {
@@ -653,19 +636,10 @@ X86_SIMD_SORT_INLINE void avx512_argselect(T *arr,
653636
ymm_vector<T>,
654637
zmm_vector<T>>::type;
655638

656-
/* Workaround for NumPy failed build on macOS x86_64: implicit instantiation of
657-
* undefined template 'zmm_vector<unsigned long>'*/
658-
#ifdef __APPLE__
659-
using argtype =
660-
typename std::conditional<sizeof(arrsize_t) == sizeof(int32_t),
661-
ymm_vector<uint32_t>,
662-
zmm_vector<uint64_t>>::type;
663-
#else
664639
using argtype =
665640
typename std::conditional<sizeof(arrsize_t) == sizeof(int32_t),
666641
ymm_vector<arrsize_t>,
667642
zmm_vector<arrsize_t>>::type;
668-
#endif
669643

670644
if (arrsize > 1) {
671645
if constexpr (std::is_floating_point_v<T>) {
@@ -702,17 +676,10 @@ X86_SIMD_SORT_INLINE void avx2_argselect(T *arr,
702676
avx2_half_vector<T>,
703677
avx2_vector<T>>::type;
704678

705-
#ifdef __APPLE__
706-
using argtype =
707-
typename std::conditional<sizeof(arrsize_t) == sizeof(int32_t),
708-
avx2_half_vector<uint32_t>,
709-
avx2_vector<uint64_t>>::type;
710-
#else
711679
using argtype =
712680
typename std::conditional<sizeof(arrsize_t) == sizeof(int32_t),
713681
avx2_half_vector<arrsize_t>,
714682
avx2_vector<arrsize_t>>::type;
715-
#endif
716683

717684
if (arrsize > 1) {
718685
if constexpr (std::is_floating_point_v<T>) {

src/xss-common-includes.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,15 @@ constexpr bool always_false = false;
9090
#define NETWORK_32BIT_6 11, 10, 9, 8, 15, 14, 13, 12, 3, 2, 1, 0, 7, 6, 5, 4
9191
#define NETWORK_32BIT_7 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8
9292

93+
/*
94+
* workaround on 64-bit macOS which defines size_t as unsigned long and defines
95+
* uint64_t as unsigned long long, both of which are 8 bytes
96+
*/
97+
#if defined(__APPLE__) && defined(__x86_64__)
98+
typedef uint64_t arrsize_t;
99+
#else
93100
typedef size_t arrsize_t;
101+
#endif
94102

95103
template <typename type>
96104
struct zmm_vector;

0 commit comments

Comments
 (0)