/sort6

Fastest way to sort 6 integers.

Primary LanguageC

sort6

Fastest way to sort 6 integers.

Based off of: http://stackoverflow.com/questions/2786899/fastest-sort-of-fixed-length-6-int-array/39336981#39336981

I fixed the provided benchmark until it was runnable out of the box. I tried a few different rank order experiments. I developed an insertion sort and a rank order sort that take place in AVX registers. My fastest AVX sort matched the performance of the serial algorithm, but was no faster.

  1. sort6_insertion_sort_avx : Permute in blend to swap out of order elements.
  2. sort6_rank_order_reuse : save the result of previous comparisons. Worse because of data dependencies.
  3. sort6_rank_order_loop : simplified rank order sort into a loop to apply for the avx version.
  4. sort6_rank_order_avx : Compute the target indices into the register and use to change the information. shuffling inside the register is too expensive because of the need to invert the indices.