64 bit version of vector mean calculation dsp api

If you have a simple question and just want an answer.
Post Reply
shaileshwankhede
Experienced Member
Posts: 65
Joined: Fri Dec 02, 2016 1:30 pm

64 bit version of vector mean calculation dsp api

Post by shaileshwankhede »

Hi,

lib_dsp provides dsp_vector_mean api and internally it performs dsp_vector_abs_sum before dividing by vector length. For large number of samples like 512 in my case it always leads to overflow for vector some. I tried to modify api by changing return type of dsp_vector_abs_sum to int64_t but then I get lot of errors in assembly code of dsp_vector_abs_sum like:
couldn't allocate output register for constraint 'r' xmos
I need help in modifying assembly source of dsp_vector_abs_sum and thus afterwards dsp_math_divide.

Thanks,
Shailesh


henk
Respected Member
Posts: 347
Joined: Wed Jan 27, 2016 5:21 pm

Post by henk »

Hi Shailesh,

There is two ways to fix it.

One is to use 'long long' instead of 'int'. That will give you a fully accurate answer.

If there is too much assembly code, you can instead replace using "vector" with "(vector >> 2)" and shift the result up by two places. This result will not be accurate in the bottom few bits.

Cheers,
Henk
shaileshwankhede
Experienced Member
Posts: 65
Joined: Fri Dec 02, 2016 1:30 pm

Post by shaileshwankhede »

If I replace int by long long, same compilation error occurs and I tried replacing x0 = input_vector_X[2] with x0 = input_vector_X[2] >> 2, similarly for vector_X[0] but that didn't help. Vector sum always overflow. Maybe shifting by just 2 bits not sufficient. Then I tried shifting with higher value till 14 but same problem (and anyway this result will be very very inaccurate),

So I created own c method of calculating vector sum.

Thanks,
Shailesh
Post Reply