SPRUI04F july 2015 – april 2023
An argument such as ptr is most commonly passed the base address of an array, for example:
short buffer[100];
...
f(buffer);
Such an array is automatically aligned to an 8-byte boundary. This is true whether the array is global, static, or local. This automatic alignment is all that is required to achieve SIMD optimization on those respective devices. You still need to include the _nassert because, in the general case, the compiler cannot guarantee that ptr holds the address of a properly aligned array.
If you always pass the base address of an array to pointers like ptr, then you can use the following macro to reflect that fact.
#if defined(_TMS320C6X)
#define ALIGNED_ARRAY(ptr) _nassert((int) ptr % 8 == 0)
#else
#define ALIGNED_ARRAY(ptr) /* empty */
#endif
void f(short *ptr)
{
ALIGNED_ARRAY(ptr);
; a loop operating on data accessed by ptr
}
The macro works for all C6000 devices or if you port the code to another target.