MATHLIB User Guide
MATHLIB_types.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (C) 2023 Texas Instruments Incorporated - https://www.ti.com/
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  ******************************************************************************/
33 
34 #ifndef MATHLIB_TYPES_H_
35 #define MATHLIB_TYPES_H_ 1
36 
37 /******************************************************************************/
38 /* */
39 /* Includes */
40 /* */
41 /******************************************************************************/
42 
43 #include <c7x.h>
44 #include <inttypes.h>
45 #include <stddef.h>
46 #include <stdint.h>
47 #include <stdio.h>
48 #include <stdlib.h>
49 
57 /******************************************************************************/
58 /* */
59 /* Defines */
60 /* */
61 /******************************************************************************/
62 
63 #define MATHLIB_TEST_OUTPUT_HEAP 0
64 #if defined(_HOST_BUILD)
65 // Valgrind works better when output is in the heap (it
66 // can't track statically allocated memory), so
67 // in host emulation mode, place test outputs in the heap rather than statically
68 // allocated MSMC
69 #define MATHLIB_TEST_OUTPUT_MSMC MATHLIB_TEST_OUTPUT_HEAP
70 #else
71 #define MATHLIB_TEST_OUTPUT_MSMC 1
72 #endif
73 
74 #ifdef _HOST_BUILD
75 #define restrict
76 #endif
77 
78 // debug print macro
79 #if !defined(MATHLIB_DEBUGPRINT)
80 #define MATHLIB_DEBUGPRINT 0
81 #endif
82 
83 #define MATHLIB_PRINTF(fmt, ...) \
84  do { \
85  fprintf(stdout, fmt, __VA_ARGS__); \
86  } while (0)
87 
88 #if MATHLIB_DEBUGPRINT > 0
89 #define MATHLIB_DEBUGPRINTFN(N, fmt, ...) \
90  do { \
91  if (MATHLIB_DEBUGPRINT >= (N)) { \
92  fprintf(stdout, "MATHLIB debug %s - %d: " fmt, __FUNCTION__, __LINE__, __VA_ARGS__); \
93  } \
94  } while (0)
95 
96 #else // MATHLIB_DEBUGPRINT == 0
97 
98 #define MATHLIB_DEBUGPRINTFN(N, fmt, ...)
99 
100 #endif // #if MATHLIB_DEBUGPRINT
101 
102 #ifdef __cplusplus
103 #include <c7x_scalable.h> // for device scalability
104 extern "C" {
105 #endif /* __cplusplus */
106 
118 /******************************************************************************/
119 /* */
120 /* Typedes */
121 /* */
122 /******************************************************************************/
123 
128 typedef enum {
145 
147 
153 typedef struct {
154  bool callCheckParams = false;
155  bool callInit = true;
156  __SE_TEMPLATE_v1 se0Params;
157  __SE_TEMPLATE_v1 se1Params;
158  __SA_TEMPLATE_v1 sa0Params;
159  size_t blockSize = 0;
161 
167 typedef enum _MATHLIB_data_type_e {
168 
169  // standard fixed-point integer datatypes
176  // standard fixed-point unsigned integer datatypes
184  // standard floating-point datatypes
187  MATHLIB_FLOAT64 = 13
190 
193 #ifdef __cplusplus
194 }
195 #endif /* __cplusplus */
196 #endif /* MATHLIB_TYPES_H_ */
MATHLIB_data_type_e
Enum of all datatypes.
MATHLIB_STATUS_NAME MATHLIB_STATUS
Return value for MATHLIB functions.
MATHLIB_STATUS_NAME
The enumeration of all status codes.
@ MATHLIB_UINT8
@ MATHLIB_UINT24
@ MATHLIB_INT128
@ MATHLIB_UINT32
@ MATHLIB_UINT16
@ MATHLIB_UINT128
@ MATHLIB_FLOAT32
@ MATHLIB_INT64
@ MATHLIB_FLOAT16
@ MATHLIB_INT16
@ MATHLIB_INT8
@ MATHLIB_INT32
@ MATHLIB_FLOAT64
@ MATHLIB_UINT64
@ MATHLIB_ERR_NOT_IMPLEMENTED
@ MATHLIB_ERR_INVALID_ACTIVATION
@ MATHLIB_ERR_INVALID_VALUE
@ MATHLIB_ERR_NOT_EQUAL_WIDTH_STRIDE
@ MATHLIB_ERROR_MAX
@ MATHLIB_ERR_INVALID_SHIFT
@ MATHLIB_ERR_INVALID_TYPE
@ MATHLIB_ERR_BUFFER_TOO_SMALL
@ MATHLIB_ERR_NULL_POINTER
@ MATHLIB_ERR_INVALID_DIMENSION
@ MATHLIB_ERR_NOT_ALIGNED_PTRS_STRIDES
@ MATHLIB_ERR_FAILURE
@ MATHLIB_ERR_NOT_ALIGNED_WIDTHS
@ MATHLIB_SUCCESS
Structure containing the initialization parameters for kernels involving 1D sequential access.
__SE_TEMPLATE_v1 se1Params
struct to hold SE1 parameters
__SE_TEMPLATE_v1 se0Params
struct to hold SE0 parameters
__SA_TEMPLATE_v1 sa0Params
struct to hold SA0 parameters