<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Mar 13, 2014 at 11:06 AM, Mike McFadden <span dir="ltr"><<a href="mailto:mike@ivideoapp.com" target="_blank">mike@ivideoapp.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi, I used a paper called "Ratio based in-place stable merging" to implement a hybrid stable sort algorithm, and have been validating the results against stable_sort and inplace_stable_sort. What's interesting is that it matches 80-90% of the speed of stable_sort with random data, is much faster in many other cases, and does so while using O(1) memory. Simply giving it more memory allows it to closely match stable_sort in speed. And compared to inplace_stable_sort it's anywhere from 3-15x faster, with random data being about 5x faster.<div>
<br></div><div>I have fully documented the algorithm and have a C++ implementation available here:</div><div><a href="https://github.com/BonzaiThePenguin/WikiSort" target="_blank">https://github.com/BonzaiThePenguin/WikiSort</a></div>
<div><br></div><div>The underlying algorithm was vetted and proven back in 2008 (there's a link to the published paper on the GitHub project page), and the simplified version used here is constantly tested against existing algorithms for correctness and speed, but toying with a core feature of libc++ is obviously not something to be taken lightly so I'm hoping for some additional vetting and consideration.</div>
</div></blockquote><div><br></div><div>Looks interesting to me. You should be able to accelerate std::rotate by using the cache even if neither range fits within it (perform a gcd rotate, moving a cache-sized chunk of the data at a time).</div>
<div><br></div><div>Incidentally, your current Rotate function is cheating. You can't use std::memcpy/std::memmove on objects of class type in general.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div>My ultimate goal would be to replace inplace_stable_sort at the very least, and ideally stable_sort as well. Maybe including it as a separate sort function for now would be wise?</div>
<span class="HOEnZb"><font color="#888888"><div><br></div><div>- Mike</div><div><br></div></font></span></div><br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div></div>