45 #include "../common/c71/DSPLIB_inlines.h"
55 typedef typename c7x::make_full_vector<float>::type vecIn;
56 int32_t eleCount = c7x::element_count_of<vecIn>::value;
57 typedef typename c7x::short_vec vecOut;
58 int32_t loopCount = blockSize / (eleCount * 2);
60 __SE_TEMPLATE_v1 se0Params = __gen_SE_TEMPLATE_v1();
61 __SA_TEMPLATE_v1 sa0Params = __gen_SA_TEMPLATE_v1();
63 __SE_ELETYPE SE_ELETYPE = c7x::se_eletype<vecIn>::value;
64 __SE_VECLEN SE_VECLEN = c7x::se_veclen<vecIn>::value;
65 __SA_VECLEN SA_VECLEN = c7x::sa_veclen<vecOut>::value;
68 se0Params.ICNT0 = eleCount;
69 se0Params.ICNT1 = loopCount;
70 se0Params.DIM1 = eleCount * 2;
71 se0Params.DIMFMT = __SE_DIMFMT_2D;
72 se0Params.ELETYPE = SE_ELETYPE;
73 se0Params.VECLEN = SE_VECLEN;
76 sa0Params.ICNT0 = blockSize;
77 sa0Params.VECLEN = SA_VECLEN;
78 sa0Params.DIMFMT = __SA_DIMFMT_1D;
87 typedef typename c7x::make_full_vector<double>::type vecIn;
88 int32_t eleCount = c7x::element_count_of<vecIn>::value;
89 typedef typename c7x::short_hvec vecOut;
90 int32_t loopCount = blockSize / (eleCount * 2);
92 __SE_TEMPLATE_v1 se0Params = __gen_SE_TEMPLATE_v1();
93 __SA_TEMPLATE_v1 sa0Params = __gen_SA_TEMPLATE_v1();
95 __SE_ELETYPE SE_ELETYPE = c7x::se_eletype<vecIn>::value;
96 __SE_VECLEN SE_VECLEN = c7x::se_veclen<vecIn>::value;
97 __SA_VECLEN SA_VECLEN = c7x::sa_veclen<vecOut>::value;
100 se0Params.ICNT0 = eleCount;
101 se0Params.ICNT1 = loopCount;
102 se0Params.DIM1 = eleCount * 2;
103 se0Params.DIMFMT = __SE_DIMFMT_2D;
104 se0Params.ELETYPE = SE_ELETYPE;
105 se0Params.VECLEN = SE_VECLEN;
108 sa0Params.ICNT0 = blockSize;
109 sa0Params.VECLEN = SA_VECLEN;
110 sa0Params.DIMFMT = __SA_DIMFMT_1D;
116 template <
typename dataTypeIn>
126 uint32_t blockSize = pKerPrivArgs->
blockSize;
127 uint8_t *pBlock = pKerPrivArgs->
bufPblock;
129 typedef typename c7x::make_full_vector<dataTypeIn>::type vecIn;
130 int32_t eleCount = c7x::element_count_of<vecIn>::value;
131 int32_t loopCount = blockSize / (eleCount * 2);
133 if (loopCount == 0) {
138 fltoq15_stream_init<dataTypeIn>(pBlock, blockSize);
158 template <
typename dataTypeIn>
161 __SE_TEMPLATE_v1 se0Params,
162 __SA_TEMPLATE_v1 sa0Params,
164 bool isSEReadEnabled);
169 __SE_TEMPLATE_v1 se0Params,
170 __SA_TEMPLATE_v1 sa0Params,
172 bool isSEReadEnabled)
174 DSPLIB_DEBUGPRINTFN(0,
"%s\n",
"Entering template function for FLOAT32 to Q15 conversion");
176 float *restrict pInLocal = (
float *) pIn;
177 int16_t *restrict pOutLocal = (int16_t *) pOut;
179 typedef typename c7x::make_full_vector<float>::type vecIn;
180 typedef typename c7x::short_vec vecOut;
182 int32_t eleCount = c7x::element_count_of<vecIn>::value;
183 int32_t loopCount = blockSize / (eleCount * 2);
184 int32_t remainingElements = blockSize - (loopCount * eleCount * 2);
187 DSPLIB_DEBUGPRINTFN(0,
"pInLocal: %p pOutLocal: %p blockSize: %d loopCount: %d remainingElements: %d\n", pInLocal,
188 pOutLocal, blockSize, loopCount, remainingElements);
190 if (isSEReadEnabled) {
191 vecIn mulFactor = (vecIn) 32768.0;
193 __SE0_OPEN(pInLocal, se0Params);
194 __SE1_OPEN(pInLocal + eleCount, se0Params);
195 __SA0_OPEN(sa0Params);
197 for (i = 0; i < loopCount; i++) {
198 vecIn loadVec1 = c7x::strm_eng<0, vecIn>::get_adv();
199 vecIn loadVec2 = c7x::strm_eng<1, vecIn>::get_adv();
201 vecIn mulLoadVec1 = loadVec1 * mulFactor;
202 vecIn mulLoadVec2 = loadVec2 * mulFactor;
204 vecOut intermediate1 = __float_to_short(mulLoadVec1);
205 vecOut intermediate2 = __float_to_short(mulLoadVec2);
207 c7x::short_vec *addr = c7x::strm_agen<0, c7x::short_vec>::get_adv(pOutLocal);
208 __vstore_packl_2src(addr, c7x::as_int_vec(intermediate1), c7x::as_int_vec(intermediate2));
215 pInLocal += loopCount * eleCount * 2;
216 pOutLocal += loopCount * eleCount * 2;
218 #pragma PROB_ITERATE(, 31)
219 for (i = 0; i < remainingElements; i++) {
220 float inData = *pInLocal++;
221 float mult = inData * 32768.00f;
222 short2 convertData = __float_to_short(mult);
223 *pOutLocal++ = convertData.s[0];
231 __SE_TEMPLATE_v1 se0Params,
232 __SA_TEMPLATE_v1 sa0Params,
234 bool isSEReadEnabled)
236 DSPLIB_DEBUGPRINTFN(0,
"%s\n",
"Entering template function for FLOAT64 to Q15 conversion");
238 double *restrict pInLocal = (
double *) pIn;
239 int16_t *restrict pOutLocal = (int16_t *) pOut;
241 typedef typename c7x::make_full_vector<double>::type vecIn;
243 int32_t eleCount = c7x::element_count_of<vecIn>::value;
244 int32_t loopCount = blockSize / (eleCount * 2);
245 int32_t remainingElements = blockSize - (loopCount * eleCount * 2);
248 DSPLIB_DEBUGPRINTFN(0,
"pInLocal: %p pOutLocal: %p blockSize: %d loopCount: %d remainingElements: %d\n", pInLocal,
249 pOutLocal, blockSize, loopCount, remainingElements);
251 if (isSEReadEnabled) {
252 vecIn mulFactor = (vecIn) 32768.0;
254 __SE0_OPEN(pInLocal, se0Params);
255 __SE1_OPEN(pInLocal + eleCount, se0Params);
256 __SA0_OPEN(sa0Params);
258 for (i = 0; i < loopCount; i++) {
260 vecIn loadVec1 = c7x::strm_eng<0, vecIn>::get_adv();
261 vecIn loadVec2 = c7x::strm_eng<1, vecIn>::get_adv();
263 loadVec1 = loadVec1 * mulFactor;
264 loadVec2 = loadVec2 * mulFactor;
266 c7x::int_vec dpToInt1 = __double_to_int(loadVec1);
267 c7x::int_vec dpToInt2 = __double_to_int(loadVec2);
269 c7x::int_vec pack1 = __pack_consec_low(dpToInt2, dpToInt1);
271 pack1 = __int_to_short_sat(pack1);
273 c7x::short_hvec *addr = c7x::strm_agen<0, c7x::short_hvec>::get_adv(pOutLocal);
274 __vstore_packl(addr, c7x::as_int_vec(pack1));
281 pInLocal += loopCount * eleCount * 2;
282 pOutLocal += loopCount * eleCount * 2;
283 #pragma PROB_ITERATE(, 15)
284 for (i = 0; i < remainingElements; i++) {
285 double inData = *pInLocal++;
286 double mult = inData * 32768.00;
287 int2 convTemp1 = __double_to_int(mult);
288 int2 convertData = __int_to_short_sat(convTemp1);
289 *pOutLocal++ = convertData.s[0];
294 template <
typename dataTypeIn>
300 uint32_t blockSize = pKerPrivArgs->
blockSize;
303 __SE_TEMPLATE_v1 se0Params;
304 __SA_TEMPLATE_v1 sa0Params;
306 uint8_t *pBlock = pKerPrivArgs->
bufPblock;
310 fltoq15_convert<dataTypeIn>(pIn, pOut, se0Params, sa0Params, blockSize, isSEReadEnabled);
#define SE_SE0_PARAM_OFFSET
#define SE_SA0_PARAM_OFFSET
void fltoq15_stream_init(uint8_t *pBlock, int32_t blockSize)
void fltoq15_convert(void *restrict pIn, void *restrict pOut, __SE_TEMPLATE_v1 se0Params, __SA_TEMPLATE_v1 sa0Params, uint32_t blockSize, bool isSEReadEnabled)
void fltoq15_convert< float >(void *restrict pIn, void *restrict pOut, __SE_TEMPLATE_v1 se0Params, __SA_TEMPLATE_v1 sa0Params, uint32_t blockSize, bool isSEReadEnabled)
DSPLIB_STATUS DSPLIB_fltoq15_init_ci(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_fltoq15_InitArgs *pKerInitArgs)
This function is the initialization function for the C7x implementation of the kernel....
void fltoq15_convert< double >(void *restrict pIn, void *restrict pOut, __SE_TEMPLATE_v1 se0Params, __SA_TEMPLATE_v1 sa0Params, uint32_t blockSize, bool isSEReadEnabled)
template DSPLIB_STATUS DSPLIB_fltoq15_exec_ci< double >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
DSPLIB_STATUS DSPLIB_fltoq15_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_fltoq15_exec_ci< float >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
template DSPLIB_STATUS DSPLIB_fltoq15_init_ci< float >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_fltoq15_InitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_fltoq15_init_ci< double >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_fltoq15_InitArgs *pKerInitArgs)
void fltoq15_stream_init< float >(uint8_t *pBlock, int32_t blockSize)
void fltoq15_stream_init< double >(uint8_t *pBlock, int32_t blockSize)
Header file for kernel's internal use. For the kernel's interface, please see DSPLIB_fltoq15.
#define DSPLIB_DEBUGPRINTFN(N, fmt,...)
DSPLIB_STATUS_NAME
The enumeration of all status codes.
void * DSPLIB_kernelHandle
Handle type for DSPLIB operations.
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_fltoq15_init that will be retrieved and used by DSP...
bool isSEReadEnabled
Flag indicating if SE reads and stores are enabled, set by DSPLIB_fltoq15_init_ci that will be retrie...
uint8_t bufPblock[DSPLIB_FLTOQ15_IXX_IXX_OXX_PBLOCK_SIZE]