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 left = 0;
|
||||||
int right = n - 1;
|
int right = n - 1;
|
||||||
while(left < right) {
|
while(left < right) {
|
||||||
bool lok = (t[left] < mid);
|
// Step over already good positioned values from left
|
||||||
bool rok = (t[right] >= mid);
|
while((left < right) && (t[left] < mid)) {
|
||||||
if(lok || rok) {
|
++left;
|
||||||
// HOT PATH
|
}
|
||||||
// Move heads until both in wrong location
|
|
||||||
left += lok;
|
// Step over already good positioned values from right
|
||||||
right -= rok;
|
while((left < right) && (t[right] >= mid)) {
|
||||||
} else {
|
--right;
|
||||||
// REGULAR PATH
|
}
|
||||||
|
|
||||||
|
// Extra check needed for edge-case!
|
||||||
|
if(left < right) {
|
||||||
// Both in wrong location - xchg them!
|
// Both in wrong location - xchg them!
|
||||||
auto tmp = t[right];
|
auto tmp = t[right];
|
||||||
t[right] = t[left];
|
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
|
// Edge-case increment if single elem happens in middle in the end
|
||||||
left += ((left == right) && (t[left] < mid));
|
left += ((left == right) && (t[left] < mid));
|
||||||
|
|
||||||
return left;
|
return left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
ypsu.cpp
4
ypsu.cpp
@ -419,8 +419,8 @@
|
|||||||
//int n = 64;
|
//int n = 64;
|
||||||
|
|
||||||
// Uncomment this for profiling and alg!
|
// Uncomment this for profiling and alg!
|
||||||
measure_single(n);
|
//measure_single(n);
|
||||||
return 0;
|
//return 0;
|
||||||
|
|
||||||
for (auto inputtype : inputtypes) {
|
for (auto inputtype : inputtypes) {
|
||||||
printf("%10s", inputtype.c_str());
|
printf("%10s", inputtype.c_str());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user