DSPLIB User Guide
DSPLIB_qrd.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_qrd_priv.h"
24 
26 {
27  int32_t privBufSize = sizeof(DSPLIB_qrd_PrivArgs);
28 
29  DSPLIB_DEBUGPRINTFN(0, "privBufSize: %d\n", privBufSize);
30 
31  return privBufSize;
32 }
33 
35  DSPLIB_bufParams2D_t *bufParamsA,
36  DSPLIB_bufParams2D_t *bufParamsQ,
37  DSPLIB_bufParams2D_t *bufParamsR,
38  DSPLIB_bufParams1D_t *bufParamsU,
39  const DSPLIB_qrdInitArgs *pKerInitArgs)
40 {
41  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering Function");
42 
44 
45  if (handle == NULL) {
46  status = DSPLIB_ERR_NULL_POINTER;
47  }
48 
49  if (status == DSPLIB_SUCCESS) {
50 
51  /* Condition change */
52  if ((bufParamsA->data_type != DSPLIB_FLOAT32) && (bufParamsA->data_type != DSPLIB_FLOAT64)) {
53  status = DSPLIB_ERR_INVALID_TYPE;
54  }
55  else if (bufParamsA->data_type != bufParamsQ->data_type || bufParamsA->data_type != bufParamsR->data_type ||
56  bufParamsA->data_type != bufParamsU->data_type) {
57  status = DSPLIB_ERR_INVALID_TYPE;
58  }
59 
60  else {
61  /* Do nothing */
62  }
63  }
64 
65  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
66 
67  return status;
68 }
69 
71  const void *restrict pA,
72  const void *restrict pQ,
73  const void *restrict pR,
74  const void *restrict pU,
75  const void *restrict pScratch)
76 {
77  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
78 
79  DSPLIB_STATUS status;
80 
81  if ((pA == NULL) || (pQ == NULL) || (pR == NULL) || (pU == NULL) || (pScratch == NULL)) {
82  status = DSPLIB_ERR_NULL_POINTER;
83  }
84  else {
85  status = DSPLIB_SUCCESS;
86  }
87  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
88 
89  return status;
90 }
91 
93  DSPLIB_bufParams2D_t *bufParamsA,
94  DSPLIB_bufParams2D_t *bufParamsQ,
95  DSPLIB_bufParams2D_t *bufParamsR,
96  DSPLIB_bufParams1D_t *bufParamsU,
97  const DSPLIB_qrdInitArgs *pKerInitArgs)
98 {
99  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
100 
101  DSPLIB_STATUS status = DSPLIB_SUCCESS;
102  DSPLIB_qrd_PrivArgs *pKerPrivArgs = (DSPLIB_qrd_PrivArgs *) handle;
103 
104  pKerPrivArgs->widthA = bufParamsA->dim_x;
105  pKerPrivArgs->heightA = bufParamsA->dim_y;
106  pKerPrivArgs->strideA = bufParamsA->stride_y;
107  pKerPrivArgs->strideQ = bufParamsQ->stride_y;
108  pKerPrivArgs->strideR = bufParamsR->stride_y;
109 
110  DSPLIB_DEBUGPRINTFN(0, "pKerInitArgs->funcStyle: %d bufParamsA->data_type: %d\n", pKerInitArgs->funcStyle,
111  bufParamsA->data_type);
112 
113  if (pKerInitArgs->funcStyle == DSPLIB_FUNCTION_NATC) {
114  if (bufParamsA->data_type == DSPLIB_FLOAT32) {
115  pKerPrivArgs->execute = DSPLIB_qrd_exec_cn<float>;
116  status = DSPLIB_qrd_init_cn<float>(handle, bufParamsA, bufParamsQ, bufParamsR, bufParamsU, pKerInitArgs);
117  }
118  else if (bufParamsA->data_type == DSPLIB_FLOAT64) {
119  pKerPrivArgs->execute = DSPLIB_qrd_exec_cn<double>;
120  status = DSPLIB_qrd_init_cn<double>(handle, bufParamsA, bufParamsQ, bufParamsR, bufParamsU, pKerInitArgs);
121  }
122  else {
123  status = DSPLIB_ERR_INVALID_TYPE;
124  }
125  }
126  else {
127  if (bufParamsA->data_type == DSPLIB_FLOAT32) {
128  pKerPrivArgs->execute = DSPLIB_qrd_exec_ci<float>;
129  status = DSPLIB_qrd_init_ci<float>(handle, bufParamsA, bufParamsQ, bufParamsR, bufParamsU, pKerInitArgs);
130  }
131  else if (bufParamsA->data_type == DSPLIB_FLOAT64) {
132  pKerPrivArgs->execute = DSPLIB_qrd_exec_ci<double>;
133  status = DSPLIB_qrd_init_ci<double>(handle, bufParamsA, bufParamsQ, bufParamsR, bufParamsU, pKerInitArgs);
134  }
135  else {
136  status = DSPLIB_ERR_INVALID_TYPE;
137  }
138  }
139  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
140 
141  return status;
142 }
143 
145  const void *restrict pA,
146  const void *restrict pQ,
147  const void *restrict pR,
148  const void *restrict pU,
149  const void *restrict pScratch)
150 {
151  DSPLIB_DEBUGPRINTFN(0, "%s\n", "Entering function");
152 
153  DSPLIB_STATUS status;
154 
155  DSPLIB_qrd_PrivArgs *pKerPrivArgs = (DSPLIB_qrd_PrivArgs *) handle;
156 
157  DSPLIB_DEBUGPRINTFN(0, "widthA: %d heightA: %d strideA: %d strideQ: %d strideR: %d\n", pKerPrivArgs->widthA,
158  pKerPrivArgs->heightA, pKerPrivArgs->strideA, pKerPrivArgs->strideQ, pKerPrivArgs->strideR);
159 
160  status = pKerPrivArgs->execute(handle, pA, pQ, pR, pU, pScratch);
161 
162  DSPLIB_DEBUGPRINTFN(0, "Exiting function with return status: %d\n", status);
163 
164  return status;
165 }
166 /* ======================================================================== */
167 /* End of file: DSPLIB_qrd.cpp */
168 /* ======================================================================== */
template DSPLIB_STATUS DSPLIB_qrd_init_ci< double >(DSPLIB_kernelHandle handle, DSPLIB_bufParams2D_t *bufParamsA, DSPLIB_bufParams2D_t *bufParamsQ, DSPLIB_bufParams2D_t *bufParamsR, DSPLIB_bufParams1D_t *bufParamsU, const DSPLIB_qrdInitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_qrd_init_ci< float >(DSPLIB_kernelHandle handle, DSPLIB_bufParams2D_t *bufParamsA, DSPLIB_bufParams2D_t *bufParamsQ, DSPLIB_bufParams2D_t *bufParamsR, DSPLIB_bufParams1D_t *bufParamsU, const DSPLIB_qrdInitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_qrd_exec_ci< float >(DSPLIB_kernelHandle handle, const void *restrict pA, const void *restrict pQ, const void *restrict pR, const void *restrict pU, const void *restrict pScratch)
template DSPLIB_STATUS DSPLIB_qrd_exec_ci< double >(DSPLIB_kernelHandle handle, const void *restrict pA, const void *restrict pQ, const void *restrict pR, const void *restrict pU, const void *restrict pScratch)
template DSPLIB_STATUS DSPLIB_qrd_exec_cn< double >(DSPLIB_kernelHandle handle, const void *restrict pA, const void *restrict pQ, const void *restrict pR, const void *restrict pU, const void *restrict pScratch)
template DSPLIB_STATUS DSPLIB_qrd_init_cn< double >(DSPLIB_kernelHandle handle, DSPLIB_bufParams2D_t *bufParamsA, DSPLIB_bufParams2D_t *bufParamsQ, DSPLIB_bufParams2D_t *bufParamsR, DSPLIB_bufParams1D_t *bufParamsU, const DSPLIB_qrdInitArgs *pKerInitArgs)
template DSPLIB_STATUS DSPLIB_qrd_exec_cn< float >(DSPLIB_kernelHandle handle, const void *restrict pA, const void *restrict pQ, const void *restrict pR, const void *restrict pU, const void *restrict pScratch)
template DSPLIB_STATUS DSPLIB_qrd_init_cn< float >(DSPLIB_kernelHandle handle, DSPLIB_bufParams2D_t *bufParamsA, DSPLIB_bufParams2D_t *bufParamsQ, DSPLIB_bufParams2D_t *bufParamsR, DSPLIB_bufParams1D_t *bufParamsU, const DSPLIB_qrdInitArgs *pKerInitArgs)
Header file for kernel's internal use. For the kernel's interface, please see DSPLIB_qrd.
#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_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_qrd_init_checkParams(DSPLIB_kernelHandle handle, DSPLIB_bufParams2D_t *bufParamsA, DSPLIB_bufParams2D_t *bufParamsQ, DSPLIB_bufParams2D_t *bufParamsR, DSPLIB_bufParams1D_t *bufParamsU, const DSPLIB_qrdInitArgs *pKerInitArgs)
This function checks the validity of the parameters passed to DSPLIB_qrd_init function....
Definition: DSPLIB_qrd.cpp:34
int32_t DSPLIB_qrd_getHandleSize(DSPLIB_qrdInitArgs *pKerInitArgs)
This is a query function to calculate the size of internal handle.
Definition: DSPLIB_qrd.cpp:25
DSPLIB_STATUS DSPLIB_qrd_init(DSPLIB_kernelHandle handle, DSPLIB_bufParams2D_t *bufParamsA, DSPLIB_bufParams2D_t *bufParamsQ, DSPLIB_bufParams2D_t *bufParamsR, DSPLIB_bufParams1D_t *bufParamsU, const DSPLIB_qrdInitArgs *pKerInitArgs)
This function should be called before the DSPLIB_qrd_exec function is called. This function takes car...
Definition: DSPLIB_qrd.cpp:92
DSPLIB_STATUS DSPLIB_qrd_exec_checkParams(DSPLIB_kernelHandle handle, const void *restrict pA, const void *restrict pQ, const void *restrict pR, const void *restrict pU, const void *restrict pScratch)
This function checks the validity of the parameters passed to DSPLIB_qrd_exec function....
Definition: DSPLIB_qrd.cpp:70
DSPLIB_STATUS DSPLIB_qrd_exec(DSPLIB_kernelHandle handle, const void *restrict pA, const void *restrict pQ, const void *restrict pR, const void *restrict pU, const void *restrict pScratch)
This function is the main kernel compute function.
Definition: DSPLIB_qrd.cpp:144
A structure for a 1 dimensional buffer descriptor.
uint32_t data_type
Values are of type DSPLIB_data_type_e.
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_qrd.h:112
int8_t funcStyle
Variant of the function refer to DSPLIB_FUNCTION_STYLE
Definition: DSPLIB_qrd.h:114
Structure that is reserved for internal use by the kernel.
pFxnDSPLIB_qrd_exec execute
Function pointer to point to the right execution variant between DSPLIB_qrd_exec_cn and DSPLIB_qrd_ex...
int32_t strideR
Stride between rows of R output data matrix
uint32_t heightA
Height of input data matrix
uint32_t widthA
Size of input buffer for different batches DSPLIB_qrd_init that will be retrieved and used by DSPLIB_...
int32_t strideQ
Stride between rows of Q output data matrix
int32_t strideA
Stride between rows of input data matrix