thiersort compile errors
This commit is contained in:
parent
8dd103ca54
commit
88a8e87418
33
thiersort.h
33
thiersort.h
@ -282,7 +282,7 @@ static inline void thiersort8_internal(
|
|||||||
void *reent_data);
|
void *reent_data);
|
||||||
|
|
||||||
/** The '<' operation used for int32 */
|
/** The '<' operation used for int32 */
|
||||||
static inline const int ts_lt_int(
|
static inline const TSBOOL ts_lt_int(
|
||||||
const union tskey ak,
|
const union tskey ak,
|
||||||
const union tskey bk,
|
const union tskey bk,
|
||||||
const TSU32 ai,
|
const TSU32 ai,
|
||||||
@ -290,7 +290,7 @@ static inline const int ts_lt_int(
|
|||||||
void *reent_data) { return (ak.i < bk.i); }
|
void *reent_data) { return (ak.i < bk.i); }
|
||||||
|
|
||||||
/** The '<' operation used for unsigned int32 */
|
/** The '<' operation used for unsigned int32 */
|
||||||
static inline const int ts_lt_uint(
|
static inline const TSBOOL ts_lt_uint(
|
||||||
const union tskey ak,
|
const union tskey ak,
|
||||||
const union tskey bk,
|
const union tskey bk,
|
||||||
const TSU32 ai,
|
const TSU32 ai,
|
||||||
@ -298,7 +298,7 @@ static inline const int ts_lt_uint(
|
|||||||
void *reent_data) { return (ak.u < bk.u); }
|
void *reent_data) { return (ak.u < bk.u); }
|
||||||
|
|
||||||
/** The '<' operation used for float */
|
/** The '<' operation used for float */
|
||||||
static inline const int ts_lt_float(
|
static inline const TSBOOL ts_lt_float(
|
||||||
const union tskey ak,
|
const union tskey ak,
|
||||||
const union tskey bk,
|
const union tskey bk,
|
||||||
const TSU32 ai,
|
const TSU32 ai,
|
||||||
@ -361,7 +361,8 @@ static inline void thiersort8_floatkey(
|
|||||||
ts_lt_float,
|
ts_lt_float,
|
||||||
TSFALSE,
|
TSFALSE,
|
||||||
TSFALSE,
|
TSFALSE,
|
||||||
TSTRUE);
|
TSTRUE,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -388,7 +389,7 @@ static inline struct tselem *thiersort_prepare_array(
|
|||||||
TSU32 length,
|
TSU32 length,
|
||||||
void* (*malloc)(size_t size)) {
|
void* (*malloc)(size_t size)) {
|
||||||
/* Allocate */
|
/* Allocate */
|
||||||
tselem *out = malloc(length * sizeof(tselem));
|
tselem *out = (tselem *)malloc(length * sizeof(tselem));
|
||||||
|
|
||||||
/* Fill */
|
/* Fill */
|
||||||
TSU32 j = 0;
|
TSU32 j = 0;
|
||||||
@ -431,12 +432,12 @@ static inline void thiersort_apply(
|
|||||||
// This also solves "already at right place" originals.
|
// This also solves "already at right place" originals.
|
||||||
while(ni != j) {
|
while(ni != j) {
|
||||||
// xchg j and ni
|
// xchg j and ni
|
||||||
memcpy(tmp, arr[(size_t)j * elemsize], elemsize);
|
memcpy(tmp, &((TSU8*)arr)[(size_t)j * elemsize], elemsize);
|
||||||
memcpy(
|
memcpy(
|
||||||
arr[(size_t)j * elemsize],
|
&((TSU8*)arr)[(size_t)j * elemsize],
|
||||||
arr[(size_t)ni * elemsize],
|
&((TSU8*)arr)[(size_t)ni * elemsize],
|
||||||
elemsize);
|
elemsize);
|
||||||
memcpy(arr[(size_t)ni * elemsize], tmp, elemsize);
|
memcpy(&((TSU8*)arr)[(size_t)ni * elemsize], tmp, elemsize);
|
||||||
|
|
||||||
// Mark j index as done in sortres for outer loop.
|
// Mark j index as done in sortres for outer loop.
|
||||||
// This is necessary for inner loop stopping early
|
// This is necessary for inner loop stopping early
|
||||||
@ -486,7 +487,7 @@ static inline TSU8 ts_radixi(
|
|||||||
union tskey k;
|
union tskey k;
|
||||||
if(isint) {
|
if(isint) {
|
||||||
/* Sign bit can be 1! */
|
/* Sign bit can be 1! */
|
||||||
k.f = (float)(arr[i].i);
|
k.f = (float)(key.i);
|
||||||
|
|
||||||
/* 8 bit float */
|
/* 8 bit float */
|
||||||
k.u >> 24;
|
k.u >> 24;
|
||||||
@ -496,7 +497,7 @@ static inline TSU8 ts_radixi(
|
|||||||
}
|
}
|
||||||
if(isunsigned) {
|
if(isunsigned) {
|
||||||
/* Sign bit CANNOT be 1! */
|
/* Sign bit CANNOT be 1! */
|
||||||
k.f = (float)(arr[i].u);
|
k.f = (float)(key.u);
|
||||||
|
|
||||||
/* 8 bit float */
|
/* 8 bit float */
|
||||||
/* top bit always zero so ignore it and use 8 useful bits */
|
/* top bit always zero so ignore it and use 8 useful bits */
|
||||||
@ -508,7 +509,7 @@ static inline TSU8 ts_radixi(
|
|||||||
}
|
}
|
||||||
if(isfloat) {
|
if(isfloat) {
|
||||||
/* Sign bit can be 1! */
|
/* Sign bit can be 1! */
|
||||||
k.f = arr[i].f;
|
k.f = key.f;
|
||||||
|
|
||||||
/* 8 bit float */
|
/* 8 bit float */
|
||||||
k.u >> 24;
|
k.u >> 24;
|
||||||
@ -540,7 +541,7 @@ static inline void ts_quicksort_inplace(
|
|||||||
TSU32 right = to - 1;
|
TSU32 right = to - 1;
|
||||||
while(left < right) {
|
while(left < right) {
|
||||||
// Step over rightly positioned elems from left
|
// Step over rightly positioned elems from left
|
||||||
const union tskey leftkey = arr[left].key;
|
union tskey leftkey = arr[left].key;
|
||||||
TSU32 lefti = arr[left].i;
|
TSU32 lefti = arr[left].i;
|
||||||
while((left < right) && lt(leftkey, pivotkey, lefti, pivoti, reent_data)) {
|
while((left < right) && lt(leftkey, pivotkey, lefti, pivoti, reent_data)) {
|
||||||
++left;
|
++left;
|
||||||
@ -549,7 +550,7 @@ static inline void ts_quicksort_inplace(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Step over rightly positioned elems from right
|
// Step over rightly positioned elems from right
|
||||||
const union tskey rightkey = arr[right].key;
|
union tskey rightkey = arr[right].key;
|
||||||
TSU32 righti = arr[right].i;
|
TSU32 righti = arr[right].i;
|
||||||
while((left < right) && lt(pivotkey, rightkey, pivoti, righti, reent_data)) {
|
while((left < right) && lt(pivotkey, rightkey, pivoti, righti, reent_data)) {
|
||||||
--right;
|
--right;
|
||||||
@ -639,7 +640,7 @@ static inline void thiersort8_internal(
|
|||||||
TSU32 radics[256] = {0};
|
TSU32 radics[256] = {0};
|
||||||
/* [from, to) index: only where prefix sums change - usually nonfull */
|
/* [from, to) index: only where prefix sums change - usually nonfull */
|
||||||
TSU32 real_radics[256 * 2] = {0};
|
TSU32 real_radics[256 * 2] = {0};
|
||||||
struct tselem *arr2 = malloc((sizeof struct tselem) * length);
|
struct tselem *arr2 = (tselem *)malloc((sizeof(struct tselem)) * length);
|
||||||
|
|
||||||
/* Step 1) Bucketing */
|
/* Step 1) Bucketing */
|
||||||
#ifdef TS_SSE2
|
#ifdef TS_SSE2
|
||||||
@ -691,7 +692,7 @@ static inline void thiersort8_internal(
|
|||||||
TSU32 to = real_radics[i + 1];
|
TSU32 to = real_radics[i + 1];
|
||||||
|
|
||||||
/* Quicksort this bucket in O(mlogm), where m << n usually */
|
/* Quicksort this bucket in O(mlogm), where m << n usually */
|
||||||
ts_quicksort_fromto(arr2, arr1, from, to, lt, reent_data);
|
ts_quicksort_fromto(arr2, arr, from, to, lt, reent_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cleanup */
|
/* Cleanup */
|
||||||
|
|||||||
1
ypsu.cpp
1
ypsu.cpp
@ -14,6 +14,7 @@
|
|||||||
#include <sys/mman.h> // mlock & munlock
|
#include <sys/mman.h> // mlock & munlock
|
||||||
#include "ska_sort.hpp"
|
#include "ska_sort.hpp"
|
||||||
#include "gptsort.h"
|
#include "gptsort.h"
|
||||||
|
#include "thiersort.h"
|
||||||
|
|
||||||
#define MAGYAR_SORT_DEFAULT_REUSE
|
#define MAGYAR_SORT_DEFAULT_REUSE
|
||||||
#include "magyarsort.h"
|
#include "magyarsort.h"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user