Other Parts Discussed in Thread: MATHLIB, FFTLIB
Tool/software:
Hello Team,
I was working on creating wrappers on top of FFTLIB, DSPLIB, MATHLIB kernels for a C7x optimized application to be run on AM275 EVM. I have followed the test drivers in the respective library and can't help notice that the processing buffers are explicitly aligned to 128-byte/64-byte during the allocation/setup as described below.
FFTLIB
In the test driver source freertos_sdk_am275x_11_00_00_16/source/fftlib/test/fft_c7x/FFTLIB_fft1d_i32f_c32fc_o32fc/FFTLIB_fft1d_i32f_c32fc_o32fc_d.c, for example, I see
pX = (FFTLIB_F32 *) TI_memalign(128, numPoints * 2 * sizeof(FFTLIB_F32));
and also a comment that says:
/* pX is required to be 16-byte aligned for streaming engine use in kernel */
DSPLIB
void *pIn = (void *) TI_memalign(DSPLIB_L2DATA_ALIGNMENT, bufParamsIn.stride_y * bufParamsIn.dim_y);
#define DSPLIB_ALIGN_SHIFT_64BYTES 6 //!< Number of bits to shift for 64-byte memory alignment #define DSPLIB_ALIGN_SHIFT_128BYTES 7 //!< Number of bits to shift for 128-byte memory alignment #define DSPLIB_ALIGN_SHIFT_256BYTES 8 //!< Number of bits to shift for 256-byte memory alignment #define DSPLIB_ALIGN_64BYTES (1 << DSPLIB_ALIGN_SHIFT_64BYTES) //!< Align by 64-byte memory alignment #define DSPLIB_ALIGN_128BYTES (1 << DSPLIB_ALIGN_SHIFT_128BYTES) //!< Align by 128-byte memory alignment #define DSPLIB_ALIGN_256BYTES (1 << DSPLIB_ALIGN_SHIFT_256BYTES) //!< Align by 256-byte memory alignment #define DSPLIB_L2DATA_ALIGN_SHIFT DSPLIB_ALIGN_SHIFT_64BYTES //!< Set the default L2 data alignment /** @brief Macro that specifies the alignment of data buffers in L2 memory for * optimal performance */ #define DSPLIB_L2DATA_ALIGNMENT (((uint32_t) 1) << ((uint32_t) DSPLIB_L2DATA_ALIGN_SHIFT))
MATHLIB
pSrc = (T *) MATHLIB_memalign(MATHLIB_L2DATA_ALIGNMENT, length * sizeof(T));
#define MATHLIB_ALIGN_SHIFT_64BYTES 6 //!< Number of bits to shift for 64-byte memory alignment #define MATHLIB_ALIGN_SHIFT_128BYTES 7 //!< Number of bits to shift for 128-byte memory alignment #define MATHLIB_ALIGN_SHIFT_256BYTES 8 //!< Number of bits to shift for 256-byte memory alignment #define MATHLIB_ALIGN_64BYTES (1 << MATHLIB_ALIGN_SHIFT_64BYTES) //!< Align by 64-byte memory alignment #define MATHLIB_ALIGN_128BYTES (1 << MATHLIB_ALIGN_SHIFT_128BYTES) //!< Align by 128-byte memory alignment #define MATHLIB_ALIGN_256BYTES (1 << MATHLIB_ALIGN_SHIFT_256BYTES) //!< Align by 256-byte memory alignment #define MATHLIB_L2DATA_ALIGN_SHIFT MATHLIB_ALIGN_SHIFT_64BYTES //!< Set the default L2 data alignment /*! @brief Macro that specifies the alignment of data buffers in L2 memory for * optimal performance */ #define MATHLIB_L2DATA_ALIGNMENT (((uint32_t) 1) << ((uint32_t) MATHLIB_L2DATA_ALIGN_SHIFT))
- if the above explicit alignments seen in the test drivers are hard requirements for processing buffers for running the optimized kernels efficiently? Can you confirm this? If yes, could you specify the alignment requirement for them in FFTLIB, DSPLIB and MATHLIB kernels?
- what is the general platform data alignment requirement? Isn't it 16 bytes? Is there a trade-off in efficiency if I use the general data alignment for processing buffers that I pass to the kernels?
I couldn't find this information in the documentation provided. I would really appreciate if the above are answered and any references to the above in the library documentation is provided.
Regards,
Sreekanth