0

I have an array of values, in which I have to average 12 consecutive values(input length is always multiples of 12) and replicate it six times in output array.

For Example

input = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, 12, soon];

Val1 = mean([a1 to a12]);

Val2 = mean([a13 to a24]);

out = [Val1, Val1, Val1, Val1, Val1, Val1, Val2, soon];

Any hints to code this functionalities in AVX?.

Edit: Values are single precision numbers.

ACE
  • 25
  • 2
  • 1
    `uint8` values or `double` values? Have you tried what happens if you do this with a simple C or C++ program compiled with `-O3 -ffast-math -march=haswell`? – chtz May 19 '21 at 16:07
  • 1
    12 is 3x4, so you can start with two _mm_add_ps, then hsum. [Fastest way to do horizontal SSE vector sum (or other reduction)](https://stackoverflow.com/q/6996764). (But unlike that Q&A, use shuffles that leave the result in all 4 elements, so you can do a store and a `movlps` 8-byte store.) – Peter Cordes May 19 '21 at 17:34

0 Answers0