DSPLIB User Guide
DSPLIB_negate.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_negate_priv.h"
24 
26 {
27  int32_t privBufSize = sizeof(DSPLIB_negate_PrivArgs);
28  return privBufSize;
29 }
30 
33  const DSPLIB_bufParams1D_t *bufParamsIn,
34  const DSPLIB_bufParams1D_t *bufParamsOut,
35  const DSPLIB_negate_InitArgs *pKerInitArgs)
36 {
38 
39 #if DSPLIB_DEBUGPRINT
40  printf("Enter DSPLIB_negate_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_INT32) && (bufParamsIn->data_type != DSPLIB_INT16) &&
48  (bufParamsIn->data_type != DSPLIB_INT8)) {
49  status = DSPLIB_ERR_INVALID_TYPE;
50  }
51  else if (bufParamsIn->data_type != bufParamsOut->data_type) {
52  status = DSPLIB_ERR_INVALID_TYPE;
53  }
54  else {
55  /* Nothing to do here */
56  }
57  }
58  else {
59  /* Nothing to do here */
60  }
61 
62  return status;
63 }
64 
66 DSPLIB_negate_exec_checkParams(DSPLIB_kernelHandle handle, const void *restrict pIn, const void *restrict pOut)
67 {
68  DSPLIB_STATUS status;
69 
70 #if DSPLIB_DEBUGPRINT
71  printf("Enter DSPLIB_negate_exec_checkParams\n");
72 #endif
73  if ((pIn == NULL) || (pOut == NULL)) {
74  status = DSPLIB_ERR_NULL_POINTER;
75  }
76  else {
77  status = DSPLIB_SUCCESS;
78  }
79 
80  return status;
81 }
82 
84  DSPLIB_bufParams1D_t *bufParamsIn,
85  DSPLIB_bufParams1D_t *bufParamsOut,
86  const DSPLIB_negate_InitArgs *pKerInitArgs)
87 {
89  DSPLIB_negate_PrivArgs *pKerPrivArgs = (DSPLIB_negate_PrivArgs *) handle;
90 
91 #if DSPLIB_DEBUGPRINT
92  printf("DSPLIB_DEBUGPRINT Enter DSPLIB_negate_init\n");
93 #endif
94  pKerPrivArgs->blockSize = pKerInitArgs->dataSize;
95 
96 #if DSPLIB_DEBUGPRINT
97  printf("DSPLIB_DEBUGPRINT DSPLIB_negate_init pKerPrivArgs->blockSize %d "
98  "bufParamsIn->data_type %d\n",
99  pKerPrivArgs->blockSize, bufParamsIn->data_type);
100 #endif
101 
102  if (pKerInitArgs->funcStyle == DSPLIB_FUNCTION_NATC) {
103  if (bufParamsIn->data_type == DSPLIB_INT32) {
105  }
106  else if (bufParamsIn->data_type == DSPLIB_INT16) {
108  }
109  else if (bufParamsIn->data_type == DSPLIB_INT8) {
111  }
112  else {
113  status = DSPLIB_ERR_INVALID_TYPE;
114 #if DSPLIB_DEBUGPRINT
115  printf("DSPLIB_DEBUGPRINT CP 2 status %d\n", status);
116 #endif
117  }
118  }
119  else {
120  if (bufParamsIn->data_type == DSPLIB_INT32) {
121  status = DSPLIB_negate_init_ci<int32_t>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
123  }
124  else if (bufParamsIn->data_type == DSPLIB_INT16) {
125  status = DSPLIB_negate_init_ci<int16_t>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
126 
128  }
129  else if (bufParamsIn->data_type == DSPLIB_INT8) {
130  status = DSPLIB_negate_init_ci<int8_t>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
131 
133  }
134  else {
135  status = DSPLIB_ERR_INVALID_TYPE;
136 #if DSPLIB_DEBUGPRINT
137  printf("DSPLIB_DEBUGPRINT CP 2 status %d\n", status);
138 #endif
139  }
140  }
141 #if DSPLIB_DEBUGPRINT
142  printf("DSPLIB_DEBUGPRINT CP 3 status %d\n", status);
143 #endif
144  return status;
145 }
146 
147 DSPLIB_STATUS DSPLIB_negate_exec(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
148 {
149  DSPLIB_STATUS status;
150 
151 #if DSPLIB_DEBUGPRINT
152  printf("DSPLIB_DEBUGPRINT Enter DSPLIB_negate_exec\n");
153 #endif
154 
155  DSPLIB_negate_PrivArgs *pKerPrivArgs = (DSPLIB_negate_PrivArgs *) handle;
156 
157 #if DSPLIB_DEBUGPRINT
158  printf("DSPLIB_DEBUGPRINT pKerPrivArgs->blockSize %d\n", pKerPrivArgs->blockSize);
159 #endif
160  status = pKerPrivArgs->execute(handle, pIn, pOut);
161 
162  return status;
163 }
template DSPLIB_STATUS DSPLIB_negate_exec_ci< int16_t, DSPLIB_INT16 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_negate_exec_ci< int32_t, DSPLIB_INT32 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_negate_exec_ci< int8_t, DSPLIB_INT8 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_negate_init_ci< int32_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_negate_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_negate_init_ci< int8_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_negate_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_negate_init_ci< int16_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_negate_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_negate_exec_cn< int8_t, DSPLIB_INT8 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_negate_exec_cn< int16_t, DSPLIB_INT16 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_negate_exec_cn< int32_t, DSPLIB_INT32 >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
Header file for kernel's internal use. For the kernel's interface, please see DSPLIB_negate.
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_INT32
@ DSPLIB_INT16
@ 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_negate_init(DSPLIB_kernelHandle handle, DSPLIB_bufParams1D_t *bufParamsIn, DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_negate_InitArgs *pKerInitArgs)
This function should be called before the DSPLIB_negate_exec function is called. This function takes ...
int32_t DSPLIB_negate_getHandleSize(DSPLIB_negate_InitArgs *pKerInitArgs)
This is a query function to calculate the size of internal handle.
DSPLIB_STATUS DSPLIB_negate_init_checkParams(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_negate_InitArgs *pKerInitArgs)
This function checks the validity of the parameters passed to DSPLIB_negate_init function....
DSPLIB_STATUS DSPLIB_negate_exec(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
This function is the main kernel compute function.
DSPLIB_STATUS DSPLIB_negate_exec_checkParams(DSPLIB_kernelHandle handle, const void *restrict pIn, const void *restrict pOut)
This function checks the validity of the parameters passed to DSPLIB_negate_exec 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.
int32_t blockSize
Size of input buffer for different batches DSPLIB_negate_init that will be retrieved and used by DSPL...
pFxnDSPLIB_negate_exec execute
Function pointer to point to the right execution variant between DSPLIB_negate_exec_cn and DSPLIB_neg...