How to load unsigned ints into SIMD

2019-03-05 16:06发布

问题:

I have a C program where I have a few arrays of unsigned ints. I'm using this declaration uint32_t.

I want to use SIMD to perform some operations on the data stored in each of the arrays. This is where I'm stuck because it looks like most of the SSE and SSE2 functions only support float and double.

What's the best way for me to load data of type uint32_t?

回答1:

For any integer SSE type you typically use _mm_load_si128/_mm_loadu_si128:

uint32_t a[N];

__m128i v = _mm_loadu_si128((__m128i *)a);