thier3: no unnecessary 4096 loops and storage because last commit makes it not necessary
This commit is contained in:
parent
1f6ef0f2ea
commit
69d1432721
18
thiersort3.h
18
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);
|
* @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) {
|
static inline void thiersort3(uint32_t *arr, uint32_t *temparr, int n) {
|
||||||
int bucket[4096]; /* Inclusive */
|
int bucket[256]; /* Inclusive */
|
||||||
int bucket_end[4096]; /* Not inclusive */
|
int bucket_end[256]; /* Not inclusive */
|
||||||
|
|
||||||
#ifndef NO_EXTRA_BIT
|
#ifndef NO_EXTRA_BIT
|
||||||
int bucket_leftend[4096]; /* for extra 1bit split processing */
|
int bucket_leftend[256]; /* for extra 1bit split processing */
|
||||||
int bucket_left[4096]; /* for extra 1bit split processing */
|
int bucket_left[256]; /* for extra 1bit split processing */
|
||||||
#endif /* NO_EXTRA_BIT */
|
#endif /* NO_EXTRA_BIT */
|
||||||
|
|
||||||
/* Check if need to sort at all - needed for invariants later */
|
/* 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 */
|
/* Count */
|
||||||
#pragma GCC unroll 64
|
#pragma GCC unroll 64
|
||||||
for(int i = 0; i < 4096; ++i) {
|
for(int i = 0; i < 256; ++i) {
|
||||||
bucket[i] = 0;
|
bucket[i] = 0;
|
||||||
}
|
}
|
||||||
#pragma GCC unroll 64
|
#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) */
|
/* Prefix sum (like in Magyarsort) */
|
||||||
uint32_t prev = 0;
|
uint32_t prev = 0;
|
||||||
#pragma GCC unroll 4
|
#pragma GCC unroll 4
|
||||||
for (int i = 0; i < 4096; i++) {
|
for (int i = 0; i < 256; i++) {
|
||||||
bucket[i] += prev;
|
bucket[i] += prev;
|
||||||
prev = bucket[i];
|
prev = bucket[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save end-offsets */
|
/* Save end-offsets */
|
||||||
#pragma GCC unroll 64
|
#pragma GCC unroll 64
|
||||||
for(int i = 0; i < 4096; ++i) {
|
for(int i = 0; i < 256; ++i) {
|
||||||
bucket_end[i] = bucket[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 */
|
/* temparr -> arr each bucket and sort them in-place */
|
||||||
#pragma GCC unroll 64
|
#pragma GCC unroll 64
|
||||||
for(int b = 0; b < 4096; ++b) {
|
for(int b = 0; b < 256; ++b) {
|
||||||
int begin = bucket[b];
|
int begin = bucket[b];
|
||||||
int end = bucket_end[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 */
|
/* temparr -> arr each bucket and sort them in-place */
|
||||||
#pragma GCC unroll 64
|
#pragma GCC unroll 64
|
||||||
for(int b = 0; b < 4096; ++b) {
|
for(int b = 0; b < 256; ++b) {
|
||||||
assert(bucket_leftend[b] == bucket[b]);
|
assert(bucket_leftend[b] == bucket[b]);
|
||||||
int lbegin = bucket_left[b];
|
int lbegin = bucket_left[b];
|
||||||
int lend = bucket[b]; /* non-inclusive */
|
int lend = bucket[b]; /* non-inclusive */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user