3 ms·
My favorite application is comparing vectors. Example in C++: // Compare 32 bytes for equality, with 2 AVX2 instructions inline bool equals( __m256i a,
by Const-me 4y ago
My favorite application is comparing vectors. Example in C++:
// Compare 32 bytes for equality, with 2 AVX2 instructions
inline bool equals( __m256i a, __m256i b )
{
// When the vectors are equal, their XOR is completely zero..
__m256i xx = _mm256_xor_si256( a, b );
// ..and there's a special instruction to test the complete vector for zero
return (bool)_mm256_testz_si256( xx, xx );
}