Skip to content

Commit d3c2169

Browse files
author
Raghuveer Devulapalli
authored
Merge pull request #123 from r-devulap/macos-np
Fix more build issues on macOS
2 parents 1372aeb + 78ed2fd commit d3c2169

File tree

3 files changed

+15
-35
lines changed

3 files changed

+15
-35
lines changed

src/avx512-64bit-common.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,19 @@ struct zmm_vector<uint64_t> {
912912
left_addr, right_addr, k, reg);
913913
}
914914
};
915+
916+
/*
917+
* workaround on 64-bit macOS which defines size_t as unsigned long and defines
918+
* uint64_t as unsigned long long, both of which are 8 bytes
919+
*/
920+
#if defined(__APPLE__) && defined(__x86_64__)
921+
static_assert(sizeof(size_t) == sizeof(uint64_t),
922+
"Size of size_t and uint64_t are not the same");
923+
template <>
924+
struct zmm_vector<size_t> : public zmm_vector<uint64_t> {
925+
};
926+
#endif
927+
915928
template <>
916929
struct zmm_vector<double> {
917930
using type_t = double;

src/xss-common-argsort.h

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

552-
/* Workaround for NumPy failed build on macOS x86_64: implicit instantiation of
553-
* undefined template 'zmm_vector<unsigned long>'*/
554-
#ifdef __APPLE__
555-
using argtype =
556-
typename std::conditional<sizeof(arrsize_t) == sizeof(int32_t),
557-
ymm_vector<uint32_t>,
558-
zmm_vector<uint64_t>>::type;
559-
#else
560552
using argtype =
561553
typename std::conditional<sizeof(arrsize_t) == sizeof(int32_t),
562554
ymm_vector<arrsize_t>,
563555
zmm_vector<arrsize_t>>::type;
564-
#endif
565556

566557
if (arrsize > 1) {
567558
if constexpr (std::is_floating_point_v<T>) {
@@ -595,18 +586,10 @@ avx2_argsort(T *arr, arrsize_t *arg, arrsize_t arrsize, bool hasnan = false)
595586
avx2_half_vector<T>,
596587
avx2_vector<T>>::type;
597588

598-
#ifdef __APPLE__
599-
using argtype =
600-
typename std::conditional<sizeof(arrsize_t) == sizeof(int32_t),
601-
avx2_half_vector<uint32_t>,
602-
avx2_vector<uint64_t>>::type;
603-
#else
604589
using argtype =
605590
typename std::conditional<sizeof(arrsize_t) == sizeof(int32_t),
606591
avx2_half_vector<arrsize_t>,
607592
avx2_vector<arrsize_t>>::type;
608-
#endif
609-
610593
if (arrsize > 1) {
611594
if constexpr (std::is_floating_point_v<T>) {
612595
if ((hasnan) && (array_has_nan<vectype>(arr, arrsize))) {
@@ -643,19 +626,10 @@ X86_SIMD_SORT_INLINE void avx512_argselect(T *arr,
643626
ymm_vector<T>,
644627
zmm_vector<T>>::type;
645628

646-
/* Workaround for NumPy failed build on macOS x86_64: implicit instantiation of
647-
* undefined template 'zmm_vector<unsigned long>'*/
648-
#ifdef __APPLE__
649-
using argtype =
650-
typename std::conditional<sizeof(arrsize_t) == sizeof(int32_t),
651-
ymm_vector<uint32_t>,
652-
zmm_vector<uint64_t>>::type;
653-
#else
654629
using argtype =
655630
typename std::conditional<sizeof(arrsize_t) == sizeof(int32_t),
656631
ymm_vector<arrsize_t>,
657632
zmm_vector<arrsize_t>>::type;
658-
#endif
659633

660634
if (arrsize > 1) {
661635
if constexpr (std::is_floating_point_v<T>) {
@@ -692,17 +666,10 @@ X86_SIMD_SORT_INLINE void avx2_argselect(T *arr,
692666
avx2_half_vector<T>,
693667
avx2_vector<T>>::type;
694668

695-
#ifdef __APPLE__
696-
using argtype =
697-
typename std::conditional<sizeof(arrsize_t) == sizeof(int32_t),
698-
avx2_half_vector<uint32_t>,
699-
avx2_vector<uint64_t>>::type;
700-
#else
701669
using argtype =
702670
typename std::conditional<sizeof(arrsize_t) == sizeof(int32_t),
703671
avx2_half_vector<arrsize_t>,
704672
avx2_vector<arrsize_t>>::type;
705-
#endif
706673

707674
if (arrsize > 1) {
708675
if constexpr (std::is_floating_point_v<T>) {

src/xss-network-keyvaluesort.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ bitonic_fullmerge_n_vec(typename keyType::reg_t *keys,
442442

443443
template <typename keyType, typename indexType, int numVecs>
444444
X86_SIMD_SORT_INLINE void argsort_n_vec(typename keyType::type_t *keys,
445-
typename indexType::type_t *indices,
445+
arrsize_t *indices,
446446
int N)
447447
{
448448
using kreg_t = typename keyType::reg_t;
@@ -587,7 +587,7 @@ X86_SIMD_SORT_INLINE void kvsort_n_vec(typename keyType::type_t *keys,
587587

588588
template <typename keyType, typename indexType, int maxN>
589589
X86_SIMD_SORT_INLINE void argsort_n(typename keyType::type_t *keys,
590-
typename indexType::type_t *indices,
590+
arrsize_t *indices,
591591
int N)
592592
{
593593
static_assert(keyType::numlanes == indexType::numlanes,

0 commit comments

Comments
 (0)