Skip to content

Commit 583ddf9

Browse files
author
Raghuveer Devulapalli
committed
Run clang format
1 parent 48b0919 commit 583ddf9

File tree

2 files changed

+38
-34
lines changed

2 files changed

+38
-34
lines changed

lib/x86simdsort-scalar.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,26 @@ namespace scalar {
2424
template <typename T>
2525
std::vector<int64_t> argsort(T *arr, int64_t arrsize)
2626
{
27-
std::vector<int64_t> arg(arrsize);
28-
std::iota(arg.begin(), arg.end(), 0);
29-
std::sort(arg.begin(),
30-
arg.end(),
31-
[arr](int64_t left, int64_t right) -> bool {
32-
return arr[left] < arr[right];
33-
});
34-
return arg;
27+
std::vector<int64_t> arg(arrsize);
28+
std::iota(arg.begin(), arg.end(), 0);
29+
std::sort(arg.begin(),
30+
arg.end(),
31+
[arr](int64_t left, int64_t right) -> bool {
32+
return arr[left] < arr[right];
33+
});
34+
return arg;
3535
}
3636
template <typename T>
3737
std::vector<int64_t> argselect(T *arr, int64_t k, int64_t arrsize)
3838
{
39-
std::vector<int64_t> arg(arrsize);
40-
std::iota(arg.begin(), arg.end(), 0);
41-
std::nth_element(arg.begin(),
42-
arg.begin() + k,
43-
arg.end(),
44-
[arr](int64_t left, int64_t right) -> bool {
45-
return arr[left] < arr[right];
46-
});
39+
std::vector<int64_t> arg(arrsize);
40+
std::iota(arg.begin(), arg.end(), 0);
41+
std::nth_element(arg.begin(),
42+
arg.begin() + k,
43+
arg.end(),
44+
[arr](int64_t left, int64_t right) -> bool {
45+
return arr[left] < arr[right];
46+
});
4747
return arg;
4848
}
4949

lib/x86simdsort.cpp

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ dispatch_requested(std::string_view cpurequested,
4545
return false;
4646
}
4747

48-
#define CAT_(a, b) a ## b
48+
#define CAT_(a, b) a##b
4949
#define CAT(a, b) CAT_(a, b)
5050

5151
#define DECLARE_INTERNAL_qsort(TYPE) \
@@ -57,31 +57,37 @@ dispatch_requested(std::string_view cpurequested,
5757
}
5858

5959
#define DECLARE_INTERNAL_qselect(TYPE) \
60-
static void (*internal_qselect##TYPE)(TYPE *, int64_t, int64_t, bool) = NULL; \
60+
static void (*internal_qselect##TYPE)(TYPE *, int64_t, int64_t, bool) \
61+
= NULL; \
6162
template <> \
6263
void qselect(TYPE *arr, int64_t k, int64_t arrsize, bool hasnan) \
6364
{ \
6465
(*internal_qselect##TYPE)(arr, k, arrsize, hasnan); \
6566
}
6667

6768
#define DECLARE_INTERNAL_partial_qsort(TYPE) \
68-
static void (*internal_partial_qsort##TYPE)(TYPE *, int64_t, int64_t, bool) = NULL; \
69+
static void (*internal_partial_qsort##TYPE)( \
70+
TYPE *, int64_t, int64_t, bool) \
71+
= NULL; \
6972
template <> \
7073
void partial_qsort(TYPE *arr, int64_t k, int64_t arrsize, bool hasnan) \
7174
{ \
7275
(*internal_partial_qsort##TYPE)(arr, k, arrsize, hasnan); \
7376
}
7477

7578
#define DECLARE_INTERNAL_argsort(TYPE) \
76-
static std::vector<int64_t> (*internal_argsort##TYPE)(TYPE *, int64_t) = NULL; \
79+
static std::vector<int64_t> (*internal_argsort##TYPE)(TYPE *, int64_t) \
80+
= NULL; \
7781
template <> \
7882
std::vector<int64_t> argsort(TYPE *arr, int64_t arrsize) \
7983
{ \
8084
return (*internal_argsort##TYPE)(arr, arrsize); \
8185
}
8286

8387
#define DECLARE_INTERNAL_argselect(TYPE) \
84-
static std::vector<int64_t> (*internal_argselect##TYPE)(TYPE *, int64_t, int64_t) = NULL; \
88+
static std::vector<int64_t> (*internal_argselect##TYPE)( \
89+
TYPE *, int64_t, int64_t) \
90+
= NULL; \
8591
template <> \
8692
std::vector<int64_t> argselect(TYPE *arr, int64_t k, int64_t arrsize) \
8793
{ \
@@ -90,8 +96,8 @@ dispatch_requested(std::string_view cpurequested,
9096

9197
/* runtime dispatch mechanism */
9298
#define DISPATCH(func, TYPE, ...) \
93-
DECLARE_INTERNAL_##func(TYPE) \
94-
static __attribute__((constructor)) void CAT(CAT(resolve_, func), TYPE)(void) \
99+
DECLARE_INTERNAL_##func(TYPE) static __attribute__((constructor)) void \
100+
CAT(CAT(resolve_, func), TYPE)(void) \
95101
{ \
96102
CAT(CAT(internal_, func), TYPE) = &xss::scalar::func<TYPE>; \
97103
__builtin_cpu_init(); \
@@ -110,8 +116,6 @@ dispatch_requested(std::string_view cpurequested,
110116
} \
111117
}
112118

113-
114-
115119
namespace x86simdsort {
116120
#ifdef __FLT16_MAX__
117121
DISPATCH(qsort, _Float16, "avx512_spr")
@@ -122,19 +126,19 @@ DISPATCH(argselect, _Float16, "none")
122126
#endif
123127

124128
#define DISPATCH_ALL(func, ISA_16BIT, ISA_32BIT, ISA_64BIT) \
125-
DISPATCH(func, uint16_t, ISA_16BIT)\
126-
DISPATCH(func, int16_t, ISA_16BIT)\
127-
DISPATCH(func, float, ISA_32BIT)\
128-
DISPATCH(func, int32_t, ISA_32BIT)\
129-
DISPATCH(func, uint32_t, ISA_32BIT)\
130-
DISPATCH(func, int64_t, ISA_64BIT)\
131-
DISPATCH(func, uint64_t, ISA_64BIT)\
132-
DISPATCH(func, double, ISA_64BIT)\
129+
DISPATCH(func, uint16_t, ISA_16BIT) \
130+
DISPATCH(func, int16_t, ISA_16BIT) \
131+
DISPATCH(func, float, ISA_32BIT) \
132+
DISPATCH(func, int32_t, ISA_32BIT) \
133+
DISPATCH(func, uint32_t, ISA_32BIT) \
134+
DISPATCH(func, int64_t, ISA_64BIT) \
135+
DISPATCH(func, uint64_t, ISA_64BIT) \
136+
DISPATCH(func, double, ISA_64BIT)
133137

134138
DISPATCH_ALL(qsort, ("avx512_icl"), ("avx512_skx"), ("avx512_skx"))
135139
DISPATCH_ALL(qselect, ("avx512_icl"), ("avx512_skx"), ("avx512_skx"))
136140
DISPATCH_ALL(partial_qsort, ("avx512_icl"), ("avx512_skx"), ("avx512_skx"))
137141
DISPATCH_ALL(argsort, "none", "avx512_skx", "avx512_skx")
138142
DISPATCH_ALL(argselect, "none", "avx512_skx", "avx512_skx")
139143

140-
} // namespace simdsort
144+
} // namespace x86simdsort

0 commit comments

Comments
 (0)