DSPLIB User Guide
DSPLIB_bexp_ci.cpp
Go to the documentation of this file.
1 /******************************************************************************/
5 /* Copyright (C) 2017-2023 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 7/13/23 Author: Asheesh Bhardwaj
39  *****************************************************************************/
40 
41 /*******************************************************************************
42  *
43  * INCLUDES
44  *
45  ******************************************************************************/
46 #include "DSPLIB_bexp_priv.h"
47 
48 /*******************************************************************************
49  *
50  * DEFINES
51  *
52  ******************************************************************************/
53 #define SE_PARAM_BASE (0x0000)
54 #define SE_SE0_PARAM_OFFSET (SE_PARAM_BASE)
55 #define SE_SE1_PARAM_OFFSET (SE_SE0_PARAM_OFFSET + SE_PARAM_SIZE)
56 #define LAST_VEC_AND_MASK_OFFSET (SE_PARAM_BASE)
57 
61 template <typename dataType>
63  const DSPLIB_bufParams1D_t *bufParamsIn,
64  const DSPLIB_bufParams1D_t *bufParamsOut,
65  const DSPLIB_bexp_InitArgs *pKerInitArgs)
66 {
67  DSPLIB_DEBUGPRINTFN(0, "%s", "Entering function\n");
69  DSPLIB_bexp_PrivArgs *pKerPrivArgs = (DSPLIB_bexp_PrivArgs *) handle;
70 
71  uint8_t *pBlock = pKerPrivArgs->bufPblock;
72  uint32_t blockSize = pKerPrivArgs->blockSize;
73 
74  typedef typename c7x::make_full_vector<dataType>::type Vec;
75  uint32_t eleCount = (int32_t) c7x::element_count_of<Vec>::value;
76  uint32_t numVecs = (blockSize + eleCount - 1) / eleCount;
78  pKerPrivArgs->isSEReadEnabled = false;
79  pKerPrivArgs->mainLoopCount = numVecs;
80 
81  dataType *pAndMask = (dataType *) ((uint8_t *) pBlock + LAST_VEC_AND_MASK_OFFSET);
82  uint32_t remElements = numVecs * eleCount - blockSize;
83  for (int32_t i = 0; i < (int32_t) eleCount; i++) {
84  pAndMask[i] = (dataType) 0;
85  }
86  for (int32_t i = 0; i < (int32_t) (eleCount - remElements); i++) {
87  pAndMask[i] = (dataType) 0xFFFFFFFFFFFFFFFFU;
88  }
89  }
90  else {
91  pKerPrivArgs->isSEReadEnabled = true;
92  pKerPrivArgs->mainLoopCount = (numVecs + 1) / 2;
93  pKerPrivArgs->se1StartAddressByteOffset = (numVecs / 2) * eleCount * sizeof(dataType);
94 
95  __SE_TEMPLATE_v1 se0Params;
96  __SE_TEMPLATE_v1 se1Params;
97  __SE_ELETYPE SE_ELETYPE;
98  __SE_VECLEN SE_VECLEN;
99 
100  SE_VECLEN = c7x::se_veclen<Vec>::value;
101  SE_ELETYPE = c7x::se_eletype<Vec>::value;
102 
103  se0Params = __gen_SE_TEMPLATE_v1();
104 
105  se0Params.ICNT0 = (numVecs - pKerPrivArgs->mainLoopCount) * eleCount;
106  se0Params.ELETYPE = SE_ELETYPE;
107  se0Params.VECLEN = SE_VECLEN;
108  se0Params.DIMFMT = __SE_DIMFMT_1D;
109 
110  se1Params = __gen_SE_TEMPLATE_v1();
111 
112  se1Params.ICNT0 = blockSize - se0Params.ICNT0;
113  se1Params.ELETYPE = SE_ELETYPE;
114  se1Params.VECLEN = SE_VECLEN;
115  se1Params.DIMFMT = __SE_DIMFMT_1D;
116 
117  *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE0_PARAM_OFFSET) = se0Params;
118  *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE1_PARAM_OFFSET) = se1Params;
119  }
120 
121  DSPLIB_DEBUGPRINTFN(0, "Exit with status: %d\n", status);
122  return status;
123 }
124 
126  const DSPLIB_bufParams1D_t *bufParamsIn,
127  const DSPLIB_bufParams1D_t *bufParamsOut,
128  const DSPLIB_bexp_InitArgs *pKerInitArgs);
129 
131  const DSPLIB_bufParams1D_t *bufParamsIn,
132  const DSPLIB_bufParams1D_t *bufParamsOut,
133  const DSPLIB_bexp_InitArgs *pKerInitArgs);
134 
136  const DSPLIB_bufParams1D_t *bufParamsIn,
137  const DSPLIB_bufParams1D_t *bufParamsOut,
138  const DSPLIB_bexp_InitArgs *pKerInitArgs);
139 
141  const DSPLIB_bufParams1D_t *bufParamsIn,
142  const DSPLIB_bufParams1D_t *bufParamsOut,
143  const DSPLIB_bexp_InitArgs *pKerInitArgs);
144 
146  const DSPLIB_bufParams1D_t *bufParamsIn,
147  const DSPLIB_bufParams1D_t *bufParamsOut,
148  const DSPLIB_bexp_InitArgs *pKerInitArgs);
149 
151  const DSPLIB_bufParams1D_t *bufParamsIn,
152  const DSPLIB_bufParams1D_t *bufParamsOut,
153  const DSPLIB_bexp_InitArgs *pKerInitArgs);
154 
156  const DSPLIB_bufParams1D_t *bufParamsIn,
157  const DSPLIB_bufParams1D_t *bufParamsOut,
158  const DSPLIB_bexp_InitArgs *pKerInitArgs);
159 
161  const DSPLIB_bufParams1D_t *bufParamsIn,
162  const DSPLIB_bufParams1D_t *bufParamsOut,
163  const DSPLIB_bexp_InitArgs *pKerInitArgs);
164 
169 template <typename UnsignedDataType>
170 inline void bexp_exec_ci_unsigned_small_inputs(void *restrict pIn,
171  void *restrict pOut,
172  uint8_t *restrict pBlock,
173  int32_t mainLoopCount)
174 {
175  DSPLIB_DEBUGPRINTFN(0, "%s", "Entering function\n");
176 
177  uint32_t *restrict pOutLocal = (uint32_t *) pOut;
178  uint32_t out_val;
179  typedef typename c7x::make_full_vector<UnsignedDataType>::type Vec;
180 
181  Vec mask = Vec(0);
182  Vec *pInLocal = (Vec *) pIn;
183  for (int32_t counter = 0; counter < (mainLoopCount - 1); counter++) {
184  Vec b = *pInLocal++;
185  mask |= b;
186  }
187  Vec lastVec = *pInLocal;
188  Vec lastVecAndMask = *(Vec *) ((uint8_t *) pBlock + LAST_VEC_AND_MASK_OFFSET);
189  lastVec &= lastVecAndMask;
190  mask |= lastVec;
191 
192  UnsignedDataType mask_final = (UnsignedDataType) c7x_horizontal_max(mask);
197  int num_bits = sizeof(UnsignedDataType) * 8;
198  int shift;
199  using SignedDataType = std::make_signed_t<UnsignedDataType>;
200  shift = __norm((SignedDataType) mask_final);
201  out_val = (uint32_t) (shift + 1);
202  if (((uint64_t) 1 << (uint64_t)(num_bits - 1)) & mask_final) {
203  out_val = 0;
204  }
205  *pOutLocal = out_val;
206 
207  DSPLIB_DEBUGPRINTFN(0, "%s","Exit function\n");
208  return;
209 }
210 template <typename SignedDataType>
211 inline void bexp_exec_ci_signed_small_inputs(void *restrict pIn,
212  void *restrict pOut,
213  uint8_t *restrict pBlock,
214  int32_t mainLoopCount)
215 {
216  DSPLIB_DEBUGPRINTFN(0, "%s", "Entering function\n");
217 
218  uint32_t *restrict pOutLocal = (uint32_t *) pOut;
219  uint32_t out_val;
220  typedef typename c7x::make_full_vector<SignedDataType>::type Vec;
221 
222  Vec mask = Vec(0);
223  Vec *pInLocal = (Vec *) pIn;
224  DSPLIB_DEBUGPRINTFN(0, "CInt: mainLoopCount = %d\n", mainLoopCount);
225  for (int32_t counter = 0; counter < (mainLoopCount - 1); counter++) {
226  Vec b = *pInLocal++;
227  mask |= __abs(b);
228  }
229  Vec lastVec = *pInLocal;
230  Vec lastVecAndMask = *(Vec *) ((uint8_t *) pBlock + LAST_VEC_AND_MASK_OFFSET);
231  mask |= __abs(lastVec & lastVecAndMask);
232 
233  using UnsignedDataType = std::make_unsigned_t<SignedDataType>;
234  typedef typename c7x::make_full_vector<UnsignedDataType>::type UVec;
235  SignedDataType mask_final = (SignedDataType) c7x_horizontal_max(c7x::reinterpret<UVec>(mask));
236  out_val = (uint32_t) __norm(mask_final);
237  *pOutLocal = out_val;
238 
239  DSPLIB_DEBUGPRINTFN(0, "%s","Exit function\n");
240  return;
241 }
242 template <typename UnsignedDataType> inline void bexp_exec_ci_unsigned(void *restrict pOut, uint32_t mainLoopCount)
243 {
244  DSPLIB_DEBUGPRINTFN(0, "%s", "Entering function\n");
245 
246  uint32_t *restrict pOutLocal = (uint32_t *) pOut;
247  uint32_t out_val;
248  typedef typename c7x::make_full_vector<UnsignedDataType>::type Vec;
249 
250  Vec mask0 = Vec(0);
251  Vec mask1 = Vec(0);
252 #pragma MUST_ITERATE(4, , 1)
253  for (uint32_t counter = 0; counter < mainLoopCount; counter++) {
254  Vec b0 = c7x::strm_eng<0, Vec>::get_adv();
255  Vec b1 = c7x::strm_eng<1, Vec>::get_adv();
256  mask0 |= b0;
257  mask1 |= b1;
258  }
259  mask0 |= mask1;
260 
261  UnsignedDataType mask_final = (UnsignedDataType) c7x_horizontal_max(mask0);
266  int num_bits = sizeof(UnsignedDataType) * 8;
267  int shift;
268  using SignedDataType = std::make_signed_t<UnsignedDataType>;
269  shift = __norm((SignedDataType) mask_final);
270  out_val = (uint32_t) (shift + 1);
271  if (((uint64_t) 1 << (uint64_t)(num_bits - 1)) & mask_final) {
272  out_val = 0;
273  }
274  *pOutLocal = out_val;
275 
276  DSPLIB_DEBUGPRINTFN(0, "%s","Exit function\n");
277  return;
278 }
279 
280 template <typename SignedDataType> inline void bexp_exec_ci_signed(void *restrict pOut, uint32_t mainLoopCount)
281 {
282  DSPLIB_DEBUGPRINTFN(0, "%s", "Entering function\n");
283 
284  uint32_t *restrict pOutLocal = (uint32_t *) pOut;
285  uint32_t out_val;
286  typedef typename c7x::make_full_vector<SignedDataType>::type Vec;
287 
288  Vec mask0 = Vec(0);
289  Vec mask1 = Vec(0);
290 #pragma MUST_ITERATE(4, , 1)
291  for (uint32_t counter = 0; counter < mainLoopCount; counter++) {
292  Vec b0 = c7x::strm_eng<0, Vec>::get_adv();
293  Vec b1 = c7x::strm_eng<1, Vec>::get_adv();
294  mask0 |= __abs(b0);
295  mask1 |= __abs(b1);
296  }
297  mask0 |= mask1;
298  using UnsignedDataType = std::make_unsigned_t<SignedDataType>;
299  typedef typename c7x::make_full_vector<UnsignedDataType>::type UVec;
300  SignedDataType mask_final = (SignedDataType) c7x_horizontal_max(c7x::reinterpret<UVec>(mask0));
301  out_val = (uint32_t) __norm(mask_final);
302  *pOutLocal = out_val;
303 
304  DSPLIB_DEBUGPRINTFN(0, "%s","Exit function\n");
305  return;
306 }
307 
312 template <>
313 DSPLIB_STATUS DSPLIB_bexp_exec_ci<int8_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
314 {
315 
316  DSPLIB_DEBUGPRINTFN(0, "%s", "Entering function\n");
317  DSPLIB_STATUS status = DSPLIB_SUCCESS;
318  DSPLIB_bexp_PrivArgs *pKerPrivArgs = (DSPLIB_bexp_PrivArgs *) handle;
319 
320  uint8_t *pBlock = pKerPrivArgs->bufPblock;
321  uint32_t mainLoopCount = pKerPrivArgs->mainLoopCount;
322  if (pKerPrivArgs->isSEReadEnabled) {
323  __SE_TEMPLATE_v1 se0Params;
324  __SE_TEMPLATE_v1 se1Params;
325  se0Params = *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE0_PARAM_OFFSET);
326  se1Params = *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE1_PARAM_OFFSET);
327  __SE0_OPEN((int8_t *) pIn, se0Params);
328  __SE1_OPEN((int8_t *) (((uint8_t *) pIn) + pKerPrivArgs->se1StartAddressByteOffset), se1Params);
329 
330  bexp_exec_ci_signed<int8_t>(pOut, mainLoopCount);
331 
332  __SE0_CLOSE();
333  __SE1_CLOSE();
334  }
335  else {
336  bexp_exec_ci_signed_small_inputs<int8_t>(pIn, pOut, pBlock, mainLoopCount);
337  }
338 
339  DSPLIB_DEBUGPRINTFN(0, "Exit with status: %d\n", status);
340  return status;
341 }
342 
343 template <>
344 DSPLIB_STATUS DSPLIB_bexp_exec_ci<uint8_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
345 {
346  DSPLIB_DEBUGPRINTFN(0, "%s", "Entering function\n");
347  DSPLIB_STATUS status = DSPLIB_SUCCESS;
348  DSPLIB_bexp_PrivArgs *pKerPrivArgs = (DSPLIB_bexp_PrivArgs *) handle;
349 
350  uint8_t *pBlock = pKerPrivArgs->bufPblock;
351  uint32_t mainLoopCount = pKerPrivArgs->mainLoopCount;
352  if (pKerPrivArgs->isSEReadEnabled) {
353  __SE_TEMPLATE_v1 se0Params;
354  __SE_TEMPLATE_v1 se1Params;
355  se0Params = *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE0_PARAM_OFFSET);
356  se1Params = *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE1_PARAM_OFFSET);
357  __SE0_OPEN((uint8_t *) pIn, se0Params);
358  __SE1_OPEN((uint8_t *) (((uint8_t *) pIn) + pKerPrivArgs->se1StartAddressByteOffset), se1Params);
359 
360  bexp_exec_ci_unsigned<uint8_t>(pOut, mainLoopCount);
361 
362  __SE0_CLOSE();
363  __SE1_CLOSE();
364  }
365  else {
366  bexp_exec_ci_unsigned_small_inputs<uint8_t>(pIn, pOut, pBlock, mainLoopCount);
367  }
368 
369  DSPLIB_DEBUGPRINTFN(0, "Exit with status: %d\n", status);
370  return status;
371 }
372 
373 template <>
374 DSPLIB_STATUS DSPLIB_bexp_exec_ci<int16_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
375 {
376  DSPLIB_DEBUGPRINTFN(0, "%s", "Entering function\n");
377  DSPLIB_STATUS status = DSPLIB_SUCCESS;
378  DSPLIB_bexp_PrivArgs *pKerPrivArgs = (DSPLIB_bexp_PrivArgs *) handle;
379 
380  uint8_t *pBlock = pKerPrivArgs->bufPblock;
381  uint32_t mainLoopCount = pKerPrivArgs->mainLoopCount;
382  if (pKerPrivArgs->isSEReadEnabled) {
383  __SE_TEMPLATE_v1 se0Params;
384  __SE_TEMPLATE_v1 se1Params;
385  se0Params = *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE0_PARAM_OFFSET);
386  se1Params = *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE1_PARAM_OFFSET);
387  __SE0_OPEN((int16_t *) pIn, se0Params);
388  __SE1_OPEN((int16_t *) (((uint8_t *) pIn) + pKerPrivArgs->se1StartAddressByteOffset), se1Params);
389 
390  bexp_exec_ci_signed<int16_t>(pOut, mainLoopCount);
391 
392  __SE0_CLOSE();
393  __SE1_CLOSE();
394  }
395  else {
396  bexp_exec_ci_signed_small_inputs<int16_t>(pIn, pOut, pBlock, mainLoopCount);
397  }
398 
399  DSPLIB_DEBUGPRINTFN(0, "Exit with status: %d\n", status);
400  return status;
401 }
402 
403 template <>
404 DSPLIB_STATUS DSPLIB_bexp_exec_ci<uint16_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
405 {
406  DSPLIB_DEBUGPRINTFN(0, "%s", "Entering function\n");
407  DSPLIB_STATUS status = DSPLIB_SUCCESS;
408  DSPLIB_bexp_PrivArgs *pKerPrivArgs = (DSPLIB_bexp_PrivArgs *) handle;
409 
410  uint8_t *pBlock = pKerPrivArgs->bufPblock;
411  uint32_t mainLoopCount = pKerPrivArgs->mainLoopCount;
412  if (pKerPrivArgs->isSEReadEnabled) {
413  __SE_TEMPLATE_v1 se0Params;
414  __SE_TEMPLATE_v1 se1Params;
415  se0Params = *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE0_PARAM_OFFSET);
416  se1Params = *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE1_PARAM_OFFSET);
417  __SE0_OPEN((uint16_t *) pIn, se0Params);
418  __SE1_OPEN((uint16_t *) (((uint8_t *) pIn) + pKerPrivArgs->se1StartAddressByteOffset), se1Params);
419 
420  bexp_exec_ci_unsigned<uint16_t>(pOut, mainLoopCount);
421 
422  __SE0_CLOSE();
423  __SE1_CLOSE();
424  }
425  else {
426  bexp_exec_ci_unsigned_small_inputs<uint16_t>(pIn, pOut, pBlock, mainLoopCount);
427  }
428 
429  DSPLIB_DEBUGPRINTFN(0, "Exit with status: %d\n", status);
430  return status;
431 }
432 
433 template <>
434 DSPLIB_STATUS DSPLIB_bexp_exec_ci<int32_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
435 {
436  DSPLIB_DEBUGPRINTFN(0, "%s", "Entering function\n");
437  DSPLIB_STATUS status = DSPLIB_SUCCESS;
438  DSPLIB_bexp_PrivArgs *pKerPrivArgs = (DSPLIB_bexp_PrivArgs *) handle;
439 
440  uint8_t *pBlock = pKerPrivArgs->bufPblock;
441  uint32_t mainLoopCount = pKerPrivArgs->mainLoopCount;
442  if (pKerPrivArgs->isSEReadEnabled) {
443  __SE_TEMPLATE_v1 se0Params;
444  __SE_TEMPLATE_v1 se1Params;
445  se0Params = *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE0_PARAM_OFFSET);
446  se1Params = *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE1_PARAM_OFFSET);
447  __SE0_OPEN((int32_t *) pIn, se0Params);
448  __SE1_OPEN((int32_t *) (((uint8_t *) pIn) + pKerPrivArgs->se1StartAddressByteOffset), se1Params);
449 
450  bexp_exec_ci_signed<int32_t>(pOut, mainLoopCount);
451 
452  __SE0_CLOSE();
453  __SE1_CLOSE();
454  }
455  else {
456  bexp_exec_ci_signed_small_inputs<int32_t>(pIn, pOut, pBlock, mainLoopCount);
457  }
458 
459  DSPLIB_DEBUGPRINTFN(0, "Exit with status: %d\n", status);
460  return status;
461 }
462 
463 template <>
464 DSPLIB_STATUS DSPLIB_bexp_exec_ci<uint32_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
465 {
466  DSPLIB_DEBUGPRINTFN(0, "%s", "Entering function\n");
467  DSPLIB_STATUS status = DSPLIB_SUCCESS;
468  DSPLIB_bexp_PrivArgs *pKerPrivArgs = (DSPLIB_bexp_PrivArgs *) handle;
469 
470  uint8_t *pBlock = pKerPrivArgs->bufPblock;
471  uint32_t mainLoopCount = pKerPrivArgs->mainLoopCount;
472  if (pKerPrivArgs->isSEReadEnabled) {
473  __SE_TEMPLATE_v1 se0Params;
474  __SE_TEMPLATE_v1 se1Params;
475  se0Params = *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE0_PARAM_OFFSET);
476  se1Params = *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE1_PARAM_OFFSET);
477  __SE0_OPEN((uint32_t *) pIn, se0Params);
478  __SE1_OPEN((uint32_t *) (((uint8_t *) pIn) + pKerPrivArgs->se1StartAddressByteOffset), se1Params);
479 
480  bexp_exec_ci_unsigned<uint32_t>(pOut, mainLoopCount);
481 
482  __SE0_CLOSE();
483  __SE1_CLOSE();
484  }
485  else {
486  bexp_exec_ci_unsigned_small_inputs<uint32_t>(pIn, pOut, pBlock, mainLoopCount);
487  }
488 
489  DSPLIB_DEBUGPRINTFN(0, "Exit with status: %d\n", status);
490  return status;
491 }
492 
493 template <>
494 DSPLIB_STATUS DSPLIB_bexp_exec_ci<int64_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
495 {
496  DSPLIB_DEBUGPRINTFN(0, "%s", "Entering function\n");
497  DSPLIB_STATUS status = DSPLIB_SUCCESS;
498  DSPLIB_bexp_PrivArgs *pKerPrivArgs = (DSPLIB_bexp_PrivArgs *) handle;
499 
500  uint8_t *pBlock = pKerPrivArgs->bufPblock;
501  uint32_t mainLoopCount = pKerPrivArgs->mainLoopCount;
502  if (pKerPrivArgs->isSEReadEnabled) {
503  __SE_TEMPLATE_v1 se0Params;
504  __SE_TEMPLATE_v1 se1Params;
505  se0Params = *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE0_PARAM_OFFSET);
506  se1Params = *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE1_PARAM_OFFSET);
507  __SE0_OPEN((int32_t *) pIn, se0Params);
508  __SE1_OPEN((int32_t *) (((uint8_t *) pIn) + pKerPrivArgs->se1StartAddressByteOffset), se1Params);
509 
510  bexp_exec_ci_signed<int64_t>(pOut, mainLoopCount);
511 
512  __SE0_CLOSE();
513  __SE1_CLOSE();
514  }
515  else {
516  bexp_exec_ci_signed_small_inputs<int64_t>(pIn, pOut, pBlock, mainLoopCount);
517  }
518 
519  DSPLIB_DEBUGPRINTFN(0, "Exit with status: %d\n", status);
520  return status;
521 }
522 
523 template <>
524 DSPLIB_STATUS DSPLIB_bexp_exec_ci<uint64_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
525 {
526  DSPLIB_DEBUGPRINTFN(0, "%s", "Entering function\n");
527  DSPLIB_STATUS status = DSPLIB_SUCCESS;
528  DSPLIB_bexp_PrivArgs *pKerPrivArgs = (DSPLIB_bexp_PrivArgs *) handle;
529 
530  uint8_t *pBlock = pKerPrivArgs->bufPblock;
531  uint32_t mainLoopCount = pKerPrivArgs->mainLoopCount;
532  if (pKerPrivArgs->isSEReadEnabled) {
533  __SE_TEMPLATE_v1 se0Params;
534  __SE_TEMPLATE_v1 se1Params;
535  se0Params = *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE0_PARAM_OFFSET);
536  se1Params = *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE1_PARAM_OFFSET);
537  __SE0_OPEN((uint32_t *) pIn, se0Params);
538  __SE1_OPEN((uint32_t *) (((uint8_t *) pIn) + pKerPrivArgs->se1StartAddressByteOffset), se1Params);
539 
540  bexp_exec_ci_unsigned<uint64_t>(pOut, mainLoopCount);
541 
542  __SE0_CLOSE();
543  __SE1_CLOSE();
544  }
545  else {
546  bexp_exec_ci_unsigned_small_inputs<uint64_t>(pIn, pOut, pBlock, mainLoopCount);
547  }
548 
549  DSPLIB_DEBUGPRINTFN(0, "Exit with status: %d\n", status);
550  return status;
551 }
template DSPLIB_STATUS DSPLIB_bexp_init_ci< uint32_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_bexp_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_bexp_init_ci< int16_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_bexp_InitArgs *pKerInitArgs)
DSPLIB_STATUS DSPLIB_bexp_init_ci(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_bexp_InitArgs *pKerInitArgs)
This function is the initialization function for the C7x implementation of the kernel....
void bexp_exec_ci_unsigned(void *restrict pOut, uint32_t mainLoopCount)
void bexp_exec_ci_signed_small_inputs(void *restrict pIn, void *restrict pOut, uint8_t *restrict pBlock, int32_t mainLoopCount)
#define SE_SE0_PARAM_OFFSET
DSPLIB_STATUS DSPLIB_bexp_exec_ci< uint64_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
DSPLIB_STATUS DSPLIB_bexp_exec_ci< uint16_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
DSPLIB_STATUS DSPLIB_bexp_exec_ci< int16_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_bexp_init_ci< uint16_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_bexp_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_bexp_init_ci< uint64_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_bexp_InitArgs *pKerInitArgs)
DSPLIB_STATUS DSPLIB_bexp_exec_ci< int8_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
#define SE_SE1_PARAM_OFFSET
template DSPLIB_STATUS DSPLIB_bexp_init_ci< int32_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_bexp_InitArgs *pKerInitArgs)
void bexp_exec_ci_signed(void *restrict pOut, uint32_t mainLoopCount)
template DSPLIB_STATUS DSPLIB_bexp_init_ci< int8_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_bexp_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_bexp_init_ci< uint8_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_bexp_InitArgs *pKerInitArgs)
void bexp_exec_ci_unsigned_small_inputs(void *restrict pIn, void *restrict pOut, uint8_t *restrict pBlock, int32_t mainLoopCount)
DSPLIB_STATUS DSPLIB_bexp_exec_ci< uint8_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
DSPLIB_STATUS DSPLIB_bexp_exec_ci< int64_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
DSPLIB_STATUS DSPLIB_bexp_exec_ci< uint32_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_bexp_init_ci< int64_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_bexp_InitArgs *pKerInitArgs)
DSPLIB_STATUS DSPLIB_bexp_exec_ci< int32_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
#define LAST_VEC_AND_MASK_OFFSET
Header file for kernel's internal use. For the kernel's interface, please see DSPLIB_bexp.
#define DSPLIB_BEXP_IXX_IXX_OXX_MIN_VECS_TO_ENABLE_SE_READS
Macro to define the minimum number of vector lengths that the input data should occupy before SE is u...
#define DSPLIB_DEBUGPRINTFN(N, fmt,...)
Definition: DSPLIB_types.h:83
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
Structure containing the parameters to initialize the kernel.
Definition: DSPLIB_bexp.h:112
Structure that is reserved for internal use by the kernel.
uint32_t se1StartAddressByteOffset
The offset in bytes of SE1 start address with respect to start address of the input data....
bool isSEReadEnabled
Flag indicating if SE reads are enabled, set by DSPLIB_bexp_init that will be retrieved and used by D...
uint32_t blockSize
Size of input buffer for different batches DSPLIB_bexp_init that will be retrieved and used by DSPLIB...
uint32_t mainLoopCount
Number of times to loop over data with isSEReadEnabled == true will be ceil_division(number of native...
uint8_t bufPblock[DSPLIB_BEXP_IXX_IXX_OXX_PBLOCK_SIZE]
A structure for a 1 dimensional buffer descriptor.