Skip to content

Instantly share code, notes, and snippets.

Created April 29, 2014 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/11394210 to your computer and use it in GitHub Desktop.
Save anonymous/11394210 to your computer and use it in GitHub Desktop.
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