3 ms·
> It’s not immediately clear how to make this use SIMD… unless you use gathers. Gathers are slow. With SSE2, you only need 2 instructions to check for duplica
by Const-me 8y ago
> It’s not immediately clear how to make this use SIMD… unless you use gathers.
Gathers are slow.
With SSE2, you only need 2 instructions to check for duplicate indices. First _mm_shuffle_epi32 to “rotate” the triangle [a,b,c] into e.g. [b,c,a], second _mm_cmpeq_epi32 to do per-lane comparison between the original and rotated.
Similarly, with AVX2, same approach can be used to check 2 triangles at once.
For best result, unroll the loop into batches of 4 triangles (8 for AVX), and use 128/256 bit loads.