Dot Product With _Nassert Guaranteeing Trip Count Range - Texas Instruments TMS320C6000 Programmer's Manual

Hide thumbs Also See for TMS320C6000:
Table of Contents

Advertisement

Example 7–4. Dot Product With _nassert Guaranteeing Trip Count Range
int dot_prod(short *a, short *b, int n)
{
int i, sum = 0;
#pragma MUST_ITERATE (20,50);
for (i = 0; i < n; i++)
sum += a[i] * b[i];
return sum;
}
Now the compiler knows that the loop will complete in less than 100 cycles
when it generates a 1-cycle kernel that must execute 50 times (which equals
50 cycles). The total cycle count of the loop is now known to be less than the
interrupt threshold, so the compiler will generate the optimal 1-cycle kernel
loop. You can do the same thing in linear assembly code by specifying both
the minimum and maximum trip counts with the .trip directive.
Note:
The compiler does not take stalls (memory bank conflict, external memory
access time, cache miss, etc.) into account. Because of this, it is recom-
mended that you are conservative with the threshold value.
Let us now assume the worst case scenario - the application needs to be inter-
ruptible at any given cycle. In this case, you will build your application with an
interrupt threshold of one. It is still possible to regain some performance lost
from setting the interrupt threshold to one. Example 7–5 shows where the fac-
tor option in .trip and using the third argument of the MUST_ITERATE pragma
are useful. For more information, see section 3.4.3.4, Loop Unrolling .
Interruptible Code Generation
Interrupts
7-9

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents