@@ -10,43 +10,55 @@ relative to std::sort. The following API's are currently supported:
10
10
11
11
#### Quicksort
12
12
13
- ```
13
+ ``` cpp
14
14
void avx512_qsort<T>(T* arr, int64_t arrsize)
15
15
```
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.
18
22
19
23
#### Argsort
20
24
21
- ```
25
+ ``` cpp
22
26
std::vector<int64_t > arg = avx512_argsort<T>(T* arr, int64_t arrsize)
23
27
void avx512_argsort<T>(T* arr, int64_t *arg, int64_t arrsize)
24
28
```
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.
27
33
28
34
#### Quickselect
29
35
30
- ```
36
+ ``` cpp
31
37
void avx512_qselect<T>(T* arr, int64_t arrsize)
32
38
void avx512_qselect<T>(T* arr, int64_t arrsize, bool hasnan)
33
39
```
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.
37
46
38
47
#### Partialsort
39
48
40
- ```
49
+ ``` cpp
41
50
void avx512_partial_qsort<T>(T* arr, int64_t arrsize)
42
51
void avx512_partial_qsort<T>(T* arr, int64_t arrsize, bool hasnan)
43
52
```
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.
47
59
48
60
#### Key-value sort
49
- ```
61
+ ``` cpp
50
62
void avx512_qsort_kv<T>(T* key, uint64_t * value , int64_t arrsize)
51
63
```
52
64
Supported datatypes: ` uint64_t, int64_t and double `
@@ -64,15 +76,6 @@ network. The core implementations of the vectorized qsort functions
64
76
` avx512_qsort<T>(T*, int64_t) ` are modified versions of avx2 quicksort
65
77
presented in the paper [ 2] and source code associated with that paper [ 3] .
66
78
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
-
76
79
## Example to include and build this in a C++ code
77
80
78
81
### Sample code ` main.cpp `
0 commit comments