Skip to content

Commit 97cb7ec

Browse files
author
Raghuveer Devulapalli
committed
Use move and use custom-float in src files
1 parent 3a69a68 commit 97cb7ec

File tree

10 files changed

+38
-34
lines changed

10 files changed

+38
-34
lines changed

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ cancompilefp16 = cpp.compiles(fp16code, args:'-march=sapphirerapids')
3636
subdir('lib')
3737
libsimdsort = shared_library('x86simdsortcpp',
3838
'lib/x86simdsort.cpp',
39-
include_directories : [utils, lib],
39+
include_directories : [src, utils, lib],
4040
link_with : [libtargets],
4141
gnu_symbol_visibility : 'inlineshidden',
4242
install : true,

src/avx512-16bit-qsort.hpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -560,10 +560,11 @@ X86_SIMD_SORT_INLINE_ONLY bool is_a_nan<uint16_t>(uint16_t elem)
560560
return ((elem & 0x7c00u) == 0x7c00u) && ((elem & 0x03ffu) != 0);
561561
}
562562

563-
X86_SIMD_SORT_INLINE void avx512_qsort_fp16(uint16_t *arr,
564-
arrsize_t arrsize,
565-
bool hasnan = false,
566-
bool descending = false)
563+
[[maybe_unused]] X86_SIMD_SORT_INLINE void
564+
avx512_qsort_fp16(uint16_t *arr,
565+
arrsize_t arrsize,
566+
bool hasnan = false,
567+
bool descending = false)
567568
{
568569
using vtype = zmm_vector<float16>;
569570

@@ -585,11 +586,12 @@ X86_SIMD_SORT_INLINE void avx512_qsort_fp16(uint16_t *arr,
585586
}
586587
}
587588

588-
X86_SIMD_SORT_INLINE void avx512_qselect_fp16(uint16_t *arr,
589-
arrsize_t k,
590-
arrsize_t arrsize,
591-
bool hasnan = false,
592-
bool descending = false)
589+
[[maybe_unused]] X86_SIMD_SORT_INLINE void
590+
avx512_qselect_fp16(uint16_t *arr,
591+
arrsize_t k,
592+
arrsize_t arrsize,
593+
bool hasnan = false,
594+
bool descending = false)
593595
{
594596
using vtype = zmm_vector<float16>;
595597

@@ -617,11 +619,12 @@ X86_SIMD_SORT_INLINE void avx512_qselect_fp16(uint16_t *arr,
617619
}
618620
}
619621

620-
X86_SIMD_SORT_INLINE void avx512_partial_qsort_fp16(uint16_t *arr,
621-
arrsize_t k,
622-
arrsize_t arrsize,
623-
bool hasnan = false,
624-
bool descending = false)
622+
[[maybe_unused]] X86_SIMD_SORT_INLINE void
623+
avx512_partial_qsort_fp16(uint16_t *arr,
624+
arrsize_t k,
625+
arrsize_t arrsize,
626+
bool hasnan = false,
627+
bool descending = false)
625628
{
626629
avx512_qselect_fp16(arr, k - 1, arrsize, hasnan, descending);
627630
avx512_qsort_fp16(arr, k - 1, descending);

src/avx512-64bit-keyvaluesort.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ avx512_qsort_kv(T1 *keys, T2 *indexes, arrsize_t arrsize, bool hasnan = false)
418418
zmm_vector<T2>>::type;
419419

420420
if (arrsize > 1) {
421-
if constexpr (std::is_floating_point_v<T1>) {
421+
if constexpr (xss::fp::is_floating_point_v<T1>) {
422422
arrsize_t nan_count = 0;
423423
if (UNLIKELY(hasnan)) {
424424
nan_count = replace_nan_with_inf<zmm_vector<T1>>(keys, arrsize);

src/xss-common-argsort.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ avx512_argsort(T *arr, arrsize_t *arg, arrsize_t arrsize, bool hasnan = false)
554554
zmm_vector<arrsize_t>>::type;
555555

556556
if (arrsize > 1) {
557-
if constexpr (std::is_floating_point_v<T>) {
557+
if constexpr (xss::fp::is_floating_point_v<T>) {
558558
if ((hasnan) && (array_has_nan<vectype>(arr, arrsize))) {
559559
std_argsort_withnan(arr, arg, 0, arrsize);
560560
return;
@@ -580,7 +580,7 @@ avx2_argsort(T *arr, arrsize_t *arg, arrsize_t arrsize, bool hasnan = false)
580580
avx2_half_vector<arrsize_t>,
581581
avx2_vector<arrsize_t>>::type;
582582
if (arrsize > 1) {
583-
if constexpr (std::is_floating_point_v<T>) {
583+
if constexpr (xss::fp::is_floating_point_v<T>) {
584584
if ((hasnan) && (array_has_nan<vectype>(arr, arrsize))) {
585585
std_argsort_withnan(arr, arg, 0, arrsize);
586586
return;
@@ -611,7 +611,7 @@ X86_SIMD_SORT_INLINE void avx512_argselect(T *arr,
611611
zmm_vector<arrsize_t>>::type;
612612

613613
if (arrsize > 1) {
614-
if constexpr (std::is_floating_point_v<T>) {
614+
if constexpr (xss::fp::is_floating_point_v<T>) {
615615
if ((hasnan) && (array_has_nan<vectype>(arr, arrsize))) {
616616
std_argselect_withnan(arr, arg, k, 0, arrsize);
617617
return;
@@ -641,7 +641,7 @@ X86_SIMD_SORT_INLINE void avx2_argselect(T *arr,
641641
avx2_vector<arrsize_t>>::type;
642642

643643
if (arrsize > 1) {
644-
if constexpr (std::is_floating_point_v<T>) {
644+
if constexpr (xss::fp::is_floating_point_v<T>) {
645645
if ((hasnan) && (array_has_nan<vectype>(arr, arrsize))) {
646646
std_argselect_withnan(arr, arg, k, 0, arrsize);
647647
return;

src/xss-common-includes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <immintrin.h>
88
#include <limits>
99
#include <vector>
10+
#include "xss-custom-float.h"
1011

1112
#define X86_SIMD_SORT_INFINITY std::numeric_limits<double>::infinity()
1213
#define X86_SIMD_SORT_INFINITYF std::numeric_limits<float>::infinity()

src/xss-common-qsort.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ X86_SIMD_SORT_INLINE void replace_inf_with_nan(type_t *arr,
105105
{
106106
if (descending) {
107107
for (arrsize_t ii = 0; nan_count > 0; ++ii) {
108-
if constexpr (std::is_floating_point_v<type_t>) {
109-
arr[ii] = std::numeric_limits<type_t>::quiet_NaN();
108+
if constexpr (xss::fp::is_floating_point_v<type_t>) {
109+
arr[ii] = xss::fp::quiet_NaN<type_t>();
110110
}
111111
else {
112112
arr[ii] = 0xFFFF;
@@ -116,8 +116,8 @@ X86_SIMD_SORT_INLINE void replace_inf_with_nan(type_t *arr,
116116
}
117117
else {
118118
for (arrsize_t ii = size - 1; nan_count > 0; --ii) {
119-
if constexpr (std::is_floating_point_v<type_t>) {
120-
arr[ii] = std::numeric_limits<type_t>::quiet_NaN();
119+
if constexpr (xss::fp::is_floating_point_v<type_t>) {
120+
arr[ii] = xss::fp::quiet_NaN<type_t>();
121121
}
122122
else {
123123
arr[ii] = 0xFFFF;
@@ -619,7 +619,7 @@ X86_SIMD_SORT_INLINE void xss_qsort(T *arr, arrsize_t arrsize, bool hasnan)
619619

620620
if (arrsize > 1) {
621621
arrsize_t nan_count = 0;
622-
if constexpr (std::is_floating_point_v<T>) {
622+
if constexpr (xss::fp::is_floating_point_v<T>) {
623623
if (UNLIKELY(hasnan)) {
624624
nan_count = replace_nan_with_inf<vtype>(arr, arrsize);
625625
}
@@ -646,7 +646,7 @@ xss_qselect(T *arr, arrsize_t k, arrsize_t arrsize, bool hasnan)
646646
arrsize_t index_first_elem = 0;
647647
arrsize_t index_last_elem = arrsize - 1;
648648

649-
if constexpr (std::is_floating_point_v<T>) {
649+
if constexpr (xss::fp::is_floating_point_v<T>) {
650650
if (UNLIKELY(hasnan)) {
651651
if constexpr (descending) {
652652
index_first_elem = move_nans_to_start_of_array(arr, arrsize);

utils/custom-float.h renamed to src/xss-custom-float.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef UTILS_FLOAT
2-
#define UTILS_FLOAT
1+
#ifndef XSS_CUSTOM_FLOAT
2+
#define XSS_CUSTOM_FLOAT
33
#include <cstdint>
44
namespace xss {
55
namespace fp {
@@ -87,4 +87,4 @@ namespace fp {
8787

8888
} // namespace fp
8989
} // namespace xss
90-
#endif
90+
#endif // XSS_CUSTOM_FLOAT

tests/meson.build

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ libtests = []
33
libtests += static_library('tests_qsort',
44
files('test-qsort.cpp', ),
55
dependencies: gtest_dep,
6-
include_directories : [lib, utils],
6+
include_directories : [src, lib, utils],
77
)
88

99
libtests += static_library('tests_kvsort',
1010
files('test-keyvalue.cpp', ),
1111
dependencies: gtest_dep,
12-
include_directories : [lib, utils],
12+
include_directories : [src, lib, utils],
1313
)
1414

1515
libtests += static_library('tests_objsort',
1616
files('test-objqsort.cpp', ),
1717
dependencies: gtest_dep,
18-
include_directories : [lib, utils],
18+
include_directories : [src, lib, utils],
1919
)

utils/custom-compare.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <limits>
22
#include <cmath>
3-
#include "custom-float.h"
3+
#include "xss-custom-float.h"
44

55
/*
66
* Custom comparator class to handle NAN's: treats NAN > INF

utils/rand_array.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <type_traits>
1111
#include <vector>
1212
#include <algorithm>
13-
#include "custom-float.h"
13+
#include "xss-custom-float.h"
1414

1515
template <typename T>
1616
static std::vector<T> get_uniform_rand_array(int64_t arrsize,

0 commit comments

Comments
 (0)