DSPLIB User Guide
DSPLIB_minIndex.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_minIndex_priv.h"
24 
26 {
27  int32_t privBufSize = sizeof(DSPLIB_minIndex_PrivArgs);
28  return privBufSize;
29 }
30 
32  const DSPLIB_bufParams1D_t *bufParamsIn,
33  const DSPLIB_bufParams1D_t *bufParamsOut,
34  const DSPLIB_minIndex_InitArgs *pKerInitArgs)
35 {
37 
38 #if DSPLIB_DEBUGPRINT
39  printf("Enter DSPLIB_minIndex_init_checkParams\n");
40 #endif
41  if (handle == NULL) {
42  status = DSPLIB_ERR_NULL_POINTER;
43  }
44 
45  if (status == DSPLIB_SUCCESS) {
46 
47  if ((bufParamsIn->data_type != DSPLIB_FLOAT32) && (bufParamsIn->data_type != DSPLIB_UINT32) &&
48  (bufParamsIn->data_type != DSPLIB_INT32) && (bufParamsIn->data_type != DSPLIB_INT8) &&
49  (bufParamsIn->data_type != DSPLIB_UINT8) && (bufParamsIn->data_type != DSPLIB_INT16) &&
50  (bufParamsIn->data_type != DSPLIB_UINT16) && (bufParamsIn->data_type != DSPLIB_FLOAT64)) {
51  status = DSPLIB_ERR_INVALID_TYPE;
52  }
53  else {
54  /* Nothing to do here */
55  }
56  }
57 
58  return status;
59 }
60 
62 DSPLIB_minIndex_exec_checkParams(DSPLIB_kernelHandle handle, const void *restrict pIn, const void *restrict pOut)
63 {
64  DSPLIB_STATUS status;
65 
66 #if DSPLIB_DEBUGPRINT
67  printf("Enter DSPLIB_minIndex_exec_checkParams\n");
68 #endif
69  if ((pIn == NULL) || (pOut == NULL)) {
70  status = DSPLIB_ERR_NULL_POINTER;
71  }
72  else {
73  status = DSPLIB_SUCCESS;
74  }
75 
76  return status;
77 }
78 
80  DSPLIB_bufParams1D_t *bufParamsIn,
81  DSPLIB_bufParams1D_t *bufParamsOut,
82  const DSPLIB_minIndex_InitArgs *pKerInitArgs)
83 {
85  DSPLIB_minIndex_PrivArgs *pKerPrivArgs = (DSPLIB_minIndex_PrivArgs *) handle;
86 
87 #if DSPLIB_DEBUGPRINT
88  printf("DSPLIB_DEBUGPRINT Enter DSPLIB_minIndex_init\n");
89 #endif
90  pKerPrivArgs->blockSize = pKerInitArgs->dataSize;
91 
92 #if DSPLIB_DEBUGPRINT
93  printf("DSPLIB_DEBUGPRINT DSPLIB_minIndex_init pKerPrivArgs->blockSize %d bufParamsIn->data_type %d\n",
94  pKerPrivArgs->blockSize, bufParamsIn->data_type);
95 #endif
96 
97  if (pKerInitArgs->funcStyle == DSPLIB_FUNCTION_NATC) {
98  if (bufParamsIn->data_type == DSPLIB_FLOAT32) {
100  }
101  else if (bufParamsIn->data_type == DSPLIB_FLOAT64) {
103  }
104  else if (bufParamsIn->data_type == DSPLIB_INT8) {
106  }
107  else if (bufParamsIn->data_type == DSPLIB_UINT8) {
109  }
110  else if (bufParamsIn->data_type == DSPLIB_INT16) {
112  }
113  else if (bufParamsIn->data_type == DSPLIB_UINT16) {
115  }
116  else if (bufParamsIn->data_type == DSPLIB_INT32) {
118  }
119  else if (bufParamsIn->data_type == DSPLIB_UINT32) {
121  }
122  else {
123  status = DSPLIB_ERR_INVALID_TYPE;
124 #if DSPLIB_DEBUGPRINT
125  printf("DSPLIB_DEBUGPRINT CP 2 status %d\n", status);
126 #endif
127  }
128  }
129  else {
130  if (bufParamsIn->data_type == DSPLIB_FLOAT32) {
131 #if DSPLIB_DEBUGPRINT
132  printf("DSPLIB_DEBUGPRINT bufParamsIn->data_type == DSPLIB_FLOAT32\n");
133 #endif
135  status = DSPLIB_minIndex_init_ci<float>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
136  }
137  else if (bufParamsIn->data_type == DSPLIB_FLOAT64) {
139  status = DSPLIB_minIndex_init_ci<double>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
140  }
141  else if (bufParamsIn->data_type == DSPLIB_INT8) {
143  status = DSPLIB_minIndex_init_ci<int8_t>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
144  }
145  else if (bufParamsIn->data_type == DSPLIB_UINT8) {
147  status = DSPLIB_minIndex_init_ci<uint8_t>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
148  }
149  else if (bufParamsIn->data_type == DSPLIB_INT16) {
151  status = DSPLIB_minIndex_init_ci<int16_t>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
152  }
153  else if (bufParamsIn->data_type == DSPLIB_UINT16) {
155  status = DSPLIB_minIndex_init_ci<uint16_t>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
156  }
157  else if (bufParamsIn->data_type == DSPLIB_INT32) {
159  status = DSPLIB_minIndex_init_ci<int32_t>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
160  }
161  else if (bufParamsIn->data_type == DSPLIB_UINT32) {
163  status = DSPLIB_minIndex_init_ci<uint32_t>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
164  }
165  else {
166  status = DSPLIB_ERR_INVALID_TYPE;
167  }
168  }
169 #if DSPLIB_DEBUGPRINT
170  printf("DSPLIB_DEBUGPRINT CP 3 status %d\n", status);
171 #endif
172  return status;
173 }
174 
176 DSPLIB_minIndex_exec(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
177 {
178  DSPLIB_STATUS status;
179 
180 #if DSPLIB_DEBUGPRINT
181  printf("DSPLIB_DEBUGPRINT Enter DSPLIB_minIndex_exec\n");
182 #endif
183 
184  DSPLIB_minIndex_PrivArgs *pKerPrivArgs = (DSPLIB_minIndex_PrivArgs *) handle;
185 
186 #if DSPLIB_DEBUGPRINT
187  printf("DSPLIB_DEBUGPRINT pKerPrivArgs->blockSize %d\n", pKerPrivArgs->blockSize);
188 #endif
189  status = pKerPrivArgs->execute(handle, pIn, pOut);
190 
191  // printf("\noptc: %d\n", *(uint32_t *) pOut);
192  return status;
193 }
template DSPLIB_STATUS DSPLIB_minIndex_init_ci< int16_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_minIndex_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_minIndex_init_ci< uint16_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_minIndex_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_minIndex_exec_ci< float, uint32_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minIndex_init_ci< double >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_minIndex_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_minIndex_exec_ci< int16_t, uint16_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minIndex_init_ci< int32_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_minIndex_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_minIndex_exec_ci< double, uint64_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minIndex_init_ci< uint8_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_minIndex_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_minIndex_init_ci< float >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_minIndex_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_minIndex_exec_ci< uint16_t, uint16_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minIndex_init_ci< uint32_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_minIndex_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_minIndex_exec_ci< int32_t, uint32_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minIndex_exec_ci< uint32_t, uint32_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minIndex_init_ci< int8_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_minIndex_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_minIndex_exec_ci< int8_t, uint8_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minIndex_exec_ci< uint8_t, uint8_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minIndex_exec_cn< uint32_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minIndex_exec_cn< uint8_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minIndex_exec_cn< int32_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minIndex_exec_cn< int8_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minIndex_exec_cn< int16_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minIndex_exec_cn< double >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minIndex_exec_cn< float >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minIndex_exec_cn< uint16_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
Header file for kernel's internal use. For the kernel's interface, please see DSPLIB_minIndex.
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_UINT8
@ DSPLIB_UINT16
@ DSPLIB_INT32
@ DSPLIB_INT16
@ DSPLIB_FLOAT32
@ 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
DSPLIB_STATUS DSPLIB_minIndex_exec_checkParams(DSPLIB_kernelHandle handle, const void *restrict pIn, const void *restrict pOut)
This function checks the validity of the parameters passed to DSPLIB_minIndex_exec function....
DSPLIB_STATUS DSPLIB_minIndex_init(DSPLIB_kernelHandle handle, DSPLIB_bufParams1D_t *bufParamsIn, DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_minIndex_InitArgs *pKerInitArgs)
This function should be called before the DSPLIB_minIndex_exec function is called....
DSPLIB_STATUS DSPLIB_minIndex_init_checkParams(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_minIndex_InitArgs *pKerInitArgs)
This function checks the validity of the parameters passed to DSPLIB_minIndex_init function....
DSPLIB_STATUS DSPLIB_minIndex_exec(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
This function is the main kernel compute function.
int32_t DSPLIB_minIndex_getHandleSize(DSPLIB_minIndex_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.
Structure containing the parameters to initialize the kernel.
int8_t funcStyle
Variant of the function refer to DSPLIB_FUNCTION_STYLE
uint32_t dataSize
Size of input data
Structure that is reserved for internal use by the kernel.
int32_t blockSize
Size of input buffer for different batches DSPLIB_minIndex_init that will be retrieved and used by DS...
pFxnDSPLIB_minIndex_exec execute
Function pointer to point to the right execution variant between DSPLIB_minIndex_exec_cn and DSPLIB_m...