Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fast in-register sort of bytes?

Given a register of 4 bytes (or 16 for SIMD), there has to be an efficient way to sort the bytes in-register with a few instructions.

Thanks in advance.

like image 625
alecco Avatar asked Oct 16 '09 22:10

alecco


People also ask

What is the fastest sort?

But since it has the upper hand in the average cases for most inputs, Quicksort is generally considered the “fastest” sorting algorithm.

Which sorting is efficient and faster?

Quicksort. Quicksort is one of the most efficient sorting algorithms, and this makes of it one of the most used as well. The first thing to do is to select a pivot number, this number will separate the data, on its left are the numbers smaller than it and the greater numbers on the right.

Is radix sort the fastest?

If all your parameters are all integers and if you have over 1024 input parameters, then radix sort is always faster.

How is a radix sort algorithm implemented?

The Radix sort algorithm works by ordering each digit from least significant to most significant. In base 10, radix sort would sort by the digits in the one's place, then the ten's place, and so on. To sort the values in each digit place, Radix sort employs counting sort as a subroutine.


1 Answers

Found it! It's in the 2007 paper "Using SIMD Registers and Instructions to Enable Instruction-Level Parallelism in Sorting Algorithms" by Furtak, Amaral, and Niewiadomski. Section 4.

It uses 4 SSE registers, has 12 steps, and runs in 19 instructions including load and store.

The same paper has some excellent work on dynamically making sorting networks with SIMD.

like image 133
alecco Avatar answered Sep 24 '22 05:09

alecco