DSPLIB User Guide
DSPLIB_lud.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_lud_priv.h"
24 
26 {
27  int32_t privBufSize = sizeof(DSPLIB_lud_PrivArgs);
28 
29  DSPLIB_DEBUGPRINTFN(0, "privBufSize: %d\n", privBufSize);
30 
31  return privBufSize;
32 }
33 
35  const DSPLIB_bufParams2D_t *bufParamsA,
36  const DSPLIB_bufParams2D_t *bufParamsL,
37  const DSPLIB_bufParams2D_t *bufParamsU,
38  const DSPLIB_bufParams2D_t *bufParamsP,
39  const DSPLIB_ludInitArgs * pKerInitArgs)
40 {
41  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering Function");
43  if (handle == NULL) {
44  status = DSPLIB_ERR_NULL_POINTER;
45  }
46  if (status == DSPLIB_SUCCESS) {
47  /* Condition change */
48  if ((bufParamsA->data_type != DSPLIB_FLOAT32) && (bufParamsA->data_type != DSPLIB_FLOAT64)) {
49  status = DSPLIB_ERR_INVALID_TYPE;
50  }
51  else if (bufParamsP->data_type != DSPLIB_UINT16) {
52  status = DSPLIB_ERR_INVALID_TYPE;
53  }
54  else if (bufParamsA->data_type != bufParamsL->data_type) {
55  status = DSPLIB_ERR_INVALID_TYPE;
56  }
57  else if (bufParamsA->data_type != bufParamsU->data_type) {
58  status = DSPLIB_ERR_INVALID_TYPE;
59  }
60  else if (bufParamsA->dim_x != bufParamsA->dim_y) {
62  }
63  else if (bufParamsL->dim_x != bufParamsL->dim_y) {
65  }
66 
67  else if (bufParamsU->dim_x != bufParamsU->dim_y) {
69  }
70 
71  else if (bufParamsP->dim_x != bufParamsP->dim_y) {
73  }
74  else {
75  /* Do nothing */
76  }
77  }
78  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
79  return status;
80 }
81 
83  const void *restrict pA,
84  const void *restrict pL,
85  const void *restrict pU,
86  const void *restrict pP)
87 {
88  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
89 
90  DSPLIB_STATUS status;
91 
92  if ((pA == NULL) || (pL == NULL) || (pU == NULL) || (pP == NULL)) {
93  status = DSPLIB_ERR_NULL_POINTER;
94  }
95  else {
96  status = DSPLIB_SUCCESS;
97  }
98  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
99 
100  return status;
101 }
102 
104  const DSPLIB_bufParams2D_t *bufParamsA,
105  const DSPLIB_bufParams2D_t *bufParamsL,
106  const DSPLIB_bufParams2D_t *bufParamsU,
107  const DSPLIB_bufParams2D_t *bufParamsP,
108  const DSPLIB_ludInitArgs * pKerInitArgs)
109 {
110  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
111 
112  DSPLIB_STATUS status = DSPLIB_SUCCESS;
113  DSPLIB_lud_PrivArgs *pKerPrivArgs = (DSPLIB_lud_PrivArgs *) handle;
114 
115  pKerPrivArgs->order = bufParamsA->dim_x;
116  pKerPrivArgs->strideOrder = bufParamsA->stride_y;
117  pKerPrivArgs->strideP = bufParamsP->stride_y;
118 
119  DSPLIB_DEBUGPRINTFN(0, "pKerInitArgs->funcStyle: %d bufParamsA->data_type: %d\n", pKerInitArgs->funcStyle,
120  bufParamsA->data_type);
121 
122  if (pKerInitArgs->funcStyle == DSPLIB_FUNCTION_NATC) {
123  if (bufParamsA->data_type == DSPLIB_FLOAT32) {
124  pKerPrivArgs->execute = DSPLIB_lud_exec_cn<float>;
125  status = DSPLIB_lud_init_cn(handle, bufParamsA, bufParamsL, bufParamsU, bufParamsP, pKerInitArgs);
126  }
127  else if (bufParamsA->data_type == DSPLIB_FLOAT64) {
128  pKerPrivArgs->execute = DSPLIB_lud_exec_cn<double>;
129  status = DSPLIB_lud_init_cn(handle, bufParamsA, bufParamsL, bufParamsU, bufParamsP, pKerInitArgs);
130  }
131  else {
132  status = DSPLIB_ERR_INVALID_TYPE;
133  }
134  }
135  else {
136  if (bufParamsA->data_type == DSPLIB_FLOAT32) {
137  pKerPrivArgs->execute = DSPLIB_lud_exec_ci<float>;
138  status = DSPLIB_lud_init_ci<float>(handle, bufParamsA, bufParamsL, bufParamsU, bufParamsP, pKerInitArgs);
139  }
140  else if (bufParamsA->data_type == DSPLIB_FLOAT64) {
141  pKerPrivArgs->execute = DSPLIB_lud_exec_ci<double>;
142  status = DSPLIB_lud_init_ci<double>(handle, bufParamsA, bufParamsL, bufParamsU, bufParamsP, pKerInitArgs);
143  }
144  else {
145  status = DSPLIB_ERR_INVALID_TYPE;
146  }
147  }
148  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
149 
150  return status;
151 }
152 
154 DSPLIB_lud_exec(DSPLIB_kernelHandle handle, void *restrict pA, void *restrict pL, void *restrict pU, void *restrict pP)
155 {
156  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
157 
158  DSPLIB_STATUS status;
159 
160  DSPLIB_lud_PrivArgs *pKerPrivArgs = (DSPLIB_lud_PrivArgs *) handle;
161 
162  DSPLIB_DEBUGPRINTFN(0, "order: %d \n", pKerPrivArgs->order);
163 
164  status = pKerPrivArgs->execute(handle, pA, pL, pU, pP);
165 
166  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
167 
168  return status;
169 }
170 
171 /* ======================================================================== */
172 /* End of file: DSPLIB_lud.cpp */
173 /* ======================================================================== */
template DSPLIB_STATUS DSPLIB_lud_init_ci< float >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsA, const DSPLIB_bufParams2D_t *bufParamsL, const DSPLIB_bufParams2D_t *bufParamsU, const DSPLIB_bufParams2D_t *bufParamsP, const DSPLIB_ludInitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_lud_exec_ci< double >(DSPLIB_kernelHandle handle, void *restrict pA, void *restrict pL, void *restrict pU, void *restrict pP)
template DSPLIB_STATUS DSPLIB_lud_exec_ci< float >(DSPLIB_kernelHandle handle, void *restrict pA, void *restrict pL, void *restrict pU, void *restrict pP)
template DSPLIB_STATUS DSPLIB_lud_init_ci< double >(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsA, const DSPLIB_bufParams2D_t *bufParamsL, const DSPLIB_bufParams2D_t *bufParamsU, const DSPLIB_bufParams2D_t *bufParamsP, const DSPLIB_ludInitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_lud_exec_cn< float >(DSPLIB_kernelHandle handle, void *restrict pA, void *restrict pL, void *restrict pU, void *restrict pP)
DSPLIB_STATUS DSPLIB_lud_init_cn(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsA, const DSPLIB_bufParams2D_t *bufParamsL, const DSPLIB_bufParams2D_t *bufParamsU, const DSPLIB_bufParams2D_t *bufParamsP, const DSPLIB_ludInitArgs *pKerInitArgs)
This function is the initialization function for the natural C implementation of the kernel....
template DSPLIB_STATUS DSPLIB_lud_exec_cn< double >(DSPLIB_kernelHandle handle, void *restrict pA, void *restrict pL, void *restrict pU, void *restrict pP)
Header file for kernel's internal use. For the kernel's interface, please see DSPLIB_lud.
#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_UINT16
@ DSPLIB_FLOAT32
@ DSPLIB_FLOAT64
@ DSPLIB_ERR_INVALID_DIMENSION
Definition: DSPLIB_types.h:156
@ 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_lud_exec(DSPLIB_kernelHandle handle, void *restrict pA, void *restrict pL, void *restrict pU, void *restrict pP)
This function is the main kernel compute function.
Definition: DSPLIB_lud.cpp:154
DSPLIB_STATUS DSPLIB_lud_init(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsA, const DSPLIB_bufParams2D_t *bufParamsL, const DSPLIB_bufParams2D_t *bufParamsU, const DSPLIB_bufParams2D_t *bufParamsP, const DSPLIB_ludInitArgs *pKerInitArgs)
This function should be called before the DSPLIB_lud_exec function is called. This function takes car...
Definition: DSPLIB_lud.cpp:103
DSPLIB_STATUS DSPLIB_lud_init_checkParams(DSPLIB_kernelHandle handle, const DSPLIB_bufParams2D_t *bufParamsA, const DSPLIB_bufParams2D_t *bufParamsL, const DSPLIB_bufParams2D_t *bufParamsU, const DSPLIB_bufParams2D_t *bufParamsP, const DSPLIB_ludInitArgs *pKerInitArgs)
This function checks the validity of the parameters passed to DSPLIB_lud_init function....
Definition: DSPLIB_lud.cpp:34
DSPLIB_STATUS DSPLIB_lud_exec_checkParams(DSPLIB_kernelHandle handle, const void *restrict pA, const void *restrict pL, const void *restrict pU, const void *restrict pP)
This function checks the validity of the parameters passed to DSPLIB_lud_exec function....
Definition: DSPLIB_lud.cpp:82
int32_t DSPLIB_lud_getHandleSize(DSPLIB_ludInitArgs *pKerInitArgs)
This is a query function to calculate the size of internal handle.
Definition: DSPLIB_lud.cpp:25
A structure for a 2 dimensional buffer descriptor.
uint32_t data_type
Values are of type DSPLIB_data_type_e.
int32_t stride_y
Stride in Y dimension in bytes.
uint32_t dim_x
Width of buffer in X dimension in elements.
uint32_t dim_y
Height of buffer in Y dimension in elements.
Structure containing the parameters to initialize the kernel.
Definition: DSPLIB_lud.h:117
int8_t funcStyle
Variant of the function refer to DSPLIB_FUNCTION_STYLE
Definition: DSPLIB_lud.h:119
Structure that is reserved for internal use by the kernel.
int32_t order
Size of input buffer for different batches DSPLIB_lud_init that will be retrieved and used by DSPLIB_...
int32_t strideOrder
Stride between rows of input and output data matrix
int32_t strideP
Stride between rows of output data matrix P
pFxnDSPLIB_lud_exec execute
Function pointer to point to the right execution variant between DSPLIB_lud_exec_cn and DSPLIB_lud_ex...