|
1 | 1 | #include <clc/clcfunc.h>
|
2 | 2 | #include <clc/clctypes.h>
|
| 3 | +#include <clc/utils.h> |
| 4 | + |
| 5 | +// Define some useful macros for type conversions. |
| 6 | +#define __CLC_AS_GENTYPE __CLC_XCONCAT(__clc_as_, __CLC_GENTYPE) |
| 7 | +#define __CLC_CONVERT_GENTYPE __CLC_XCONCAT(__clc_convert_, __CLC_GENTYPE) |
| 8 | + |
| 9 | +// Define some macros for types matching the same vector size as __CLC_GENTYPE. |
| 10 | +#define __CLC_HALFN __CLC_XCONCAT(half, __CLC_VECSIZE) |
| 11 | +#define __CLC_FLOATN __CLC_XCONCAT(float, __CLC_VECSIZE) |
| 12 | +#define __CLC_DOUBLEN __CLC_XCONCAT(double, __CLC_VECSIZE) |
| 13 | + |
| 14 | +#define __CLC_CHARN __CLC_XCONCAT(char, __CLC_VECSIZE) |
| 15 | +#define __CLC_SHORTN __CLC_XCONCAT(short, __CLC_VECSIZE) |
| 16 | +#define __CLC_INTN __CLC_XCONCAT(int, __CLC_VECSIZE) |
| 17 | +#define __CLC_LONGN __CLC_XCONCAT(long, __CLC_VECSIZE) |
| 18 | + |
| 19 | +#define __CLC_UCHARN __CLC_XCONCAT(uchar, __CLC_VECSIZE) |
| 20 | +#define __CLC_USHORTN __CLC_XCONCAT(ushort, __CLC_VECSIZE) |
| 21 | +#define __CLC_UINTN __CLC_XCONCAT(uint, __CLC_VECSIZE) |
| 22 | +#define __CLC_ULONGN __CLC_XCONCAT(ulong, __CLC_VECSIZE) |
| 23 | + |
| 24 | +#define __CLC_AS_CHARN __CLC_XCONCAT(__clc_as_, __CLC_CHARN) |
| 25 | +#define __CLC_AS_SHORTN __CLC_XCONCAT(__clc_as_, __CLC_SHORTN) |
| 26 | +#define __CLC_AS_INTN __CLC_XCONCAT(__clc_as_, __CLC_INTN) |
| 27 | +#define __CLC_AS_LONGN __CLC_XCONCAT(__clc_as_, __CLC_LONGN) |
| 28 | + |
| 29 | +#define __CLC_AS_UCHARN __CLC_XCONCAT(__clc_as_, __CLC_UCHARN) |
| 30 | +#define __CLC_AS_USHORTN __CLC_XCONCAT(__clc_as_, __CLC_USHORTN) |
| 31 | +#define __CLC_AS_UINTN __CLC_XCONCAT(__clc_as_, __CLC_UINTN) |
| 32 | +#define __CLC_AS_ULONGN __CLC_XCONCAT(__clc_as_, __CLC_ULONGN) |
| 33 | + |
| 34 | +#define __CLC_CONVERT_HALFN __CLC_XCONCAT(__clc_convert_half, __CLC_VECSIZE) |
| 35 | +#define __CLC_CONVERT_FLOATN __CLC_XCONCAT(__clc_convert_float, __CLC_VECSIZE) |
| 36 | +#define __CLC_CONVERT_DOUBLEN __CLC_XCONCAT(__clc_convert_double, __CLC_VECSIZE) |
| 37 | + |
| 38 | +#define __CLC_CONVERT_CHARN __CLC_XCONCAT(__clc_convert_, __CLC_CHARN) |
| 39 | +#define __CLC_CONVERT_SHORTN __CLC_XCONCAT(__clc_convert_, __CLC_SHORTN) |
| 40 | +#define __CLC_CONVERT_INTN __CLC_XCONCAT(__clc_convert_, __CLC_INTN) |
| 41 | +#define __CLC_CONVERT_LONGN __CLC_XCONCAT(__clc_convert_, __CLC_LONGN) |
| 42 | + |
| 43 | +#define __CLC_CONVERT_UCHARN __CLC_XCONCAT(__clc_convert_, __CLC_UCHARN) |
| 44 | +#define __CLC_CONVERT_USHORTN __CLC_XCONCAT(__clc_convert_, __CLC_USHORTN) |
| 45 | +#define __CLC_CONVERT_UINTN __CLC_XCONCAT(__clc_convert_, __CLC_UINTN) |
| 46 | +#define __CLC_CONVERT_ULONGN __CLC_XCONCAT(__clc_convert_, __CLC_ULONGN) |
| 47 | + |
| 48 | +// See definitions of __CLC_S_GENTYPE/__CLC_U_GENTYPE below, which depend on the |
| 49 | +// specific size of floating-point type. These are the signed and unsigned |
| 50 | +// integers of the same bitwidth and element count as the GENTYPE. They match |
| 51 | +// the naming conventions in the integer version gentype.inc, for |
| 52 | +// convenience. |
| 53 | +#define __CLC_AS_S_GENTYPE __CLC_XCONCAT(__clc_as_, __CLC_S_GENTYPE) |
| 54 | +#define __CLC_AS_U_GENTYPE __CLC_XCONCAT(__clc_as_, __CLC_U_GENTYPE) |
| 55 | + |
| 56 | +#define __CLC_CONVERT_S_GENTYPE __CLC_XCONCAT(__clc_convert_, __CLC_S_GENTYPE) |
| 57 | +#define __CLC_CONVERT_U_GENTYPE __CLC_XCONCAT(__clc_convert_, __CLC_U_GENTYPE) |
3 | 58 |
|
4 | 59 | #define __CLC_SCALAR_GENTYPE float
|
5 | 60 | #define __CLC_FPSIZE 32
|
6 | 61 | #define __CLC_FP_LIT(x) x##F
|
7 | 62 |
|
| 63 | +#define __CLC_S_GENTYPE __CLC_XCONCAT(int, __CLC_VECSIZE) |
| 64 | +#define __CLC_U_GENTYPE __CLC_XCONCAT(uint, __CLC_VECSIZE) |
| 65 | + |
8 | 66 | #define __CLC_GENTYPE float
|
9 |
| -#define __CLC_INTN int |
10 | 67 | #define __CLC_BIT_INTN int
|
11 | 68 | #define __CLC_SCALAR
|
| 69 | +#define __CLC_VECSIZE |
12 | 70 | #include __CLC_BODY
|
| 71 | +#undef __CLC_VECSIZE |
13 | 72 | #undef __CLC_GENTYPE
|
14 | 73 | #undef __CLC_BIT_INTN
|
15 |
| -#undef __CLC_INTN |
16 | 74 | #undef __CLC_SCALAR
|
17 | 75 |
|
18 | 76 | #define __CLC_GENTYPE float2
|
19 |
| -#define __CLC_INTN int2 |
20 | 77 | #define __CLC_BIT_INTN int2
|
21 | 78 | #define __CLC_VECSIZE 2
|
22 | 79 | #include __CLC_BODY
|
23 | 80 | #undef __CLC_VECSIZE
|
24 | 81 | #undef __CLC_GENTYPE
|
25 | 82 | #undef __CLC_BIT_INTN
|
26 |
| -#undef __CLC_INTN |
27 | 83 |
|
28 | 84 | #define __CLC_GENTYPE float3
|
29 |
| -#define __CLC_INTN int3 |
30 | 85 | #define __CLC_BIT_INTN int3
|
31 | 86 | #define __CLC_VECSIZE 3
|
32 | 87 | #include __CLC_BODY
|
33 | 88 | #undef __CLC_VECSIZE
|
34 | 89 | #undef __CLC_GENTYPE
|
35 | 90 | #undef __CLC_BIT_INTN
|
36 |
| -#undef __CLC_INTN |
37 | 91 |
|
38 | 92 | #define __CLC_GENTYPE float4
|
39 |
| -#define __CLC_INTN int4 |
40 | 93 | #define __CLC_BIT_INTN int4
|
41 | 94 | #define __CLC_VECSIZE 4
|
42 | 95 | #include __CLC_BODY
|
43 | 96 | #undef __CLC_VECSIZE
|
44 | 97 | #undef __CLC_GENTYPE
|
45 | 98 | #undef __CLC_BIT_INTN
|
46 |
| -#undef __CLC_INTN |
47 | 99 |
|
48 | 100 | #define __CLC_GENTYPE float8
|
49 |
| -#define __CLC_INTN int8 |
50 | 101 | #define __CLC_BIT_INTN int8
|
51 | 102 | #define __CLC_VECSIZE 8
|
52 | 103 | #include __CLC_BODY
|
53 | 104 | #undef __CLC_VECSIZE
|
54 | 105 | #undef __CLC_GENTYPE
|
55 | 106 | #undef __CLC_BIT_INTN
|
56 |
| -#undef __CLC_INTN |
57 | 107 |
|
58 | 108 | #define __CLC_GENTYPE float16
|
59 |
| -#define __CLC_INTN int16 |
60 | 109 | #define __CLC_BIT_INTN int16
|
61 | 110 | #define __CLC_VECSIZE 16
|
62 | 111 | #include __CLC_BODY
|
63 | 112 | #undef __CLC_VECSIZE
|
64 | 113 | #undef __CLC_GENTYPE
|
65 | 114 | #undef __CLC_BIT_INTN
|
66 |
| -#undef __CLC_INTN |
67 | 115 |
|
| 116 | +#undef __CLC_U_GENTYPE |
| 117 | +#undef __CLC_S_GENTYPE |
68 | 118 | #undef __CLC_FP_LIT
|
69 | 119 | #undef __CLC_FPSIZE
|
70 | 120 | #undef __CLC_SCALAR_GENTYPE
|
|
77 | 127 | #define __CLC_FPSIZE 64
|
78 | 128 | #define __CLC_FP_LIT(x) (x)
|
79 | 129 |
|
| 130 | +#define __CLC_S_GENTYPE __CLC_XCONCAT(long, __CLC_VECSIZE) |
| 131 | +#define __CLC_U_GENTYPE __CLC_XCONCAT(ulong, __CLC_VECSIZE) |
| 132 | + |
80 | 133 | #define __CLC_SCALAR
|
| 134 | +#define __CLC_VECSIZE |
81 | 135 | #define __CLC_GENTYPE double
|
82 |
| -#define __CLC_INTN int |
83 | 136 | #define __CLC_BIT_INTN long
|
84 | 137 | #include __CLC_BODY
|
85 | 138 | #undef __CLC_GENTYPE
|
86 | 139 | #undef __CLC_BIT_INTN
|
87 |
| -#undef __CLC_INTN |
| 140 | +#undef __CLC_VECSIZE |
88 | 141 | #undef __CLC_SCALAR
|
89 | 142 |
|
90 | 143 | #define __CLC_GENTYPE double2
|
91 |
| -#define __CLC_INTN int2 |
92 | 144 | #define __CLC_BIT_INTN long2
|
93 | 145 | #define __CLC_VECSIZE 2
|
94 | 146 | #include __CLC_BODY
|
95 | 147 | #undef __CLC_VECSIZE
|
96 | 148 | #undef __CLC_GENTYPE
|
97 | 149 | #undef __CLC_BIT_INTN
|
98 |
| -#undef __CLC_INTN |
99 | 150 |
|
100 | 151 | #define __CLC_GENTYPE double3
|
101 |
| -#define __CLC_INTN int3 |
102 | 152 | #define __CLC_BIT_INTN long3
|
103 | 153 | #define __CLC_VECSIZE 3
|
104 | 154 | #include __CLC_BODY
|
105 | 155 | #undef __CLC_VECSIZE
|
106 | 156 | #undef __CLC_GENTYPE
|
107 | 157 | #undef __CLC_BIT_INTN
|
108 |
| -#undef __CLC_INTN |
109 | 158 |
|
110 | 159 | #define __CLC_GENTYPE double4
|
111 |
| -#define __CLC_INTN int4 |
112 | 160 | #define __CLC_BIT_INTN long4
|
113 | 161 | #define __CLC_VECSIZE 4
|
114 | 162 | #include __CLC_BODY
|
115 | 163 | #undef __CLC_VECSIZE
|
116 | 164 | #undef __CLC_GENTYPE
|
117 | 165 | #undef __CLC_BIT_INTN
|
118 |
| -#undef __CLC_INTN |
119 | 166 |
|
120 | 167 | #define __CLC_GENTYPE double8
|
121 |
| -#define __CLC_INTN int8 |
122 | 168 | #define __CLC_BIT_INTN long8
|
123 | 169 | #define __CLC_VECSIZE 8
|
124 | 170 | #include __CLC_BODY
|
125 | 171 | #undef __CLC_VECSIZE
|
126 | 172 | #undef __CLC_GENTYPE
|
127 | 173 | #undef __CLC_BIT_INTN
|
128 |
| -#undef __CLC_INTN |
129 | 174 |
|
130 | 175 | #define __CLC_GENTYPE double16
|
131 |
| -#define __CLC_INTN int16 |
132 | 176 | #define __CLC_BIT_INTN long16
|
133 | 177 | #define __CLC_VECSIZE 16
|
134 | 178 | #include __CLC_BODY
|
135 | 179 | #undef __CLC_VECSIZE
|
136 | 180 | #undef __CLC_GENTYPE
|
137 | 181 | #undef __CLC_BIT_INTN
|
138 |
| -#undef __CLC_INTN |
139 | 182 |
|
| 183 | +#undef __CLC_U_GENTYPE |
| 184 | +#undef __CLC_S_GENTYPE |
140 | 185 | #undef __CLC_FP_LIT
|
141 | 186 | #undef __CLC_FPSIZE
|
142 | 187 | #undef __CLC_SCALAR_GENTYPE
|
|
151 | 196 | #define __CLC_FPSIZE 16
|
152 | 197 | #define __CLC_FP_LIT(x) x##H
|
153 | 198 |
|
| 199 | +#define __CLC_S_GENTYPE __CLC_XCONCAT(short, __CLC_VECSIZE) |
| 200 | +#define __CLC_U_GENTYPE __CLC_XCONCAT(ushort, __CLC_VECSIZE) |
| 201 | + |
154 | 202 | #define __CLC_SCALAR
|
| 203 | +#define __CLC_VECSIZE |
155 | 204 | #define __CLC_GENTYPE half
|
156 |
| -#define __CLC_INTN int |
157 | 205 | #define __CLC_BIT_INTN short
|
158 | 206 | #include __CLC_BODY
|
159 | 207 | #undef __CLC_GENTYPE
|
160 | 208 | #undef __CLC_BIT_INTN
|
161 |
| -#undef __CLC_INTN |
| 209 | +#undef __CLC_VECSIZE |
162 | 210 | #undef __CLC_SCALAR
|
163 | 211 |
|
164 | 212 | #define __CLC_GENTYPE half2
|
165 |
| -#define __CLC_INTN int2 |
166 | 213 | #define __CLC_BIT_INTN short2
|
167 | 214 | #define __CLC_VECSIZE 2
|
168 | 215 | #include __CLC_BODY
|
169 | 216 | #undef __CLC_VECSIZE
|
170 | 217 | #undef __CLC_GENTYPE
|
171 | 218 | #undef __CLC_BIT_INTN
|
172 |
| -#undef __CLC_INTN |
173 | 219 |
|
174 | 220 | #define __CLC_GENTYPE half3
|
175 |
| -#define __CLC_INTN int3 |
176 | 221 | #define __CLC_BIT_INTN short3
|
177 | 222 | #define __CLC_VECSIZE 3
|
178 | 223 | #include __CLC_BODY
|
179 | 224 | #undef __CLC_VECSIZE
|
180 | 225 | #undef __CLC_GENTYPE
|
181 | 226 | #undef __CLC_BIT_INTN
|
182 |
| -#undef __CLC_INTN |
183 | 227 |
|
184 | 228 | #define __CLC_GENTYPE half4
|
185 |
| -#define __CLC_INTN int4 |
186 | 229 | #define __CLC_BIT_INTN short4
|
187 | 230 | #define __CLC_VECSIZE 4
|
188 | 231 | #include __CLC_BODY
|
189 | 232 | #undef __CLC_VECSIZE
|
190 | 233 | #undef __CLC_GENTYPE
|
191 | 234 | #undef __CLC_BIT_INTN
|
192 |
| -#undef __CLC_INTN |
193 | 235 |
|
194 | 236 | #define __CLC_GENTYPE half8
|
195 |
| -#define __CLC_INTN int8 |
196 | 237 | #define __CLC_BIT_INTN short8
|
197 | 238 | #define __CLC_VECSIZE 8
|
198 | 239 | #include __CLC_BODY
|
199 | 240 | #undef __CLC_VECSIZE
|
200 | 241 | #undef __CLC_GENTYPE
|
201 | 242 | #undef __CLC_BIT_INTN
|
202 |
| -#undef __CLC_INTN |
203 | 243 |
|
204 | 244 | #define __CLC_GENTYPE half16
|
205 |
| -#define __CLC_INTN int16 |
206 | 245 | #define __CLC_BIT_INTN short16
|
207 | 246 | #define __CLC_VECSIZE 16
|
208 | 247 | #include __CLC_BODY
|
209 | 248 | #undef __CLC_VECSIZE
|
210 | 249 | #undef __CLC_GENTYPE
|
211 | 250 | #undef __CLC_BIT_INTN
|
212 |
| -#undef __CLC_INTN |
213 | 251 |
|
| 252 | +#undef __CLC_U_GENTYPE |
| 253 | +#undef __CLC_S_GENTYPE |
214 | 254 | #undef __CLC_FP_LIT
|
215 | 255 | #undef __CLC_FPSIZE
|
216 | 256 | #undef __CLC_SCALAR_GENTYPE
|
217 | 257 | #endif
|
218 | 258 | #endif
|
219 | 259 |
|
220 | 260 | #undef __CLC_BODY
|
| 261 | + |
| 262 | +#undef __CLC_AS_U_GENTYPE |
| 263 | +#undef __CLC_AS_S_GENTYPE |
| 264 | + |
| 265 | +#undef __CLC_CONVERT_U_GENTYPE |
| 266 | +#undef __CLC_CONVERT_S_GENTYPE |
| 267 | + |
| 268 | +#undef __CLC_AS_CHARN |
| 269 | +#undef __CLC_AS_SHORTN |
| 270 | +#undef __CLC_AS_INTN |
| 271 | +#undef __CLC_AS_LONGN |
| 272 | + |
| 273 | +#undef __CLC_AS_UCHARN |
| 274 | +#undef __CLC_AS_USHORTN |
| 275 | +#undef __CLC_AS_UINTN |
| 276 | +#undef __CLC_AS_ULONGN |
| 277 | + |
| 278 | +#undef __CLC_CONVERT_HALFN |
| 279 | +#undef __CLC_CONVERT_FLOATN |
| 280 | +#undef __CLC_CONVERT_DOUBLEN |
| 281 | + |
| 282 | +#undef __CLC_CONVERT_CHARN |
| 283 | +#undef __CLC_CONVERT_SHORTN |
| 284 | +#undef __CLC_CONVERT_INTN |
| 285 | +#undef __CLC_CONVERT_LONGN |
| 286 | + |
| 287 | +#undef __CLC_CONVERT_UCHARN |
| 288 | +#undef __CLC_CONVERT_USHORTN |
| 289 | +#undef __CLC_CONVERT_UINTN |
| 290 | +#undef __CLC_CONVERT_ULONGN |
| 291 | + |
| 292 | +#undef __CLC_ULONGN |
| 293 | +#undef __CLC_UINTN |
| 294 | +#undef __CLC_USHORTN |
| 295 | +#undef __CLC_UCHARN |
| 296 | + |
| 297 | +#undef __CLC_LONGN |
| 298 | +#undef __CLC_INTN |
| 299 | +#undef __CLC_SHORTN |
| 300 | +#undef __CLC_CHARN |
| 301 | + |
| 302 | +#undef __CLC_DOUBLEN |
| 303 | +#undef __CLC_FLOATN |
| 304 | +#undef __CLC_HALFN |
| 305 | + |
| 306 | +#undef __CLC_AS_GENTYPE |
| 307 | +#undef __CLC_CONVERT_GENTYPE |
0 commit comments