on-internet
← Community

Computing 8 horizontal sums of eight AVX single-precision floating-point vectors

Stack Overflow ·

I have 8 AVX vectors containing 8 floats each (64 floats in total) and I want to sum elements in each vector together (basically perform eight horizontal sums). For now, I'm using the following code: __m256 HorizontalSums(__m256 v0, __m256 v1, __m256 v2, __m256 v3, __m256 v4, __m256 v5, __m256 v6, __m256 v7) { // transpose const __m256 t0 = _mm256_unpacklo_ps(v0, v1); const __m256 t1 = _mm256_unpackhi_ps(v0, v1); const __m256 t2 = _mm256_unpacklo_ps(v2, v3); const __m256 t3 = _mm256_unpackhi_ps(v2, v3); const __m256 t4 = _mm256_unpacklo_ps(v4, v5); const __m256 t5 = _mm256_unpackhi_ps(v4, v5);

Comments

Sign in or sign up to comment and upvote.

No comments yet.