DSPLIB User Guide
DSPLIB_blk_move_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 Aug 2023 Author: Asheesh Bhardwaj
39  *****************************************************************************/
40 
41 /*******************************************************************************
42  *
43  * INCLUDES
44  *
45  ******************************************************************************/
46 #include "DSPLIB_blk_move_priv.h"
47 
48 template <typename dataType>
50  const DSPLIB_bufParams1D_t *bufParamsIn,
51  const DSPLIB_bufParams1D_t *bufParamsOut,
52  const DSPLIB_blk_move_InitArgs *pKerInitArgs)
53 {
54  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
55 
57  DSPLIB_blk_move_PrivArgs *pKerPrivArgs = (DSPLIB_blk_move_PrivArgs *) handle;
58  uint32_t blockSize = pKerPrivArgs->blockSize;
59  typedef typename c7x::make_full_vector<dataType>::type vec;
60  __SE_TEMPLATE_v1 se0Params;
61  __SA_TEMPLATE_v1 sa0Params;
62 
63  __SE_ELETYPE SE_ELETYPE = c7x::se_eletype<vec>::value;
64  __SE_VECLEN SE_VECLEN = c7x::se_veclen<vec>::value;
65  __SA_VECLEN SA_VECLEN = c7x::sa_veclen<vec>::value;
66 
67  uint8_t *pBlock = pKerPrivArgs->bufPblock;
68 
69  /**********************************************************************/
70  /* Prepare streaming engine 0 to fetch the input */
71  /**********************************************************************/
72  se0Params = __gen_SE_TEMPLATE_v1();
73  se0Params.ICNT0 = blockSize;
74  se0Params.ELETYPE = SE_ELETYPE;
75  se0Params.VECLEN = SE_VECLEN;
76  se0Params.DIMFMT = __SE_DIMFMT_1D;
77 
78  /**********************************************************************/
79  /* Prepare SA template to store output */
80  /**********************************************************************/
81  sa0Params = __gen_SA_TEMPLATE_v1();
82  sa0Params.ICNT0 = blockSize;
83  sa0Params.VECLEN = SA_VECLEN;
84  sa0Params.DIMFMT = __SA_DIMFMT_1D;
85 
86  *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE0_PARAM_OFFSET) = se0Params;
87  *(__SA_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SA0_PARAM_OFFSET) = sa0Params;
88 
89  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
90 
91  return status;
92 }
93 
95  const DSPLIB_bufParams1D_t *bufParamsIn,
96  const DSPLIB_bufParams1D_t *bufParamsOut,
97  const DSPLIB_blk_move_InitArgs *pKerInitArgs);
98 
100  const DSPLIB_bufParams1D_t *bufParamsIn,
101  const DSPLIB_bufParams1D_t *bufParamsOut,
102  const DSPLIB_blk_move_InitArgs *pKerInitArgs);
103 
105  const DSPLIB_bufParams1D_t *bufParamsIn,
106  const DSPLIB_bufParams1D_t *bufParamsOut,
107  const DSPLIB_blk_move_InitArgs *pKerInitArgs);
108 
110  const DSPLIB_bufParams1D_t *bufParamsIn,
111  const DSPLIB_bufParams1D_t *bufParamsOut,
112  const DSPLIB_blk_move_InitArgs *pKerInitArgs);
113 
115  const DSPLIB_bufParams1D_t *bufParamsIn,
116  const DSPLIB_bufParams1D_t *bufParamsOut,
117  const DSPLIB_blk_move_InitArgs *pKerInitArgs);
118 
120  const DSPLIB_bufParams1D_t *bufParamsIn,
121  const DSPLIB_bufParams1D_t *bufParamsOut,
122  const DSPLIB_blk_move_InitArgs *pKerInitArgs);
123 
125  const DSPLIB_bufParams1D_t *bufParamsIn,
126  const DSPLIB_bufParams1D_t *bufParamsOut,
127  const DSPLIB_blk_move_InitArgs *pKerInitArgs);
128 
130  const DSPLIB_bufParams1D_t *bufParamsIn,
131  const DSPLIB_bufParams1D_t *bufParamsOut,
132  const DSPLIB_blk_move_InitArgs *pKerInitArgs);
133 
135  const DSPLIB_bufParams1D_t *bufParamsIn,
136  const DSPLIB_bufParams1D_t *bufParamsOut,
137  const DSPLIB_blk_move_InitArgs *pKerInitArgs);
138 
140  const DSPLIB_bufParams1D_t *bufParamsIn,
141  const DSPLIB_bufParams1D_t *bufParamsOut,
142  const DSPLIB_blk_move_InitArgs *pKerInitArgs);
143 
144 template <typename dataType>
145 DSPLIB_STATUS DSPLIB_blk_move_exec_ci(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
146 {
147  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
148 
149  DSPLIB_blk_move_PrivArgs *pKerPrivArgs = (DSPLIB_blk_move_PrivArgs *) handle;
150  uint32_t blockSize = pKerPrivArgs->blockSize;
151 
152  dataType *restrict pInLocal = (dataType *) pIn;
153  dataType *restrict pOutLocal = (dataType *) pOut;
154  typedef typename c7x::make_full_vector<dataType>::type vec;
155  int32_t eleCount = c7x::element_count_of<vec>::value;
156 
157  DSPLIB_DEBUGPRINTFN(0, "pInLocal: %p pOutLocal: %p blockSize: %d eleCount: %d\n", pInLocal, pOutLocal, blockSize,
158  eleCount);
159 
160  uint8_t *pBlock = pKerPrivArgs->bufPblock;
161  __SE_TEMPLATE_v1 se0Params = *(__SE_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SE0_PARAM_OFFSET);
162  __SA_TEMPLATE_v1 sa0Params = *(__SA_TEMPLATE_v1 *) ((uint8_t *) pBlock + SE_SA0_PARAM_OFFSET);
163 
164  // Input samples
165  __SE0_OPEN(pInLocal, se0Params);
166  // Output samples
167  __SA0_OPEN(sa0Params);
168 
169  for (uint32_t counter = 0; counter < blockSize; counter += eleCount) {
170  vec out = c7x::strm_eng<0, vec>::get_adv();
171  __vpred vpred = c7x::strm_agen<0, vec>::get_vpred();
172  vec *addr = c7x::strm_agen<0, vec>::get_adv(pOutLocal);
173  __vstore_pred(vpred, addr, out);
174  }
175 
176  __SE0_CLOSE();
177  __SA0_CLOSE();
178 
179  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", DSPLIB_SUCCESS);
180 
181  return DSPLIB_SUCCESS;
182 }
183 
185 DSPLIB_blk_move_exec_ci<float>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut);
186 
188 DSPLIB_blk_move_exec_ci<double>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut);
189 
191 DSPLIB_blk_move_exec_ci<int8_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut);
192 
194 DSPLIB_blk_move_exec_ci<uint8_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut);
195 
197 DSPLIB_blk_move_exec_ci<int16_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut);
198 
200 DSPLIB_blk_move_exec_ci<uint16_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut);
201 
203 DSPLIB_blk_move_exec_ci<int32_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut);
204 
206 DSPLIB_blk_move_exec_ci<uint32_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut);
207 
209 DSPLIB_blk_move_exec_ci<int64_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut);
210 
212 DSPLIB_blk_move_exec_ci<uint64_t>(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut);
#define SE_SE0_PARAM_OFFSET
#define SE_SA0_PARAM_OFFSET
template DSPLIB_STATUS DSPLIB_blk_move_exec_ci< double >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_move_init_ci< uint8_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_move_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_blk_move_exec_ci< uint64_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_move_exec_ci< uint8_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
DSPLIB_STATUS DSPLIB_blk_move_exec_ci(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
This function is the main execution function for the C7x implementation of the kernel....
template DSPLIB_STATUS DSPLIB_blk_move_exec_ci< float >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_move_exec_ci< int16_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_move_init_ci< double >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_move_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_blk_move_exec_ci< uint32_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_move_exec_ci< uint16_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
DSPLIB_STATUS DSPLIB_blk_move_init_ci(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_move_InitArgs *pKerInitArgs)
This function is the initialization function for the C7x implementation of the kernel....
template DSPLIB_STATUS DSPLIB_blk_move_init_ci< uint32_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_move_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_blk_move_init_ci< float >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_move_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_blk_move_init_ci< int8_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_move_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_blk_move_init_ci< int16_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_move_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_blk_move_exec_ci< int8_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_move_init_ci< int64_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_move_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_blk_move_init_ci< uint16_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_move_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_blk_move_init_ci< int32_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_move_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_blk_move_exec_ci< int64_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_move_exec_ci< int32_t >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_blk_move_init_ci< uint64_t >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_blk_move_InitArgs *pKerInitArgs)
Header file for kernel's internal use. For the kernel's interface, please see DSPLIB_blk_move.
#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.
Structure that is reserved for internal use by the kernel.
uint8_t bufPblock[DSPLIB_BLK_MOVE_IXX_IXX_OXX_PBLOCK_SIZE]
Buffer to save SE & SA configuration parameters
int32_t blockSize
Size of input buffer for different batches DSPLIB_blk_move_init that will be retrieved and used by DS...
A structure for a 1 dimensional buffer descriptor.