diff --git a/magyarsort.h b/magyarsort.h index 4937a9d..4de14b2 100644 --- a/magyarsort.h +++ b/magyarsort.h @@ -51,9 +51,9 @@ namespace MagyarSort { void debugRadics(size_t *radics) { for(size_t j = 0; j < DIGITS; ++j) { - printf("d%d: ", j); + printf("d%zu: ", j); for(size_t i = 0; i < DIGIT_RANGE; ++i) { - printf("%d,", radics[i + DIGIT_RANGE*j]); + printf("%zu,", radics[i + DIGIT_RANGE*j]); } printf("\n\n"); } diff --git a/makefile b/makefile index 2511d23..b3836fc 100644 --- a/makefile +++ b/makefile @@ -1,6 +1,9 @@ debug: test.cpp magyarsort.h g++ test.cpp -g -std=c++14 -o test.out +release_coz: test.cpp magyarsort.h + g++ test.cpp -g1 -gdwarf-2 -std=c++14 -O2 -ldl -o test.out + release_debug_sym: test.cpp magyarsort.h g++ test.cpp -g -std=c++14 -O2 -o test.out diff --git a/test.cpp b/test.cpp index 3d92212..02fed39 100644 --- a/test.cpp +++ b/test.cpp @@ -7,18 +7,22 @@ // Number of input elements to generate - unused when CREEL is defined! //#define SORT_WIDTH 200000000 -#define SORT_WIDTH 400000 +#define SORT_WIDTH 40000000 // Uncomment this to use nibbles as digits and not bytes - CREEL defines this anyways //#define MAGYAR_SORT_NIBBLE // Uncomment if you want to see output before / after sorts (debugging for example) //#define PRINT_OUTPUT -#define SKA_SORT +//#define SKA_SORT // Uncomment for perf / cachegring and similar runs! #define MEASURE_ONLY +// Uncomment this for performance measuring with "coz" +// XXX: Beware that we will do this many times of sorts! +#define COZ_MEASURE 400 + /* Includes */ #include @@ -34,6 +38,10 @@ #include "ska_sort.hpp" #endif // SKA_SORT +#ifdef COZ_MEASURE +#include "coz.h" +#endif // COZ_MEASURE + /* Input generation and prerequisites */ #ifdef CREEL @@ -122,6 +130,20 @@ int main() { MagyarSort::sort(arr1, in1.size()); auto ourEnd = std::chrono::high_resolution_clock::now(); +#ifdef COZ_MEASURE + std::vector in_coz_common = GenerateInput();; + for(int i = 0; i < COZ_MEASURE; ++i) { + std::vector in_coz = in_coz_common; // cpy + + uint32_t *arr_coz = &(in_coz[0]); + + MagyarSort::sort(arr1, in1.size()); + COZ_PROGRESS_NAMED("magyarsort_progress"); + + if((i % 128) == 0) { printf("%d / %d\n", i, COZ_MEASURE); } + } +#endif // COZ_MEASURE + #ifdef PRINT_OUTPUT printf("Our: "); MagyarSort::debugArr(arr1, in1.size()); @@ -139,14 +161,18 @@ int main() { printf("Results:\n\n"); printf("- Sorted %zu elements", in1.size()); #ifndef MEASURE_ONLY - if(good) printf("- Same result as std::sort!\n"); - else printf("- Differs from std::sort! Error!\n"); + if(good) printf("- Same result as known sort result!\n"); + else printf("- Differs from known sort result! Error!\n"); printf("\n"); auto stdElapsed = std::chrono::duration_cast(stdEnd - stdBegin); #endif // !MEASURE_ONLY auto ourElapsed = std::chrono::duration_cast(ourEnd - ourBegin); #ifndef MEASURE_ONLY +#ifdef SKA_SORT + printf("Time (ska sort): %.3f ms.\n", stdElapsed.count() * 1e-6); +#else printf("Time (std sort): %.3f ms.\n", stdElapsed.count() * 1e-6); +#endif #endif // !MEASURE_ONLY printf("Time (our sort): %.3f ms.\n", ourElapsed.count() * 1e-6);