VXLIB User Guide
VXLIB_debugPrintVector.h
Go to the documentation of this file.
1 
2 /******************************************************************************/
6 /* Copyright (C) 2015 Texas Instruments Incorporated - https://www.ti.com/
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the
18  * distribution.
19  *
20  * Neither the name of Texas Instruments Incorporated nor the names of
21  * its contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  *
36  ******************************************************************************/
37 
38 #ifndef COMMON_VXLIB_UTIL_DEBUGPRINTVECTOR_H_
39 #define COMMON_VXLIB_UTIL_DEBUGPRINTFECTOR_H_ 1
40 
41 /*******************************************************************************
42  *
43  * INCLUDES
44  *
45  ******************************************************************************/
46 
47 #include "../VXLIB_types.h"
48 
49 //----------------------------------------------------------------------------------
50 #ifdef __cplusplus
51 #include <c7x_scalable.h> // for device scalability
52 
53 #pragma FUNC_ALWAYS_INLINE
54 static inline void VXLIB_debugPrintVector(c7x::uchar_vec vector)
55 {
56 #if VXLIB_DEBUGPRINT
57  for (uint i = 0; i < c7x::element_count_of<c7x::uchar_vec>::value; i++) {
58  VXLIB_PRINTF("%04u ", *((uchar *) (&vector) + i));
59  }
60 
61  VXLIB_PRINTF("%s", "\n");
62 #endif
63 }
64 
65 #pragma FUNC_ALWAYS_INLINE
66 static inline void VXLIB_debugPrintVector(c7x::char_vec vector)
67 {
68 #if VXLIB_DEBUGPRINT
69  for (uint i = 0; i < c7x::element_count_of<c7x::char_vec>::value; i++) {
70  VXLIB_PRINTF("%04d ", *((int8_t *) (&vector) + i));
71  }
72 
73  VXLIB_PRINTF("%s", "\n");
74 #endif
75 }
76 
77 #pragma FUNC_ALWAYS_INLINE
78 static inline void VXLIB_debugPrintVector(c7x::ushort_vec vector)
79 {
80 #if VXLIB_DEBUGPRINT
81  for (uint i = 0; i < c7x::element_count_of<c7x::ushort_vec>::value; i++) {
82  VXLIB_PRINTF("%05u ", *((ushort *) (&vector) + i));
83  }
84 
85  VXLIB_PRINTF("%s", "\n");
86 #endif
87 }
88 
89 #pragma FUNC_ALWAYS_INLINE
90 static inline void VXLIB_debugPrintVector(c7x::short_vec vector)
91 {
92 #if VXLIB_DEBUGPRINT
93  for (uint i = 0; i < c7x::element_count_of<c7x::short_vec>::value; i++) {
94  VXLIB_PRINTF("%05d ", *((short *) (&vector) + i));
95  }
96 
97  VXLIB_PRINTF("%s", "\n");
98 #endif
99 }
100 
101 #pragma FUNC_ALWAYS_INLINE
102 static inline void VXLIB_debugPrintVector(c7x::uint_vec vector)
103 {
104 #if VXLIB_DEBUGPRINT
105  for (uint i = 0; i < c7x::element_count_of<c7x::uint_vec>::value; i++) {
106  VXLIB_PRINTF("%010u ", *((uint *) (&vector) + i));
107  }
108 
109  VXLIB_PRINTF("%s", "\n");
110 #endif
111 }
112 
113 #pragma FUNC_ALWAYS_INLINE
114 static inline void VXLIB_debugPrintVector(c7x::float_vec vector)
115 {
116 #if VXLIB_DEBUGPRINT
117  for (uint i = 0; i < c7x::element_count_of<c7x::float_vec>::value; i++) {
118  VXLIB_PRINTF("%f ", *((float *) (&vector) + i));
119  }
120 
121  VXLIB_PRINTF("%s", "\n");
122 #endif
123 }
124 
125 #pragma FUNC_ALWAYS_INLINE
126 static inline void VXLIB_debugPrintVector(c7x::double_vec vector)
127 {
128 #if VXLIB_DEBUGPRINT
129  for (uint i = 0; i < c7x::element_count_of<c7x::double_vec>::value; i++) {
130  VXLIB_PRINTF("%lf ", *((double *) (&vector) + i));
131  }
132 
133  VXLIB_PRINTF("%s", "\n");
134 #endif
135 }
136 #pragma FUNC_ALWAYS_INLINE
137 static inline void VXLIB_debugPrintVector(c7x::int_vec vector)
138 {
139 #if VXLIB_DEBUGPRINT
140  for (uint i = 0; i < c7x::element_count_of<c7x::int_vec>::value; i++) {
141  VXLIB_PRINTF("%010d ", *((int *) (&vector) + i));
142  }
143 
144  VXLIB_PRINTF("%s", "\n");
145 #endif
146 }
147 
148 #pragma FUNC_ALWAYS_INLINE
149 static inline void VXLIB_debugPrintVectorInHex(c7x::long_vec vector)
150 {
151 #if VXLIB_DEBUGPRINT
152  for (uint i = 0; i < c7x::element_count_of<c7x::long_vec>::value; i++) {
153  VXLIB_PRINTF("%016lx ", *((long *) (&vector) + i));
154  }
155 
156  VXLIB_PRINTF("%s", "\n");
157 #endif
158 }
159 
160 #if __C7X_VEC_SIZE_BITS__ == 512
161 #pragma FUNC_ALWAYS_INLINE
162 static inline void VXLIB_debugPrintNonScalableVectorInHex(long8 vector)
163 {
164 #if VXLIB_DEBUGPRINT
165  VXLIB_PRINTF("%010lx ", vector.s[7]);
166  VXLIB_PRINTF("%010lx ", vector.s[6]);
167  VXLIB_PRINTF("%010lx ", vector.s[5]);
168  VXLIB_PRINTF("%010lx ", vector.s[4]);
169  VXLIB_PRINTF("%010lx ", vector.s[3]);
170  VXLIB_PRINTF("%010lx ", vector.s[2]);
171  VXLIB_PRINTF("%010lx ", vector.s[1]);
172  VXLIB_PRINTF("%010lx ", vector.s[0]);
173 
174  VXLIB_PRINTF("%s", "\n");
175 #endif
176  return;
177 }
178 #endif
179 
180 #endif //#ifdef __cplusplus
181 #endif /* COMMON_VXLIB_UTIL_DEBUGPRINTVECTOR_H_ */
#define VXLIB_PRINTF(fmt,...)
Definition: VXLIB_types.h:95