#include #include #include #include #include #include #include #include "nibble.h" static long timediff(struct timespec start, struct timespec end) { struct timespec temp; if ((end.tv_nsec-start.tv_nsec)<0) { temp.tv_sec = end.tv_sec-start.tv_sec - 1; temp.tv_nsec = 1000000000L + end.tv_nsec-start.tv_nsec; } else { temp.tv_sec = end.tv_sec-start.tv_sec; temp.tv_nsec = end.tv_nsec-start.tv_nsec; } return temp.tv_sec * 1000000000L + temp.tv_nsec; } static const int REPS = 25; static const int BUFSIZE = 1024; typedef void (*nibble_func_t)(unsigned long *buf); typedef struct { nibble_func_t func; const char *name; } nibble_sort_t; static nibble_sort_t funcs[] = { { nibble_sort_ref, "ref" }, { nibble_sort_payer, "payer" }, { nibble_sort_anon, "anon" }, { nibble_sort_alexander1, "alexander1" }, { nibble_sort_alexander2, "alexander2" }, { nibble_sort_pdewacht, "pdewacht" }, { nibble_sort_carlos, "carlos" }, { nibble_sort_burton, "burton" }, { nibble_sort_rogers, "rogers" }, }; static unsigned long *getbuf(void) { unsigned long *p; int res = posix_memalign((void **)&p, 4096, BUFSIZE*8); assert(res == 0); assert(p); assert(((intptr_t)p & 0xfff) == 0); return p; } int main (void) { assert(sizeof(unsigned long)==8); srand(time(NULL) + getpid()); unsigned long *random_data = getbuf(); unsigned long *buf = getbuf(); unsigned long *buf2 = getbuf(); for (int i=0; i