DSPLIB User Guide
DSPLIB_svd_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_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_IXX_IXX_OXX_PRIV_H_
22 #define DSPLIB_SVD_IXX_IXX_OXX_PRIV_H_
23 
24 #include "../common/DSPLIB_inlines.h"
25 #include "../common/DSPLIB_utility.h"
26 #include "../DSPLIB_matTrans/DSPLIB_matTrans_priv.h"
27 #include "DSPLIB_svd.h"
28 
40 #define DSPLIB_SVD_IXX_IXX_OXX_PBLOCK_SIZE (26 * 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  void *restrict pV1,
55  void *restrict pScratch);
56 
90 template <typename dataType>
92  const DSPLIB_bufParams2D_t *bufParamsIn,
93  const DSPLIB_bufParams2D_t *bufParamsU,
94  const DSPLIB_bufParams2D_t *bufParamsV,
95  const DSPLIB_bufParams1D_t *bufParamsDiag,
96  const DSPLIB_bufParams1D_t *bufParamsSuperDiag,
97  const DSPLIB_svdInitArgs *pKerInitArgs);
98 
99 
128 template <typename dataType>
130  void *restrict pA,
131  void *restrict pU,
132  void *restrict pV,
133  void *restrict pDiag,
134  void *restrict pSuperDiag,
135  void *restrict pU1,
136  void *restrict pV1,
137  void *restrict pScratch);
138 
163  const DSPLIB_bufParams2D_t *bufParamsIn,
164  const DSPLIB_bufParams2D_t *bufParamsU,
165  const DSPLIB_bufParams2D_t *bufParamsV,
166  const DSPLIB_bufParams1D_t *bufParamsDiag,
167  const DSPLIB_bufParams1D_t *bufParamsSuperDiag,
168  const DSPLIB_svdInitArgs *pKerInitArgs);
169 
190 template <typename dataType>
192  void *restrict pA,
193  void *restrict pU,
194  void *restrict pV,
195  void *restrict pDiag,
196  void *restrict pSuperDiag,
197  void *restrict pU1,
198  void *restrict pV1,
199  void *restrict pScratch);
200 
204 typedef struct {
213  uint32_t widthIn;
215  uint32_t heightIn;
217  int32_t strideIn;
219  uint32_t strideU;
221  uint32_t strideV;
222  uint32_t strideURows;
223  uint32_t strideVRows;
237 
238 /* *****************************************************************************
239  *
240  * INTERNAL IMPLEMENTATION FUNCTIONS DECLARATION
241  *
242  ***************************************************************************** */
243 
244 template <typename dataType>
245 void uColProcess(dataType *U,
246  int32_t Nrows,
247  int32_t Ncols,
248  int32_t colUStride,
249  dataType half_norm_squared,
250  dataType *U1,
251  dataType scale,
252  uint8_t *pBlock);
253 
254 template <typename dataType>
255 dataType DSPLIB_bidiag_uCol_halfnorm_ci(dataType *U,
256  int32_t Nrows,
257  int32_t Ncols,
258  int32_t colUStride,
259  dataType *half_norm_squared,
260  dataType *U1,
261  dataType *s,
262  uint8_t *pBlock);
263 
264 template <typename dataType>
265 dataType DSPLIB_bidiag_uRow_halfnorm_ci(dataType *U,
266  int32_t Nrows,
267  int32_t Ncols,
268  int32_t colUStride,
269  dataType *half_norm_squared,
270  dataType *U1,
271  dataType *s,
272  dataType *superdiag,
273  uint8_t *pBlock);
274 
275 template <typename dataType>
276 void uRowProcess(dataType *U,
277  int32_t Nrows,
278  int32_t Ncols,
279  int32_t colUStride,
280  dataType *superdiag,
281  dataType *U1,
282  dataType scale,
283  uint8_t *pBlock);
284 
285 template <typename dataType>
286 void vColProcess(dataType *V,
287  int32_t Nrows,
288  int32_t Ncols,
289  int32_t colVStride,
290  dataType s,
291  dataType *U1,
292  dataType *U,
293  int32_t colUStride,
294  uint8_t *PBlock);
295 
296 template <typename dataType>
297 void DSPLIB_bidiag_uFinal_expand_ci(dataType *U, int32_t Nrows, int32_t Ncols, int32_t colUStride, uint8_t *pBlock);
298 
299 template <typename dataType>
300 void uSiUpdate(dataType *U,
301  int32_t Nrows,
302  int32_t Ncols,
303  int32_t colUStride,
304  dataType s,
305  dataType *U1,
306  uint8_t *pBlock);
307 
308 template <typename dataType>
309 void DSPLIB_bidiag_uFinal_normalize_ci(dataType *U, int32_t Nrows, dataType s, int32_t colUStride, uint8_t *pBlock);
310 
311 template <typename dataType>
312 void DSPLIB_bidiag_uFinal_initalize_ci(dataType *U,
313  int32_t Nrows,
314  int32_t Ncols,
315  int32_t colUStride,
316  dataType s,
317  dataType *U1,
318  uint8_t *pBlock);
319 
320 template <typename dataType>
321 void DSPLIB_diag_proc_ci(dataType *V,
322  int32_t startRow,
323  int32_t Nrows,
324  int32_t Ncols,
325  int32_t rowVStride,
326  dataType *cV,
327  dataType *sV,
328  uint8_t *pBlock);
329 
330 template <typename dataType>
331 void DSPLIB_singularSort_swap_ci(dataType *V,
332  int32_t Nrows,
333  int32_t Ncols,
334  int32_t rowVStride,
335  int32_t *sortIndex,
336  dataType *vBuff,
337  uint8_t *pBlock);
338 
339 template <typename dataType>
340 void DSPLIB_bidiag_uCol_ci(dataType *U,
341  int32_t Nrows,
342  int32_t Ncols,
343  int32_t colUStride,
344  dataType half_norm_squared,
345  dataType *U1,
346  dataType scale,
347  uint8_t *pBlock);
348 
349 template <typename dataType>
350 void DSPLIB_bidiag_uRow_ci(dataType *U,
351  int32_t Nrows,
352  int32_t Ncols,
353  int32_t colUStride,
354  dataType *superdiag,
355  dataType *U1,
356  dataType scale,
357  uint8_t *pBlock);
358 
359 template <typename dataType>
360 void DSPLIB_bidiag_uFinal_ci(dataType *U,
361  int32_t Nrows,
362  int32_t Ncols,
363  int32_t colUStride,
364  dataType s,
365  dataType *U1,
366  uint8_t *pBlock);
367 
368 template <typename dataType>
369 void DSPLIB_bidiag_v_ci(dataType *V,
370  int32_t Nrows,
371  int32_t Ncols,
372  int32_t colVStride,
373  dataType s,
374  dataType *U1,
375  dataType *U,
376  int32_t colUStride,
377  uint8_t *pBlock);
378 
379 template <typename dataType>
380 void DSPLIB_diag_negate_v_ci(dataType *V, int32_t Ncols, int32_t colVStride, uint8_t *pBlock);
381 
382 template <typename dataType>
383 void DSPLIB_diag_epsilon_ci(dataType *diag, dataType *superdiag, dataType *epsilon, int32_t Ncols, uint8_t *pBlock);
384 
385 template <typename dataType>
386 void DSPLIB_diag_rotation_check_ci(dataType *diag,
387  dataType *superdiag,
388  dataType epsilon,
389  int32_t *m,
390  int32_t *rotation_test,
391  int32_t Ncols,
392  uint8_t *pBlock);
393 
394 template <typename dataType>
395 void DSPLIB_diag_rotation_proc_ci(dataType *U,
396  int32_t startRow,
397  int32_t Nrows,
398  int32_t Ncols,
399  int32_t rowUStride,
400  dataType *cU,
401  dataType *sU,
402  uint8_t *pBlock);
403 
404 template <typename dataType>
405 void DSPLIB_singularSort_index_ci(dataType *singular_values,
406  dataType *singularBuffer,
407  int32_t *maxIndArr,
408  int32_t Ncols,
409  uint8_t *pBlock);
410 
411 template <typename dataType>
412 void DSPLIB_diag_sqrt_ci(dataType *superdiag, dataType *diag, int32_t length, uint8_t *pBlock);
413 
414 template <typename dataType>
415 void DSPLIB_svd_blk_move_ci(dataType *pOut,
416  dataType *pIn,
417  int32_t Nrows,
418  int32_t Ncols,
419  int32_t colOutStride,
420  int32_t colInStride,
421  uint8_t *pBlock);
422 
423 /* *****************************************************************************
424  *
425  * INTERNAL INIT FUNCTIONS DECLARATION
426  *
427  ***************************************************************************** */
428 
429 template <typename dataType> void DSPLIB_bidiag_uFinal_init_ci(DSPLIB_kernelHandle handle);
430 
431 template <typename dataType> void DSPLIB_diag_proc_init_ci(DSPLIB_kernelHandle handle);
432 
433 template <typename dataType> void DSPLIB_singularSort_swap_init_ci(DSPLIB_kernelHandle handle);
434 
435 template <typename dataType> void DSPLIB_bidiag_u_init_ci(DSPLIB_kernelHandle handle);
436 
437 template <typename dataType> void DSPLIB_bidiag_v_init_ci(DSPLIB_kernelHandle handle);
438 
439 template <typename dataType> void DSPLIB_svd_matTrans_init_ci(DSPLIB_kernelHandle handle, const DSPLIB_svdInitArgs *kerInitArgs);
440 
441 /* Common function to calculate reciprocal value */
442 template <typename dataType>
443 inline dataType getRecip(dataType value)
444 {
445  dataType TwoP0 = 2.0;
446 
447  dataType yy1 = __recip(value);
448 
449  yy1 = yy1 * (TwoP0 - value * yy1);
450  yy1 = yy1 * (TwoP0 - value * yy1);
451 
452 #if defined(ENABLE_LDRA_COVERAGE)
453 /* Higher precision calculations to enter the rotation_check path. We only use this
454  as a coverage component. We do not include these operations for normal execution
455  considering the PERFORMANCE */
456  yy1 = yy1 * (TwoP0 - value * yy1);
457  yy1 = yy1 * (TwoP0 - value * yy1);
458 #endif
459 
460 
461  return yy1;
462 }
463 template float getRecip(float value);
464 template double getRecip(double value);
465 
466 
467 #endif /* DSPLIB_SVD_IXX_IXX_OXX_PRIV_H_ */
468 
469 /* ======================================================================== */
470 /* End of file: DSPLIB_svd_priv.h */
471 /* ======================================================================== */
void DSPLIB_bidiag_uFinal_ci(dataType *U, int32_t Nrows, int32_t Ncols, int32_t colUStride, dataType s, dataType *U1, uint8_t *pBlock)
This function implements the process corresponding to the "update U" loop in natural implementation.
void DSPLIB_bidiag_uFinal_initalize_ci(dataType *U, int32_t Nrows, int32_t Ncols, int32_t colUStride, dataType s, dataType *U1, uint8_t *pBlock)
This function implements the process corresponding to the "initial U" loop in natural implementation.
void DSPLIB_singularSort_swap_init_ci(DSPLIB_kernelHandle handle)
void DSPLIB_diag_negate_v_ci(dataType *V, int32_t Ncols, int32_t colVStride, uint8_t *pBlock)
Negates the values of a row in V.
void DSPLIB_bidiag_uFinal_init_ci(DSPLIB_kernelHandle handle)
void DSPLIB_bidiag_v_init_ci(DSPLIB_kernelHandle handle)
void DSPLIB_singularSort_index_ci(dataType *singular_values, dataType *singularBuffer, int32_t *maxIndArr, int32_t Ncols, uint8_t *pBlock)
This function sorts the singular values in descending order and also records the max index values for...
DSPLIB_STATUS DSPLIB_svd_exec_cn(DSPLIB_kernelHandle handle, void *restrict pA, void *restrict pU, void *restrict pV, void *restrict pDiag, void *restrict pSuperDiag, void *restrict pU1, void *restrict pV1, void *restrict pScratch)
This function is the main execution function for the natural C implementation of the kernel....
void uRowProcess(dataType *U, int32_t Nrows, int32_t Ncols, int32_t colUStride, dataType *superdiag, dataType *U1, dataType scale, uint8_t *pBlock)
DSPLIB_STATUS DSPLIB_svd_exec_ci(DSPLIB_kernelHandle handle, void *restrict pA, void *restrict pU, void *restrict pV, void *restrict pDiag, void *restrict pSuperDiag, void *restrict pU1, void *restrict pV1, void *restrict pScratch)
This function is the main execution function for the C7x implementation of the kernel....
void DSPLIB_diag_proc_init_ci(DSPLIB_kernelHandle handle)
void uColProcess(dataType *U, int32_t Nrows, int32_t Ncols, int32_t colUStride, dataType half_norm_squared, dataType *U1, dataType scale, uint8_t *pBlock)
void DSPLIB_diag_rotation_check_ci(dataType *diag, dataType *superdiag, dataType epsilon, int32_t *m, int32_t *rotation_test, int32_t Ncols, uint8_t *pBlock)
Updates values of "m" and "rotation_test" flag vased on the values present in "diag",...
void DSPLIB_svd_blk_move_ci(dataType *pOut, dataType *pIn, int32_t Nrows, int32_t Ncols, int32_t colOutStride, int32_t colInStride, uint8_t *pBlock)
Copy input matrix pIn to pOut.
void DSPLIB_bidiag_uCol_ci(dataType *U, int32_t Nrows, int32_t Ncols, int32_t colUStride, dataType half_norm_squared, dataType *U1, dataType scale, uint8_t *pBlock)
This function implements the Household processing on columns of input U matrix corresponding to the n...
DSPLIB_STATUS DSPLIB_svd_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_svdInitArgs *pKerInitArgs)
This function is the initialization function for the natural C implementation of the kernel....
void DSPLIB_bidiag_v_ci(dataType *V, int32_t Nrows, int32_t Ncols, int32_t colVStride, dataType s, dataType *U1, dataType *U, int32_t colUStride, uint8_t *pBlock)
This function implements the process corresponding to the "update V" loop in natural implementation.
void DSPLIB_bidiag_uFinal_normalize_ci(dataType *U, int32_t Nrows, dataType s, int32_t colUStride, uint8_t *pBlock)
This function normalizes the column of input matrix U.
void DSPLIB_bidiag_uFinal_expand_ci(dataType *U, int32_t Nrows, int32_t Ncols, int32_t colUStride, uint8_t *pBlock)
This function expands columns of U matrix to get a square matrix and fill the columns with '0' values...
void DSPLIB_bidiag_u_init_ci(DSPLIB_kernelHandle handle)
void DSPLIB_svd_matTrans_init_ci(DSPLIB_kernelHandle handle, const DSPLIB_svdInitArgs *kerInitArgs)
void uSiUpdate(dataType *U, int32_t Nrows, int32_t Ncols, int32_t colUStride, dataType s, dataType *U1, uint8_t *pBlock)
DSPLIB_STATUS(* pFxnDSPLIB_svd_exec)(DSPLIB_kernelHandle handle, void *restrict pA, void *restrict pU, void *restrict pV, void *restrict pDiag, void *restrict pSuperDiag, void *restrict pU1, void *restrict pV1, void *restrict pScratch)
This is a function pointer type that conforms to the declaration of DSPLIB_svd_exec_ci and DSPLIB_svd...
void DSPLIB_diag_epsilon_ci(dataType *diag, dataType *superdiag, dataType *epsilon, int32_t Ncols, uint8_t *pBlock)
Updates "epsilon" value based on absolute max values from "diag" and "superdiag" vectors.
#define DSPLIB_SVD_IXX_IXX_OXX_PBLOCK_SIZE
Macro to define the size of bufPblock array of DSPLIB_svd_PrivArgs structure.
dataType getRecip(dataType value)
dataType DSPLIB_bidiag_uRow_halfnorm_ci(dataType *U, int32_t Nrows, int32_t Ncols, int32_t colUStride, dataType *half_norm_squared, dataType *U1, dataType *s, dataType *superdiag, uint8_t *pBlock)
This function calculates the half-norm corresponding to the row of input matrix U and returns scale.
dataType DSPLIB_bidiag_uCol_halfnorm_ci(dataType *U, int32_t Nrows, int32_t Ncols, int32_t colUStride, dataType *half_norm_squared, dataType *U1, dataType *s, uint8_t *pBlock)
This function calculates the half-norms corresponding to the column of input matrix U and returns sca...
void DSPLIB_diag_proc_ci(dataType *V, int32_t startRow, int32_t Nrows, int32_t Ncols, int32_t rowVStride, dataType *cV, dataType *sV, uint8_t *pBlock)
Updates rows of V' and U' based on the precalculated cV/cU and sV/sU vectors.
DSPLIB_STATUS DSPLIB_svd_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_svdInitArgs *pKerInitArgs)
This function is the initialization function for the C7x implementation of the kernel....
void DSPLIB_bidiag_uRow_ci(dataType *U, int32_t Nrows, int32_t Ncols, int32_t colUStride, dataType *superdiag, dataType *U1, dataType scale, uint8_t *pBlock)
This function implements the Household processing on rows of input U matrix corresponding to the natu...
void DSPLIB_diag_sqrt_ci(dataType *superdiag, dataType *diag, int32_t length, uint8_t *pBlock)
Calculates the reciprocal of square-roots of "diag" and "superdiag" vectors.
void vColProcess(dataType *V, int32_t Nrows, int32_t Ncols, int32_t colVStride, dataType s, dataType *U1, dataType *U, int32_t colUStride, uint8_t *PBlock)
void DSPLIB_diag_rotation_proc_ci(dataType *U, int32_t startRow, int32_t Nrows, int32_t Ncols, int32_t rowUStride, dataType *cU, dataType *sU, uint8_t *pBlock)
Updates rows of U' based on the precalculated cU and sU vectors.
void DSPLIB_singularSort_swap_ci(dataType *V, int32_t Nrows, int32_t Ncols, int32_t rowVStride, int32_t *sortIndex, dataType *vBuff, uint8_t *pBlock)
This function uses the max index values calculated from DSPLIB_singularSort_index_ci to shuffle the r...
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 that is reserved for internal use by the kernel.
Structure containing the parameters to initialize the kernel.
Definition: DSPLIB_svd.h:129
Structure that is reserved for internal use by the kernel.
uint32_t widthIn
Size of input buffer for different batches DSPLIB_svd_init that will be retrieved and used by DSPLIB_...
DSPLIB_matTrans_PrivArgs pMatTransKerPrivArgs5
DSPLIB_matTrans_PrivArgs pMatTransKerPrivArgs2
uint32_t strideU
Stride between rows of U matrix
DSPLIB_matTrans_PrivArgs pMatTransKerPrivArgs4
uint32_t enableReducedForm
Flag for enabling the calculation of reduced form enableReducedForm = 1 for reduced form SVD calc ena...
DSPLIB_matTrans_PrivArgs pMatTransKerPrivArgs1
Privargs for the matTrans kernel.
pFxnDSPLIB_svd_exec execute
Function pointer to point to the right execution variant between DSPLIB_svd_exec_cn and DSPLIB_svd_ex...
int32_t strideIn
Stride between rows of input data matrix
uint32_t strideV
Stride between rows of V matrix
DSPLIB_matTrans_PrivArgs pMatTransKerPrivArgs3
uint32_t heightIn
Height of input data matrix