FFTLIB User Guide
FFTLIB_FFT_fft_ixX_cxX_oxX.cpp
Go to the documentation of this file.
1 /******************************************************************************
2 * *
3 * module name :FFTLIB *
4 * *
5 * module descripton :Matrix Multiply Accelerator Library module for C7x+MMA *
6 * *
7 * Copyright (C) 2017-2018 Texas Instruments Incorporated - https://www.ti.com/ *
8 * ALL RIGHTS RESERVED *
9 * *
10 ******************************************************************************/
11 
24 
27 {
28  int32_t privBufSize = sizeof(FFTLIB_FFT_fft_ixX_cxX_oxX_PrivArgs);
29  return privBufSize ;
30 }
31 
33  const FFTLIB_FFT_fft_ixX_cxX_oxX_InitArgs *pKerInitArgs,
34  int32_t MMA_SIZE,
35  int32_t *dftSmall,
36  int32_t *dftLarge,
37  int32_t *highRadixDecompositions)
38 {
39  int32_t fftSize = pKerInitArgs->fftSize;
40  int32_t batchSize = pKerInitArgs->batchSize;
41  uint32_t interleave = pKerInitArgs->interleave;
42 
43  *dftSmall = 0;
44  *dftLarge = 0;
45  *highRadixDecompositions = 0;
46  if (fftSize <= MMA_SIZE/2) {
47  *dftSmall = 1;
48  } else if (fftSize == MMA_SIZE) {
49  *dftLarge = 1;
50  } else if (fftSize == MMA_SIZE*2) {
51  if (batchSize < MMA_SIZE/2) {
52  *highRadixDecompositions = 1;
53  } else if (batchSize == MMA_SIZE/2) {
54  if (interleave) {
55  *highRadixDecompositions = 1;
56  } else {
57  *dftLarge = 1;
58  }
59  } else {
60  *dftLarge = 1;
61  }
62  } else {
63  *highRadixDecompositions = 1;
64  }
65 }
66 
67 
69  FFTLIB_kernelHandle handle,
70  const FFTLIB_bufParams1D_t * bufParamsX,
71  const FFTLIB_bufParams1D_t * bufParamsW,
72  const FFTLIB_bufParams1D_t * bufParamsY,
73  const FFTLIB_FFT_fft_ixX_cxX_oxX_InitArgs *pKerInitArgs)
74 {
77  int32_t MMA_SIZE;
78  int32_t dftSmall, dftLarge, highRadixDecompositions;
79 
80 #if FFTLIB_DEBUGPRINT
81  printf("In FFTLIB_FFT_fft_ixX_cxX_oxX_init_checkParams()..\n");
82 #endif
83  if(handle == NULL) {
84  status = FFTLIB_ERR_NULL_POINTER;
85  } else {
86  pKerPrivArgs = (FFTLIB_FFT_fft_ixX_cxX_oxX_PrivArgs *)handle;
87 
88  if (bufParamsX->data_type == FFTLIB_INT16) {
89  MMA_SIZE = FFTLIB_MMA_SIZE_16_BIT;
90  } else if (bufParamsX->data_type == FFTLIB_INT32) {
91  MMA_SIZE = FFTLIB_MMA_SIZE_32_BIT;
92  } else {
94  }
95  }
96 
97  if (status == FFTLIB_SUCCESS) {
99  pKerInitArgs,
100  MMA_SIZE,
101  &dftSmall,
102  &dftLarge,
103  &highRadixDecompositions);
104 
105  if (dftSmall) {
106  #if FFTLIB_DEBUGPRINT
107  printf("About to call FFTLIB_FFT_dftSmall_ixX_cxX_oxX_init_checkParams()..\n");
108  #endif
110  (FFTLIB_kernelHandle)&pKerPrivArgs->privArgs.dftSmall,
111  bufParamsX,
112  bufParamsW,
113  bufParamsY,
114  (const FFTLIB_FFT_dftSmall_ixX_cxX_oxX_InitArgs *)pKerInitArgs);
115  }
116 
117  if (dftLarge) {
118  #if FFTLIB_DEBUGPRINT
119  printf("About to call FFTLIB_FFT_dftLarge_ixX_cxX_oxX_init_checkParams()..\n");
120  #endif
122  (FFTLIB_kernelHandle)&pKerPrivArgs->privArgs.dftLarge,
123  bufParamsX,
124  bufParamsW,
125  bufParamsY,
126  (const FFTLIB_FFT_dftLarge_ixX_cxX_oxX_InitArgs *)pKerInitArgs);
127  }
128 
129  if (highRadixDecompositions) {
130  #if FFTLIB_DEBUGPRINT
131  printf("About to call FFTLIB_FFT_highRadixDecompositions_ixX_cxX_oxX_init_checkParams()..\n");
132  #endif
135  bufParamsX,
136  bufParamsW,
137  bufParamsY,
139  }
140  }
141 
142  return status;
143 }
144 
146  FFTLIB_kernelHandle handle,
147  const void *restrict pX,
148  const void *restrict pW,
149  const void *restrict pY)
150 {
151  FFTLIB_STATUS status;
152 
153  if ((pX == NULL) || (pW == NULL) || (pY == NULL) ) {
154  status = FFTLIB_ERR_NULL_POINTER;
155  } else {
156  status = FFTLIB_SUCCESS ;
157  }
158 
159  return status;
160 }
161 
163  const FFTLIB_FFT_fft_ixX_cxX_oxX_InitArgs * pKerInitArgs,
164  FFTLIB_bufParams1D_t * bufParamsX,
165  FFTLIB_bufParams1D_t * bufParamsW,
166  FFTLIB_bufParams1D_t * bufParamsY)
167 {
168  FFTLIB_STATUS status ;
169 
170  if (bufParamsX->data_type == FFTLIB_INT16) {
172  bufParamsX,
173  bufParamsW,
174  bufParamsY);
175  } else if (bufParamsX->data_type == FFTLIB_INT32) {
177  bufParamsX,
178  bufParamsW,
179  bufParamsY);
180  } else {
182  }
183 
184  return status ;
185 }
186 
188  const FFTLIB_FFT_fft_ixX_cxX_oxX_InitArgs * pKerInitArgs,
189  void *pW,
190  const FFTLIB_bufParams1D_t * bufParamsW)
191 {
192  FFTLIB_STATUS status ;
193 
194  if (bufParamsW->data_type == FFTLIB_INT16) {
195  status = FFTLIB_FFT_fft_ixX_cxX_oxX_twGen<int16_t>(pKerInitArgs,
196  pW,
197  bufParamsW);
198  } else if (bufParamsW->data_type == FFTLIB_INT32) {
199  status = FFTLIB_FFT_fft_ixX_cxX_oxX_twGen<int32_t>(pKerInitArgs,
200  pW,
201  bufParamsW);
202  } else {
204  }
205 
206  return status ;
207 }
208 
210  FFTLIB_kernelHandle handle,
211  FFTLIB_bufParams1D_t * bufParamsX,
212  FFTLIB_bufParams1D_t * bufParamsW,
213  FFTLIB_bufParams1D_t * bufParamsY,
214  const FFTLIB_FFT_fft_ixX_cxX_oxX_InitArgs *pKerInitArgs)
215 {
216 
217  FFTLIB_STATUS status = FFTLIB_SUCCESS;
219  int32_t MMA_SIZE;
220  int32_t dftSmall, dftLarge, highRadixDecompositions;
221 
222 #if FFTLIB_DEBUGPRINT
223  printf("In FFTLIB_FFT_fft_ixX_cxX_oxX_init()..\n");
224 #endif
225  if(handle == NULL) {
226  status = FFTLIB_ERR_NULL_POINTER;
227  } else {
228  pKerPrivArgs = (FFTLIB_FFT_fft_ixX_cxX_oxX_PrivArgs *)handle;
229 
230  if (bufParamsX->data_type == FFTLIB_INT16) {
231  MMA_SIZE = FFTLIB_MMA_SIZE_16_BIT;
232  } else if (bufParamsX->data_type == FFTLIB_INT32) {
233  MMA_SIZE = FFTLIB_MMA_SIZE_32_BIT;
234  } else {
236  }
237  }
238 
239  if (status == FFTLIB_SUCCESS) {
240  pKerPrivArgs->mmaSize = MMA_SIZE;
241  pKerPrivArgs->initArgs = *pKerInitArgs;
242 
244  pKerInitArgs,
245  MMA_SIZE,
246  &dftSmall,
247  &dftLarge,
248  &highRadixDecompositions);
249 
250  if (dftSmall) {
251  #if FFTLIB_DEBUGPRINT
252  printf("About to call FFTLIB_FFT_dftSmall_ixX_cxX_oxX_init()..\n");
253  #endif
254  status =
256  (FFTLIB_kernelHandle)&pKerPrivArgs->privArgs.dftSmall,
257  bufParamsX,
258  bufParamsW,
259  bufParamsY,
261  }
262 
263  if (dftLarge) {
264  #if FFTLIB_DEBUGPRINT
265  printf("About to call FFTLIB_FFT_dftLarge_ixX_cxX_oxX_init()..\n");
266  #endif
267  status =
269  (FFTLIB_kernelHandle)&pKerPrivArgs->privArgs.dftLarge,
270  bufParamsX,
271  bufParamsW,
272  bufParamsY,
274  }
275 
276  if (highRadixDecompositions) {
277  #if FFTLIB_DEBUGPRINT
278  printf("About to call FFTLIB_FFT_highRadixDecompositions_ixX_cxX_oxX_init()..\n");
279  #endif
280  status =
283  bufParamsX,
284  bufParamsW,
285  bufParamsY,
287  }
288  }
289  return status;
290 }
291 
293  FFTLIB_kernelHandle handle,
294  void *restrict pX,
295  void *restrict pW,
296  void *restrict pY)
297 {
301  int32_t MMA_SIZE = pKerPrivArgs->mmaSize;
302  int32_t dftSmall, dftLarge, highRadixDecompositions;
303 
304 #if FFTLIB_DEBUGPRINT
305  printf("In FFTLIB_FFT_fft_ixX_cxX_oxX_exec()..\n");
306 #endif
307 
309  &(pKerPrivArgs->initArgs),
310  MMA_SIZE,
311  &dftSmall,
312  &dftLarge,
313  &highRadixDecompositions);
314 
315  if (dftSmall) {
316 #if FFTLIB_DEBUGPRINT
317  printf("About to call FFTLIB_FFT_dftSmall_ixX_cxX_oxX_exec()..\n");
318 #endif
319  status =
321  (FFTLIB_kernelHandle)&pKerPrivArgs->privArgs.dftSmall,
322  pX,
323  pW,
324  pY);
325  }
326 
327  if (dftLarge) {
328 #if FFTLIB_DEBUGPRINT
329  printf("About to call FFTLIB_FFT_dftLarge_ixX_cxX_oxX_exec()..\n");
330 #endif
331  status =
333  (FFTLIB_kernelHandle)&pKerPrivArgs->privArgs.dftLarge,
334  pX,
335  pW,
336  pY);
337  }
338 
339  if (highRadixDecompositions) {
340 #if FFTLIB_DEBUGPRINT
341  printf("About to call FFTLIB_FFT_highRadixDecompositions_ixX_cxX_oxX_exec()..\n");
342 #endif
343  status =
346  pX,
347  pW,
348  pY);
349  }
350 
351  return status;
352 }
void FFTLIB_FFT_fft_ixX_cxX_oxX_determineKernelVariant(const FFTLIB_FFT_fft_ixX_cxX_oxX_InitArgs *pKerInitArgs, int32_t MMA_SIZE, int32_t *dftSmall, int32_t *dftLarge, int32_t *highRadixDecompositions)
This is an internal function that is used to determine which FFT kernel variant to call for optimal D...
template FFTLIB_STATUS FFTLIB_FFT_fft_ixX_cxX_oxX_twGen< int32_t >(const FFTLIB_FFT_fft_ixX_cxX_oxX_InitArgs *pKerInitArgs, void *restrict pW, const FFTLIB_bufParams1D_t *bufParamsW)
template FFTLIB_STATUS FFTLIB_FFT_fft_ixX_cxX_oxX_getSizes< FFTLIB_INT16 >(const FFTLIB_FFT_fft_ixX_cxX_oxX_InitArgs *pKerInitArgs, FFTLIB_bufParams1D_t *bufParamsX, FFTLIB_bufParams1D_t *bufParamsW, FFTLIB_bufParams1D_t *bufParamsY)
template FFTLIB_STATUS FFTLIB_FFT_fft_ixX_cxX_oxX_twGen< int16_t >(const FFTLIB_FFT_fft_ixX_cxX_oxX_InitArgs *pKerInitArgs, void *restrict pW, const FFTLIB_bufParams1D_t *bufParamsW)
template FFTLIB_STATUS FFTLIB_FFT_fft_ixX_cxX_oxX_getSizes< FFTLIB_INT32 >(const FFTLIB_FFT_fft_ixX_cxX_oxX_InitArgs *pKerInitArgs, FFTLIB_bufParams1D_t *bufParamsX, FFTLIB_bufParams1D_t *bufParamsW, FFTLIB_bufParams1D_t *bufParamsY)
@ FFTLIB_INT16
@ FFTLIB_INT32
void * FFTLIB_kernelHandle
Handle type for FFTLIB operations.
Definition: FFTLIB_types.h:217
FFTLIB_STATUS_NAME
The enumeration of all status codes.
Definition: FFTLIB_types.h:172
@ FFTLIB_ERR_NOT_IMPLEMENTED
Definition: FFTLIB_types.h:179
@ FFTLIB_ERR_FAILURE
Definition: FFTLIB_types.h:174
@ FFTLIB_ERR_NULL_POINTER
Definition: FFTLIB_types.h:178
@ FFTLIB_SUCCESS
Definition: FFTLIB_types.h:173
#define FFTLIB_MMA_SIZE_16_BIT
type is 16-bit integers
#define FFTLIB_MMA_SIZE_32_BIT
type is 32-bit integers
FFTLIB_STATUS FFTLIB_FFT_dftLarge_ixX_cxX_oxX_init_checkParams(FFTLIB_kernelHandle handle, const FFTLIB_bufParams1D_t *bufParamsX, const FFTLIB_bufParams1D_t *bufParamsW, const FFTLIB_bufParams1D_t *bufParamsY, const FFTLIB_FFT_dftLarge_ixX_cxX_oxX_InitArgs *pKerInitArgs)
This function checks the validity of the parameters passed to FFTLIB_FFT_dftLarge_ixX_cxX_oxX_init fu...
FFTLIB_STATUS FFTLIB_FFT_dftLarge_ixX_cxX_oxX_init(FFTLIB_kernelHandle handle, const FFTLIB_bufParams1D_t *bufParamsX, const FFTLIB_bufParams1D_t *bufParamsW, const FFTLIB_bufParams1D_t *bufParamsY, const FFTLIB_FFT_dftLarge_ixX_cxX_oxX_InitArgs *pKerInitArgs)
This function should be called before the FFTLIB_FFT_dftLarge_ixX_cxX_oxX_exec function is called....
FFTLIB_STATUS FFTLIB_FFT_dftLarge_ixX_cxX_oxX_exec(FFTLIB_kernelHandle handle, const void *restrict pX, const void *restrict pW, void *restrict pY)
This function is the main kernel compute function.
FFTLIB_STATUS FFTLIB_FFT_dftSmall_ixX_cxX_oxX_init_checkParams(FFTLIB_kernelHandle handle, const FFTLIB_bufParams1D_t *bufParamsX, const FFTLIB_bufParams1D_t *bufParamsW, const FFTLIB_bufParams1D_t *bufParamsY, const FFTLIB_FFT_dftSmall_ixX_cxX_oxX_InitArgs *pKerInitArgs)
This function checks the validity of the parameters passed to FFTLIB_FFT_dftSmall_ixX_cxX_oxX_init fu...
FFTLIB_STATUS FFTLIB_FFT_dftSmall_ixX_cxX_oxX_init(FFTLIB_kernelHandle handle, FFTLIB_bufParams1D_t *bufParamsX, FFTLIB_bufParams1D_t *bufParamsW, FFTLIB_bufParams1D_t *bufParamsY, FFTLIB_FFT_dftSmall_ixX_cxX_oxX_InitArgs *pKerInitArgs)
This function should be called before the FFTLIB_FFT_dftSmall_ixX_cxX_oxX_exec function is called....
FFTLIB_STATUS FFTLIB_FFT_dftSmall_ixX_cxX_oxX_exec(FFTLIB_kernelHandle handle, void *restrict pX, void *restrict pW, void *restrict pY)
This function is the main kernel compute function.
int32_t FFTLIB_FFT_fft_ixX_cxX_oxX_getHandleSize(FFTLIB_FFT_fft_ixX_cxX_oxX_InitArgs *pKerInitArgs)
This is a query function to calculate the size of internal handle.
FFTLIB_STATUS FFTLIB_FFT_fft_ixX_cxX_oxX_exec_checkParams(FFTLIB_kernelHandle handle, const void *restrict pX, const void *restrict pW, const void *restrict pY)
This function checks the validity of the parameters passed to FFTLIB_FFT_fft_ixX_cxX_oxX_exec functio...
FFTLIB_STATUS FFTLIB_FFT_fft_ixX_cxX_oxX_init(FFTLIB_kernelHandle handle, FFTLIB_bufParams1D_t *bufParamsX, FFTLIB_bufParams1D_t *bufParamsW, FFTLIB_bufParams1D_t *bufParamsY, const FFTLIB_FFT_fft_ixX_cxX_oxX_InitArgs *pKerInitArgs)
This function should be called before the FFTLIB_FFT_fft_ixX_cxX_oxX_exec function is called....
FFTLIB_STATUS FFTLIB_FFT_fft_ixX_cxX_oxX_twGen(const FFTLIB_FFT_fft_ixX_cxX_oxX_InitArgs *pKerInitArgs, void *pW, const FFTLIB_bufParams1D_t *bufParamsW)
This is a utility function that generates the computational matrix (DFT matrix and twiddle factors) i...
FFTLIB_STATUS FFTLIB_FFT_fft_ixX_cxX_oxX_getSizes(const FFTLIB_FFT_fft_ixX_cxX_oxX_InitArgs *pKerInitArgs, FFTLIB_bufParams1D_t *bufParamsX, FFTLIB_bufParams1D_t *bufParamsW, FFTLIB_bufParams1D_t *bufParamsY)
This is a query function to calculate the sizes of input, output and the computational matrix buffers...
FFTLIB_STATUS FFTLIB_FFT_fft_ixX_cxX_oxX_init_checkParams(FFTLIB_kernelHandle handle, const FFTLIB_bufParams1D_t *bufParamsX, const FFTLIB_bufParams1D_t *bufParamsW, const FFTLIB_bufParams1D_t *bufParamsY, const FFTLIB_FFT_fft_ixX_cxX_oxX_InitArgs *pKerInitArgs)
This function checks the validity of the parameters passed to FFTLIB_FFT_fft_ixX_cxX_oxX_init functio...
FFTLIB_STATUS FFTLIB_FFT_fft_ixX_cxX_oxX_exec(FFTLIB_kernelHandle handle, void *restrict pX, void *restrict pW, void *restrict pY)
This function is the main kernel compute function.
FFTLIB_STATUS FFTLIB_FFT_highRadixDecompositions_ixX_cxX_oxX_init(FFTLIB_kernelHandle handle, FFTLIB_bufParams1D_t *bufParamsX, FFTLIB_bufParams1D_t *bufParamsW, FFTLIB_bufParams1D_t *bufParamsY, FFTLIB_FFT_highRadixDecompositions_ixX_cxX_oxX_InitArgs *pKerInitArgs)
This function should be called before the FFTLIB_FFT_highRadixDecompositions_ixX_cxX_oxX_exec functio...
FFTLIB_STATUS FFTLIB_FFT_highRadixDecompositions_ixX_cxX_oxX_exec(FFTLIB_kernelHandle handle, void *restrict pX, void *restrict pW, void *restrict pY)
This function is the main kernel compute function.
FFTLIB_STATUS FFTLIB_FFT_highRadixDecompositions_ixX_cxX_oxX_init_checkParams(FFTLIB_kernelHandle handle, const FFTLIB_bufParams1D_t *bufParamsX, const FFTLIB_bufParams1D_t *bufParamsW, const FFTLIB_bufParams1D_t *bufParamsY, const FFTLIB_FFT_highRadixDecompositions_ixX_cxX_oxX_InitArgs *pKerInitArgs)
This function checks the validity of the parameters passed to FFTLIB_FFT_highRadixDecompositions_ixX_...
Structure containing the parameters for DFT computation.
Structure containing the parameters for DFT computation.
Structure containing the parameters for DFT computation.
uint32_t interleave
Flag to indicate if the real and imaginary parts of data are interleaved or not. A value of 1 indicat...
uint32_t fftSize
Size of each channel's data in terms of number of complex points.
uint32_t batchSize
Size of the batch in terms of number of channels of DFT's.
Structure that is reserved for internal use by the kernel.
union FFTLIB_FFT_fft_ixX_cxX_oxX_PrivArgs::@0 privArgs
FFTLIB_FFT_dftSmall_ixX_cxX_oxX_PrivArgs dftSmall
Structure to maintain the internal use parameters of FFTLIB_FFT_dftSmall_ixX_cxX_oxX kernel
FFTLIB_FFT_highRadixDecompositions_ixX_cxX_oxX_PrivArgs highRadixDecompositions
Structure to maintain the internal use parameters of FFTLIB_FFT_highRadixDecompositions_ixX_cxX_oxX k...
int32_t mmaSize
Field to maintain the MMA vector width value
FFTLIB_FFT_fft_ixX_cxX_oxX_InitArgs initArgs
Structure holding initialization parameters
FFTLIB_FFT_dftLarge_ixX_cxX_oxX_PrivArgs dftLarge
Structure to maintain the internal use parameters of FFTLIB_FFT_dftLarge_ixX_cxX_oxX kernel
A structure for a 1 dimensional buffer descriptor.
uint32_t data_type
Values are of type FFTLIB_data_type_e.