DSPLIB User Guide
DSPLIB_maxIndex_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_maxIndex_priv.h"
30 
31 template <typename dataType>
32 DSPLIB_STATUS DSPLIB_maxIndex_exec_cn(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
33 {
35 
36  DSPLIB_maxIndex_PrivArgs *pKerPrivArgs = (DSPLIB_maxIndex_PrivArgs *) handle;
37  int32_t blockSize = pKerPrivArgs->blockSize;
38 
39 #if DSPLIB_DEBUGPRINT
40  printf("Enter DSPLIB_maxIndex_exec_cn\n");
41 #endif
42 
43  dataType *pInLocal = (dataType *) pIn;
44  uint32_t *pOutLocal = (uint32_t *) pOut;
45 
46 #if DSPLIB_DEBUGPRINT
47  printf("Enter pInLocal %p pOut %p\n", pInLocal, pOut);
48 #endif
49 
50  dataType a, currMax;
51  uint32_t out;
52 
53  out = 0;
54  currMax = pInLocal[0];
55 
56  for (int32_t counter = 0; counter < blockSize; counter++) {
57  a = *pInLocal++;
58 
59  out = (a > currMax) ? (uint32_t) counter : out;
60  currMax = (a > currMax) ? a : currMax;
61 
62 #if DSPLIB_DEBUGPRINT
63  if (counter <= 8)
64  printf("counter %d y %d\n", counter, out);
65 #endif
66  }
67 
68  *pOutLocal = out;
69 
70  // printf("\n natc: %d\n", out);
71  return (status);
72 }
73 
74 // explicit instantiation for the different data type versions
75 template DSPLIB_STATUS
76 DSPLIB_maxIndex_exec_cn<float>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut);
77 
78 template DSPLIB_STATUS
79 DSPLIB_maxIndex_exec_cn<double>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut);
80 template DSPLIB_STATUS
81 DSPLIB_maxIndex_exec_cn<int8_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut);
82 template DSPLIB_STATUS
83 DSPLIB_maxIndex_exec_cn<uint8_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut);
84 template DSPLIB_STATUS
85 DSPLIB_maxIndex_exec_cn<int16_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut);
86 template DSPLIB_STATUS
87 DSPLIB_maxIndex_exec_cn<uint16_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut);
88 template DSPLIB_STATUS
89 DSPLIB_maxIndex_exec_cn<int32_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut);
90 template DSPLIB_STATUS
91 DSPLIB_maxIndex_exec_cn<uint32_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut);
DSPLIB_STATUS DSPLIB_maxIndex_exec_cn(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
This function is the main execution function for the natural C implementation of the kernel....
template DSPLIB_STATUS DSPLIB_maxIndex_exec_cn< uint8_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_maxIndex_exec_cn< float >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_maxIndex_exec_cn< uint32_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_maxIndex_exec_cn< int16_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_maxIndex_exec_cn< int32_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_maxIndex_exec_cn< uint16_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_maxIndex_exec_cn< int8_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_maxIndex_exec_cn< double >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
Header file for kernel's internal use. For the kernel's interface, please see DSPLIB_maxIndex.
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 that is reserved for internal use by the kernel.
int32_t blockSize
Size of input buffer for different batches DSPLIB_maxIndex_init that will be retrieved and used by DS...