Skip to content

Instantly share code, notes, and snippets.

/gist:11394210
Created Apr 29, 2014

Embed
What would you like to do?
int dotproduct_sse(int*F, int*S) {
__m128i F1 = _mm_load_si128((__m128i*)F); //load aligned
__m128i F2 = _mm_load_si128((__m128i*)F+1);
__m128i S1 = _mm_loadu_si128((__m128i*)S); //load unaligned
__m128i S2 = _mm_loadu_si128((__m128i*)S+1);
__m128i res = _mm_add_epi32(_mm_mullo_epi32(F1, S1), _mm_mullo_epi32(F2, S2));
res = _mm_add_epi32(res, _mm_srli_si128(res, 8));
res = _mm_add_epi32(res, _mm_srli_si128(res, 4));
return _mm_cvtsi128_si32(res);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.