Texas Instruments TMS320C64X User Manual
Page 99
DSP_vecsumsq
4-71
C64x+ DSPLIB Reference
Sum of Squares
DSP_vecsumsq
Function
int DSP_vecsumsq (const short *x, int nx)
Arguments
x[nx]
Input vector
nx
Number of elements in x. Must be multiple of 4 and
≥
8.
return int
Sum of the squares
Description
This routine returns the sum of squares of the elements contained in the vector
x[ ].
Algorithm
This is the C equivalent of the assembly code without restrictions. Note that
the assembly code is hand optimized and restrictions may apply.
int DSP_vecsumsq(short x[ ], int nx)
{
int i, sum=0;
for(i=0; i { sum += x[i]*x[i]; } return(sum); } Special Requirements nx must be a multiple of 4 and greater than or equal to 32. Implementation Notes - Bank Conflicts: No bank conflicts occur. - Interruptibility: The code is interrupt-tolerant but not interruptible. - The code is unrolled 4 times to enable full memory and multiplier Benchmarks Cycles nx/4 + 11 Codesize 188 bytes
bandwidth to be utilized.