Skip to content

Commit c69eff2

Browse files
committed
Upgrade to C++20 and use portable definition of unlikely attribute
Signed-off-by: Fabio Cannizzo <[email protected]>
1 parent c477a9c commit c69eff2

File tree

5 files changed

+7
-13
lines changed

5 files changed

+7
-13
lines changed

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
project('x86-simd-sort', 'cpp',
22
version : '7.0.x',
33
license : 'BSD 3-clause',
4-
default_options : ['cpp_std=c++17'])
4+
default_options : ['cpp_std=c++20'])
55
fs = import('fs')
66
cpp = meson.get_compiler('cpp')
77
src = include_directories('src')

src/avx512-16bit-qsort.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ avx512_qsort_fp16(uint16_t *arr,
590590

591591
if (arrsize > 1) {
592592
arrsize_t nan_count = 0;
593-
if (UNLIKELY(hasnan)) {
593+
if (hasnan) [[unlikely]] {
594594
nan_count = replace_nan_with_inf<vtype, uint16_t>(arr, arrsize);
595595
}
596596
if (descending) {
@@ -623,7 +623,7 @@ avx512_qselect_fp16(uint16_t *arr,
623623
arrsize_t index_first_elem = 0;
624624
arrsize_t index_last_elem = arrsize - 1;
625625

626-
if (UNLIKELY(hasnan)) {
626+
if (hasnan) [[unlikely]] {
627627
if (descending) {
628628
index_first_elem = move_nans_to_start_of_array(arr, arrsize);
629629
}

src/xss-common-includes.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,14 @@
4242
#define X86_SIMD_SORT_INLINE_ONLY inline
4343
#define X86_SIMD_SORT_INLINE static inline
4444
#define X86_SIMD_SORT_FINLINE static __forceinline
45-
#define LIKELY(x) (x)
46-
#define UNLIKELY(x) (x)
4745
#elif defined(__GNUC__)
4846
#define X86_SIMD_SORT_INLINE_ONLY inline
4947
#define X86_SIMD_SORT_INLINE static inline
5048
#define X86_SIMD_SORT_FINLINE static inline __attribute__((always_inline))
51-
#define LIKELY(x) __builtin_expect((x), 1)
52-
#define UNLIKELY(x) __builtin_expect((x), 0)
5349
#else
5450
#define X86_SIMD_SORT_INLINE_ONLY
5551
#define X86_SIMD_SORT_INLINE static
5652
#define X86_SIMD_SORT_FINLINE static
57-
#define LIKELY(x) (x)
58-
#define UNLIKELY(x) (x)
5953
#endif
6054

6155
#if defined(__INTEL_COMPILER) and !defined(__SANITIZE_ADDRESS__)

src/xss-common-keyvaluesort.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ X86_SIMD_SORT_INLINE void xss_qsort_kv(
595595
if (minarrsize) {
596596
arrsize_t index_last_elem = arrsize - 1;
597597
if constexpr (xss::fp::is_floating_point_v<T1>) {
598-
if (UNLIKELY(hasnan)) {
598+
if (hasnan) [[unlikely]] {
599599
index_last_elem
600600
= move_nans_to_end_of_array<T1, T2, full_vector<T1>>(
601601
keys, indexes, arrsize);
@@ -692,7 +692,7 @@ X86_SIMD_SORT_INLINE void xss_select_kv(T1 *keys,
692692

693693
arrsize_t index_last_elem = arrsize - 1;
694694
if constexpr (xss::fp::is_floating_point_v<T1>) {
695-
if (UNLIKELY(hasnan)) {
695+
if (hasnan) [[unlikely]] {
696696
index_last_elem
697697
= move_nans_to_end_of_array<T1, T2, full_vector<T1>>(
698698
keys, indexes, arrsize);

src/xss-common-qsort.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ X86_SIMD_SORT_INLINE void xss_qsort(T *arr, arrsize_t arrsize, bool hasnan)
660660
if (arrsize > 1) {
661661
arrsize_t nan_count = 0;
662662
if constexpr (xss::fp::is_floating_point_v<T>) {
663-
if (UNLIKELY(hasnan)) {
663+
if (hasnan) [[unlikely]] {
664664
nan_count = replace_nan_with_inf<vtype>(arr, arrsize);
665665
}
666666
}
@@ -726,7 +726,7 @@ xss_qselect(T *arr, arrsize_t k, arrsize_t arrsize, bool hasnan)
726726
arrsize_t index_last_elem = arrsize - 1;
727727

728728
if constexpr (xss::fp::is_floating_point_v<T>) {
729-
if (UNLIKELY(hasnan)) {
729+
if (hasnan) [[unlikely]] {
730730
if constexpr (descending) {
731731
index_first_elem = move_nans_to_start_of_array(arr, arrsize);
732732
}

0 commit comments

Comments
 (0)