DSPLIB User Guide
DSPLIB_svd_small_priv.h
Go to the documentation of this file.
1 /******************************************************************************
2  * *
3  * module name :DSPLIB *
4  * *
5  * module descripton :Digital Signal Processing 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 
12 /********************************************************************************
13  * @file DSPLIB_svd_small_priv.h
14  *
15  * @brief File to hold private parameter of function DSPLIB_svd
16  *
17  * @version 0.1 - Jun 2023 : Initial Version
18  *
19  ********************************************************************************/
20 
21 #ifndef DSPLIB_SVD_SMALL_IXX_IXX_OXX_PRIV_H_
22 #define DSPLIB_SVD_SMALL_IXX_IXX_OXX_PRIV_H_
23 
24 // #include "../DSPLIB_matTrans/DSPLIB_matTrans_priv.h"
25 #include "../common/DSPLIB_inlines.h"
26 #include "../common/DSPLIB_utility.h"
27 #include "DSPLIB_svd_small.h"
28 
40 #define DSPLIB_SVD_SMALL_IXX_IXX_OXX_PBLOCK_SIZE (0 * SE_PARAM_SIZE)
41 
48  void *restrict pA,
49  void *restrict pU,
50  void *restrict pV,
51  void *restrict pDiag,
52  void *restrict pSuperDiag,
53  void *restrict pU1);
54 
88 template <typename dataType>
90  const DSPLIB_bufParams2D_t *bufParamsIn,
91  const DSPLIB_bufParams2D_t *bufParamsU,
92  const DSPLIB_bufParams2D_t *bufParamsV,
93  const DSPLIB_bufParams1D_t *bufParamsDiag,
94  const DSPLIB_bufParams1D_t *bufParamsSuperDiag,
95  const DSPLIB_svd_small_InitArgs *pKerInitArgs);
96 
123 template <typename dataType>
125  void *restrict pA,
126  void *restrict pU,
127  void *restrict pV,
128  void *restrict pDiag,
129  void *restrict pSuperDiag,
130  void *restrict pU1);
131 
156  const DSPLIB_bufParams2D_t *bufParamsIn,
157  const DSPLIB_bufParams2D_t *bufParamsU,
158  const DSPLIB_bufParams2D_t *bufParamsV,
159  const DSPLIB_bufParams1D_t *bufParamsDiag,
160  const DSPLIB_bufParams1D_t *bufParamsSuperDiag,
161  const DSPLIB_svd_small_InitArgs *pKerInitArgs);
162 
181 template <typename dataType>
183  void *restrict pA,
184  void *restrict pU,
185  void *restrict pV,
186  void *restrict pDiag,
187  void *restrict pSuperDiag,
188  void *restrict pU1);
189 
193 typedef struct {
202  uint32_t widthIn;
204  uint32_t heightIn;
206  int32_t strideIn;
208  uint32_t strideU;
210  uint32_t strideV;
211  uint32_t strideURows;
212  uint32_t strideVRows;
218  uint32_t data_type;
222 
223 /* *****************************************************************************
224  *
225  * COMMON UTILITY FUNCTIONS
226  *
227  ***************************************************************************** */
228 
229 /* Common function to calculate reciprocal value */
230 template <typename dataType> inline dataType getRecip(dataType value)
231 {
232  dataType TwoP0 = 2.0;
233 
234  dataType yy1 = __recip(value);
235 
236  yy1 = yy1 * (TwoP0 - value * yy1);
237  yy1 = yy1 * (TwoP0 - value * yy1);
238 #if defined(ENABLE_LDRA_COVERAGE)
239 /* Higher precision calculations to enter the rotation_check path. We only use this
240  as a coverage component. We do not include these operations for normal execution
241  considering the PERFORMANCE */
242  yy1 = yy1 * (TwoP0 - value * yy1);
243  yy1 = yy1 * (TwoP0 - value * yy1);
244 #endif
245 
246  return yy1;
247 }
248 template float getRecip(float value);
249 template double getRecip(double value);
250 
251 template <typename dataType> inline dataType getSqrt(dataType a)
252 {
253  const dataType Half = 0.5f;
254  const dataType OneP5 = 1.5f;
255  dataType x, y;
256  // int i;
257 
258  x = __recip_sqrt(a); /* compute square root reciprocal */
259 
260  // #pragma UNROLL(1) /* PRAGMA: do not unroll this loop */
261  // for (i = 0; i < 2; i++)
262  {
263  x = x * (OneP5 - (a * x * x * Half));
264  x = x * (OneP5 - (a * x * x * Half));
265  // x = x * (OneP5 - (a * x * x * Half));
266  // x = x * (OneP5 - (a * x * x * Half));
267  }
268  y = a * x;
269 
270  return (y);
271 }
272 template float getSqrt<float>(float a);
273 template double getSqrt<double>(double a);
274 template c7x::double_vec getSqrt<c7x::double_vec>(c7x::double_vec a);
275 
276 template <typename dataType> inline dataType getRecipSqrt(dataType a)
277 {
278  const dataType Half = 0.5f;
279  const dataType OneP5 = 1.5f;
280  dataType x;
281  // int i;
282 
283  x = __recip_sqrt(a); // compute square root reciprocal
284 
285  // PRAGMA: do not unroll this loop
286  // #pragma UNROLL(1)
287  // for (i = 0; i < 2; i++)
288  {
289  x = x * (OneP5 - (a * x * x * Half));
290  x = x * (OneP5 - (a * x * x * Half));
291  }
292 
293  return x;
294 }
295 template float getRecipSqrt<float>(float a);
296 template double getRecipSqrt<double>(double a);
297 
298 #endif /* DSPLIB_SVD_SMALL_IXX_IXX_OXX_PRIV_H_ */
299 
300 /* ======================================================================== */
301 /* End of file: DSPLIB_svd_small_priv.h */
302 /* ======================================================================== */
DSPLIB_STATUS DSPLIB_svd_small_exec_cn(DSPLIB_kernelHandle handle, void *restrict pA, void *restrict pU, void *restrict pV, void *restrict pDiag, void *restrict pSuperDiag, void *restrict pU1)
This function is the main execution function for the natural C implementation of the kernel....
DSPLIB_STATUS DSPLIB_svd_small_init_cn(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsIn, const DSPLIB_bufParams2D_t *bufParamsU, const DSPLIB_bufParams2D_t *bufParamsV, const DSPLIB_bufParams1D_t *bufParamsDiag, const DSPLIB_bufParams1D_t *bufParamsSuperDiag, const DSPLIB_svd_small_InitArgs *pKerInitArgs)
This function is the initialization function for the natural C implementation of the kernel....
template float getSqrt< float >(float a)
#define DSPLIB_SVD_SMALL_IXX_IXX_OXX_PBLOCK_SIZE
Macro to define the size of bufPblock array of DSPLIB_svd_PrivArgs structure.
DSPLIB_STATUS DSPLIB_svd_small_init_ci(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsIn, const DSPLIB_bufParams2D_t *bufParamsU, const DSPLIB_bufParams2D_t *bufParamsV, const DSPLIB_bufParams1D_t *bufParamsDiag, const DSPLIB_bufParams1D_t *bufParamsSuperDiag, const DSPLIB_svd_small_InitArgs *pKerInitArgs)
This function is the initialization function for the C7x implementation of the kernel....
DSPLIB_STATUS(* pFxnDSPLIB_svd_small_exec)(DSPLIB_kernelHandle handle, void *restrict pA, void *restrict pU, void *restrict pV, void *restrict pDiag, void *restrict pSuperDiag, void *restrict pU1)
This is a function pointer type that conforms to the declaration of DSPLIB_svd_exec_ci and DSPLIB_svd...
dataType getSqrt(dataType a)
template double getRecipSqrt< double >(double a)
DSPLIB_STATUS DSPLIB_svd_small_exec_ci(DSPLIB_kernelHandle handle, void *restrict pA, void *restrict pU, void *restrict pV, void *restrict pDiag, void *restrict pSuperDiag, void *restrict pU1)
This function is the main execution function for the C7x implementation of the kernel....
dataType getRecip(dataType value)
dataType getRecipSqrt(dataType a)
template float getRecipSqrt< float >(float a)
template double getSqrt< double >(double a)
DSPLIB_STATUS_NAME DSPLIB_STATUS
Return value for DSPLIB functions.
Definition: DSPLIB_types.h:170
DSPLIB_STATUS_NAME
The enumeration of all status codes.
Definition: DSPLIB_types.h:151
void * DSPLIB_kernelHandle
Handle type for DSPLIB operations.
Definition: DSPLIB_types.h:172
A structure for a 1 dimensional buffer descriptor.
A structure for a 2 dimensional buffer descriptor.
Structure containing the parameters to initialize the kernel.
Structure that is reserved for internal use by the kernel.
uint32_t enableReducedForm
Flag for enabling the calculation of reduced form enableReducedForm = 1 for reduced form SVD calc ena...
uint32_t strideU
Stride between rows of U matrix
uint32_t strideV
Stride between rows of V matrix
pFxnDSPLIB_svd_small_exec execute
Function pointer to point to the right execution variant between DSPLIB_svd_small_exec_cn and DSPLIB_...
int32_t strideIn
Stride between rows of input data matrix
uint32_t widthIn
Size of input buffer for different batches DSPLIB_svd_small_init that will be retrieved and used by D...
uint32_t heightIn
Height of input data matrix