DSPLIB User Guide
DSPLIB_svd_small.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_small_priv.h"
24 
26 {
27  int32_t privBufSize = sizeof(DSPLIB_svd_small_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_svd_small_InitArgs *pKerInitArgs)
41 {
42  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering Function");
43 
45 
46 #if (__C7X_VEC_SIZE_BITS__ == 512)
47 
48  if (handle == NULL) {
49  status = DSPLIB_ERR_NULL_POINTER;
50  }
51 
52  if (status == DSPLIB_SUCCESS) {
53 
54  /* Condition change */
55  if (bufParamsA->data_type != DSPLIB_FLOAT64) {
56  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Only double precision data is supported");
57  status = DSPLIB_ERR_INVALID_TYPE;
58  }
59  else if (bufParamsA->data_type != bufParamsU->data_type) {
60  status = DSPLIB_ERR_INVALID_TYPE;
61  }
62  else if (bufParamsA->data_type != bufParamsV->data_type) {
63  status = DSPLIB_ERR_INVALID_TYPE;
64  }
65  else if (bufParamsA->data_type != bufParamsDiag->data_type) {
66  status = DSPLIB_ERR_INVALID_TYPE;
67  }
68  else if (bufParamsA->data_type != bufParamsSuperDiag->data_type) {
69  status = DSPLIB_ERR_INVALID_TYPE;
70  }
71  else {
72  /* Do nothing */
73  }
74 
75  bool condWidth = (bufParamsA->dim_y == 6);
76  bool condHeight = (bufParamsA->dim_x == 6) || (bufParamsA->dim_x == 7);
77 
78  if (!(bool)((uint32_t)condWidth & (uint32_t)condHeight)) {
79  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Valid dimensions are 6 X 6 and 6 X 7");
81  }
82  }
83 
84 #else
85  DSPLIB_DEBUGPRINTFN(0, "%s\n", "The Kernel is NOT IMPLEMENTED for __C7X_VEC_SIZE_BITS__ != 512 ");
87 #endif
88  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
89  return status;
90 }
91 
93  const void *restrict pA,
94  const void *restrict pU,
95  const void *restrict pV,
96  const void *restrict pDiag,
97  const void *restrict pSuperDiag,
98  const void *restrict pU1)
99 {
100  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
101  DSPLIB_STATUS status = DSPLIB_SUCCESS;
102 #if (__C7X_VEC_SIZE_BITS__ == 512)
103 
104  if ((pA == NULL) || (pU == NULL) || (pV == NULL) || (pDiag == NULL) || (pSuperDiag == NULL) || (pU1 == NULL)) {
105  status = DSPLIB_ERR_NULL_POINTER;
106  }
107  else {
108  status = DSPLIB_SUCCESS;
109  }
110 
111 
112 #else
113  DSPLIB_DEBUGPRINTFN(0, "%s\n", "The Kernel is NOT IMPLEMENTED for __C7X_VEC_SIZE_BITS__ != 512 ");
115 #endif
116 
117  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
118 
119  return status;
120 }
121 
123  const DSPLIB_bufParams2D_t *bufParamsA,
124  const DSPLIB_bufParams2D_t *bufParamsU,
125  const DSPLIB_bufParams2D_t *bufParamsV,
126  const DSPLIB_bufParams1D_t *bufParamsDiag,
127  const DSPLIB_bufParams1D_t *bufParamsSuperDiag,
128  const DSPLIB_svd_small_InitArgs *pKerInitArgs)
129 {
130  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
131 
132  DSPLIB_STATUS status = DSPLIB_SUCCESS;
133 
134 #if (__C7X_VEC_SIZE_BITS__ == 512)
135 
136  DSPLIB_svd_small_PrivArgs *pKerPrivArgs = (DSPLIB_svd_small_PrivArgs *) handle;
137 
138  pKerPrivArgs->widthIn = bufParamsA->dim_x;
139  pKerPrivArgs->heightIn = bufParamsA->dim_y;
140  pKerPrivArgs->strideIn = bufParamsA->stride_y;
141  pKerPrivArgs->strideU = bufParamsU->stride_y;
142  pKerPrivArgs->strideV = bufParamsV->stride_y;
143  pKerPrivArgs->enableReducedForm = pKerInitArgs->enableReducedForm;
144  pKerPrivArgs->strideURows = pKerInitArgs->strideURows;
145  pKerPrivArgs->strideVRows = pKerInitArgs->strideVRows;
146  pKerPrivArgs->data_type = bufParamsA->data_type;
147 
148  DSPLIB_DEBUGPRINTFN(0, "pKerInitArgs->funcStyle: %d bufParamsA->data_type: %d\n", pKerInitArgs->funcStyle,
149  bufParamsA->data_type);
150 
151  if (pKerInitArgs->funcStyle == DSPLIB_FUNCTION_NATC) {
152  // if (bufParamsA->data_type == DSPLIB_FLOAT32) {
153  // pKerPrivArgs->execute = DSPLIB_svd_small_exec_cn<float>;
154  // status = DSPLIB_svd_small_init_cn(handle, bufParamsA, bufParamsU, bufParamsV, bufParamsDiag,
155  // bufParamsSuperDiag, pKerInitArgs);
156  // }
157  if (bufParamsA->data_type == DSPLIB_FLOAT64) {
159  status = DSPLIB_svd_small_init_cn(handle, bufParamsA, bufParamsU, bufParamsV, bufParamsDiag,
160  bufParamsSuperDiag, pKerInitArgs);
161  }
162  else {
163  status = DSPLIB_ERR_INVALID_TYPE;
164  }
165  }
166  else {
167  // if (bufParamsA->data_type == DSPLIB_FLOAT32) {
168  // pKerPrivArgs->execute = DSPLIB_svd_small_exec_ci<float>;
169  // status = DSPLIB_svd_small_init_ci<float>(handle, bufParamsA, bufParamsU, bufParamsV, bufParamsDiag,
170  // bufParamsSuperDiag, pKerInitArgs);
171  // }
172  if (bufParamsA->data_type == DSPLIB_FLOAT64) {
174  status = DSPLIB_svd_small_init_ci<double>(handle, bufParamsA, bufParamsU, bufParamsV, bufParamsDiag,
175  bufParamsSuperDiag, pKerInitArgs);
176  }
177  else {
178  status = DSPLIB_ERR_INVALID_TYPE;
179  }
180  }
181 
182 #else
183  DSPLIB_DEBUGPRINTFN(0, "%s\n", "The Kernel is NOT IMPLEMENTED for __C7X_VEC_SIZE_BITS__ != 512 ");
185 #endif
186 
187  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
188  return status;
189 }
190 
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 {
199  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
200 
201  DSPLIB_STATUS status = DSPLIB_SUCCESS;
202 
203 #if (__C7X_VEC_SIZE_BITS__ == 512)
204 
205  DSPLIB_svd_small_PrivArgs *pKerPrivArgs = (DSPLIB_svd_small_PrivArgs *) handle;
206 
207  DSPLIB_DEBUGPRINTFN(0, "widthIn: %d heightIn: %d strideIn: %d strideU: %d srideV: %d\n", pKerPrivArgs->widthIn,
208  pKerPrivArgs->heightIn, pKerPrivArgs->strideIn, pKerPrivArgs->strideU, pKerPrivArgs->strideV);
209 
210  status = pKerPrivArgs->execute(handle, pA, pU, pV, pDiag, pSuperDiag, pU1);
211 
212 
213 #else
214  DSPLIB_DEBUGPRINTFN(0, "%s\n", "The Kernel is NOT IMPLEMENTED for __C7X_VEC_SIZE_BITS__ != 512 ");
216 #endif
217 
218  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
219 
220  return status;
221 }
222 
223 /* ======================================================================== */
224 /* End of file: DSPLIB_svd_small.cpp */
225 /* ======================================================================== */
template DSPLIB_STATUS DSPLIB_svd_small_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_svd_small_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_svd_small_exec_ci< double >(DSPLIB_kernelHandle handle, void *restrict pA, void *restrict pU, void *restrict pV, void *restrict pDiag, void *restrict pSuperDiag, void *restrict pU1)
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 DSPLIB_STATUS DSPLIB_svd_small_exec_cn< double >(DSPLIB_kernelHandle handle, void *restrict pA, void *restrict pU, void *restrict pV, void *restrict pDiag, void *restrict pSuperDiag, void *restrict pU1)
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_FLOAT64
@ DSPLIB_SUCCESS
Definition: DSPLIB_types.h:152
@ DSPLIB_ERR_NULL_POINTER
Definition: DSPLIB_types.h:157
@ DSPLIB_ERR_NOT_IMPLEMENTED
Definition: DSPLIB_types.h:158
@ DSPLIB_ERR_INVALID_TYPE
Definition: DSPLIB_types.h:155
DSPLIB_STATUS DSPLIB_svd_small_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_svd_small_InitArgs *pKerInitArgs)
This function checks the validity of the parameters passed to DSPLIB_svd_small_init function....
DSPLIB_STATUS DSPLIB_svd_small_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)
This function checks the validity of the parameters passed to DSPLIB_svd_small_exec function....
DSPLIB_STATUS DSPLIB_svd_small_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_svd_small_InitArgs *pKerInitArgs)
This function should be called before the DSPLIB_svd_small_exec function is called....
DSPLIB_STATUS DSPLIB_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 function is the main kernel compute function.
int32_t DSPLIB_svd_small_getHandleSize(DSPLIB_svd_small_InitArgs *pKerInitArgs)
This is a query function to calculate the size of internal handle.
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.
uint32_t strideVRows
Stride value for V matrix in the transposed form.
int8_t funcStyle
Variant of the function refer to DSPLIB_FUNCTION_STYLE
uint32_t strideURows
Stride value for U matrix in the transposed form.
uint32_t enableReducedForm
Flag to activate reduced form calculation | 1 => REDUCED FORM | 0 => NON-REDUCED FORM.
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