I am reading Intel's intrinsics guide while implementing SIMD support. I have a few confusions and my questions are as below.
__m128 _mm_cmpeq_ps (__m128 a, __m128 b)
documentation says it is used to compare packed single precision floating points. What does "packed" mean? Do I need to pack my float values somehow before I can use them?
For double precision there are intrinsics like _mm_cmpeq_sd
which means compare the "lower" double precision floating point elements. What does lower and upper double precision elemtns mean? Can I use them to compare a vector of C++ double
type elements or not? Or do I need to process them in some way before I compare them?
In SSE, the 128 bits registers can be represented as 4 elements of 32 bits.
SSE defines two types of operations; scalar and packed. Scalar operation only operates on the least-significant data element (bit 0~31), and packed operation computes all four elements in parallel.
_mm_cmpeq_sd
would only compare the least-significant data element (first 32 bits) of the two operands while _mm_cmpeq_ps
would compare each group of 32 bits in parallel.
If you're using 64 bits double, you could pack the double by pair to make use of the 128 bits space. That way, _mm_cmpeq_ps
would be able to make two comparaison of 4 double in parallel.
If you want to make only one comparison at a time, you can use _mm_cmpeq_pd
to compare two 64 bits double.
Note that _mm_cmpeq_pd
is SSE2 while _mm_cmpeq_ps
is SSE.