tried fewer but simpler bucketing

This commit is contained in:
Richard Thier 2025-09-12 01:58:28 +02:00
parent 2c5b0b1177
commit 30e868d154
2 changed files with 7 additions and 0 deletions

View File

@ -16,6 +16,9 @@ release: test.cpp magyarsort.h
release_ypsu: ypsu.cpp magyarsort.h
g++ ypsu.cpp -DNDEBUG -std=c++17 -O2 -o ypsu.out
release3_ypsu: ypsu.cpp magyarsort.h
g++ ypsu.cpp -DNDEBUG -std=c++17 -O3 -o ypsu.out
release_ypsu_assert: ypsu.cpp magyarsort.h
g++ ypsu.cpp -std=c++17 -O2 -o ypsu.out

View File

@ -24,8 +24,12 @@ static inline uint32_t witch_bucket(uint32_t key) {
/* This approach uses 12 bits from a 32 bit float to map onto a byte bucket index */
th2_fu as;
as.f = (float) key;
uint32_t witch_base = (key <= 2) ? 0 : (as.u >> 23) - 128; // 0, [127..159] -> [0..31]
return witch_base * 8 + ((as.u >> (23 - 3)) & 7);
/* Alternative (but I measure it being worse):
return (as.u >> 23);
*/
}
/**