DSPLIB User Guide
DSPLIB_dotp_sqr.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * *
3  * module name :DSPLIB *
4  * *
5  * module descripton :Matrix Multiply Accelerator 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_dotp_sqr_priv.h"
24 
26 {
27  int32_t privBufSize = sizeof(DSPLIB_dotp_sqr_PrivArgs);
28  return privBufSize;
29 }
30 
33  const DSPLIB_bufParams1D_t *bufParamsIn,
34  const DSPLIB_bufParams1D_t *bufParamsOut,
35  const DSPLIB_dotp_sqr_InitArgs *pKerInitArgs)
36 {
38 
39 #if DSPLIB_DEBUGPRINT
40  printf("Enter DSPLIB_dotp_sqr_init_checkParams\n");
41 #endif
42  if (handle == NULL) {
43  status = DSPLIB_ERR_NULL_POINTER;
44  }
45 
46  if (status == DSPLIB_SUCCESS) {
47  if ((bufParamsIn->data_type == DSPLIB_UINT8) && (bufParamsOut->data_type == DSPLIB_UINT32)){
48  status = DSPLIB_SUCCESS;
49  }
50  else if ((bufParamsIn->data_type == DSPLIB_INT8) && (bufParamsOut->data_type == DSPLIB_INT32)){
51  status = DSPLIB_SUCCESS;
52  }
53  else if ((bufParamsIn->data_type == DSPLIB_UINT16) && (bufParamsOut->data_type == DSPLIB_UINT64)){
54  status = DSPLIB_SUCCESS;
55  }
56  else if ((bufParamsIn->data_type == DSPLIB_INT16) && (bufParamsOut->data_type == DSPLIB_INT64)){
57  status = DSPLIB_SUCCESS;
58  }
59  else if ((bufParamsIn->data_type == DSPLIB_UINT32) && (bufParamsOut->data_type == DSPLIB_UINT64)){
60  status = DSPLIB_SUCCESS;
61  }
62  else if ((bufParamsIn->data_type == DSPLIB_INT32) && (bufParamsOut->data_type == DSPLIB_INT64)){
63  status = DSPLIB_SUCCESS;
64  }
65  else if ((bufParamsIn->data_type == DSPLIB_FLOAT32) && (bufParamsOut->data_type == DSPLIB_FLOAT32)){
66  status = DSPLIB_SUCCESS;
67  }
68  else if ((bufParamsIn->data_type == DSPLIB_FLOAT64) && (bufParamsOut->data_type == DSPLIB_FLOAT64)){
69  status = DSPLIB_SUCCESS;
70  }
71  else {
72  status = DSPLIB_ERR_INVALID_TYPE;
73  }
74  }
75 
76  return status;
77 }
78 
80  const void *restrict pIn1,
81  const void *restrict pIn2,
82  const void *restrict pOut)
83 {
84  DSPLIB_STATUS status;
85 
86 #if DSPLIB_DEBUGPRINT
87  printf("Enter DSPLIB_dotp_sqr_exec_checkParams\n");
88 #endif
89  if ((pIn1 == NULL) || (pIn2 == NULL) || (pOut == NULL)) {
90  status = DSPLIB_ERR_NULL_POINTER;
91  }
92  else {
93  status = DSPLIB_SUCCESS;
94  }
95 
96  return status;
97 }
98 
100  DSPLIB_bufParams1D_t *bufParamsIn,
101  DSPLIB_bufParams1D_t *bufParamsOut,
102  const DSPLIB_dotp_sqr_InitArgs *pKerInitArgs)
103 {
104  DSPLIB_STATUS status = DSPLIB_SUCCESS;
105  DSPLIB_dotp_sqr_PrivArgs *pKerPrivArgs = (DSPLIB_dotp_sqr_PrivArgs *) handle;
106 
107 #if DSPLIB_DEBUGPRINT
108  printf("DSPLIB_DEBUGPRINT Enter DSPLIB_dotp_sqr_init\n");
109 #endif
110  pKerPrivArgs->blockSize = pKerInitArgs->dataSize;
111 
112 #if DSPLIB_DEBUGPRINT
113  printf("DSPLIB_DEBUGPRINT DSPLIB_dotp_sqr_init pKerPrivArgs->blockSize %d "
114  "bufParamsIn->data_type %d\n",
115  pKerPrivArgs->blockSize, bufParamsIn->data_type);
116 #endif
117 
118  if (pKerInitArgs->funcStyle == DSPLIB_FUNCTION_NATC) {
119  if (bufParamsIn->data_type == DSPLIB_FLOAT32) {
120  pKerPrivArgs->execute = DSPLIB_dotp_sqr_exec_cn<float>;
121  }
122  else if (bufParamsIn->data_type == DSPLIB_FLOAT64) {
124  }
125  else if (bufParamsIn->data_type == DSPLIB_INT8) {
127  }
128  else if (bufParamsIn->data_type == DSPLIB_UINT8) {
130  }
131  else if (bufParamsIn->data_type == DSPLIB_INT16) {
133  }
134  else if (bufParamsIn->data_type == DSPLIB_UINT16) {
136  }
137  else if (bufParamsIn->data_type == DSPLIB_INT32) {
139  }
140  else if (bufParamsIn->data_type == DSPLIB_UINT32) {
142  }
143  else {
144  status = DSPLIB_ERR_INVALID_TYPE;
145 #if DSPLIB_DEBUGPRINT
146  printf("DSPLIB_DEBUGPRINT CP 2 status %d\n", status);
147 #endif
148  }
149  }
150  else {
151  if (bufParamsIn->data_type == DSPLIB_FLOAT32) {
152 #if DSPLIB_DEBUGPRINT
153  printf("DSPLIB_DEBUGPRINT bufParamsIn->data_type == DSPLIB_FLOAT32\n");
154 #endif
155  pKerPrivArgs->execute = DSPLIB_dotp_sqr_exec_ci<float>;
156  status = DSPLIB_dotp_sqr_init_ci<float>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
157  }
158  else if (bufParamsIn->data_type == DSPLIB_FLOAT64) {
160  status = DSPLIB_dotp_sqr_init_ci<double>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
161  }
162  else if (bufParamsIn->data_type == DSPLIB_INT8) {
164  status = DSPLIB_dotp_sqr_init_ci<int8_t>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
165  }
166  else if (bufParamsIn->data_type == DSPLIB_UINT8) {
168  status = DSPLIB_dotp_sqr_init_ci<uint8_t>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
169  }
170  else if (bufParamsIn->data_type == DSPLIB_INT16) {
172  status = DSPLIB_dotp_sqr_init_ci<int16_t>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
173  }
174  else if (bufParamsIn->data_type == DSPLIB_UINT16) {
176  status = DSPLIB_dotp_sqr_init_ci<uint16_t>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
177  }
178  else if (bufParamsIn->data_type == DSPLIB_INT32) {
180  status = DSPLIB_dotp_sqr_init_ci<int32_t>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
181  }
182  else if (bufParamsIn->data_type == DSPLIB_UINT32) {
184  status = DSPLIB_dotp_sqr_init_ci<uint32_t>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
185  }
186  else {
187  status = DSPLIB_ERR_INVALID_TYPE;
188  }
189  }
190 #if DSPLIB_DEBUGPRINT
191  printf("DSPLIB_DEBUGPRINT CP 3 status %d\n", status);
192 #endif
193  return status;
194 }
195 
197 DSPLIB_dotp_sqr_exec(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
198 {
199  DSPLIB_STATUS status;
200 
201 #if DSPLIB_DEBUGPRINT
202  printf("DSPLIB_DEBUGPRINT Enter DSPLIB_dotp_sqr_exec\n");
203 #endif
204 
205  DSPLIB_dotp_sqr_PrivArgs *pKerPrivArgs = (DSPLIB_dotp_sqr_PrivArgs *) handle;
206 
207 #if DSPLIB_DEBUGPRINT
208  printf("DSPLIB_DEBUGPRINT pKerPrivArgs->blockSize %d\n", pKerPrivArgs->blockSize);
209 #endif
210 
211  status = pKerPrivArgs->execute(handle, pIn1, pIn2, pOut);
212 
213  return status;
214 }
template DSPLIB_STATUS DSPLIB_dotp_sqr_init_ci< uint32_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_dotp_sqr_InitArgs *pKerInitArgs)
DSPLIB_STATUS DSPLIB_dotp_sqr_exec_ci< uint8_t >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_dotp_sqr_init_ci< int32_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_dotp_sqr_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_dotp_sqr_init_ci< uint8_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_dotp_sqr_InitArgs *pKerInitArgs)
DSPLIB_STATUS DSPLIB_dotp_sqr_init_ci< int8_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_dotp_sqr_InitArgs *pKerInitArgs)
DSPLIB_STATUS DSPLIB_dotp_sqr_exec_ci< uint32_t >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_dotp_sqr_exec_ci< float >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_dotp_sqr_exec_ci< double >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_dotp_sqr_init_ci< double >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_dotp_sqr_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_dotp_sqr_init_ci< int16_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_dotp_sqr_InitArgs *pKerInitArgs)
DSPLIB_STATUS DSPLIB_dotp_sqr_exec_ci< int16_t >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
DSPLIB_STATUS DSPLIB_dotp_sqr_exec_ci< int32_t >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_dotp_sqr_init_ci< float >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_dotp_sqr_InitArgs *pKerInitArgs)
DSPLIB_STATUS DSPLIB_dotp_sqr_exec_ci< int8_t >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
DSPLIB_STATUS DSPLIB_dotp_sqr_exec_ci< uint16_t >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_dotp_sqr_init_ci< uint16_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_dotp_sqr_InitArgs *pKerInitArgs)
DSPLIB_STATUS DSPLIB_dotp_sqr_exec_cn< uint32_t >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_dotp_sqr_exec_cn< double >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_dotp_sqr_exec_cn< float >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
DSPLIB_STATUS DSPLIB_dotp_sqr_exec_cn< uint16_t >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
DSPLIB_STATUS DSPLIB_dotp_sqr_exec_cn< int8_t >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
DSPLIB_STATUS DSPLIB_dotp_sqr_exec_cn< int16_t >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
DSPLIB_STATUS DSPLIB_dotp_sqr_exec_cn< uint8_t >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
DSPLIB_STATUS DSPLIB_dotp_sqr_exec_cn< int32_t >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
Header file for kernel's internal use. For the kernel's interface, please see DSPLIB_dotp_sqr.
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_SUCCESS
Definition: DSPLIB_types.h:152
@ DSPLIB_ERR_NULL_POINTER
Definition: DSPLIB_types.h:157
@ DSPLIB_ERR_INVALID_TYPE
Definition: DSPLIB_types.h:155
int32_t DSPLIB_dotp_sqr_getHandleSize(DSPLIB_dotp_sqr_InitArgs *pKerInitArgs)
This is a query function to calculate the size of internal handle.
DSPLIB_STATUS DSPLIB_dotp_sqr_exec(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
This function is the main kernel compute function.
DSPLIB_STATUS DSPLIB_dotp_sqr_init(DSPLIB_kernelHandle handle, DSPLIB_bufParams1D_t *bufParamsIn, DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_dotp_sqr_InitArgs *pKerInitArgs)
This function should be called before the DSPLIB_dotp_sqr_exec function is called....
DSPLIB_STATUS DSPLIB_dotp_sqr_exec_checkParams(DSPLIB_kernelHandle handle, const void *restrict pIn1, const void *restrict pIn2, const void *restrict pOut)
This function checks the validity of the parameters passed to DSPLIB_dotp_sqr_exec function....
DSPLIB_STATUS DSPLIB_dotp_sqr_init_checkParams(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_dotp_sqr_InitArgs *pKerInitArgs)
This function checks the validity of the parameters passed to DSPLIB_dotp_sqr_init function....
A structure for a 1 dimensional buffer descriptor.
uint32_t data_type
Values are of type DSPLIB_data_type_e.
Structure containing the parameters to initialize the kernel.
uint32_t dataSize
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.
pFxnDSPLIB_dotp_sqr_exec execute
Function pointer to point to the right execution variant between DSPLIB_dotp_sqr_exec_cn and DSPLIB_d...
int32_t blockSize
Size of input buffer for different batches DSPLIB_dotp_sqr_init that will be retrieved and used by DS...