DSPLIB User Guide
DSPLIB_fltoq15.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * *
3  * module name :DSPLIB *
4  * *
5  * module descripton :Digital Signal Processing Library module for C7x+MMA *
6  * *
7  * Copyright (C) 2017-2018 Texas Instruments Incorporated - https://www.ti.com/ *
8  * ALL RIGHTS RESERVED *
9  * *
10  ******************************************************************************/
11 
23 #include "DSPLIB_fltoq15_priv.h"
24 
26 {
27  int32_t privBufSize = sizeof(DSPLIB_fltoq15_PrivArgs);
28 
29  DSPLIB_DEBUGPRINTFN(0, "privBufSize: %d\n", privBufSize);
30 
31  return privBufSize;
32 }
33 
35  const DSPLIB_bufParams1D_t *bufParamsIn,
36  const DSPLIB_bufParams1D_t *bufParamsOut,
37  const DSPLIB_fltoq15_InitArgs *pKerInitArgs)
38 {
39  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering Function");
40 
42 
43  if (handle == NULL) {
44  status = DSPLIB_ERR_NULL_POINTER;
45  }
46 
47  if (status == DSPLIB_SUCCESS) {
48  if ((bufParamsIn->data_type != DSPLIB_FLOAT32) && (bufParamsIn->data_type != DSPLIB_FLOAT64)) {
49  status = DSPLIB_ERR_INVALID_TYPE;
50  }
51  else if (bufParamsOut->data_type != DSPLIB_INT16) {
52  status = DSPLIB_ERR_INVALID_TYPE;
53  }
54  else {
55  /* Nothing to do here */
56  }
57  }
58 
59  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
60 
61  return status;
62 }
63 
65 DSPLIB_fltoq15_exec_checkParams(DSPLIB_kernelHandle handle, const void *restrict pIn, const void *restrict pOut)
66 {
67  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
68 
69  DSPLIB_STATUS status;
70 
71  if ((pIn == NULL) || (pOut == NULL)) {
72  status = DSPLIB_ERR_NULL_POINTER;
73  }
74  else {
75  status = DSPLIB_SUCCESS;
76  }
77  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
78 
79  return status;
80 }
81 
83  DSPLIB_bufParams1D_t *bufParamsIn,
84  DSPLIB_bufParams1D_t *bufParamsOut,
85  const DSPLIB_fltoq15_InitArgs *pKerInitArgs)
86 {
87  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
88 
90  DSPLIB_fltoq15_PrivArgs *pKerPrivArgs = (DSPLIB_fltoq15_PrivArgs *) handle;
91 
92  pKerPrivArgs->blockSize = pKerInitArgs->dataSize;
93 
94  DSPLIB_DEBUGPRINTFN(0, "pKerInitArgs->funcStyle: %d bufParamsOut->data_type: %d\n", pKerInitArgs->funcStyle,
95  bufParamsOut->data_type);
96 
97  if (pKerInitArgs->funcStyle == DSPLIB_FUNCTION_NATC) {
98  if (bufParamsIn->data_type == DSPLIB_FLOAT32) {
99  pKerPrivArgs->execute = DSPLIB_fltoq15_exec_cn<float>;
100  status = DSPLIB_fltoq15_init_cn(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
101  }
102  else if (bufParamsIn->data_type == DSPLIB_FLOAT64) {
103  pKerPrivArgs->execute = DSPLIB_fltoq15_exec_cn<double>;
104  status = DSPLIB_fltoq15_init_cn(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
105  }
106  else {
107  status = DSPLIB_ERR_INVALID_TYPE;
108  }
109  }
110  else {
111  if (bufParamsIn->data_type == DSPLIB_FLOAT32) {
112  pKerPrivArgs->execute = DSPLIB_fltoq15_exec_ci<float>;
113  status = DSPLIB_fltoq15_init_ci<float>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
114  }
115  else if (bufParamsIn->data_type == DSPLIB_FLOAT64) {
116  pKerPrivArgs->execute = DSPLIB_fltoq15_exec_ci<double>;
117  status = DSPLIB_fltoq15_init_ci<double>(handle, bufParamsIn, bufParamsOut, pKerInitArgs);
118  }
119  else {
120  status = DSPLIB_ERR_INVALID_TYPE;
121  }
122  }
123  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
124 
125  return status;
126 }
127 
128 DSPLIB_STATUS DSPLIB_fltoq15_exec(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
129 {
130  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
131 
132  DSPLIB_STATUS status;
133 
134  DSPLIB_fltoq15_PrivArgs *pKerPrivArgs = (DSPLIB_fltoq15_PrivArgs *) handle;
135 
136  DSPLIB_DEBUGPRINTFN(0, "pKerPrivArgs->blockSize %d\n", pKerPrivArgs->blockSize);
137 
138  status = pKerPrivArgs->execute(handle, pIn, pOut);
139 
140  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
141 
142  return status;
143 }
template DSPLIB_STATUS DSPLIB_fltoq15_exec_ci< double >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
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)
template DSPLIB_STATUS DSPLIB_fltoq15_exec_cn< float >(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
DSPLIB_STATUS DSPLIB_fltoq15_init_cn(DSPLIB_kernelHandle handle, DSPLIB_bufParams1D_t *bufParamsIn, DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_fltoq15_InitArgs *pKerInitArgs)
This function is the initialization function for the natural C implementation of the kernel....
template DSPLIB_STATUS DSPLIB_fltoq15_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_fltoq15.
#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_FUNCTION_NATC
Definition: DSPLIB_types.h:176
@ DSPLIB_INT16
@ DSPLIB_FLOAT32
@ DSPLIB_FLOAT64
@ DSPLIB_SUCCESS
Definition: DSPLIB_types.h:152
@ DSPLIB_ERR_NULL_POINTER
Definition: DSPLIB_types.h:157
@ DSPLIB_ERR_INVALID_TYPE
Definition: DSPLIB_types.h:155
DSPLIB_STATUS DSPLIB_fltoq15_init_checkParams(DSPLIB_kernelHandle handle, const DSPLIB_bufParams1D_t *bufParamsIn, const DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_fltoq15_InitArgs *pKerInitArgs)
This function checks the validity of the parameters passed to DSPLIB_fltoq15_init function....
int32_t DSPLIB_fltoq15_getHandleSize(DSPLIB_fltoq15_InitArgs *pKerInitArgs)
This is a query function to calculate the size of internal handle.
DSPLIB_STATUS DSPLIB_fltoq15_exec(DSPLIB_kernelHandle handle, void *restrict pIn, void *restrict pOut)
This function is the main kernel compute function.
DSPLIB_STATUS DSPLIB_fltoq15_exec_checkParams(DSPLIB_kernelHandle handle, const void *restrict pIn, const void *restrict pOut)
This function checks the validity of the parameters passed to DSPLIB_fltoq15_exec function....
DSPLIB_STATUS DSPLIB_fltoq15_init(DSPLIB_kernelHandle handle, DSPLIB_bufParams1D_t *bufParamsIn, DSPLIB_bufParams1D_t *bufParamsOut, const DSPLIB_fltoq15_InitArgs *pKerInitArgs)
This function should be called before the DSPLIB_fltoq15_exec function is called. This function takes...
A structure for a 1 dimensional buffer descriptor.
uint32_t data_type
Values are of type DSPLIB_data_type_e.
Structure containing the parameters to initialize the kernel.
uint32_t dataSize
Size of input data
int8_t funcStyle
Variant of the function refer to DSPLIB_FUNCTION_STYLE
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...
pFxnDSPLIB_fltoq15_exec execute
Function pointer to point to the right execution variant between DSPLIB_fltoq15_exec_cn and DSPLIB_fl...