17#if defined(HIGHWAY_HWY_CONTRIB_SORT_TRAITS_TOGGLE) == \
18 defined(HWY_TARGET_TOGGLE)
19#ifdef HIGHWAY_HWY_CONTRIB_SORT_TRAITS_TOGGLE
20#undef HIGHWAY_HWY_CONTRIB_SORT_TRAITS_TOGGLE
22#define HIGHWAY_HWY_CONTRIB_SORT_TRAITS_TOGGLE
37#if VQSORT_ENABLED || HWY_IDE
44 constexpr bool Is128()
const {
return false; }
65 template <
class V,
class M>
66 HWY_INLINE V CompressKeys(V keys, M mask)
const {
99 return ReverseKeys(
d,
v);
103 HWY_INLINE V OddEvenKeys(
const V odd,
const V even)
const {
107 template <
class D, HWY_IF_LANE_SIZE_D(D, 2)>
108 HWY_INLINE Vec<D> SwapAdjacentPairs(D
d,
const Vec<D>
v)
const {
109 const Repartition<uint32_t, D> du32;
112 template <
class D, HWY_IF_LANE_SIZE_D(D, 4)>
113 HWY_INLINE Vec<D> SwapAdjacentPairs(D ,
const Vec<D>
v)
const {
116 template <
class D, HWY_IF_LANE_SIZE_D(D, 8)>
117 HWY_INLINE Vec<D> SwapAdjacentPairs(D ,
const Vec<D>
v)
const {
121 template <
class D, HWY_IF_NOT_LANE_SIZE_D(D, 8)>
122 HWY_INLINE Vec<D> SwapAdjacentQuads(D
d,
const Vec<D>
v)
const {
124 const RepartitionToWide<D> dw;
126 const RepartitionToWide<RebindToUnsigned<D>> dw;
130 template <
class D, HWY_IF_LANE_SIZE_D(D, 8)>
131 HWY_INLINE Vec<D> SwapAdjacentQuads(D
d,
const Vec<D>
v)
const {
136 template <
class D, HWY_IF_NOT_LANE_SIZE_D(D, 8)>
137 HWY_INLINE Vec<D> OddEvenPairs(D
d,
const Vec<D> odd,
138 const Vec<D> even)
const {
140 const RepartitionToWide<D> dw;
142 const RepartitionToWide<RebindToUnsigned<D>> dw;
146 template <
class D, HWY_IF_LANE_SIZE_D(D, 8)>
147 HWY_INLINE Vec<D> OddEvenPairs(D , Vec<D> odd, Vec<D> even)
const {
151 template <
class D, HWY_IF_NOT_LANE_SIZE_D(D, 8)>
152 HWY_INLINE Vec<D> OddEvenQuads(D
d, Vec<D> odd, Vec<D> even)
const {
154 const RepartitionToWide<D> dw;
156 const RepartitionToWide<RebindToUnsigned<D>> dw;
160 template <
class D, HWY_IF_LANE_SIZE_D(D, 8)>
161 HWY_INLINE Vec<D> OddEvenQuads(D
d, Vec<D> odd, Vec<D> even)
const {
174struct OrderAscending :
public KeyLane<T> {
175 using Order = SortAscending;
188 HWY_INLINE Vec<D> First(D ,
const Vec<D> a,
const Vec<D> b)
const {
193 HWY_INLINE Vec<D> Last(D ,
const Vec<D> a,
const Vec<D> b)
const {
211 return Set(
d, hwy::LowestValue<T>());
216 return Set(
d, hwy::HighestValue<T>());
221struct OrderDescending :
public KeyLane<T> {
222 using Order = SortDescending;
234 HWY_INLINE Vec<D> First(D ,
const Vec<D> a,
const Vec<D> b)
const {
239 HWY_INLINE Vec<D> Last(D ,
const Vec<D> a,
const Vec<D> b)
const {
257 return Set(
d, hwy::HighestValue<T>());
262 return Set(
d, hwy::LowestValue<T>());
268struct TraitsLane :
public Base {
274 HWY_INLINE void Sort2(D
d, Vec<D>& a, Vec<D>& b)
const {
275 const Base* base =
static_cast<const Base*
>(
this);
277 const Vec<D> a_copy = a;
280#if HWY_AVX3 < HWY_TARGET && HWY_TARGET <= HWY_SSSE3
281 if (
sizeof(TFromD<D>) == 8) {
282 const Mask<D> cmp = base->Compare(
d, a, b);
288 a = base->First(
d, a, b);
289 b = base->Last(
d, a_copy, b);
293 template <
class D, HWY_IF_LANE_SIZE_D(D, 8)>
294 HWY_INLINE Vec<D> SortPairsDistance1(D
d, Vec<D>
v)
const {
295 const Base* base =
static_cast<const Base*
>(
this);
296 Vec<D> swapped = base->ReverseKeys2(
d,
v);
299#if HWY_AVX3 < HWY_TARGET && HWY_TARGET <= HWY_SSSE3
303 Sort2(
d,
v, swapped);
304 return base->OddEvenKeys(swapped,
v);
309 template <
class D, HWY_IF_NOT_LANE_SIZE_D(D, 8)>
310 HWY_INLINE Vec<D> SortPairsDistance1(D
d, Vec<D>
v)
const {
311 const Base* base =
static_cast<const Base*
>(
this);
312 Vec<D> swapped = base->ReverseKeys2(
d,
v);
313 Sort2(
d,
v, swapped);
314 return base->OddEvenKeys(swapped,
v);
319 HWY_INLINE Vec<D> SortPairsReverse4(D
d, Vec<D>
v)
const {
320 const Base* base =
static_cast<const Base*
>(
this);
321 Vec<D> swapped = base->ReverseKeys4(
d,
v);
322 Sort2(
d,
v, swapped);
323 return base->OddEvenPairs(
d, swapped,
v);
328 HWY_INLINE Vec<D> SortPairsDistance4(D
d, Vec<D>
v)
const {
329 const Base* base =
static_cast<const Base*
>(
this);
330 Vec<D> swapped = base->SwapAdjacentQuads(
d,
v);
333 Sort2(
d,
v, swapped);
334 return base->OddEvenQuads(
d, swapped,
v);
343 constexpr bool Is128()
const {
return false; }
380template <
class Order>
383 template <
typename T>
#define HWY_RESTRICT
Definition: base.h:61
#define HWY_INLINE
Definition: base.h:62
HWY_API Vec128< T, N > Shuffle2301(const Vec128< T, N > a, const Vec128< T, N > b)
Definition: wasm_128-inl.h:2425
HWY_INLINE Vec128< T, N > OddEven(hwy::SizeTag< 1 >, const Vec128< T, N > a, const Vec128< T, N > b)
Definition: wasm_128-inl.h:3035
HWY_INLINE Vec128< T, 1 > MinOfLanes(hwy::SizeTag< sizeof(T)>, const Vec128< T, 1 > v)
Definition: arm_neon-inl.h:4804
HWY_INLINE Vec128< T, N > CompressNot(Vec128< T, N > v, const uint64_t mask_bits)
Definition: arm_neon-inl.h:5751
HWY_INLINE Vec128< T, N > IfThenElse(hwy::SizeTag< 1 >, Mask128< T, N > mask, Vec128< T, N > yes, Vec128< T, N > no)
Definition: x86_128-inl.h:673
HWY_INLINE Vec128< T, 1 > MaxOfLanes(hwy::SizeTag< sizeof(T)>, const Vec128< T, 1 > v)
Definition: arm_neon-inl.h:4809
d
Definition: rvv-inl.h:1742
HWY_API Vec128< T, N > OddEvenBlocks(Vec128< T, N >, Vec128< T, N > even)
Definition: arm_neon-inl.h:4533
HWY_API Vec128< T, N > DupOdd(Vec128< T, N > v)
Definition: arm_neon-inl.h:4498
HWY_API Vec128< T > Shuffle1032(const Vec128< T > v)
Definition: arm_neon-inl.h:4046
HWY_API auto Lt(V a, V b) -> decltype(a==b)
Definition: arm_neon-inl.h:6309
HWY_API Vec128< uint64_t, N > Min(const Vec128< uint64_t, N > a, const Vec128< uint64_t, N > b)
Definition: arm_neon-inl.h:2470
HWY_API Vec128< uint64_t, N > Max(const Vec128< uint64_t, N > a, const Vec128< uint64_t, N > b)
Definition: arm_neon-inl.h:2508
HWY_API Vec128< T, N > ConcatLowerUpper(const Simd< T, N, 0 > d, Vec128< T, N > hi, Vec128< T, N > lo)
Definition: arm_neon-inl.h:4380
HWY_API Vec128< T, N > IfVecThenElse(Vec128< T, N > mask, Vec128< T, N > yes, Vec128< T, N > no)
Definition: arm_neon-inl.h:2006
HWY_API Vec128< T, N > VecFromMask(Simd< T, N, 0 > d, const Mask128< T, N > v)
Definition: arm_neon-inl.h:2182
HWY_API Vec128< T, N > SwapAdjacentBlocks(Vec128< T, N > v)
Definition: arm_neon-inl.h:4540
HWY_API Vec128< T, N > Reverse2(Simd< T, N, 0 > d, const Vec128< T, N > v)
Definition: arm_neon-inl.h:3976
svuint16_t Set(Simd< bfloat16_t, N, kPow2 > d, bfloat16_t arg)
Definition: arm_sve-inl.h:312
HWY_API Vec128< T, N > Reverse8(Simd< T, N, 0 > d, const Vec128< T, N > v)
Definition: arm_neon-inl.h:4028
HWY_API Vec128< T, N > ConcatUpperLower(Simd< T, N, 0 > d, Vec128< T, N > hi, Vec128< T, N > lo)
Definition: arm_neon-inl.h:4406
HWY_API Vec128< T, N > BitCast(Simd< T, N, 0 > d, Vec128< FromT, N *sizeof(T)/sizeof(FromT)> v)
Definition: arm_neon-inl.h:988
decltype(MaskFromVec(Zero(D()))) Mask
Definition: generic_ops-inl.h:38
HWY_API Vec128< T, N > Reverse4(Simd< T, N, 0 > d, const Vec128< T, N > v)
Definition: arm_neon-inl.h:4005
HWY_API Vec128< T, 1 > Reverse(Simd< T, 1, 0 >, const Vec128< T, 1 > v)
Definition: arm_neon-inl.h:3945
const vfloat64m1_t v
Definition: rvv-inl.h:1742
typename D::T TFromD
Definition: ops/shared-inl.h:191
decltype(Zero(D())) Vec
Definition: generic_ops-inl.h:32
HWY_DLLEXPORT void TypeName(const TypeInfo &info, size_t N, char *string100)
Definition: aligned_allocator.h:27
#define HWY_NAMESPACE
Definition: set_macros-inl.h:82
Definition: traits-inl.h:342
T LaneType
Definition: traits-inl.h:346
constexpr size_t LanesPerKey() const
Definition: traits-inl.h:344
T KeyType
Definition: traits-inl.h:347
constexpr bool Is128() const
Definition: traits-inl.h:343
std::string KeyString() const
Definition: traits-inl.h:349
Definition: traits-inl.h:357
HWY_INLINE bool Compare1(const T *a, const T *b)
Definition: traits-inl.h:360
HWY_INLINE Mask< D > Compare(D, Vec< D > a, Vec< D > b)
Definition: traits-inl.h:363
SortAscending Order
Definition: traits-inl.h:358
Definition: traits-inl.h:369
HWY_INLINE bool Compare1(const T *a, const T *b)
Definition: traits-inl.h:372
HWY_INLINE Mask< D > Compare(D, Vec< D > a, Vec< D > b)
Definition: traits-inl.h:375
SortDescending Order
Definition: traits-inl.h:370
Definition: traits-inl.h:381
HWY_INLINE void Swap(T *a, T *b) const
Definition: traits-inl.h:384
HWY_INLINE Vec< D > SetKey(D d, const TFromD< D > *key) const
Definition: traits-inl.h:391
static constexpr size_t kMaxCols
Definition: contrib/sort/shared-inl.h:34