DSPLIB User Guide
DSPLIB_fir_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_fir_priv.h"
30 
32  DSPLIB_bufParams2D_t *bufParamsIn,
33  DSPLIB_bufParams2D_t *bufParamsFilter,
34  DSPLIB_bufParams2D_t *bufParamsOut,
35  DSPLIB_fir_InitArgs *pKerInitArgs)
36 {
38  return status;
39 }
40 
41 template <typename dataType, typename accumulateType>
43 DSPLIB_fir_exec_cn(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pFilter, void *restrict pOut)
44 {
46 
47 #if DSPLIB_DEBUGPRINT
48  printf("Enter DSPLIB_fir_exec_cn\n");
49 #endif
50 
51  int32_t j, k, l;
52  dataType outProd, outTemp;
53  dataType *pInLocal = (dataType *) pIn;
54  dataType *pFilterLocal = (dataType *) pFilter;
55  dataType *pOutLocal = (dataType *) pOut;
56  DSPLIB_fir_PrivArgs *pKerPrivArgs = (DSPLIB_fir_PrivArgs *) handle;
57  int32_t batchSize = pKerPrivArgs->initArgs.batchSize;
58  int32_t filterSize = pKerPrivArgs->initArgs.filterSize;
59  int32_t outputSize = pKerPrivArgs->outputSize;
60  uint32_t enableNchCoefs = pKerPrivArgs->initArgs.enableNchCoefs;
61 
62  uint32_t dataBufferInPitch = pKerPrivArgs->dataBufferInPitch;
63  uint32_t dataBufferOutPitch = pKerPrivArgs->dataBufferOutPitch;
64 
65 #if DSPLIB_DEBUGPRINT
66  printf("Enter pFilter %p\n", pFilterLocal);
67 #endif
68  int32_t dataOffset = 0;
69  int32_t dataOffsetOut = 0;
70 
71  uint32_t filterPitch = (enableNchCoefs == 0) ? 0 : pKerPrivArgs->filterPitch;
72 
73  for (l = 0; l < batchSize; l++) {
74  for (j = 0; j < outputSize; j++) {
75  outTemp = 0;
76  dataOffset = l * dataBufferInPitch + j;
77  dataOffsetOut = l * dataBufferOutPitch + j;
78  int32_t filterCtr = 0;
79  for (k = filterSize - 1; k > -1; k--) {
80  outProd = pInLocal[dataOffset + filterCtr] * pFilterLocal[k];
81  outTemp = outTemp + outProd;
82 #if DSPLIB_DEBUGPRINT
83 // printf("DSPLIB_DEBUGPRINT l %d dataOffset %d filterCtr %d
84 // dataBufferInPitch %d dataBufferOutPitch %d\n", l, dataOffset,
85 // filterCtr, dataBufferInPitch, dataBufferOutPitch);
86 // printf("DSPLIB_DEBUGPRINT pInLocal: %f, pFilterLocal[k]: %f,
87 // outputSize: %d outTemp: %f outProd %f j %d k %d\n",
88 // pInLocal[dataOffset + filterCtr], pFilterLocal[k], outputSize,
89 // outTemp, outProd, j, k);
90 #endif
91  filterCtr++;
92  }
93  pOutLocal[dataOffsetOut] = outTemp;
94 #if DSPLIB_DEBUGPRINT
95 // printf("DSPLIB_DEBUGPRINT outTemp: %f, filterSize: %d, outputSize: %d
96 // batchSize: %d j %d k %d\n", outTemp, filterSize, outputSize, batchSize,
97 // j, k);
98 #endif
99  }
100 
101  pFilterLocal += filterPitch;
102  }
103 
104  return (status);
105 }
106 
107 // explicit instantiation for the different data type versions
109  void *restrict pIn,
110  void *restrict pFilter,
111  void *restrict pOut);
112 
114  void *restrict pIn,
115  void *restrict pFilter,
116  void *restrict pOut);
117 
119  void *restrict pIn,
120  void *restrict pFilter,
121  void *restrict pOut);
123  void *restrict pIn,
124  void *restrict pFilter,
125  void *restrict pOut);
template DSPLIB_STATUS DSPLIB_fir_exec_cn< int16_t, int64_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pFilter, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_fir_exec_cn< int8_t, int32_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pFilter, void *restrict pOut)
DSPLIB_STATUS DSPLIB_fir_exec_cn(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pFilter, void *restrict pOut)
This function is the main execution function for the natural C implementation of the kernel....
DSPLIB_STATUS DSPLIB_fir_init_cn(DSPLIB_kernelHandle handle, DSPLIB_bufParams2D_t *bufParamsIn, DSPLIB_bufParams2D_t *bufParamsFilter, DSPLIB_bufParams2D_t *bufParamsOut, DSPLIB_fir_InitArgs *pKerInitArgs)
This function is the initialization function for the natural C implementation of the kernel....
template DSPLIB_STATUS DSPLIB_fir_exec_cn< int32_t, DSPLIB_int128_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pFilter, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_fir_exec_cn< float, int32_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pFilter, void *restrict pOut)
Header file for kernel's internal use. For the kernel's interface, please see DSPLIB_fir.
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 2 dimensional buffer descriptor.
Structure containing the parameters to initialize the kernel.
Definition: DSPLIB_fir.h:105
uint32_t enableNchCoefs
Flag to enable per channel filter coefficients: 0 => same coefficients for all channels in batch 1 =>...
Definition: DSPLIB_fir.h:125
int32_t batchSize
Size of batch in terms of number of channels of input data
Definition: DSPLIB_fir.h:111
int32_t filterSize
Size of filter
Definition: DSPLIB_fir.h:113
Structure that is reserved for internal use by the kernel.
uint32_t dataBufferOutPitch
Pitch of output buffer for different batches DSPLIB_fir_init that will be retrieved and used by DSPLI...
uint32_t filterPitch
Pitch of filter coefficient buffer for different batches DSPLIB_fir_init that will be retrieved and u...
uint32_t dataBufferInPitch
Pitch of input buffer for different batches DSPLIB_fir_init that will be retrieved and used by DSPLIB...
DSPLIB_fir_InitArgs initArgs
Structure holding initialization parameters