|
34 | 34 | return x86simdsortStatic::argselect(arr, k, arrsize, hasnan); \ |
35 | 35 | } |
36 | 36 |
|
37 | | -#define DEFINE_KEYVALUE_METHODS(type) \ |
38 | | - template <> \ |
39 | | - void keyvalue_qsort(type *key, uint64_t *val, size_t arrsize, bool hasnan) \ |
40 | | - { \ |
41 | | - x86simdsortStatic::keyvalue_qsort(key, val, arrsize, hasnan); \ |
42 | | - } \ |
43 | | - template <> \ |
44 | | - void keyvalue_qsort(type *key, int64_t *val, size_t arrsize, bool hasnan) \ |
45 | | - { \ |
46 | | - x86simdsortStatic::keyvalue_qsort(key, val, arrsize, hasnan); \ |
47 | | - } \ |
48 | | - template <> \ |
49 | | - void keyvalue_qsort(type *key, double *val, size_t arrsize, bool hasnan) \ |
50 | | - { \ |
51 | | - x86simdsortStatic::keyvalue_qsort(key, val, arrsize, hasnan); \ |
52 | | - } \ |
| 37 | +#define DEFINE_KEYVALUE_METHODS_BASE(type1, type2) \ |
53 | 38 | template <> \ |
54 | | - void keyvalue_qsort(type *key, uint32_t *val, size_t arrsize, bool hasnan) \ |
| 39 | + void keyvalue_qsort(type1 *key, \ |
| 40 | + type2 *val, \ |
| 41 | + size_t arrsize, \ |
| 42 | + bool hasnan, \ |
| 43 | + bool descending) \ |
55 | 44 | { \ |
56 | | - x86simdsortStatic::keyvalue_qsort(key, val, arrsize, hasnan); \ |
| 45 | + x86simdsortStatic::keyvalue_qsort( \ |
| 46 | + key, val, arrsize, hasnan, descending); \ |
57 | 47 | } \ |
58 | 48 | template <> \ |
59 | | - void keyvalue_qsort(type *key, int32_t *val, size_t arrsize, bool hasnan) \ |
| 49 | + void keyvalue_select(type1 *key, \ |
| 50 | + type2 *val, \ |
| 51 | + size_t k, \ |
| 52 | + size_t arrsize, \ |
| 53 | + bool hasnan, \ |
| 54 | + bool descending) \ |
60 | 55 | { \ |
61 | | - x86simdsortStatic::keyvalue_qsort(key, val, arrsize, hasnan); \ |
| 56 | + x86simdsortStatic::keyvalue_select( \ |
| 57 | + key, val, k, arrsize, hasnan, descending); \ |
62 | 58 | } \ |
63 | 59 | template <> \ |
64 | | - void keyvalue_qsort(type *key, float *val, size_t arrsize, bool hasnan) \ |
| 60 | + void keyvalue_partial_sort(type1 *key, \ |
| 61 | + type2 *val, \ |
| 62 | + size_t k, \ |
| 63 | + size_t arrsize, \ |
| 64 | + bool hasnan, \ |
| 65 | + bool descending) \ |
65 | 66 | { \ |
66 | | - x86simdsortStatic::keyvalue_qsort(key, val, arrsize, hasnan); \ |
| 67 | + x86simdsortStatic::keyvalue_partial_sort( \ |
| 68 | + key, val, k, arrsize, hasnan, descending); \ |
67 | 69 | } |
68 | 70 |
|
| 71 | +#define DEFINE_KEYVALUE_METHODS(type) \ |
| 72 | + DEFINE_KEYVALUE_METHODS_BASE(type, uint64_t) \ |
| 73 | + DEFINE_KEYVALUE_METHODS_BASE(type, int64_t) \ |
| 74 | + DEFINE_KEYVALUE_METHODS_BASE(type, double) \ |
| 75 | + DEFINE_KEYVALUE_METHODS_BASE(type, uint32_t) \ |
| 76 | + DEFINE_KEYVALUE_METHODS_BASE(type, int32_t) \ |
| 77 | + DEFINE_KEYVALUE_METHODS_BASE(type, float) |
| 78 | + |
69 | 79 | namespace xss { |
70 | 80 | namespace avx2 { |
71 | 81 | DEFINE_ALL_METHODS(uint32_t) |
|
0 commit comments