DSPLIB User Guide
DSPLIB_svd.cpp
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 
23 #include "DSPLIB_svd_priv.h"
24 
26 {
27  int32_t privBufSize = sizeof(DSPLIB_svd_PrivArgs);
28 
29  DSPLIB_DEBUGPRINTFN(0, "privBufSize: %d\n", privBufSize);
30 
31  return privBufSize;
32 }
33 
35  const DSPLIB_bufParams2D_t *bufParamsA,
36  const DSPLIB_bufParams2D_t *bufParamsU,
37  const DSPLIB_bufParams2D_t *bufParamsV,
38  const DSPLIB_bufParams1D_t *bufParamsDiag,
39  const DSPLIB_bufParams1D_t *bufParamsSuperDiag,
40  const DSPLIB_svdInitArgs *pKerInitArgs)
41 {
42  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering Function");
43 
45 
46  if (handle == NULL) {
47  status = DSPLIB_ERR_NULL_POINTER;
48  }
49 
50  if (status == DSPLIB_SUCCESS) {
51 
52  /* Condition change */
53  if ((bufParamsA->data_type != DSPLIB_FLOAT32) && (bufParamsA->data_type != DSPLIB_FLOAT64)) {
54  status = DSPLIB_ERR_INVALID_TYPE;
55  }
56  else if (bufParamsA->data_type != bufParamsU->data_type) {
57  status = DSPLIB_ERR_INVALID_TYPE;
58  }
59  else if (bufParamsA->data_type != bufParamsV->data_type) {
60  status = DSPLIB_ERR_INVALID_TYPE;
61  }
62  else if (bufParamsA->data_type != bufParamsDiag->data_type) {
63  status = DSPLIB_ERR_INVALID_TYPE;
64  }
65  else if (bufParamsA->data_type != bufParamsSuperDiag->data_type) {
66  status = DSPLIB_ERR_INVALID_TYPE;
67  }
68  else {
69  /* Do nothing */
70  }
71  }
72 
73  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
74 
75  return status;
76 }
77 
79  const void *restrict pA,
80  const void *restrict pU,
81  const void *restrict pV,
82  const void *restrict pDiag,
83  const void *restrict pSuperDiag,
84  const void *restrict pU1,
85  const void *restrict pV1,
86  const void *restrict pScratch)
87 {
88  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
89 
90  DSPLIB_STATUS status;
91 
92  if ((pA == NULL) || (pU == NULL) || (pV == NULL) || (pDiag == NULL) || (pSuperDiag == NULL) || (pU1 == NULL) ||
93  (pV1 == NULL) || (pScratch == NULL)) {
94  status = DSPLIB_ERR_NULL_POINTER;
95  }
96  else {
97  status = DSPLIB_SUCCESS;
98  }
99  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
100 
101  return status;
102 }
103 
105  const DSPLIB_bufParams2D_t *bufParamsA,
106  const DSPLIB_bufParams2D_t *bufParamsU,
107  const DSPLIB_bufParams2D_t *bufParamsV,
108  const DSPLIB_bufParams1D_t *bufParamsDiag,
109  const DSPLIB_bufParams1D_t *bufParamsSuperDiag,
110  const DSPLIB_svdInitArgs *pKerInitArgs)
111 {
112  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
113 
114  DSPLIB_STATUS status = DSPLIB_SUCCESS;
115  DSPLIB_svd_PrivArgs *pKerPrivArgs = (DSPLIB_svd_PrivArgs *) handle;
116 
117  pKerPrivArgs->widthIn = bufParamsA->dim_x;
118  pKerPrivArgs->heightIn = bufParamsA->dim_y;
119  pKerPrivArgs->strideIn = bufParamsA->stride_y;
120  pKerPrivArgs->strideU = bufParamsU->stride_y;
121  pKerPrivArgs->strideV = bufParamsV->stride_y;
122  pKerPrivArgs->enableReducedForm = pKerInitArgs->enableReducedForm;
123  pKerPrivArgs->strideURows = pKerInitArgs->strideURows;
124  pKerPrivArgs->strideVRows = pKerInitArgs->strideVRows;
125 
126  DSPLIB_DEBUGPRINTFN(0, "pKerInitArgs->funcStyle: %d bufParamsA->data_type: %d\n", pKerInitArgs->funcStyle,
127  bufParamsA->data_type);
128 
129  if (pKerInitArgs->funcStyle == DSPLIB_FUNCTION_NATC) {
130  if (bufParamsA->data_type == DSPLIB_FLOAT32) {
131  pKerPrivArgs->execute = DSPLIB_svd_exec_cn<float>;
132  status = DSPLIB_svd_init_cn(handle, bufParamsA, bufParamsU, bufParamsV, bufParamsDiag, bufParamsSuperDiag,
133  pKerInitArgs);
134  }
135  else if (bufParamsA->data_type == DSPLIB_FLOAT64) {
136  pKerPrivArgs->execute = DSPLIB_svd_exec_cn<double>;
137  status = DSPLIB_svd_init_cn(handle, bufParamsA, bufParamsU, bufParamsV, bufParamsDiag, bufParamsSuperDiag,
138  pKerInitArgs);
139  }
140  else {
141  status = DSPLIB_ERR_INVALID_TYPE;
142  }
143  }
144  else {
145  if (bufParamsA->data_type == DSPLIB_FLOAT32) {
146  pKerPrivArgs->execute = DSPLIB_svd_exec_ci<float>;
147  status = DSPLIB_svd_init_ci<float>(handle, bufParamsA, bufParamsU, bufParamsV, bufParamsDiag,
148  bufParamsSuperDiag, pKerInitArgs);
149  }
150  else if (bufParamsA->data_type == DSPLIB_FLOAT64) {
151  pKerPrivArgs->execute = DSPLIB_svd_exec_ci<double>;
152  status = DSPLIB_svd_init_ci<double>(handle, bufParamsA, bufParamsU, bufParamsV, bufParamsDiag,
153  bufParamsSuperDiag, pKerInitArgs);
154  }
155  else {
156  status = DSPLIB_ERR_INVALID_TYPE;
157  }
158  }
159  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
160 
161  return status;
162 }
163 
165  void *restrict pA,
166  void *restrict pU,
167  void *restrict pV,
168  void *restrict pDiag,
169  void *restrict pSuperDiag,
170  void *restrict pU1,
171  void *restrict pV1,
172  void *restrict pScratch)
173 {
174  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
175 
176  DSPLIB_STATUS status;
177 
178  DSPLIB_svd_PrivArgs *pKerPrivArgs = (DSPLIB_svd_PrivArgs *) handle;
179 
180  DSPLIB_DEBUGPRINTFN(0, "widthIn: %d heightIn: %d strideIn: %d strideU: %d srideV: %d\n", pKerPrivArgs->widthIn,
181  pKerPrivArgs->heightIn, pKerPrivArgs->strideIn, pKerPrivArgs->strideU, pKerPrivArgs->strideV);
182 
183  status = pKerPrivArgs->execute(handle, pA, pU, pV, pDiag, pSuperDiag, pU1, pV1, pScratch);
184 
185  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
186 
187  return status;
188 }
189 
190 /* ======================================================================== */
191 /* End of file: DSPLIB_svd.cpp */
192 /* ======================================================================== */
template DSPLIB_STATUS DSPLIB_svd_exec_ci< double >(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)
template DSPLIB_STATUS DSPLIB_svd_init_ci< float >(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)
template DSPLIB_STATUS DSPLIB_svd_exec_ci< float >(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)
template DSPLIB_STATUS DSPLIB_svd_init_ci< double >(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)
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....
template DSPLIB_STATUS DSPLIB_svd_exec_cn< double >(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)
template DSPLIB_STATUS DSPLIB_svd_exec_cn< float >(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)
Header file for kernel's internal use. For the kernel's interface, please see DSPLIB_svd.
#define DSPLIB_DEBUGPRINTFN(N, fmt,...)
Definition: DSPLIB_types.h:83
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
@ DSPLIB_FUNCTION_NATC
Definition: DSPLIB_types.h:176
@ DSPLIB_FLOAT32
@ DSPLIB_FLOAT64
@ DSPLIB_SUCCESS
Definition: DSPLIB_types.h:152
@ DSPLIB_ERR_NULL_POINTER
Definition: DSPLIB_types.h:157
@ DSPLIB_ERR_INVALID_TYPE
Definition: DSPLIB_types.h:155
DSPLIB_STATUS DSPLIB_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 function is the main kernel compute function.
Definition: DSPLIB_svd.cpp:164
DSPLIB_STATUS DSPLIB_svd_exec_checkParams(DSPLIB_kernelHandle handle, const void *restrict pA, const void *restrict pU, const void *restrict pV, const void *restrict pDiag, const void *restrict pSuperDiag, const void *restrict pU1, const void *restrict pV1, const void *restrict pScratch)
This function checks the validity of the parameters passed to DSPLIB_svd_exec function....
Definition: DSPLIB_svd.cpp:78
DSPLIB_STATUS DSPLIB_svd_init_checkParams(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsA, 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 checks the validity of the parameters passed to DSPLIB_svd_init function....
Definition: DSPLIB_svd.cpp:34
int32_t DSPLIB_svd_getHandleSize(DSPLIB_svdInitArgs *pKerInitArgs)
This is a query function to calculate the size of internal handle.
Definition: DSPLIB_svd.cpp:25
DSPLIB_STATUS DSPLIB_svd_init(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsA, 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 should be called before the DSPLIB_svd_exec function is called. This function takes car...
Definition: DSPLIB_svd.cpp:104
A structure for a 1 dimensional buffer descriptor.
uint32_t data_type
Values are of type DSPLIB_data_type_e.
A structure for a 2 dimensional buffer descriptor.
uint32_t data_type
Values are of type DSPLIB_data_type_e.
int32_t stride_y
Stride in Y dimension in bytes.
uint32_t dim_x
Width of buffer in X dimension in elements.
uint32_t dim_y
Height of buffer in Y dimension in elements.
Structure containing the parameters to initialize the kernel.
Definition: DSPLIB_svd.h:129
uint32_t enableReducedForm
Flag to activate reduced form calculation | 1 => REDUCED FORM | 0 => NON-REDUCED FORM.
Definition: DSPLIB_svd.h:137
uint32_t strideVRows
Stride value for V matrix in the transposed form.
Definition: DSPLIB_svd.h:141
uint32_t strideURows
Stride value for U matrix in the transposed form.
Definition: DSPLIB_svd.h:139
int8_t funcStyle
Variant of the function refer to DSPLIB_FUNCTION_STYLE
Definition: DSPLIB_svd.h:131
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_...
uint32_t strideU
Stride between rows of U matrix
uint32_t enableReducedForm
Flag for enabling the calculation of reduced form enableReducedForm = 1 for reduced form SVD calc ena...
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
uint32_t heightIn
Height of input data matrix