DSPLIB User Guide
DSPLIB_mat_submat_copy.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 
24 
26 {
27  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
28  int32_t privBufSize = sizeof(DSPLIB_mat_submat_copy_PrivArgs);
29  DSPLIB_DEBUGPRINTFN(0, "privBufSize: %d\n", privBufSize);
30  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", DSPLIB_SUCCESS);
31  return privBufSize;
32 }
33 
35  const DSPLIB_bufParams2D_t *bufParamsX,
36  const DSPLIB_bufParams2D_t *bufParamsY,
37  const DSPLIB_mat_submat_copyInitArgs *pKerInitArgs)
38 {
39  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering Function");
40 
42 
43  if (handle == NULL) {
44  status = DSPLIB_ERR_NULL_POINTER;
45  }
46 
47  if (status == DSPLIB_SUCCESS) {
48 
49  /* Condition change */
50  if ((bufParamsX->data_type != DSPLIB_INT64) && (bufParamsX->data_type != DSPLIB_INT32) &&
51  (bufParamsX->data_type != DSPLIB_INT16) && (bufParamsX->data_type != DSPLIB_INT8) &&
52  (bufParamsX->data_type != DSPLIB_UINT64) && (bufParamsX->data_type != DSPLIB_UINT32) &&
53  (bufParamsX->data_type != DSPLIB_UINT16) && (bufParamsX->data_type != DSPLIB_UINT8) &&
54  (bufParamsX->data_type != DSPLIB_FLOAT32) && (bufParamsX->data_type != DSPLIB_FLOAT64)) {
55  status = DSPLIB_ERR_INVALID_TYPE;
56  }
57  else if (bufParamsX->data_type != bufParamsY->data_type) {
58  status = DSPLIB_ERR_INVALID_TYPE;
59  }
60  else {
61  /* Do nothing */
62  }
63  }
64 
65  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
66 
67  return status;
68 }
69 
71 DSPLIB_mat_submat_copy_exec_checkParams(DSPLIB_kernelHandle handle, const void *restrict pX, const void *restrict pY)
72 {
73  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
74 
75  DSPLIB_STATUS status;
76 
77  if ((pX == NULL) || (pY == NULL)) {
78  status = DSPLIB_ERR_NULL_POINTER;
79  }
80  else {
81  status = DSPLIB_SUCCESS;
82  }
83  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
84 
85  return status;
86 }
87 
89  DSPLIB_bufParams2D_t *bufParamsX,
90  DSPLIB_bufParams2D_t *bufParamsY,
91  const DSPLIB_mat_submat_copyInitArgs *pKerInitArgs)
92 {
93  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
94 
97 
98  pKerPrivArgs->widthX = bufParamsX->dim_x;
99  pKerPrivArgs->heightX = bufParamsX->dim_y;
100  pKerPrivArgs->strideX = bufParamsX->stride_y;
101  pKerPrivArgs->strideY = bufParamsY->stride_y;
102  pKerPrivArgs->dir = pKerInitArgs->dir;
103  pKerPrivArgs->stRow = pKerInitArgs->stRow;
104  pKerPrivArgs->stCol = pKerInitArgs->stCol;
105  pKerPrivArgs->nRows = pKerInitArgs->nRows;
106  pKerPrivArgs->nCols = pKerInitArgs->nCols;
107 
108  DSPLIB_DEBUGPRINTFN(0, "pKerInitArgs->funcStyle: %d bufParamsY->data_type: %d\n", pKerInitArgs->funcStyle,
109  bufParamsY->data_type);
110  if ((pKerPrivArgs->stCol + pKerPrivArgs->nCols) > pKerPrivArgs->widthX || (pKerPrivArgs->stRow + pKerPrivArgs->nRows) > pKerPrivArgs->heightX) {
112  }
113  else {
114  if (pKerInitArgs->funcStyle == DSPLIB_FUNCTION_NATC) {
115  if (bufParamsX->data_type == DSPLIB_FLOAT32) {
117  status = DSPLIB_mat_submat_copy_init_cn(handle, bufParamsX, bufParamsY, pKerInitArgs);
118  }
119  else if (bufParamsX->data_type == DSPLIB_FLOAT64) {
121  status = DSPLIB_mat_submat_copy_init_cn(handle, bufParamsX, bufParamsY, pKerInitArgs);
122  }
123  else if (bufParamsX->data_type == DSPLIB_INT8) {
125  status = DSPLIB_mat_submat_copy_init_cn(handle, bufParamsX, bufParamsY, pKerInitArgs);
126  }
127  else if (bufParamsX->data_type == DSPLIB_UINT8) {
129  status = DSPLIB_mat_submat_copy_init_cn(handle, bufParamsX, bufParamsY, pKerInitArgs);
130  }
131  else if (bufParamsX->data_type == DSPLIB_INT16) {
133  status = DSPLIB_mat_submat_copy_init_cn(handle, bufParamsX, bufParamsY, pKerInitArgs);
134  }
135  else if (bufParamsX->data_type == DSPLIB_UINT16) {
137  status = DSPLIB_mat_submat_copy_init_cn(handle, bufParamsX, bufParamsY, pKerInitArgs);
138  }
139  else if (bufParamsX->data_type == DSPLIB_INT32) {
141  status = DSPLIB_mat_submat_copy_init_cn(handle, bufParamsX, bufParamsY, pKerInitArgs);
142  }
143  else if (bufParamsX->data_type == DSPLIB_UINT32) {
145  status = DSPLIB_mat_submat_copy_init_cn(handle, bufParamsX, bufParamsY, pKerInitArgs);
146  }
147  else if (bufParamsX->data_type == DSPLIB_INT64) {
149  status = DSPLIB_mat_submat_copy_init_cn(handle, bufParamsX, bufParamsY, pKerInitArgs);
150  }
151  else if (bufParamsX->data_type == DSPLIB_UINT64) {
153  status = DSPLIB_mat_submat_copy_init_cn(handle, bufParamsX, bufParamsY, pKerInitArgs);
154  }
155 
156  else {
157  status = DSPLIB_ERR_INVALID_TYPE;
158  }
159  }
160  else {
161  if (bufParamsX->data_type == DSPLIB_FLOAT32) {
163  status = DSPLIB_mat_submat_copy_init_ci<float>(handle, bufParamsX, bufParamsY, pKerInitArgs);
164  }
165  else if (bufParamsX->data_type == DSPLIB_FLOAT64) {
167  status = DSPLIB_mat_submat_copy_init_ci<double>(handle, bufParamsX, bufParamsY, pKerInitArgs);
168  }
169  else if (bufParamsX->data_type == DSPLIB_INT8) {
171  status = DSPLIB_mat_submat_copy_init_ci<int8_t>(handle, bufParamsX, bufParamsY, pKerInitArgs);
172  }
173  else if (bufParamsX->data_type == DSPLIB_UINT8) {
175  status = DSPLIB_mat_submat_copy_init_ci<uint8_t>(handle, bufParamsX, bufParamsY, pKerInitArgs);
176  }
177  else if (bufParamsX->data_type == DSPLIB_INT16) {
179  status = DSPLIB_mat_submat_copy_init_ci<int16_t>(handle, bufParamsX, bufParamsY, pKerInitArgs);
180  }
181  else if (bufParamsX->data_type == DSPLIB_UINT16) {
183  status = DSPLIB_mat_submat_copy_init_ci<uint16_t>(handle, bufParamsX, bufParamsY, pKerInitArgs);
184  }
185  else if (bufParamsX->data_type == DSPLIB_INT32) {
187  status = DSPLIB_mat_submat_copy_init_ci<int32_t>(handle, bufParamsX, bufParamsY, pKerInitArgs);
188  }
189  else if (bufParamsX->data_type == DSPLIB_UINT32) {
191  status = DSPLIB_mat_submat_copy_init_ci<uint32_t>(handle, bufParamsX, bufParamsY, pKerInitArgs);
192  }
193  else if (bufParamsX->data_type == DSPLIB_INT64) {
195  status = DSPLIB_mat_submat_copy_init_ci<int64_t>(handle, bufParamsX, bufParamsY, pKerInitArgs);
196  }
197  else if (bufParamsX->data_type == DSPLIB_UINT64) {
199  status = DSPLIB_mat_submat_copy_init_ci<uint64_t>(handle, bufParamsX, bufParamsY, pKerInitArgs);
200  }
201  else {
202  status = DSPLIB_ERR_INVALID_TYPE;
203  }
204  }
205  }
206  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
207 
208  return status;
209 }
210 
211 DSPLIB_STATUS DSPLIB_mat_submat_copy_exec(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
212 {
213  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
214 
215  DSPLIB_STATUS status;
217 
218  DSPLIB_DEBUGPRINTFN(0, "widthX: %d heightX: %d strideX: %d strideY: %d\n", pKerPrivArgs->widthX,
219  pKerPrivArgs->heightX, pKerPrivArgs->strideX, pKerPrivArgs->strideY);
220  status = pKerPrivArgs->execute(handle, pX, pY);
221 
222  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
223 
224  return status;
225 }
226 /* ======================================================================== */
227 /* End of file: DSPLIB_mat_submat_copy.cpp */
228 /* ======================================================================== */
template DSPLIB_STATUS DSPLIB_mat_submat_copy_init_ci< uint32_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsX, const DSPLIB_bufParams2D_t *bufParamsY, const DSPLIB_mat_submat_copyInitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_exec_ci< uint32_t >(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_init_ci< uint16_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsX, const DSPLIB_bufParams2D_t *bufParamsY, const DSPLIB_mat_submat_copyInitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_exec_ci< float >(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_init_ci< uint64_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsX, const DSPLIB_bufParams2D_t *bufParamsY, const DSPLIB_mat_submat_copyInitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_init_ci< int64_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsX, const DSPLIB_bufParams2D_t *bufParamsY, const DSPLIB_mat_submat_copyInitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_exec_ci< int64_t >(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_exec_ci< int16_t >(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_exec_ci< double >(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_exec_ci< uint16_t >(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_exec_ci< uint8_t >(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_init_ci< uint8_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsX, const DSPLIB_bufParams2D_t *bufParamsY, const DSPLIB_mat_submat_copyInitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_init_ci< int32_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsX, const DSPLIB_bufParams2D_t *bufParamsY, const DSPLIB_mat_submat_copyInitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_init_ci< int16_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsX, const DSPLIB_bufParams2D_t *bufParamsY, const DSPLIB_mat_submat_copyInitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_exec_ci< int32_t >(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_init_ci< float >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsX, const DSPLIB_bufParams2D_t *bufParamsY, const DSPLIB_mat_submat_copyInitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_init_ci< double >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsX, const DSPLIB_bufParams2D_t *bufParamsY, const DSPLIB_mat_submat_copyInitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_exec_ci< int8_t >(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_init_ci< int8_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsX, const DSPLIB_bufParams2D_t *bufParamsY, const DSPLIB_mat_submat_copyInitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_exec_ci< uint64_t >(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_exec_cn< uint32_t >(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
DSPLIB_STATUS DSPLIB_mat_submat_copy_init_cn(DSPLIB_kernelHandle handle, DSPLIB_bufParams2D_t *bufParamsX, DSPLIB_bufParams2D_t *bufParamsY, const DSPLIB_mat_submat_copyInitArgs *pKerInitArgs)
This function is the initialization function for the natural C implementation of the kernel....
template DSPLIB_STATUS DSPLIB_mat_submat_copy_exec_cn< int8_t >(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_exec_cn< float >(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_exec_cn< int16_t >(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_exec_cn< double >(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_exec_cn< uint8_t >(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_exec_cn< uint16_t >(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_exec_cn< int32_t >(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_exec_cn< uint64_t >(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
template DSPLIB_STATUS DSPLIB_mat_submat_copy_exec_cn< int64_t >(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
Header file for kernel's internal use. For the kernel's interface, please see DSPLIB_mat_submat_copy.
#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_UINT64
@ DSPLIB_UINT8
@ DSPLIB_UINT16
@ DSPLIB_INT32
@ DSPLIB_INT16
@ DSPLIB_FLOAT32
@ DSPLIB_INT64
@ DSPLIB_FLOAT64
@ DSPLIB_UINT32
@ DSPLIB_INT8
@ DSPLIB_ERR_INVALID_DIMENSION
Definition: DSPLIB_types.h:156
@ 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_mat_submat_copy_init(DSPLIB_kernelHandle handle, DSPLIB_bufParams2D_t *bufParamsX, DSPLIB_bufParams2D_t *bufParamsY, const DSPLIB_mat_submat_copyInitArgs *pKerInitArgs)
This function should be called before the DSPLIB_mat_submat_copy_exec function is called....
DSPLIB_STATUS DSPLIB_mat_submat_copy_exec(DSPLIB_kernelHandle handle, void *restrict pX, void *restrict pY)
This function is the main kernel compute function.
DSPLIB_STATUS DSPLIB_mat_submat_copy_exec_checkParams(DSPLIB_kernelHandle handle, const void *restrict pX, const void *restrict pY)
This function checks the validity of the parameters passed to DSPLIB_mat_submat_copy_exec function....
int32_t DSPLIB_mat_submat_copy_getHandleSize(DSPLIB_mat_submat_copyInitArgs *pKerInitArgs)
This is a query function to calculate the size of internal handle.
DSPLIB_STATUS DSPLIB_mat_submat_copy_init_checkParams(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsX, const DSPLIB_bufParams2D_t *bufParamsY, const DSPLIB_mat_submat_copyInitArgs *pKerInitArgs)
This function checks the validity of the parameters passed to DSPLIB_mat_submat_copy_init function....
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 nCols
The number of coulmns to be copied
uint32_t stCol
Copying starting from stCol column of matrix
uint32_t stRow
Copying starting from stRow row of matrix
int8_t funcStyle
Variant of the function refer to DSPLIB_FUNCTION_STYLE
uint32_t dir
Direction of the data flow
uint32_t nRows
The number of rows to be copied
Structure that is reserved for internal use by the kernel.
uint32_t nCols
The number of cols to be copied
pFxnDSPLIB_mat_submat_copy_exec execute
Function pointer to point to the right execution variant between DSPLIB_mat_submat_copy_exec_cn and D...
uint32_t stRow
Copying starting from stRow row of matrix
uint32_t strideX
Stride between rows of input data matrix
uint32_t stCol
Copying starting from stCol col of matrix
uint32_t widthX
Size of input buffer for different batches DSPLIB_mat_submat_copy_init that will be retrieved and use...
uint32_t nRows
The number of rows to be copied
uint32_t heightX
Height of input data matrix
uint32_t strideY
Stride between rows of output data matrix