Adding two arrays of unsigned integers using SIMD intrinsics (in C)

Viewed 33

I want to add up two arrays of uint32_t. They represent two big numbers. However I don't know how to take care of the carry. So far I have:

for (i=0; i < (max_len - (max_len%4)); i += 4) {
    __m128i a = _mm_loadu_si128((__m128i_u *) &num1.num_arr[i]);
    __m128i b = _mm_loadu_si128((__m128i_u *) &num2.num_arr[i]);

    __m128i result = _mm_add_epi32(a, b);
    //result = _mm_add_epi32(result, carry_arr);   // add the carry bits
    _mm_storeu_si128((__m128i*) &result_buf[i], result);
    // TODO calculate carry

Thanks in advance

0 Answers
Related