4 ms·
I played a bit with sorting 8 floats in 2 SSE registers with a sorting network. I had a bit of trouble shuffling the registers so the values would be in the rig
by 0xf00ff00f 4y ago
I played a bit with sorting 8 floats in 2 SSE registers with a sorting network. I had a bit of trouble shuffling the registers so the values would be in the right places, so I ended up brute-forcing it:
https://github.com/0xf00ff00f/short-simd-sorter https://github.com/0xf00ff00f/short-simd-sorter
I don't know if you could use the same idea to sort 16 values in 2 AVX registers. There's probably a better way.
- ww520 4y agoThat's pretty cool. The compare_and_swap ops of the sorting network can be done in SIMD using _mm_min_epi32, _mm_max_epi32, and _mm_blend_epi32. For the 8-value network, they can operate on 4 pairs of the values and 8 pairs for 16-value network, as long as the pairs have no dependency with each other.