DSPLIB User Guide
DSPLIB_w_vec_cn.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2 **+--------------------------------------------------------------------------+**
3 **| **** |**
4 **| **** |**
5 **| ******o*** |**
6 **| ********_///_**** |**
7 **| ***** /_//_/ **** |**
8 **| ** ** (__/ **** |**
9 **| ********* |**
10 **| **** |**
11 **| *** |**
12 **| |**
13 **| Copyright (c) 2016 Texas Instruments Incorporated |**
14 **| ALL RIGHTS RESERVED |**
15 **| |**
16 **| Permission to use, copy, modify, or distribute this software, |**
17 **| whether in part or in whole, for any purpose is forbidden without |**
18 **| a signed licensing agreement and NDA from Texas Instruments |**
19 **| Incorporated (TI). |**
20 **| |**
21 **| TI makes no representation or warranties with respect to the |**
22 **| performance of this computer program, and specifically disclaims |**
23 **| any responsibility for any damages, special or consequential, |**
24 **| connected with the use of this program. |**
25 **| |**
26 **+--------------------------------------------------------------------------+**
27 *******************************************************************************/
28 
29 #include "DSPLIB_w_vec_priv.h"
30 
31 template <typename dataType>
33  void *restrict pIn1,
34  void *restrict pIn2,
35  void *restrict pM,
36  void *restrict pOut)
37 {
39 
40  DSPLIB_w_vec_PrivArgs *pKerPrivArgs = (DSPLIB_w_vec_PrivArgs *) handle;
41  uint32_t blockSize = pKerPrivArgs->blockSize;
42 
43 #if DSPLIB_DEBUGPRINT
44  printf("Enter DSPLIB_w_vec_exec_cn\n");
45 #endif
46 
47  dataType *pInLocal1 = (dataType *) pIn1;
48  dataType *pInLocal2 = (dataType *) pIn2;
49  dataType *pMLocal = (dataType *) pM;
50  dataType *pOutLocal = (dataType *) pOut;
51 
52 #if DSPLIB_DEBUGPRINT
53  printf("Enter pInLocal1 %p pInLocal2 %p pMLocal %p pOut %p\n", pInLocal1, pInLocal2, pMLocal, pOut);
54 #endif
55 
56  DSPLIB_w_vec_weightStyle weightFlag = pKerPrivArgs->initArgs.weightStyle;
57  dataType a, b, w, out;
58 
59  // execute natc of scalar version
60  if (weightFlag == DSPLIB_SCALAR) {
61  w = *pMLocal;
62 
63  for (int32_t counter = 0; counter < blockSize; counter++) {
64  a = *pInLocal1++;
65  b = *pInLocal2++;
66 #if DSPLIB_DEBUGPRINT
67  if (counter <= 8)
68  printf("counter %d a %f b %f w %f \n", counter, a, b, w);
69 #endif
70 
71  out = a * w + b;
72 #if DSPLIB_DEBUGPRINT
73  if (counter <= 8)
74  printf("counter %d y %f\n", counter, out);
75 #endif
76 
77  *pOutLocal++ = out;
78  }
79 
80  // // print natc out vector
81  // for (uint32_t i = 0; i < blockSize; i++) {
82  // printf("%f, ", pOutp[i]);
83  // }
84  // printf("\n");
85  }
86 
87  // execute natc of vector version
88  else {
89 
90  for (int32_t counter = 0; counter < blockSize; counter++) {
91  a = *pInLocal1++;
92  b = *pInLocal2++;
93  w = *pMLocal++;
94 #if DSPLIB_DEBUGPRINT
95  if (counter <= 8)
96  printf("counter %d a %d b %d\n", counter, a, b);
97 #endif
98 
99  out = a * w + b;
100 #if DSPLIB_DEBUGPRINT
101  if (counter <= 8)
102  printf("counter %d y %d\n", counter, out);
103 #endif
104 
105  *pOutLocal++ = out;
106  }
107  }
108 
109  return (status);
110 }
111 
112 // explicit instantiation for the different data type versions
114  void *restrict pIn1,
115  void *restrict pIn2,
116  void *restrict pM,
117  void *restrict pOut);
118 
120  void *restrict pIn1,
121  void *restrict pIn2,
122  void *restrict pM,
123  void *restrict pOut);
124 
126  void *restrict pIn1,
127  void *restrict pIn2,
128  void *restrict pM,
129  void *restrict pOut);
130 
132  void *restrict pIn1,
133  void *restrict pIn2,
134  void *restrict pM,
135  void *restrict pOut);
136 
138  void *restrict pIn1,
139  void *restrict pIn2,
140  void *restrict pM,
141  void *restrict pOut);
142 
144  void *restrict pIn1,
145  void *restrict pIn2,
146  void *restrict pM,
147  void *restrict pOut);
148 
150  void *restrict pIn1,
151  void *restrict pIn2,
152  void *restrict pM,
153  void *restrict pOut);
154 
156  void *restrict pIn1,
157  void *restrict pIn2,
158  void *restrict pM,
159  void *restrict pOut);
template DSPLIB_STATUS DSPLIB_w_vec_exec_cn< uint16_t >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pM, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_w_vec_exec_cn< int8_t >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pM, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_w_vec_exec_cn< float >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pM, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_w_vec_exec_cn< int16_t >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pM, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_w_vec_exec_cn< uint32_t >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pM, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_w_vec_exec_cn< double >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pM, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_w_vec_exec_cn< int32_t >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pM, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_w_vec_exec_cn< uint8_t >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pM, void *restrict pOut)
DSPLIB_STATUS DSPLIB_w_vec_exec_cn(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pM, void *restrict pOut)
This function is the main execution function for the natural C implementation of the kernel....
Header file for kernel's internal use. For the kernel's interface, please see DSPLIB_w_vec.
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_SUCCESS
Definition: DSPLIB_types.h:152
DSPLIB_w_vec_weightStyle
Enumeration for w_vec flag pertaining to scalar or vector input weight.
Definition: DSPLIB_w_vec.h:107
@ DSPLIB_SCALAR
Input Weight is a Scalar.
Definition: DSPLIB_w_vec.h:109
DSPLIB_w_vec_weightStyle weightStyle
Weight Input Style
Definition: DSPLIB_w_vec.h:123
Structure that is reserved for internal use by the kernel.
DSPLIB_w_vec_InitArgs initArgs
int32_t blockSize
Size of input buffer for different batches DSPLIB_w_vec_init that will be retrieved and used by DSPLI...