@@ -10,43 +10,55 @@ relative to std::sort. The following API's are currently supported:
1010
1111#### Quicksort
1212
13- ```
13+ ``` cpp
1414void avx512_qsort<T>(T* arr, int64_t arrsize)
1515```
16- Supported datatypes: `uint16_t, int16_t, _ Float16, uint32_t, int32_t, float,
17- uint64_t, int64_t and double`
16+ Supported datatypes: ` uint16_t ` , ` int16_t ` , ` _Float16 ` , ` uint32_t ` , ` int32_t ` ,
17+ ` float ` , ` uint64_t ` , ` int64_t ` and ` double ` .
18+
19+ For floating-point types, if ` arr ` contains NaNs, they are moved to the end and
20+ replaced with a quiet NaN. That is, the original, bit-exact NaNs in the input
21+ are not preserved.
1822
1923#### Argsort
2024
21- ```
25+ ``` cpp
2226std::vector<int64_t > arg = avx512_argsort<T>(T* arr, int64_t arrsize)
2327void avx512_argsort<T>(T* arr, int64_t *arg, int64_t arrsize)
2428```
25- Supported datatypes: ` uint32_t, int32_t, float, uint64_t, int64_t and double ` .
26- The algorithm resorts to scalar ` std::sort ` if the array contains NAN.
29+ Supported datatypes: ` uint32_t ` , ` int32_t ` , ` float ` , ` uint64_t ` , ` int64_t ` and
30+ ` double ` .
31+
32+ The algorithm resorts to scalar ` std::sort ` if the array contains NaNs.
2733
2834#### Quickselect
2935
30- ```
36+ ``` cpp
3137void avx512_qselect<T>(T* arr, int64_t arrsize)
3238void avx512_qselect<T>(T* arr, int64_t arrsize, bool hasnan)
3339```
34- Supported datatypes: `uint16_t, int16_t, _ Float16 ,uint32_t, int32_t, float,
35- uint64_t, int64_t and double` . Use an additional optional argument ` bool
36- hasnan` if you expect your arrays to contain nan.
40+ Supported datatypes: ` uint16_t ` , ` int16_t ` , ` _Float16 ` , ` uint32_t ` , ` int32_t ` ,
41+ ` float ` , ` uint64_t ` , ` int64_t ` and ` double ` .
42+
43+ For floating-point types, if ` bool hasnan ` is set, NaNs are moved to the end of
44+ the array, preserving the bit-exact NaNs in the input. If NaNs are present but
45+ ` hasnan ` is ` false ` , the behavior is undefined.
3746
3847#### Partialsort
3948
40- ```
49+ ``` cpp
4150void avx512_partial_qsort<T>(T* arr, int64_t arrsize)
4251void avx512_partial_qsort<T>(T* arr, int64_t arrsize, bool hasnan)
4352```
44- Supported datatypes: `uint16_t, int16_t, _ Float16 ,uint32_t, int32_t, float,
45- uint64_t, int64_t and double` . Use an additional optional argument ` bool
46- hasnan` if you expect your arrays to contain nan.
53+ Supported datatypes: ` uint16_t ` , ` int16_t ` , ` _Float16 ` , ` uint32_t ` , ` int32_t ` ,
54+ ` float ` , ` uint64_t ` , ` int64_t ` and ` double ` .
55+
56+ For floating-point types, if ` bool hasnan ` is set, NaNs are moved to the end of
57+ the array, preserving the bit-exact NaNs in the input. If NaNs are present but
58+ ` hasnan ` is ` false ` , the behavior is undefined.
4759
4860#### Key-value sort
49- ```
61+ ``` cpp
5062void avx512_qsort_kv<T>(T* key, uint64_t * value , int64_t arrsize)
5163```
5264Supported datatypes: ` uint64_t, int64_t and double `
@@ -64,15 +76,6 @@ network. The core implementations of the vectorized qsort functions
6476` avx512_qsort<T>(T*, int64_t) ` are modified versions of avx2 quicksort
6577presented in the paper [ 2] and source code associated with that paper [ 3] .
6678
67- ## A note on NAN in float and double arrays
68-
69- If you expect your array to contain NANs, please be aware that the these
70- routines ** do not preserve your NANs as you pass them** . The quicksort,
71- quickselect, partialsort and key-value sorting routines will sort NAN's to the
72- end of the array and replace them with ` std::nan("1") ` . ` avx512_argsort `
73- routines will also resort to a scalar argsort that uses ` std::sort ` to sort array
74- that contains NAN.
75-
7679## Example to include and build this in a C++ code
7780
7881### Sample code ` main.cpp `
0 commit comments