more ILP in some nearly sorted bucket parts in spsort - rand still not good so much
This commit is contained in:
parent
4bed99751f
commit
f8793f71ab
@ -139,15 +139,18 @@ inline int internal_array_separate(uint32_t *t, int n, uint32_t mid) {
|
||||
int left = 0;
|
||||
int right = n - 1;
|
||||
while(left < right) {
|
||||
bool lok = (t[left] < mid);
|
||||
bool rok = (t[right] >= mid);
|
||||
if(lok || rok) {
|
||||
// HOT PATH
|
||||
// Move heads until both in wrong location
|
||||
left += lok;
|
||||
right -= rok;
|
||||
} else {
|
||||
// REGULAR PATH
|
||||
// Step over already good positioned values from left
|
||||
while((left < right) && (t[left] < mid)) {
|
||||
++left;
|
||||
}
|
||||
|
||||
// Step over already good positioned values from right
|
||||
while((left < right) && (t[right] >= mid)) {
|
||||
--right;
|
||||
}
|
||||
|
||||
// Extra check needed for edge-case!
|
||||
if(left < right) {
|
||||
// Both in wrong location - xchg them!
|
||||
auto tmp = t[right];
|
||||
t[right] = t[left];
|
||||
@ -159,7 +162,6 @@ inline int internal_array_separate(uint32_t *t, int n, uint32_t mid) {
|
||||
|
||||
// Edge-case increment if single elem happens in middle in the end
|
||||
left += ((left == right) && (t[left] < mid));
|
||||
|
||||
return left;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user