Texas Instruments TMS320C64X manual DSPdotprod, Vector Dot Product

Models: TMS320C64X

1 169
Download 169 pages 59.58 Kb
Page 88
Image 88

DSP_dotprod

DSP_dotprod

Vector Dot Product

Function

 

int DSP_dotprod(const short * restrict x, const short * restrict y, int nx)

 

Arguments

 

x[nx]

First vector array. Must be double-word aligned.

 

 

y[nx]

Second vector array. Must be double word-aligned.

 

 

nx

Number of elements of vector. Must be multiple of 4.

 

 

return int

Dot product of x and y.

Description

 

This routine takes two vectors and calculates their dot product. The inputs are

 

 

16-bit short data and the output is a 32-bit number.

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_dotprod(short x[ ],short y[ ], int nx)

{

int sum; int i; sum = 0;

for(i=0; i<nx; i++){ sum += (x[i] * y[i]);

}

return (sum);

}

Special Requirements

-The input length must be a multiple of 4.

-The input data x[ ] and y[ ] are stored on double-word aligned boundaries.

-To avoid bank conflicts, the input arrays x[ ] and y[ ] must be offset by 4 half-words (8 bytes).

4-60

Page 88
Image 88
Texas Instruments TMS320C64X manual DSPdotprod, Vector Dot Product