4 ms·
I am not very experienced with SIMD but wouldn't a SIMD-based binary search be faster? In this particular case (assuming SIMD can make 4 comparisons at once),
by AlexanderTheGr8 5y ago
I am not very experienced with SIMD but wouldn't a SIMD-based binary search be faster?
In this particular case (assuming SIMD can make 4 comparisons at once), we have an array with 128 elements. So we can compare the needle with indices {24, 48, 72, 96} in one CPU cycle; so we narrow down to approx 24 elements in 1 cycle. Repeat this until we get the answer.
This^ is a very approximate idea. There are a lot of edge-cases and things to consider. But couldn't we solve this problem in 4-5 cycles with SIMD binary search?
- pkhuong 5y agoSIMD gather are slow on commodity hardware, often as slow as loading and inserting each element one at a time.