From 7ca9a19c5d1ace022abace60831bc2dca80a8488 Mon Sep 17 00:00:00 2001 From: Richard Thier Date: Mon, 29 Sep 2025 18:18:37 +0200 Subject: [PATCH] tests for thier3 - works and very fast --- thiersort2.h | 2 +- ypsu.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/thiersort2.h b/thiersort2.h index 19c13b8..935404e 100644 --- a/thiersort2.h +++ b/thiersort2.h @@ -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) { diff --git a/ypsu.cpp b/ypsu.cpp index c9bee07..e3afa07 100644 --- a/ypsu.cpp +++ b/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 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);