DSPLIB User Guide
DSPLIB_minEvery_ci.cpp
Go to the documentation of this file.
1 /******************************************************************************/
5 /* Copyright (C) 2017 Texas Instruments Incorporated - https://www.ti.com/
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  *
14  * Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the
17  * distribution.
18  *
19  * Neither the name of Texas Instruments Incorporated nor the names of
20  * its contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  *
35  ******************************************************************************/
36 
37 /******************************************************************************
38  * Version 1.0 Date 10/2/22 Author: Asheesh Bhardwaj
39  *****************************************************************************/
40 
41 /*******************************************************************************
42  *
43  * INCLUDES
44  *
45  ******************************************************************************/
46 
47 #include "../common/c71/DSPLIB_inlines.h"
48 #include "DSPLIB_minEvery_priv.h"
49 #include <float.h>
50 
51 template <typename dataType>
53  const DSPLIB_bufParams1D_t *bufParamsIn,
54  const DSPLIB_bufParams1D_t *bufParamsOut,
55  const DSPLIB_minEvery_InitArgs *pKerInitArgs)
56 {
58  __SE_TEMPLATE_v1 se0Params;
59  __SA_TEMPLATE_v1 sa0Params;
60 
61  __SE_ELETYPE SE_ELETYPE;
62  __SE_VECLEN SE_VECLEN;
63  __SA_VECLEN SA_VECLEN;
64 
65  DSPLIB_minEvery_PrivArgs *pKerPrivArgs = (DSPLIB_minEvery_PrivArgs *) handle;
66 
67  uint8_t *pBlock = pKerPrivArgs->bufPblock;
68  uint32_t blockSize = pKerPrivArgs->blockSize;
69 
70  typedef typename c7x::make_full_vector<dataType>::type vec;
71  SE_VECLEN = c7x::se_veclen<vec>::value;
72  SA_VECLEN = c7x::sa_veclen<vec>::value;
73  SE_ELETYPE = c7x::se_eletype<vec>::value;
74 
75 #if DSPLIB_DEBUGPRINT
76  int32_t eleCount = c7x::element_count_of<vec>::value;
77  printf("Enter eleCount %d\n", eleCount);
78 #endif
79 
80  /**********************************************************************/
81  /* Prepare streaming engine 1 to fetch the input */
82  /**********************************************************************/
83  se0Params = __gen_SE_TEMPLATE_v1();
84 
85  se0Params.ICNT0 = blockSize;
86  se0Params.ELETYPE = SE_ELETYPE;
87  se0Params.VECLEN = SE_VECLEN;
88  se0Params.DIMFMT = __SE_DIMFMT_1D;
89 
90  /**********************************************************************/
91  /* Prepare SA template to store output */
92  /**********************************************************************/
93  sa0Params = __gen_SA_TEMPLATE_v1();
94 
95  sa0Params.ICNT0 = blockSize;
96  sa0Params.DIM1 = blockSize;
97  sa0Params.VECLEN = SA_VECLEN;
98  sa0Params.DIMFMT = __SA_DIMFMT_1D;
99 
100  *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE0_PARAM_OFFSET) = se0Params;
101  *(__SA_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SA0_PARAM_OFFSET) = sa0Params;
102 
103  return status;
104 }
105 
107  const DSPLIB_bufParams1D_t *bufParamsIn,
108  const DSPLIB_bufParams1D_t *bufParamsOut,
109  const DSPLIB_minEvery_InitArgs *pKerInitArgs);
110 
112  const DSPLIB_bufParams1D_t *bufParamsIn,
113  const DSPLIB_bufParams1D_t *bufParamsOut,
114  const DSPLIB_minEvery_InitArgs *pKerInitArgs);
115 
117  const DSPLIB_bufParams1D_t *bufParamsIn,
118  const DSPLIB_bufParams1D_t *bufParamsOut,
119  const DSPLIB_minEvery_InitArgs *pKerInitArgs);
120 
122  const DSPLIB_bufParams1D_t *bufParamsIn,
123  const DSPLIB_bufParams1D_t *bufParamsOut,
124  const DSPLIB_minEvery_InitArgs *pKerInitArgs);
125 
127  const DSPLIB_bufParams1D_t *bufParamsIn,
128  const DSPLIB_bufParams1D_t *bufParamsOut,
129  const DSPLIB_minEvery_InitArgs *pKerInitArgs);
130 
132  const DSPLIB_bufParams1D_t *bufParamsIn,
133  const DSPLIB_bufParams1D_t *bufParamsOut,
134  const DSPLIB_minEvery_InitArgs *pKerInitArgs);
135 
137  const DSPLIB_bufParams1D_t *bufParamsIn,
138  const DSPLIB_bufParams1D_t *bufParamsOut,
139  const DSPLIB_minEvery_InitArgs *pKerInitArgs);
140 
142  const DSPLIB_bufParams1D_t *bufParamsIn,
143  const DSPLIB_bufParams1D_t *bufParamsOut,
144  const DSPLIB_minEvery_InitArgs *pKerInitArgs);
145 
146 template <typename dataType, int32_t dataIn>
148 DSPLIB_minEvery_exec_ci(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
149 {
150  DSPLIB_minEvery_PrivArgs *pKerPrivArgs = (DSPLIB_minEvery_PrivArgs *) handle;
151  uint32_t blockSize = pKerPrivArgs->blockSize;
152 
153  __SE_TEMPLATE_v1 se0Params;
154  __SA_TEMPLATE_v1 sa0Params;
155 
156  dataType *restrict pInLocal1 = (dataType *) pIn1;
157  dataType *restrict pInLocal2 = (dataType *) pIn2;
158  dataType *restrict pOutLocal = (dataType *) pOut;
159 
160 #if DSPLIB_DEBUGPRINT
161  printf("Enter DSPLIB_minEvery_exec_ci\n");
162 #endif
163 
164  typedef typename c7x::make_full_vector<dataType>::type vec;
165  int32_t eleCount = c7x::element_count_of<vec>::value;
166 
167 #if DSPLIB_DEBUGPRINT
168  printf("Enter eleCount %d\n", eleCount);
169 #endif
170 
171  uint8_t *pBlock = pKerPrivArgs->bufPblock;
172  se0Params = *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE0_PARAM_OFFSET);
173  sa0Params = *(__SA_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SA0_PARAM_OFFSET);
174 
175  // Input samples
176  __SE0_OPEN(pInLocal1, se0Params);
177  __SE1_OPEN(pInLocal2, se0Params);
178 
179  // Output samples
180  __SA0_OPEN(sa0Params);
181 
182 #if DSPLIB_DEBUGPRINT
183  printf("DSPLIB_DEBUGPRINT blockSize %d\n", blockSize);
184 #endif
185 
186  vec out;
187  __vpred cmp_lt;
188  for (int32_t counter = 0; counter < (int32_t)blockSize; counter += eleCount) {
189  vec a = c7x::strm_eng<0, vec>::get_adv();
190  vec b = c7x::strm_eng<1, vec>::get_adv();
191 
192  // cmp_lt = __cmp_le_pred(a, b);
193  // out = __select(cmp_lt, a, b);
194 
195  out = __min(a, b);
196 
197  __vpred tmp = c7x::strm_agen<0, vec>::get_vpred();
198  vec *VB1 = c7x::strm_agen<0, vec>::get_adv(pOutLocal);
199 
200  __vstore_pred(tmp, VB1, out);
201 #if DSPLIB_DEBUGPRINT
202 // if (counter == 0) {
203 // DSPLIB_debugPrintVector(a);
204 // DSPLIB_debugPrintVector(b);
205 // DSPLIB_debugPrintVector(out);
206 // }
207 #endif
208  }
209  __SE0_CLOSE();
210  __SE1_CLOSE();
211  __SA0_CLOSE();
212 
213  return DSPLIB_SUCCESS;
214 }
215 
217  void *restrict pIn1,
218  void *restrict pIn2,
219  void *restrict pOut);
220 
222  void *restrict pIn1,
223  void *restrict pIn2,
224  void *restrict pOut);
225 
227  void *restrict pIn1,
228  void *restrict pIn2,
229  void *restrict pOut);
230 
232  void *restrict pIn1,
233  void *restrict pIn2,
234  void *restrict pOut);
235 
237  void *restrict pIn1,
238  void *restrict pIn2,
239  void *restrict pOut);
240 
242  void *restrict pIn1,
243  void *restrict pIn2,
244  void *restrict pOut);
245 
247  void *restrict pIn1,
248  void *restrict pIn2,
249  void *restrict pOut);
250 
252  void *restrict pIn1,
253  void *restrict pIn2,
254  void *restrict pOut);
#define SE_SE0_PARAM_OFFSET
#define SE_SA0_PARAM_OFFSET
template DSPLIB_STATUS DSPLIB_minEvery_exec_ci< uint8_t, DSPLIB_UINT8 >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minEvery_exec_ci< int16_t, DSPLIB_INT16 >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minEvery_init_ci< uint8_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_minEvery_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_minEvery_exec_ci< uint16_t, DSPLIB_UINT16 >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minEvery_exec_ci< int32_t, DSPLIB_INT32 >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minEvery_exec_ci< uint32_t, DSPLIB_UINT32 >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minEvery_init_ci< double >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_minEvery_InitArgs *pKerInitArgs)
DSPLIB_STATUS DSPLIB_minEvery_init_ci(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_minEvery_InitArgs *pKerInitArgs)
This function is the initialization function for the C7x implementation of the kernel....
template DSPLIB_STATUS DSPLIB_minEvery_init_ci< int32_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_minEvery_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_minEvery_init_ci< float >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_minEvery_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_minEvery_init_ci< uint32_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_minEvery_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_minEvery_init_ci< int8_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_minEvery_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_minEvery_exec_ci< float, DSPLIB_FLOAT32 >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
DSPLIB_STATUS DSPLIB_minEvery_exec_ci(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
This function is the main execution function for the C7x implementation of the kernel....
template DSPLIB_STATUS DSPLIB_minEvery_exec_ci< int8_t, DSPLIB_INT8 >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minEvery_exec_ci< double, DSPLIB_FLOAT64 >(DSPLIB_kernelHandle handle, void *restrict pIn1, void *restrict pIn2, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_minEvery_init_ci< uint16_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_minEvery_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_minEvery_init_ci< int16_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_minEvery_InitArgs *pKerInitArgs)
Header file for kernel's internal use. For the kernel's interface, please see DSPLIB_minEvery.
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
A structure for a 1 dimensional buffer descriptor.
Structure containing the parameters to initialize the kernel.
Structure that is reserved for internal use by the kernel.
int32_t blockSize
Size of input buffer for different batches DSPLIB_minEvery_init that will be retrieved and used by DS...
uint8_t bufPblock[DSPLIB_MINEVERY_IXX_IXX_OXX_PBLOCK_SIZE]