scandum / fluxsort

A fast branchless stable quicksort / mergesort hybrid that is highly adaptive.
The Unlicense
678 stars 21 forks source link

Make quadsort and fluxsort compilable as C++ code #6

Closed Voultapher closed 1 year ago

Voultapher commented 1 year ago

There are slight implicit cast differences depending if code is compiled as C and C++ code. With some minor changes quadsort and fluxsort can be made to support both compiling as C and C++.

Voultapher commented 1 year ago

This is mostly a pain when I update them in my sort-research-rs repo. Also I'm seeing a slight improvement to crumsort if it uses the quadsort version from fluxsort. It might be a good idea to somehow unify or reference the code so it doesn't have to be updated in x various repositories.

scandum commented 1 year ago

I already had this fixed this upstream, but I also have some other changes that need a bit more testing.

You can use g++ -fpermissive to get the current code to compile, though clang++ doesn't support that option.

Voultapher commented 1 year ago

I try to give each sort I'm testing the best perf I can find, and for crumsort and fluxsort that means clang now, previously I saw slightly better perf with gcc. So no I can't use -fpermissive. Are your other changes incompatible with this PR, if not I suggest merging this and doing your changes in addition to them.

scandum commented 1 year ago

My approach to getting it to compile for clang++ was quite a bit different. I'll try to update in the next couple of days.

Keep in mind I primarily focus on performance for strings and tables, so there might be some performance regression for arrays of primitives from time to time.

scandum commented 1 year ago

Alright, I updated blitsort, crumsort, fluxsort, and quadsort. Should compile with clang++, though there's an odd issue with clang and #include <algorithm> in some cases.

Edit: Blitsort won't run very fast in clang due to the binary search and rotation code not compiling optimally.

Voultapher commented 1 year ago

Thanks, fluxsort can now be compiled as C++ barring https://github.com/scandum/fluxsort/pull/7