DSPLIB User Guide
DSPLIB_svd_common_ci.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 /* *****************************************************************************
24  *
25  * INCLUDES
26  *
27  ***************************************************************************** */
28 
29 #include "DSPLIB_svd_priv.h"
30 
31 /* *****************************************************************************
32  *
33  * INITIALIZATION
34  *
35  ***************************************************************************** */
39 template <typename dataType> void DSPLIB_svd_matTrans_init_ci(DSPLIB_kernelHandle handle, const DSPLIB_svdInitArgs *pKerInitArgs)
40 {
41  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
42  DSPLIB_svd_PrivArgs *pKerPrivArgs = (DSPLIB_svd_PrivArgs *) handle;
43  uint8_t *pBlock = pKerPrivArgs->bufPblock;
44  __SA_TEMPLATE_v1 sa1Params = __gen_SA_TEMPLATE_v1();
45 
46  typedef typename c7x::make_full_vector<dataType>::type vec;
47  __SA_VECLEN SA_VECLEN = c7x::sa_veclen<vec>::value;
48  sa1Params.DIMFMT = __SA_DIMFMT_2D;
49  sa1Params.VECLEN = SA_VECLEN;
50  *(__SA_TEMPLATE_v1 *) ((uint8_t *) pBlock + (25 * SE_PARAM_SIZE)) = sa1Params;
51 
52  DSPLIB_matTrans_PrivArgs *pMatTransKerPrivArgs1 = &pKerPrivArgs->pMatTransKerPrivArgs1;
53  DSPLIB_matTrans_PrivArgs *pMatTransKerPrivArgs2 = &pKerPrivArgs->pMatTransKerPrivArgs2;
54  DSPLIB_matTrans_PrivArgs *pMatTransKerPrivArgs3 = &pKerPrivArgs->pMatTransKerPrivArgs3;
55  DSPLIB_matTrans_PrivArgs *pMatTransKerPrivArgs4 = &pKerPrivArgs->pMatTransKerPrivArgs4;
56  DSPLIB_matTrans_PrivArgs *pMatTransKerPrivArgs5 = &pKerPrivArgs->pMatTransKerPrivArgs5;
57 
58  DSPLIB_matTransInitArgs kerInitArgsMatTrans;
59  kerInitArgsMatTrans.funcStyle = pKerInitArgs->funcStyle;
60  kerInitArgsMatTrans.dimX = pKerInitArgs->dimX;
61  kerInitArgsMatTrans.dimY = pKerInitArgs->dimY;
62 
63  uint32_t Nrows = pKerPrivArgs->heightIn;
64  uint32_t Ncols = pKerPrivArgs->widthIn;
65  int Nrows1 = 0;
66  int Ncols1 = 0;
67  if (Nrows >= Ncols) {
68  Nrows1 = Nrows;
69  Ncols1 = Ncols;
70  }
71  else {
72  Nrows1 = Ncols;
73  Ncols1 = Nrows;
74  }
75 
76  DSPLIB_bufParams2D_t bufParamsIn, bufParamsOut;
77 
78  /* First matTrans Init */
79  bufParamsIn.dim_y = bufParamsOut.dim_x = Ncols1;
80  bufParamsIn.dim_x = bufParamsOut.dim_y = Nrows1;
81  bufParamsIn.stride_y = pKerPrivArgs->strideIn;
82  bufParamsOut.stride_y = pKerPrivArgs->strideU;
83  pMatTransKerPrivArgs1->heightIn = Ncols1;
84  pMatTransKerPrivArgs1->widthIn = Nrows1;
85  pMatTransKerPrivArgs1->strideIn = pKerPrivArgs->strideIn;
86  pMatTransKerPrivArgs1->strideOut = pKerPrivArgs->strideU;
87  DSPLIB_matTrans_init_ci<dataType>(pMatTransKerPrivArgs1, &bufParamsIn, &bufParamsOut, &kerInitArgsMatTrans);
88 
89 
90  /* Second matTrans Init */
91  bufParamsIn.dim_y = bufParamsOut.dim_x = Nrows1;
92  bufParamsIn.dim_x = bufParamsOut.dim_y = Nrows1;
93  bufParamsIn.stride_y = pKerPrivArgs->strideURows;
94  bufParamsOut.stride_y = pKerPrivArgs->strideURows;
95  pMatTransKerPrivArgs2->heightIn = Nrows1;
96  pMatTransKerPrivArgs2->widthIn = Nrows1;
97  pMatTransKerPrivArgs2->strideIn = pKerPrivArgs->strideURows;
98  pMatTransKerPrivArgs2->strideOut = pKerPrivArgs->strideURows;
99  DSPLIB_matTrans_init_ci<dataType>(pMatTransKerPrivArgs2, &bufParamsIn, &bufParamsOut, &kerInitArgsMatTrans);
100 
101 
102  /* Third matTrans Init */
103  bufParamsIn.dim_y = bufParamsOut.dim_x = Nrows1;
104  bufParamsIn.dim_x = bufParamsOut.dim_y = Ncols1;
105  bufParamsIn.stride_y = pKerPrivArgs->strideU;
106  bufParamsOut.stride_y = pKerPrivArgs->strideURows;
107  pMatTransKerPrivArgs3->heightIn = Nrows1;
108  pMatTransKerPrivArgs3->widthIn = Ncols1;
109  pMatTransKerPrivArgs3->strideIn = pKerPrivArgs->strideU;
110  pMatTransKerPrivArgs3->strideOut = pKerPrivArgs->strideURows;
111  DSPLIB_matTrans_init_ci<dataType>(pMatTransKerPrivArgs3, &bufParamsIn, &bufParamsOut, &kerInitArgsMatTrans);
112 
113  /* Fourth matTrans Init */
114  bufParamsIn.dim_y = bufParamsOut.dim_x = Ncols1;
115  bufParamsIn.dim_x = bufParamsOut.dim_y = Nrows1;
116  bufParamsIn.stride_y = pKerPrivArgs->strideURows;
117  bufParamsOut.stride_y = pKerPrivArgs->strideU;
118  pMatTransKerPrivArgs4->heightIn = Ncols1;
119  pMatTransKerPrivArgs4->widthIn = Nrows1;
120  pMatTransKerPrivArgs4->strideIn = pKerPrivArgs->strideURows;
121  pMatTransKerPrivArgs4->strideOut = pKerPrivArgs->strideU;
122  DSPLIB_matTrans_init_ci<dataType>(pMatTransKerPrivArgs4, &bufParamsIn, &bufParamsOut, &kerInitArgsMatTrans);
123 
124  /* Fifth matTrans Init */
125  bufParamsIn.dim_y = bufParamsOut.dim_x = Ncols1;
126  bufParamsIn.dim_x = bufParamsOut.dim_y = Ncols1;
127  bufParamsIn.stride_y = pKerPrivArgs->strideVRows;
128  bufParamsOut.stride_y = pKerPrivArgs->strideV;
129  pMatTransKerPrivArgs5->heightIn = Ncols1;
130  pMatTransKerPrivArgs5->widthIn = Ncols1;
131  pMatTransKerPrivArgs5->strideIn = pKerPrivArgs->strideVRows;
132  pMatTransKerPrivArgs5->strideOut = pKerPrivArgs->strideV;
133  DSPLIB_matTrans_init_ci<dataType>(pMatTransKerPrivArgs5, &bufParamsIn, &bufParamsOut, &kerInitArgsMatTrans);
134 
135 
136 
137  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", DSPLIB_SUCCESS);
138 
139 
140 
141 }
144 
145 /* *****************************************************************************
146  *
147  * IMPLEMENTATION
148  *
149  ***************************************************************************** */
150 
154 template <typename dataType>
155 void DSPLIB_svd_blk_move_ci(dataType *pOut,
156  dataType *pIn,
157  int32_t Nrows,
158  int32_t Ncols,
159  int32_t colOutStride,
160  int32_t colInStride,
161  uint8_t *pBlock)
162 {
163  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
164 
165  __SE_TEMPLATE_v1 se0Params = *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + (22 * SE_PARAM_SIZE));
166  __SA_TEMPLATE_v1 sa0Params = *(__SA_TEMPLATE_v1 *) ((uint8_t *) pBlock + (25 * SE_PARAM_SIZE));
167 
168  typedef typename c7x::make_full_vector<dataType>::type vec;
169  int32_t eleCount = c7x::element_count_of<vec>::value;
170  int32_t nVec = DSPLIB_ceilingDiv(Ncols, eleCount);
171  int32_t loopCount = nVec * Nrows;
172 
173  se0Params.ICNT0 = Ncols;
174  se0Params.ICNT1 = Nrows;
175  se0Params.DIM1 = colInStride;
176 
177  sa0Params.ICNT0 = Ncols;
178  sa0Params.ICNT1 = Nrows;
179  sa0Params.DIM1 = colOutStride;
180 
181  __SE0_OPEN(pIn, se0Params);
182  __SA0_OPEN(sa0Params);
183  for (int32_t i = 0; i < loopCount; i++) {
184  vec v1 = c7x::strm_eng<0, vec>::get_adv();
185 
186  __vpred pred = c7x::strm_agen<0, vec>::get_vpred();
187  vec *pStore = c7x::strm_agen<0, vec>::get_adv(pOut);
188  __vstore_pred(pred, pStore, v1);
189  }
190 
191  __SE0_CLOSE();
192  __SA0_CLOSE();
193  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Exiting function");
194 }
195 template void DSPLIB_svd_blk_move_ci<float>(float *pOut,
196  float *pIn,
197  int32_t Nrows,
198  int32_t Ncols,
199  int32_t colOutStride,
200  int32_t colInStride,
201  uint8_t *pBlock);
202 template void DSPLIB_svd_blk_move_ci<double>(double *pOut,
203  double *pIn,
204  int32_t Nrows,
205  int32_t Ncols,
206  int32_t colOutStride,
207  int32_t colInStride,
208  uint8_t *pBlock);
209 
210 /* ======================================================================== */
211 /* End of file: DSPLIB_svd_common_ci.cpp */
212 /* ======================================================================== */
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.
template void DSPLIB_svd_blk_move_ci< float >(float *pOut, float *pIn, int32_t Nrows, int32_t Ncols, int32_t colOutStride, int32_t colInStride, uint8_t *pBlock)
template void DSPLIB_svd_matTrans_init_ci< float >(DSPLIB_kernelHandle handle, const DSPLIB_svdInitArgs *pKerInitArgs)
void DSPLIB_svd_matTrans_init_ci(DSPLIB_kernelHandle handle, const DSPLIB_svdInitArgs *pKerInitArgs)
template void DSPLIB_svd_blk_move_ci< double >(double *pOut, double *pIn, int32_t Nrows, int32_t Ncols, int32_t colOutStride, int32_t colInStride, uint8_t *pBlock)
template void DSPLIB_svd_matTrans_init_ci< double >(DSPLIB_kernelHandle handle, const DSPLIB_svdInitArgs *pKerInitArgs)
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
void * DSPLIB_kernelHandle
Handle type for DSPLIB operations.
Definition: DSPLIB_types.h:172
@ DSPLIB_SUCCESS
Definition: DSPLIB_types.h:152
A structure for a 2 dimensional buffer descriptor.
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 dimX
Size of input data.
int8_t funcStyle
Variant of the function refer to DSPLIB_FUNCTION_STYLE
Structure that is reserved for internal use by the kernel.
int32_t strideOut
Stride between rows of output data matrix
uint32_t heightIn
Height of input data matrix
int32_t strideIn
Stride between rows of input data matrix
uint32_t widthIn
Size of input buffer for different batches DSPLIB_matTrans_init that will be retrieved and used by DS...
Structure containing the parameters to initialize the kernel.
Definition: DSPLIB_svd.h:129
uint32_t dimY
Size of input data dimY => Number of rows.
Definition: DSPLIB_svd.h:135
int8_t funcStyle
Variant of the function refer to DSPLIB_FUNCTION_STYLE
Definition: DSPLIB_svd.h:131
uint32_t dimX
Size of input data dimX => Number of columns.
Definition: DSPLIB_svd.h:133
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
uint8_t bufPblock[DSPLIB_SVD_IXX_IXX_OXX_PBLOCK_SIZE]
Buffer to save SE & SA configuration parameters
DSPLIB_matTrans_PrivArgs pMatTransKerPrivArgs4
DSPLIB_matTrans_PrivArgs pMatTransKerPrivArgs1
Privargs for the matTrans kernel.
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