not random, but thier3->2 change in rthier (which feels best now except for big rand magyar is best and smaller rand frewr and for comparison sort schwab is best)

This commit is contained in:
Richard Thier 2025-10-03 14:23:42 +02:00
parent 88da973e02
commit ae88ba5725

View File

@ -232,12 +232,17 @@ static inline void do_thier3(uint32_t *a, int n) noexcept {
static inline void do_rthier(uint32_t *a, int n) noexcept { static inline void do_rthier(uint32_t *a, int n) noexcept {
assert(n * uint32_t(sizeof(a[0])) <= INT_MAX); assert(n * uint32_t(sizeof(a[0])) <= INT_MAX);
if(n > 20000000) { if(n > 20000000) {
std::vector<uint32_t> tmp(n);
/* Helps a bit against our worst cases in big numbers */ /* Helps a bit against our worst cases in big numbers */
uint32_t junk; uint32_t junk;
randominus(a, n, junk); sch_rand_state state = schwab_rand_state(junk);
//randominus(a, n, junk);
//thiersort3(a, &(tmp[0]), n); // slower even with randominus
thiersort2(a, &(tmp[0]), n, &state);
} else {
std::vector<uint32_t> tmp(n);
thiersort3(a, &(tmp[0]), n);
} }
std::vector<uint32_t> tmp(n);
thiersort3(a, &(tmp[0]), n);
} }
/** 3+1 pass bottom-up radix */ /** 3+1 pass bottom-up radix */
@ -942,12 +947,6 @@ int main(int argc, char **argv) {
} }
}); });
w = v;
measure(inputtype, "magyar", [&] {
MagyarSort::sort<uint32_t>(&w[0], w.size());
});
assert(w == expected);
/* /*
w = v; w = v;
measure(inputtype, "rmagyar", [&] { measure(inputtype, "rmagyar", [&] {
@ -1095,6 +1094,13 @@ int main(int argc, char **argv) {
assert(w == expected); assert(w == expected);
*/ */
w = v;
measure(inputtype, "magyar", [&] {
MagyarSort::sort<uint32_t>(&w[0], w.size());
});
assert(w == expected);
for (auto r : results) printf("%9.3fs", r.second); for (auto r : results) printf("%9.3fs", r.second);
puts(""); puts("");
fflush(stdout); fflush(stdout);