tests for thier3 - works and very fast
This commit is contained in:
parent
86f81d2a1c
commit
7ca9a19c5d
@ -91,7 +91,7 @@ static inline void thiersort2(uint32_t *arr, uint32_t *temparr, int n, sch_rand_
|
||||
}
|
||||
|
||||
/* arr -> temparr */
|
||||
/* Move to the buckets - backwards going save a few cache miss */
|
||||
/* Move to the buckets */
|
||||
/* Rem.: This also changes bucket[i] so they will point to bucket beginnings */
|
||||
#pragma GCC unroll 64
|
||||
for(int i = 0; i < n; ++i) {
|
||||
|
||||
12
ypsu.cpp
12
ypsu.cpp
@ -22,6 +22,7 @@
|
||||
#include "qsort/schwab_sort.h"
|
||||
#include "qsort/chatgpt_qs.h"
|
||||
#include "threepass.h"
|
||||
#include "thiersort3.h"
|
||||
|
||||
// #define MAGYAR_SORT_DEFAULT_REUSE
|
||||
#include "magyarsort.h"
|
||||
@ -219,6 +220,13 @@ static inline void do_thier2(uint32_t *a, int n) noexcept {
|
||||
thiersort2(a, &(tmp[0]), n, &state);
|
||||
}
|
||||
|
||||
/** thier3 */
|
||||
static inline void do_thier3(uint32_t *a, int n) noexcept {
|
||||
assert(n * uint32_t(sizeof(a[0])) <= INT_MAX);
|
||||
std::vector<uint32_t> tmp(n);
|
||||
thiersort3(a, &(tmp[0]), n);
|
||||
}
|
||||
|
||||
/** 3+1 pass bottom-up radix */
|
||||
static inline void do_threepass(uint32_t *a, int n) noexcept {
|
||||
threepass(a, n);
|
||||
@ -999,6 +1007,10 @@ int main(int argc, char **argv) {
|
||||
measure(inputtype, "thier2", [&] { do_thier2(&w[0], w.size()); });
|
||||
assert(w == expected);
|
||||
|
||||
w = v;
|
||||
measure(inputtype, "thier3", [&] { do_thier3(&w[0], w.size()); });
|
||||
assert(w == expected);
|
||||
|
||||
w = v;
|
||||
measure(inputtype, "threep", [&] { do_threepass(&w[0], w.size()); });
|
||||
assert(w == expected);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user