Skip to content

eliasgierlinger/assembler_radixsort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Radix Sort in x64 Assembly

This program sorts arrays of unsigned long ints using a radix sort algorithm written in x64 MASM assembly. The bucket count / radix of the sort is 2. For calculating the prefix sum I used 8 AVX 256 bit registers, which can process 8 unsigned long ints at once. Because I am using a radix of 2, I make use of the popcnt instruction, which counts the amounts of 1 bits in a register.

Here are some timings of the algorithm done on an AMD Ryzen 7 2700X - note that the time it takes for the helper array to be allocated is not considered:

Array lengthTime in ms
100000000079100
75000000059979
50000000039483
25000000019688
--------
1000000007940
750000006019
500000004055
250000002031
--------
10000000813
7500000599
5000000419
2500000201
--------
100000084
75000062
50000045
25000023
--------
10000011
750008
500006
250003

As can be seen, the timings scale linearly with the array size.

Unfortunately this program performs quite badly when compared to a radix sort with a bucket count of 256. I'd assume, that the thing, which holds this algorithm down, is that the entire array needs to be reordered 32 times. A 256 bucket radix sort only needs to reorder the array 4 times.

About

Radix sort written in assembly

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published