From 69d1432721f11ff0e8a50f2b6ca55fe08cfc73d4 Mon Sep 17 00:00:00 2001 From: Richard Thier Date: Wed, 1 Oct 2025 00:34:08 +0200 Subject: [PATCH] thier3: no unnecessary 4096 loops and storage because last commit makes it not necessary --- thiersort3.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/thiersort3.h b/thiersort3.h index 219b345..c3f4328 100644 --- a/thiersort3.h +++ b/thiersort3.h @@ -53,12 +53,12 @@ static inline uint32_t witch_bucket3(uint32_t key) { * @param rstate Create with sch_rand_state rstate = schwab_rand_state(junk_uint32_t); */ static inline void thiersort3(uint32_t *arr, uint32_t *temparr, int n) { - int bucket[4096]; /* Inclusive */ - int bucket_end[4096]; /* Not inclusive */ + int bucket[256]; /* Inclusive */ + int bucket_end[256]; /* Not inclusive */ #ifndef NO_EXTRA_BIT - int bucket_leftend[4096]; /* for extra 1bit split processing */ - int bucket_left[4096]; /* for extra 1bit split processing */ + int bucket_leftend[256]; /* for extra 1bit split processing */ + int bucket_left[256]; /* for extra 1bit split processing */ #endif /* NO_EXTRA_BIT */ /* Check if need to sort at all - needed for invariants later */ @@ -68,7 +68,7 @@ static inline void thiersort3(uint32_t *arr, uint32_t *temparr, int n) { /* Count */ #pragma GCC unroll 64 - for(int i = 0; i < 4096; ++i) { + for(int i = 0; i < 256; ++i) { bucket[i] = 0; } #pragma GCC unroll 64 @@ -79,14 +79,14 @@ static inline void thiersort3(uint32_t *arr, uint32_t *temparr, int n) { /* Prefix sum (like in Magyarsort) */ uint32_t prev = 0; #pragma GCC unroll 4 - for (int i = 0; i < 4096; i++) { + for (int i = 0; i < 256; i++) { bucket[i] += prev; prev = bucket[i]; } /* Save end-offsets */ #pragma GCC unroll 64 - for(int i = 0; i < 4096; ++i) { + for(int i = 0; i < 256; ++i) { bucket_end[i] = bucket[i]; } @@ -115,7 +115,7 @@ static inline void thiersort3(uint32_t *arr, uint32_t *temparr, int n) { /* temparr -> arr each bucket and sort them in-place */ #pragma GCC unroll 64 - for(int b = 0; b < 4096; ++b) { + for(int b = 0; b < 256; ++b) { int begin = bucket[b]; int end = bucket_end[b]; @@ -149,7 +149,7 @@ static inline void thiersort3(uint32_t *arr, uint32_t *temparr, int n) { /* temparr -> arr each bucket and sort them in-place */ #pragma GCC unroll 64 - for(int b = 0; b < 4096; ++b) { + for(int b = 0; b < 256; ++b) { assert(bucket_leftend[b] == bucket[b]); int lbegin = bucket_left[b]; int lend = bucket[b]; /* non-inclusive */