DSPLIB User Guide
DSPLIB_bufParams.h
Go to the documentation of this file.
1 /******************************************************************************
2  * *
3  * module name :DSPLIB *
4  * *
5  * module descripton :Matrix Multiply Accelerator 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 
12 #ifndef DSPLIB_BUFPARAMS_H_
13 #define DSPLIB_BUFPARAMS_H_
14 
15 #ifndef __OPENCL_VERSION__
16 #include <stdint.h>
17 #endif
18 
26 static inline int32_t DSPLIB_sizeof(uint32_t type);
27 
29 typedef enum _DSPLIB_data_type_e {
30  /* Standard fixed point data types */
44  /* Standard floating point data types */
47  DSPLIB_FLOAT64 = 13
50 
51 /* ---------------------------------------------------------------- */
52 /* MISRAC Rule 4.9(DEFINE.FUNC) Deviation: The advisory is not */
53 /* being addressed */
54 /* ---------------------------------------------------------------- */
55 // MACRO for determining signedness of DSPLIB data types; fragile in that it
56 // depends on ordering of DSPLIB_data_type_e
57 #define DSPLIB_ISSIGNED(type) ((type) < DSPLIB_UINT8 || (type) > DSPLIB_UINT128)
58 #define DSPLIB_SIGNEDNESS(type) (DSPLIB_ISSIGNED((type)) ? "signed" : "unsigned")
59 
61 typedef enum _DSPLIB_dimension_e {
62  DSPLIB_2D = 0,
63  DSPLIB_3D = 1,
64  DSPLIB_4D = 2,
65  DSPLIB_5D = 3,
66  DSPLIB_6D = 4
68 
70 typedef struct {
71  uint32_t data_type;
73  uint32_t dim_x;
76 
78 typedef struct {
79  uint32_t data_type;
81  uint32_t dim_x;
82  uint32_t dim_y;
84  int32_t stride_y;
87 
89 typedef struct {
90  uint32_t data_type;
92  uint32_t dim_x;
94  uint32_t dim_y;
95  int32_t stride_y;
97  uint32_t dim_z;
98  int32_t stride_z;
101 
103 typedef struct {
104  uint32_t data_type;
106  uint32_t dim_0;
107 
108  uint32_t dim_1;
109  int32_t stride_1;
111  uint32_t dim_2;
112  int32_t stride_2;
115  uint32_t dim_3;
117  int32_t stride_3;
120  uint32_t dim_4;
122  int32_t stride_4;
125  uint32_t dim_5;
127  int32_t stride_5;
130  uint32_t dimension;
133 
136 static inline int32_t DSPLIB_sizeof(uint32_t type)
137 {
138 
139  int32_t size = 1;
140 
141  if ((type == (uint32_t) DSPLIB_INT8) || (type == (uint32_t) DSPLIB_UINT8)) {
142  size = 1;
143  }
144  else if ((type == (uint32_t) DSPLIB_INT16) || (type == (uint32_t) DSPLIB_UINT16) ||
145  (type == (uint32_t) DSPLIB_FLOAT16)) {
146  size = 2;
147  }
148  else if (type == (uint32_t) DSPLIB_UINT24) {
149  size = 3;
150  }
151  else if ((type == (uint32_t) DSPLIB_INT32) || (type == (uint32_t) DSPLIB_UINT32) ||
152  (type == (uint32_t) DSPLIB_FLOAT32)) {
153  size = 4;
154  }
155  else if ((type == (uint32_t) DSPLIB_INT64) || (type == (uint32_t) DSPLIB_UINT64) ||
156  (type == (uint32_t) DSPLIB_FLOAT64)) {
157  size = 8;
158  }
159  else if ((type == (uint32_t) DSPLIB_INT128) || (type == (uint32_t) DSPLIB_UINT128)) {
160  size = 16;
161  }
162  else {
163  size = 1;
164  }
165 
166  return size;
167 }
168 
170 #endif /* DSPLIB_BUFPARAMS_H_ */
DSPLIB_dimension_e
The enumeration of multidimensional buffer types.
static int32_t DSPLIB_sizeof(uint32_t type)
Inline function returns number of bytes per element given a type of DSPLIB_data_type_e.
DSPLIB_data_type_e
The enumeration of all data types.
@ DSPLIB_6D
@ DSPLIB_5D
@ DSPLIB_3D
@ DSPLIB_2D
@ DSPLIB_4D
@ DSPLIB_UINT24
@ DSPLIB_UINT64
@ DSPLIB_UINT128
@ DSPLIB_UINT8
@ DSPLIB_UINT16
@ DSPLIB_INT32
@ DSPLIB_FLOAT16
@ DSPLIB_INT16
@ DSPLIB_FLOAT32
@ DSPLIB_INT64
@ DSPLIB_FLOAT64
@ DSPLIB_INT128
@ DSPLIB_UINT32
@ DSPLIB_INT8
A structure for a 1 dimensional buffer descriptor.
uint32_t dim_x
Width of buffer in X dimension in elements.
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.
A structure for a 3 dimensional buffer descriptor.
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_z
Depth of patch in Z dimension in elements.
int32_t stride_z
Stride in Z dimension in bytes.
uint32_t dim_y
Height of buffer in Y dimension in elements.
uint32_t data_type
Values are of type DSPLIB_data_type_e.
A structure for a N dimensional buffer descriptor.
int32_t stride_4
Stride in bytes; Uninitialized when dimension = {DSPLIB_2D, DSPLIB_3D, DSPLIB_4D}.
int32_t stride_1
Stride in bytes.
uint32_t data_type
Values are of type DSPLIB_data_type_e.
int32_t stride_3
Stride in bytes; Uninitialized when dimension = {DSPLIB_2D, DSPLIB_3D}.
uint32_t dim_5
Uninitialized when dimension = {DSPLIB_2D, DSPLIB_3D, DSPLIB_4D, DSPLIB_5D}.
uint32_t dim_2
Uninitialized when dimension = {DSPLIB_2D}.
uint32_t dimension
Values are of type DSPLIB_dimension_e.
int32_t stride_5
Stride in bytes; Uninitialized when dimension = {DSPLIB_2D, DSPLIB_3D, DSPLIB_4D, DSPLIB_5D}.
uint32_t dim_4
Uninitialized when dimension = {DSPLIB_2D, DSPLIB_3D, DSPLIB_4D}.
uint32_t dim_3
Uninitialized when dimension = {DSPLIB_2D, DSPLIB_3D}.
int32_t stride_2
Stride in bytes; Uninitialized when dimension = {DSPLIB_2D}.