blob: c2f408fed59fc42f9c2573061704610498890b40 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/**********************************************************************************
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01002 * Copyright (c) 2008-2018 The Khronos Group Inc.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and/or associated documentation files (the
6 * "Materials"), to deal in the Materials without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Materials, and to
9 * permit persons to whom the Materials are furnished to do so, subject to
10 * the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Materials.
14 *
Pablo Telloe86a09f2018-01-11 15:44:48 +000015 * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
16 * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
17 * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
18 * https://www.khronos.org/registry/
19 *
Anthony Barbier6ff3b192017-09-04 18:44:23 +010020 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
27 **********************************************************************************/
28
Anthony Barbier6ff3b192017-09-04 18:44:23 +010029#ifndef __CL_PLATFORM_H
30#define __CL_PLATFORM_H
31
32#ifdef __APPLE__
Anthony Barbier8b2fdc92018-08-09 11:42:38 +010033 #include <OpenCL/cl_version.h>
34
Anthony Barbier6ff3b192017-09-04 18:44:23 +010035 /* Contains #defines for AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER below */
36 #include <AvailabilityMacros.h>
Anthony Barbier8b2fdc92018-08-09 11:42:38 +010037#else
38 #include <CL/cl_version.h>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010039#endif
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45#if defined(_WIN32)
46 #define CL_API_ENTRY
47 #define CL_API_CALL __stdcall
48 #define CL_CALLBACK __stdcall
49#else
50 #define CL_API_ENTRY
51 #define CL_API_CALL
52 #define CL_CALLBACK
53#endif
54
Pablo Telloe86a09f2018-01-11 15:44:48 +000055/*
56 * Deprecation flags refer to the last version of the header in which the
57 * feature was not deprecated.
58 *
59 * E.g. VERSION_1_1_DEPRECATED means the feature is present in 1.1 without
60 * deprecation but is deprecated in versions later than 1.1.
61 */
62
Anthony Barbier6ff3b192017-09-04 18:44:23 +010063#ifdef __APPLE__
64 #define CL_EXTENSION_WEAK_LINK __attribute__((weak_import))
65 #define CL_API_SUFFIX__VERSION_1_0 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
66 #define CL_EXT_SUFFIX__VERSION_1_0 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
67 #define CL_API_SUFFIX__VERSION_1_1 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
68 #define GCL_API_SUFFIX__VERSION_1_1 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
69 #define CL_EXT_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
70 #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7
Anthony Barbier8b2fdc92018-08-09 11:42:38 +010071
Anthony Barbier6ff3b192017-09-04 18:44:23 +010072 #ifdef AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
73 #define CL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
74 #define GCL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
75 #define CL_EXT_SUFFIX__VERSION_1_2 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
76 #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
77 #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8
78 #else
79 #warning This path should never happen outside of internal operating system development. AvailabilityMacros do not function correctly here!
80 #define CL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
81 #define GCL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
82 #define CL_EXT_SUFFIX__VERSION_1_2 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
83 #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
84 #endif
85#else
Anthony Barbier8b2fdc92018-08-09 11:42:38 +010086 #define CL_EXTENSION_WEAK_LINK
Anthony Barbier6ff3b192017-09-04 18:44:23 +010087 #define CL_API_SUFFIX__VERSION_1_0
88 #define CL_EXT_SUFFIX__VERSION_1_0
89 #define CL_API_SUFFIX__VERSION_1_1
90 #define CL_EXT_SUFFIX__VERSION_1_1
91 #define CL_API_SUFFIX__VERSION_1_2
92 #define CL_EXT_SUFFIX__VERSION_1_2
Pablo Telloe86a09f2018-01-11 15:44:48 +000093 #define CL_API_SUFFIX__VERSION_2_0
94 #define CL_EXT_SUFFIX__VERSION_2_0
95 #define CL_API_SUFFIX__VERSION_2_1
96 #define CL_EXT_SUFFIX__VERSION_2_1
97 #define CL_API_SUFFIX__VERSION_2_2
98 #define CL_EXT_SUFFIX__VERSION_2_2
Anthony Barbier8b2fdc92018-08-09 11:42:38 +010099
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100100 #ifdef __GNUC__
101 #ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS
102 #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100103 #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100104 #else
105 #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED __attribute__((deprecated))
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100106 #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100107 #endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100108
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100109 #ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100110 #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
111 #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100112 #else
113 #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED __attribute__((deprecated))
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100114 #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100115 #endif
Pablo Telloe86a09f2018-01-11 15:44:48 +0000116
117 #ifdef CL_USE_DEPRECATED_OPENCL_1_2_APIS
118 #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
119 #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED
120 #else
121 #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED __attribute__((deprecated))
122 #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED
123 #endif
124
125 #ifdef CL_USE_DEPRECATED_OPENCL_2_0_APIS
126 #define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED
127 #define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED
128 #else
129 #define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED __attribute__((deprecated))
130 #define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED
131 #endif
132
133 #ifdef CL_USE_DEPRECATED_OPENCL_2_1_APIS
134 #define CL_EXT_SUFFIX__VERSION_2_1_DEPRECATED
135 #define CL_EXT_PREFIX__VERSION_2_1_DEPRECATED
136 #else
137 #define CL_EXT_SUFFIX__VERSION_2_1_DEPRECATED __attribute__((deprecated))
138 #define CL_EXT_PREFIX__VERSION_2_1_DEPRECATED
139 #endif
140 #elif defined(_WIN32)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100141 #ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS
Pablo Telloe86a09f2018-01-11 15:44:48 +0000142 #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100143 #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100144 #else
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100145 #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
146 #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED __declspec(deprecated)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100147 #endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100148
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100149 #ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS
150 #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100151 #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100152 #else
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100153 #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
154 #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED __declspec(deprecated)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100155 #endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100156
Pablo Telloe86a09f2018-01-11 15:44:48 +0000157 #ifdef CL_USE_DEPRECATED_OPENCL_1_2_APIS
158 #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
159 #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED
160 #else
161 #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
162 #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED __declspec(deprecated)
163 #endif
164
165 #ifdef CL_USE_DEPRECATED_OPENCL_2_0_APIS
166 #define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED
167 #define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED
168 #else
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100169 #define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED
Pablo Telloe86a09f2018-01-11 15:44:48 +0000170 #define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED __declspec(deprecated)
171 #endif
172
173 #ifdef CL_USE_DEPRECATED_OPENCL_2_1_APIS
174 #define CL_EXT_SUFFIX__VERSION_2_1_DEPRECATED
175 #define CL_EXT_PREFIX__VERSION_2_1_DEPRECATED
176 #else
177 #define CL_EXT_SUFFIX__VERSION_2_1_DEPRECATED
178 #define CL_EXT_PREFIX__VERSION_2_1_DEPRECATED __declspec(deprecated)
179 #endif
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100180 #else
181 #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
182 #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100183
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100184 #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
185 #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100186
Pablo Telloe86a09f2018-01-11 15:44:48 +0000187 #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
188 #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED
189
190 #define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED
191 #define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED
192
193 #define CL_EXT_SUFFIX__VERSION_2_1_DEPRECATED
194 #define CL_EXT_PREFIX__VERSION_2_1_DEPRECATED
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100195 #endif
196#endif
197
198#if (defined (_WIN32) && defined(_MSC_VER))
199
200/* scalar types */
201typedef signed __int8 cl_char;
202typedef unsigned __int8 cl_uchar;
203typedef signed __int16 cl_short;
204typedef unsigned __int16 cl_ushort;
205typedef signed __int32 cl_int;
206typedef unsigned __int32 cl_uint;
207typedef signed __int64 cl_long;
208typedef unsigned __int64 cl_ulong;
209
210typedef unsigned __int16 cl_half;
211typedef float cl_float;
212typedef double cl_double;
213
214/* Macro names and corresponding values defined by OpenCL */
215#define CL_CHAR_BIT 8
216#define CL_SCHAR_MAX 127
217#define CL_SCHAR_MIN (-127-1)
218#define CL_CHAR_MAX CL_SCHAR_MAX
219#define CL_CHAR_MIN CL_SCHAR_MIN
220#define CL_UCHAR_MAX 255
221#define CL_SHRT_MAX 32767
222#define CL_SHRT_MIN (-32767-1)
223#define CL_USHRT_MAX 65535
224#define CL_INT_MAX 2147483647
225#define CL_INT_MIN (-2147483647-1)
226#define CL_UINT_MAX 0xffffffffU
227#define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL)
228#define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL)
229#define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL)
230
231#define CL_FLT_DIG 6
232#define CL_FLT_MANT_DIG 24
233#define CL_FLT_MAX_10_EXP +38
234#define CL_FLT_MAX_EXP +128
235#define CL_FLT_MIN_10_EXP -37
236#define CL_FLT_MIN_EXP -125
237#define CL_FLT_RADIX 2
238#define CL_FLT_MAX 340282346638528859811704183484516925440.0f
239#define CL_FLT_MIN 1.175494350822287507969e-38f
Pablo Telloe86a09f2018-01-11 15:44:48 +0000240#define CL_FLT_EPSILON 1.1920928955078125e-7f
241
242#define CL_HALF_DIG 3
243#define CL_HALF_MANT_DIG 11
244#define CL_HALF_MAX_10_EXP +4
245#define CL_HALF_MAX_EXP +16
246#define CL_HALF_MIN_10_EXP -4
247#define CL_HALF_MIN_EXP -13
248#define CL_HALF_RADIX 2
249#define CL_HALF_MAX 65504.0f
250#define CL_HALF_MIN 6.103515625e-05f
251#define CL_HALF_EPSILON 9.765625e-04f
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100252
253#define CL_DBL_DIG 15
254#define CL_DBL_MANT_DIG 53
255#define CL_DBL_MAX_10_EXP +308
256#define CL_DBL_MAX_EXP +1024
257#define CL_DBL_MIN_10_EXP -307
258#define CL_DBL_MIN_EXP -1021
259#define CL_DBL_RADIX 2
Pablo Telloe86a09f2018-01-11 15:44:48 +0000260#define CL_DBL_MAX 1.7976931348623158e+308
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100261#define CL_DBL_MIN 2.225073858507201383090e-308
262#define CL_DBL_EPSILON 2.220446049250313080847e-16
263
Pablo Telloe86a09f2018-01-11 15:44:48 +0000264#define CL_M_E 2.7182818284590452354
265#define CL_M_LOG2E 1.4426950408889634074
266#define CL_M_LOG10E 0.43429448190325182765
267#define CL_M_LN2 0.69314718055994530942
268#define CL_M_LN10 2.30258509299404568402
269#define CL_M_PI 3.14159265358979323846
270#define CL_M_PI_2 1.57079632679489661923
271#define CL_M_PI_4 0.78539816339744830962
272#define CL_M_1_PI 0.31830988618379067154
273#define CL_M_2_PI 0.63661977236758134308
274#define CL_M_2_SQRTPI 1.12837916709551257390
275#define CL_M_SQRT2 1.41421356237309504880
276#define CL_M_SQRT1_2 0.70710678118654752440
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100277
Pablo Telloe86a09f2018-01-11 15:44:48 +0000278#define CL_M_E_F 2.718281828f
279#define CL_M_LOG2E_F 1.442695041f
280#define CL_M_LOG10E_F 0.434294482f
281#define CL_M_LN2_F 0.693147181f
282#define CL_M_LN10_F 2.302585093f
283#define CL_M_PI_F 3.141592654f
284#define CL_M_PI_2_F 1.570796327f
285#define CL_M_PI_4_F 0.785398163f
286#define CL_M_1_PI_F 0.318309886f
287#define CL_M_2_PI_F 0.636619772f
288#define CL_M_2_SQRTPI_F 1.128379167f
289#define CL_M_SQRT2_F 1.414213562f
290#define CL_M_SQRT1_2_F 0.707106781f
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100291
292#define CL_NAN (CL_INFINITY - CL_INFINITY)
293#define CL_HUGE_VALF ((cl_float) 1e50)
294#define CL_HUGE_VAL ((cl_double) 1e500)
295#define CL_MAXFLOAT CL_FLT_MAX
296#define CL_INFINITY CL_HUGE_VALF
297
298#else
299
300#include <stdint.h>
301
302/* scalar types */
303typedef int8_t cl_char;
304typedef uint8_t cl_uchar;
305typedef int16_t cl_short __attribute__((aligned(2)));
306typedef uint16_t cl_ushort __attribute__((aligned(2)));
307typedef int32_t cl_int __attribute__((aligned(4)));
308typedef uint32_t cl_uint __attribute__((aligned(4)));
309typedef int64_t cl_long __attribute__((aligned(8)));
310typedef uint64_t cl_ulong __attribute__((aligned(8)));
311
312typedef uint16_t cl_half __attribute__((aligned(2)));
313typedef float cl_float __attribute__((aligned(4)));
314typedef double cl_double __attribute__((aligned(8)));
315
316/* Macro names and corresponding values defined by OpenCL */
317#define CL_CHAR_BIT 8
318#define CL_SCHAR_MAX 127
319#define CL_SCHAR_MIN (-127-1)
320#define CL_CHAR_MAX CL_SCHAR_MAX
321#define CL_CHAR_MIN CL_SCHAR_MIN
322#define CL_UCHAR_MAX 255
323#define CL_SHRT_MAX 32767
324#define CL_SHRT_MIN (-32767-1)
325#define CL_USHRT_MAX 65535
326#define CL_INT_MAX 2147483647
327#define CL_INT_MIN (-2147483647-1)
328#define CL_UINT_MAX 0xffffffffU
329#define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL)
330#define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL)
331#define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL)
332
333#define CL_FLT_DIG 6
334#define CL_FLT_MANT_DIG 24
335#define CL_FLT_MAX_10_EXP +38
336#define CL_FLT_MAX_EXP +128
337#define CL_FLT_MIN_10_EXP -37
338#define CL_FLT_MIN_EXP -125
339#define CL_FLT_RADIX 2
Pablo Telloe86a09f2018-01-11 15:44:48 +0000340#define CL_FLT_MAX 340282346638528859811704183484516925440.0f
341#define CL_FLT_MIN 1.175494350822287507969e-38f
342#define CL_FLT_EPSILON 1.1920928955078125e-7f
343
344#define CL_HALF_DIG 3
345#define CL_HALF_MANT_DIG 11
346#define CL_HALF_MAX_10_EXP +4
347#define CL_HALF_MAX_EXP +16
348#define CL_HALF_MIN_10_EXP -4
349#define CL_HALF_MIN_EXP -13
350#define CL_HALF_RADIX 2
351#define CL_HALF_MAX 65504.0f
352#define CL_HALF_MIN 6.103515625e-05f
353#define CL_HALF_EPSILON 9.765625e-04f
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100354
355#define CL_DBL_DIG 15
356#define CL_DBL_MANT_DIG 53
357#define CL_DBL_MAX_10_EXP +308
358#define CL_DBL_MAX_EXP +1024
359#define CL_DBL_MIN_10_EXP -307
360#define CL_DBL_MIN_EXP -1021
361#define CL_DBL_RADIX 2
Pablo Telloe86a09f2018-01-11 15:44:48 +0000362#define CL_DBL_MAX 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0
363#define CL_DBL_MIN 2.225073858507201383090e-308
364#define CL_DBL_EPSILON 2.220446049250313080847e-16
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100365
Pablo Telloe86a09f2018-01-11 15:44:48 +0000366#define CL_M_E 2.7182818284590452354
367#define CL_M_LOG2E 1.4426950408889634074
368#define CL_M_LOG10E 0.43429448190325182765
369#define CL_M_LN2 0.69314718055994530942
370#define CL_M_LN10 2.30258509299404568402
371#define CL_M_PI 3.14159265358979323846
372#define CL_M_PI_2 1.57079632679489661923
373#define CL_M_PI_4 0.78539816339744830962
374#define CL_M_1_PI 0.31830988618379067154
375#define CL_M_2_PI 0.63661977236758134308
376#define CL_M_2_SQRTPI 1.12837916709551257390
377#define CL_M_SQRT2 1.41421356237309504880
378#define CL_M_SQRT1_2 0.70710678118654752440
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100379
Pablo Telloe86a09f2018-01-11 15:44:48 +0000380#define CL_M_E_F 2.718281828f
381#define CL_M_LOG2E_F 1.442695041f
382#define CL_M_LOG10E_F 0.434294482f
383#define CL_M_LN2_F 0.693147181f
384#define CL_M_LN10_F 2.302585093f
385#define CL_M_PI_F 3.141592654f
386#define CL_M_PI_2_F 1.570796327f
387#define CL_M_PI_4_F 0.785398163f
388#define CL_M_1_PI_F 0.318309886f
389#define CL_M_2_PI_F 0.636619772f
390#define CL_M_2_SQRTPI_F 1.128379167f
391#define CL_M_SQRT2_F 1.414213562f
392#define CL_M_SQRT1_2_F 0.707106781f
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100393
394#if defined( __GNUC__ )
395 #define CL_HUGE_VALF __builtin_huge_valf()
396 #define CL_HUGE_VAL __builtin_huge_val()
397 #define CL_NAN __builtin_nanf( "" )
398#else
399 #define CL_HUGE_VALF ((cl_float) 1e50)
400 #define CL_HUGE_VAL ((cl_double) 1e500)
401 float nanf( const char * );
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100402 #define CL_NAN nanf( "" )
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100403#endif
404#define CL_MAXFLOAT CL_FLT_MAX
405#define CL_INFINITY CL_HUGE_VALF
406
407#endif
408
409#include <stddef.h>
410
411/* Mirror types to GL types. Mirror types allow us to avoid deciding which 87s to load based on whether we are using GL or GLES here. */
412typedef unsigned int cl_GLuint;
413typedef int cl_GLint;
414typedef unsigned int cl_GLenum;
415
416/*
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100417 * Vector types
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100418 *
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100419 * Note: OpenCL requires that all types be naturally aligned.
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100420 * This means that vector types must be naturally aligned.
421 * For example, a vector of four floats must be aligned to
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100422 * a 16 byte boundary (calculated as 4 * the natural 4-byte
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100423 * alignment of the float). The alignment qualifiers here
424 * will only function properly if your compiler supports them
425 * and if you don't actively work to defeat them. For example,
426 * in order for a cl_float4 to be 16 byte aligned in a struct,
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100427 * the start of the struct must itself be 16-byte aligned.
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100428 *
429 * Maintaining proper alignment is the user's responsibility.
430 */
431
432/* Define basic vector types */
433#if defined( __VEC__ )
434 #include <altivec.h> /* may be omitted depending on compiler. AltiVec spec provides no way to detect whether the header is required. */
435 typedef vector unsigned char __cl_uchar16;
436 typedef vector signed char __cl_char16;
437 typedef vector unsigned short __cl_ushort8;
438 typedef vector signed short __cl_short8;
439 typedef vector unsigned int __cl_uint4;
440 typedef vector signed int __cl_int4;
441 typedef vector float __cl_float4;
442 #define __CL_UCHAR16__ 1
443 #define __CL_CHAR16__ 1
444 #define __CL_USHORT8__ 1
445 #define __CL_SHORT8__ 1
446 #define __CL_UINT4__ 1
447 #define __CL_INT4__ 1
448 #define __CL_FLOAT4__ 1
449#endif
450
451#if defined( __SSE__ )
452 #if defined( __MINGW64__ )
453 #include <intrin.h>
454 #else
455 #include <xmmintrin.h>
456 #endif
457 #if defined( __GNUC__ )
458 typedef float __cl_float4 __attribute__((vector_size(16)));
459 #else
460 typedef __m128 __cl_float4;
461 #endif
462 #define __CL_FLOAT4__ 1
463#endif
464
465#if defined( __SSE2__ )
466 #if defined( __MINGW64__ )
467 #include <intrin.h>
468 #else
469 #include <emmintrin.h>
470 #endif
471 #if defined( __GNUC__ )
472 typedef cl_uchar __cl_uchar16 __attribute__((vector_size(16)));
473 typedef cl_char __cl_char16 __attribute__((vector_size(16)));
474 typedef cl_ushort __cl_ushort8 __attribute__((vector_size(16)));
475 typedef cl_short __cl_short8 __attribute__((vector_size(16)));
476 typedef cl_uint __cl_uint4 __attribute__((vector_size(16)));
477 typedef cl_int __cl_int4 __attribute__((vector_size(16)));
478 typedef cl_ulong __cl_ulong2 __attribute__((vector_size(16)));
479 typedef cl_long __cl_long2 __attribute__((vector_size(16)));
480 typedef cl_double __cl_double2 __attribute__((vector_size(16)));
481 #else
482 typedef __m128i __cl_uchar16;
483 typedef __m128i __cl_char16;
484 typedef __m128i __cl_ushort8;
485 typedef __m128i __cl_short8;
486 typedef __m128i __cl_uint4;
487 typedef __m128i __cl_int4;
488 typedef __m128i __cl_ulong2;
489 typedef __m128i __cl_long2;
490 typedef __m128d __cl_double2;
491 #endif
492 #define __CL_UCHAR16__ 1
493 #define __CL_CHAR16__ 1
494 #define __CL_USHORT8__ 1
495 #define __CL_SHORT8__ 1
496 #define __CL_INT4__ 1
497 #define __CL_UINT4__ 1
498 #define __CL_ULONG2__ 1
499 #define __CL_LONG2__ 1
500 #define __CL_DOUBLE2__ 1
501#endif
502
503#if defined( __MMX__ )
504 #include <mmintrin.h>
505 #if defined( __GNUC__ )
506 typedef cl_uchar __cl_uchar8 __attribute__((vector_size(8)));
507 typedef cl_char __cl_char8 __attribute__((vector_size(8)));
508 typedef cl_ushort __cl_ushort4 __attribute__((vector_size(8)));
509 typedef cl_short __cl_short4 __attribute__((vector_size(8)));
510 typedef cl_uint __cl_uint2 __attribute__((vector_size(8)));
511 typedef cl_int __cl_int2 __attribute__((vector_size(8)));
512 typedef cl_ulong __cl_ulong1 __attribute__((vector_size(8)));
513 typedef cl_long __cl_long1 __attribute__((vector_size(8)));
514 typedef cl_float __cl_float2 __attribute__((vector_size(8)));
515 #else
516 typedef __m64 __cl_uchar8;
517 typedef __m64 __cl_char8;
518 typedef __m64 __cl_ushort4;
519 typedef __m64 __cl_short4;
520 typedef __m64 __cl_uint2;
521 typedef __m64 __cl_int2;
522 typedef __m64 __cl_ulong1;
523 typedef __m64 __cl_long1;
524 typedef __m64 __cl_float2;
525 #endif
526 #define __CL_UCHAR8__ 1
527 #define __CL_CHAR8__ 1
528 #define __CL_USHORT4__ 1
529 #define __CL_SHORT4__ 1
530 #define __CL_INT2__ 1
531 #define __CL_UINT2__ 1
532 #define __CL_ULONG1__ 1
533 #define __CL_LONG1__ 1
534 #define __CL_FLOAT2__ 1
535#endif
536
537#if defined( __AVX__ )
538 #if defined( __MINGW64__ )
539 #include <intrin.h>
540 #else
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100541 #include <immintrin.h>
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100542 #endif
543 #if defined( __GNUC__ )
544 typedef cl_float __cl_float8 __attribute__((vector_size(32)));
545 typedef cl_double __cl_double4 __attribute__((vector_size(32)));
546 #else
547 typedef __m256 __cl_float8;
548 typedef __m256d __cl_double4;
549 #endif
550 #define __CL_FLOAT8__ 1
551 #define __CL_DOUBLE4__ 1
552#endif
553
Pablo Telloe86a09f2018-01-11 15:44:48 +0000554/* Define capabilities for anonymous struct members. */
555#if !defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
556#define __CL_HAS_ANON_STRUCT__ 1
557#define __CL_ANON_STRUCT__
558#elif defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
559#define __CL_HAS_ANON_STRUCT__ 1
560#define __CL_ANON_STRUCT__ __extension__
561#elif defined( _WIN32) && defined(_MSC_VER)
562 #if _MSC_VER >= 1500
563 /* Microsoft Developer Studio 2008 supports anonymous structs, but
564 * complains by default. */
565 #define __CL_HAS_ANON_STRUCT__ 1
566 #define __CL_ANON_STRUCT__
567 /* Disable warning C4201: nonstandard extension used : nameless
568 * struct/union */
569 #pragma warning( push )
570 #pragma warning( disable : 4201 )
571 #endif
572#else
573#define __CL_HAS_ANON_STRUCT__ 0
574#define __CL_ANON_STRUCT__
575#endif
576
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100577/* Define alignment keys */
578#if defined( __GNUC__ )
579 #define CL_ALIGNED(_x) __attribute__ ((aligned(_x)))
580#elif defined( _WIN32) && (_MSC_VER)
581 /* Alignment keys neutered on windows because MSVC can't swallow function arguments with alignment requirements */
582 /* http://msdn.microsoft.com/en-us/library/373ak2y1%28VS.71%29.aspx */
583 /* #include <crtdefs.h> */
584 /* #define CL_ALIGNED(_x) _CRT_ALIGN(_x) */
585 #define CL_ALIGNED(_x)
586#else
587 #warning Need to implement some method to align data here
588 #define CL_ALIGNED(_x)
589#endif
590
591/* Indicate whether .xyzw, .s0123 and .hi.lo are supported */
Pablo Telloe86a09f2018-01-11 15:44:48 +0000592#if __CL_HAS_ANON_STRUCT__
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100593 /* .xyzw and .s0123...{f|F} are supported */
594 #define CL_HAS_NAMED_VECTOR_FIELDS 1
595 /* .hi and .lo are supported */
596 #define CL_HAS_HI_LO_VECTOR_FIELDS 1
597#endif
598
599/* Define cl_vector types */
600
601/* ---- cl_charn ---- */
602typedef union
603{
604 cl_char CL_ALIGNED(2) s[2];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000605#if __CL_HAS_ANON_STRUCT__
606 __CL_ANON_STRUCT__ struct{ cl_char x, y; };
607 __CL_ANON_STRUCT__ struct{ cl_char s0, s1; };
608 __CL_ANON_STRUCT__ struct{ cl_char lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100609#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100610#if defined( __CL_CHAR2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100611 __cl_char2 v2;
612#endif
613}cl_char2;
614
615typedef union
616{
617 cl_char CL_ALIGNED(4) s[4];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000618#if __CL_HAS_ANON_STRUCT__
619 __CL_ANON_STRUCT__ struct{ cl_char x, y, z, w; };
620 __CL_ANON_STRUCT__ struct{ cl_char s0, s1, s2, s3; };
621 __CL_ANON_STRUCT__ struct{ cl_char2 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100622#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100623#if defined( __CL_CHAR2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100624 __cl_char2 v2[2];
625#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100626#if defined( __CL_CHAR4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100627 __cl_char4 v4;
628#endif
629}cl_char4;
630
631/* cl_char3 is identical in size, alignment and behavior to cl_char4. See section 6.1.5. */
632typedef cl_char4 cl_char3;
633
634typedef union
635{
636 cl_char CL_ALIGNED(8) s[8];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000637#if __CL_HAS_ANON_STRUCT__
638 __CL_ANON_STRUCT__ struct{ cl_char x, y, z, w; };
639 __CL_ANON_STRUCT__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7; };
640 __CL_ANON_STRUCT__ struct{ cl_char4 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100641#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100642#if defined( __CL_CHAR2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100643 __cl_char2 v2[4];
644#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100645#if defined( __CL_CHAR4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100646 __cl_char4 v4[2];
647#endif
648#if defined( __CL_CHAR8__ )
649 __cl_char8 v8;
650#endif
651}cl_char8;
652
653typedef union
654{
655 cl_char CL_ALIGNED(16) s[16];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000656#if __CL_HAS_ANON_STRUCT__
657 __CL_ANON_STRUCT__ struct{ cl_char x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
658 __CL_ANON_STRUCT__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
659 __CL_ANON_STRUCT__ struct{ cl_char8 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100660#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100661#if defined( __CL_CHAR2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100662 __cl_char2 v2[8];
663#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100664#if defined( __CL_CHAR4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100665 __cl_char4 v4[4];
666#endif
667#if defined( __CL_CHAR8__ )
668 __cl_char8 v8[2];
669#endif
670#if defined( __CL_CHAR16__ )
671 __cl_char16 v16;
672#endif
673}cl_char16;
674
675
676/* ---- cl_ucharn ---- */
677typedef union
678{
679 cl_uchar CL_ALIGNED(2) s[2];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000680#if __CL_HAS_ANON_STRUCT__
681 __CL_ANON_STRUCT__ struct{ cl_uchar x, y; };
682 __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1; };
683 __CL_ANON_STRUCT__ struct{ cl_uchar lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100684#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100685#if defined( __cl_uchar2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100686 __cl_uchar2 v2;
687#endif
688}cl_uchar2;
689
690typedef union
691{
692 cl_uchar CL_ALIGNED(4) s[4];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000693#if __CL_HAS_ANON_STRUCT__
694 __CL_ANON_STRUCT__ struct{ cl_uchar x, y, z, w; };
695 __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1, s2, s3; };
696 __CL_ANON_STRUCT__ struct{ cl_uchar2 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100697#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100698#if defined( __CL_UCHAR2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100699 __cl_uchar2 v2[2];
700#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100701#if defined( __CL_UCHAR4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100702 __cl_uchar4 v4;
703#endif
704}cl_uchar4;
705
706/* cl_uchar3 is identical in size, alignment and behavior to cl_uchar4. See section 6.1.5. */
707typedef cl_uchar4 cl_uchar3;
708
709typedef union
710{
711 cl_uchar CL_ALIGNED(8) s[8];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000712#if __CL_HAS_ANON_STRUCT__
713 __CL_ANON_STRUCT__ struct{ cl_uchar x, y, z, w; };
714 __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7; };
715 __CL_ANON_STRUCT__ struct{ cl_uchar4 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100716#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100717#if defined( __CL_UCHAR2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100718 __cl_uchar2 v2[4];
719#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100720#if defined( __CL_UCHAR4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100721 __cl_uchar4 v4[2];
722#endif
723#if defined( __CL_UCHAR8__ )
724 __cl_uchar8 v8;
725#endif
726}cl_uchar8;
727
728typedef union
729{
730 cl_uchar CL_ALIGNED(16) s[16];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000731#if __CL_HAS_ANON_STRUCT__
732 __CL_ANON_STRUCT__ struct{ cl_uchar x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
733 __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
734 __CL_ANON_STRUCT__ struct{ cl_uchar8 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100735#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100736#if defined( __CL_UCHAR2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100737 __cl_uchar2 v2[8];
738#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100739#if defined( __CL_UCHAR4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100740 __cl_uchar4 v4[4];
741#endif
742#if defined( __CL_UCHAR8__ )
743 __cl_uchar8 v8[2];
744#endif
745#if defined( __CL_UCHAR16__ )
746 __cl_uchar16 v16;
747#endif
748}cl_uchar16;
749
750
751/* ---- cl_shortn ---- */
752typedef union
753{
754 cl_short CL_ALIGNED(4) s[2];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000755#if __CL_HAS_ANON_STRUCT__
756 __CL_ANON_STRUCT__ struct{ cl_short x, y; };
757 __CL_ANON_STRUCT__ struct{ cl_short s0, s1; };
758 __CL_ANON_STRUCT__ struct{ cl_short lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100759#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100760#if defined( __CL_SHORT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100761 __cl_short2 v2;
762#endif
763}cl_short2;
764
765typedef union
766{
767 cl_short CL_ALIGNED(8) s[4];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000768#if __CL_HAS_ANON_STRUCT__
769 __CL_ANON_STRUCT__ struct{ cl_short x, y, z, w; };
770 __CL_ANON_STRUCT__ struct{ cl_short s0, s1, s2, s3; };
771 __CL_ANON_STRUCT__ struct{ cl_short2 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100772#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100773#if defined( __CL_SHORT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100774 __cl_short2 v2[2];
775#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100776#if defined( __CL_SHORT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100777 __cl_short4 v4;
778#endif
779}cl_short4;
780
781/* cl_short3 is identical in size, alignment and behavior to cl_short4. See section 6.1.5. */
782typedef cl_short4 cl_short3;
783
784typedef union
785{
786 cl_short CL_ALIGNED(16) s[8];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000787#if __CL_HAS_ANON_STRUCT__
788 __CL_ANON_STRUCT__ struct{ cl_short x, y, z, w; };
789 __CL_ANON_STRUCT__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7; };
790 __CL_ANON_STRUCT__ struct{ cl_short4 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100791#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100792#if defined( __CL_SHORT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100793 __cl_short2 v2[4];
794#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100795#if defined( __CL_SHORT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100796 __cl_short4 v4[2];
797#endif
798#if defined( __CL_SHORT8__ )
799 __cl_short8 v8;
800#endif
801}cl_short8;
802
803typedef union
804{
805 cl_short CL_ALIGNED(32) s[16];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000806#if __CL_HAS_ANON_STRUCT__
807 __CL_ANON_STRUCT__ struct{ cl_short x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
808 __CL_ANON_STRUCT__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
809 __CL_ANON_STRUCT__ struct{ cl_short8 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100810#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100811#if defined( __CL_SHORT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100812 __cl_short2 v2[8];
813#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100814#if defined( __CL_SHORT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100815 __cl_short4 v4[4];
816#endif
817#if defined( __CL_SHORT8__ )
818 __cl_short8 v8[2];
819#endif
820#if defined( __CL_SHORT16__ )
821 __cl_short16 v16;
822#endif
823}cl_short16;
824
825
826/* ---- cl_ushortn ---- */
827typedef union
828{
829 cl_ushort CL_ALIGNED(4) s[2];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000830#if __CL_HAS_ANON_STRUCT__
831 __CL_ANON_STRUCT__ struct{ cl_ushort x, y; };
832 __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1; };
833 __CL_ANON_STRUCT__ struct{ cl_ushort lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100834#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100835#if defined( __CL_USHORT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100836 __cl_ushort2 v2;
837#endif
838}cl_ushort2;
839
840typedef union
841{
842 cl_ushort CL_ALIGNED(8) s[4];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000843#if __CL_HAS_ANON_STRUCT__
844 __CL_ANON_STRUCT__ struct{ cl_ushort x, y, z, w; };
845 __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1, s2, s3; };
846 __CL_ANON_STRUCT__ struct{ cl_ushort2 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100847#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100848#if defined( __CL_USHORT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100849 __cl_ushort2 v2[2];
850#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100851#if defined( __CL_USHORT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100852 __cl_ushort4 v4;
853#endif
854}cl_ushort4;
855
856/* cl_ushort3 is identical in size, alignment and behavior to cl_ushort4. See section 6.1.5. */
857typedef cl_ushort4 cl_ushort3;
858
859typedef union
860{
861 cl_ushort CL_ALIGNED(16) s[8];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000862#if __CL_HAS_ANON_STRUCT__
863 __CL_ANON_STRUCT__ struct{ cl_ushort x, y, z, w; };
864 __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7; };
865 __CL_ANON_STRUCT__ struct{ cl_ushort4 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100866#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100867#if defined( __CL_USHORT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100868 __cl_ushort2 v2[4];
869#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100870#if defined( __CL_USHORT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100871 __cl_ushort4 v4[2];
872#endif
873#if defined( __CL_USHORT8__ )
874 __cl_ushort8 v8;
875#endif
876}cl_ushort8;
877
878typedef union
879{
880 cl_ushort CL_ALIGNED(32) s[16];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000881#if __CL_HAS_ANON_STRUCT__
882 __CL_ANON_STRUCT__ struct{ cl_ushort x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
883 __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
884 __CL_ANON_STRUCT__ struct{ cl_ushort8 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100885#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100886#if defined( __CL_USHORT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100887 __cl_ushort2 v2[8];
888#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100889#if defined( __CL_USHORT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100890 __cl_ushort4 v4[4];
891#endif
892#if defined( __CL_USHORT8__ )
893 __cl_ushort8 v8[2];
894#endif
895#if defined( __CL_USHORT16__ )
896 __cl_ushort16 v16;
897#endif
898}cl_ushort16;
899
Pablo Telloe86a09f2018-01-11 15:44:48 +0000900
901/* ---- cl_halfn ---- */
902typedef union
903{
904 cl_half CL_ALIGNED(4) s[2];
905#if __CL_HAS_ANON_STRUCT__
906 __CL_ANON_STRUCT__ struct{ cl_half x, y; };
907 __CL_ANON_STRUCT__ struct{ cl_half s0, s1; };
908 __CL_ANON_STRUCT__ struct{ cl_half lo, hi; };
909#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100910#if defined( __CL_HALF2__)
Pablo Telloe86a09f2018-01-11 15:44:48 +0000911 __cl_half2 v2;
912#endif
913}cl_half2;
914
915typedef union
916{
917 cl_half CL_ALIGNED(8) s[4];
918#if __CL_HAS_ANON_STRUCT__
919 __CL_ANON_STRUCT__ struct{ cl_half x, y, z, w; };
920 __CL_ANON_STRUCT__ struct{ cl_half s0, s1, s2, s3; };
921 __CL_ANON_STRUCT__ struct{ cl_half2 lo, hi; };
922#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100923#if defined( __CL_HALF2__)
Pablo Telloe86a09f2018-01-11 15:44:48 +0000924 __cl_half2 v2[2];
925#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100926#if defined( __CL_HALF4__)
Pablo Telloe86a09f2018-01-11 15:44:48 +0000927 __cl_half4 v4;
928#endif
929}cl_half4;
930
931/* cl_half3 is identical in size, alignment and behavior to cl_half4. See section 6.1.5. */
932typedef cl_half4 cl_half3;
933
934typedef union
935{
936 cl_half CL_ALIGNED(16) s[8];
937#if __CL_HAS_ANON_STRUCT__
938 __CL_ANON_STRUCT__ struct{ cl_half x, y, z, w; };
939 __CL_ANON_STRUCT__ struct{ cl_half s0, s1, s2, s3, s4, s5, s6, s7; };
940 __CL_ANON_STRUCT__ struct{ cl_half4 lo, hi; };
941#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100942#if defined( __CL_HALF2__)
Pablo Telloe86a09f2018-01-11 15:44:48 +0000943 __cl_half2 v2[4];
944#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100945#if defined( __CL_HALF4__)
Pablo Telloe86a09f2018-01-11 15:44:48 +0000946 __cl_half4 v4[2];
947#endif
948#if defined( __CL_HALF8__ )
949 __cl_half8 v8;
950#endif
951}cl_half8;
952
953typedef union
954{
955 cl_half CL_ALIGNED(32) s[16];
956#if __CL_HAS_ANON_STRUCT__
957 __CL_ANON_STRUCT__ struct{ cl_half x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
958 __CL_ANON_STRUCT__ struct{ cl_half s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
959 __CL_ANON_STRUCT__ struct{ cl_half8 lo, hi; };
960#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100961#if defined( __CL_HALF2__)
Pablo Telloe86a09f2018-01-11 15:44:48 +0000962 __cl_half2 v2[8];
963#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100964#if defined( __CL_HALF4__)
Pablo Telloe86a09f2018-01-11 15:44:48 +0000965 __cl_half4 v4[4];
966#endif
967#if defined( __CL_HALF8__ )
968 __cl_half8 v8[2];
969#endif
970#if defined( __CL_HALF16__ )
971 __cl_half16 v16;
972#endif
973}cl_half16;
974
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100975/* ---- cl_intn ---- */
976typedef union
977{
978 cl_int CL_ALIGNED(8) s[2];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000979#if __CL_HAS_ANON_STRUCT__
980 __CL_ANON_STRUCT__ struct{ cl_int x, y; };
981 __CL_ANON_STRUCT__ struct{ cl_int s0, s1; };
982 __CL_ANON_STRUCT__ struct{ cl_int lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100983#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100984#if defined( __CL_INT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100985 __cl_int2 v2;
986#endif
987}cl_int2;
988
989typedef union
990{
991 cl_int CL_ALIGNED(16) s[4];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000992#if __CL_HAS_ANON_STRUCT__
993 __CL_ANON_STRUCT__ struct{ cl_int x, y, z, w; };
994 __CL_ANON_STRUCT__ struct{ cl_int s0, s1, s2, s3; };
995 __CL_ANON_STRUCT__ struct{ cl_int2 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100996#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100997#if defined( __CL_INT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100998 __cl_int2 v2[2];
999#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001000#if defined( __CL_INT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001001 __cl_int4 v4;
1002#endif
1003}cl_int4;
1004
1005/* cl_int3 is identical in size, alignment and behavior to cl_int4. See section 6.1.5. */
1006typedef cl_int4 cl_int3;
1007
1008typedef union
1009{
1010 cl_int CL_ALIGNED(32) s[8];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001011#if __CL_HAS_ANON_STRUCT__
1012 __CL_ANON_STRUCT__ struct{ cl_int x, y, z, w; };
1013 __CL_ANON_STRUCT__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7; };
1014 __CL_ANON_STRUCT__ struct{ cl_int4 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001015#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001016#if defined( __CL_INT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001017 __cl_int2 v2[4];
1018#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001019#if defined( __CL_INT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001020 __cl_int4 v4[2];
1021#endif
1022#if defined( __CL_INT8__ )
1023 __cl_int8 v8;
1024#endif
1025}cl_int8;
1026
1027typedef union
1028{
1029 cl_int CL_ALIGNED(64) s[16];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001030#if __CL_HAS_ANON_STRUCT__
1031 __CL_ANON_STRUCT__ struct{ cl_int x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
1032 __CL_ANON_STRUCT__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
1033 __CL_ANON_STRUCT__ struct{ cl_int8 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001034#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001035#if defined( __CL_INT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001036 __cl_int2 v2[8];
1037#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001038#if defined( __CL_INT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001039 __cl_int4 v4[4];
1040#endif
1041#if defined( __CL_INT8__ )
1042 __cl_int8 v8[2];
1043#endif
1044#if defined( __CL_INT16__ )
1045 __cl_int16 v16;
1046#endif
1047}cl_int16;
1048
1049
1050/* ---- cl_uintn ---- */
1051typedef union
1052{
1053 cl_uint CL_ALIGNED(8) s[2];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001054#if __CL_HAS_ANON_STRUCT__
1055 __CL_ANON_STRUCT__ struct{ cl_uint x, y; };
1056 __CL_ANON_STRUCT__ struct{ cl_uint s0, s1; };
1057 __CL_ANON_STRUCT__ struct{ cl_uint lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001058#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001059#if defined( __CL_UINT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001060 __cl_uint2 v2;
1061#endif
1062}cl_uint2;
1063
1064typedef union
1065{
1066 cl_uint CL_ALIGNED(16) s[4];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001067#if __CL_HAS_ANON_STRUCT__
1068 __CL_ANON_STRUCT__ struct{ cl_uint x, y, z, w; };
1069 __CL_ANON_STRUCT__ struct{ cl_uint s0, s1, s2, s3; };
1070 __CL_ANON_STRUCT__ struct{ cl_uint2 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001071#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001072#if defined( __CL_UINT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001073 __cl_uint2 v2[2];
1074#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001075#if defined( __CL_UINT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001076 __cl_uint4 v4;
1077#endif
1078}cl_uint4;
1079
1080/* cl_uint3 is identical in size, alignment and behavior to cl_uint4. See section 6.1.5. */
1081typedef cl_uint4 cl_uint3;
1082
1083typedef union
1084{
1085 cl_uint CL_ALIGNED(32) s[8];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001086#if __CL_HAS_ANON_STRUCT__
1087 __CL_ANON_STRUCT__ struct{ cl_uint x, y, z, w; };
1088 __CL_ANON_STRUCT__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7; };
1089 __CL_ANON_STRUCT__ struct{ cl_uint4 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001090#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001091#if defined( __CL_UINT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001092 __cl_uint2 v2[4];
1093#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001094#if defined( __CL_UINT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001095 __cl_uint4 v4[2];
1096#endif
1097#if defined( __CL_UINT8__ )
1098 __cl_uint8 v8;
1099#endif
1100}cl_uint8;
1101
1102typedef union
1103{
1104 cl_uint CL_ALIGNED(64) s[16];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001105#if __CL_HAS_ANON_STRUCT__
1106 __CL_ANON_STRUCT__ struct{ cl_uint x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
1107 __CL_ANON_STRUCT__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
1108 __CL_ANON_STRUCT__ struct{ cl_uint8 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001109#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001110#if defined( __CL_UINT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001111 __cl_uint2 v2[8];
1112#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001113#if defined( __CL_UINT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001114 __cl_uint4 v4[4];
1115#endif
1116#if defined( __CL_UINT8__ )
1117 __cl_uint8 v8[2];
1118#endif
1119#if defined( __CL_UINT16__ )
1120 __cl_uint16 v16;
1121#endif
1122}cl_uint16;
1123
1124/* ---- cl_longn ---- */
1125typedef union
1126{
1127 cl_long CL_ALIGNED(16) s[2];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001128#if __CL_HAS_ANON_STRUCT__
1129 __CL_ANON_STRUCT__ struct{ cl_long x, y; };
1130 __CL_ANON_STRUCT__ struct{ cl_long s0, s1; };
1131 __CL_ANON_STRUCT__ struct{ cl_long lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001132#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001133#if defined( __CL_LONG2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001134 __cl_long2 v2;
1135#endif
1136}cl_long2;
1137
1138typedef union
1139{
1140 cl_long CL_ALIGNED(32) s[4];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001141#if __CL_HAS_ANON_STRUCT__
1142 __CL_ANON_STRUCT__ struct{ cl_long x, y, z, w; };
1143 __CL_ANON_STRUCT__ struct{ cl_long s0, s1, s2, s3; };
1144 __CL_ANON_STRUCT__ struct{ cl_long2 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001145#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001146#if defined( __CL_LONG2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001147 __cl_long2 v2[2];
1148#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001149#if defined( __CL_LONG4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001150 __cl_long4 v4;
1151#endif
1152}cl_long4;
1153
1154/* cl_long3 is identical in size, alignment and behavior to cl_long4. See section 6.1.5. */
1155typedef cl_long4 cl_long3;
1156
1157typedef union
1158{
1159 cl_long CL_ALIGNED(64) s[8];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001160#if __CL_HAS_ANON_STRUCT__
1161 __CL_ANON_STRUCT__ struct{ cl_long x, y, z, w; };
1162 __CL_ANON_STRUCT__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7; };
1163 __CL_ANON_STRUCT__ struct{ cl_long4 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001164#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001165#if defined( __CL_LONG2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001166 __cl_long2 v2[4];
1167#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001168#if defined( __CL_LONG4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001169 __cl_long4 v4[2];
1170#endif
1171#if defined( __CL_LONG8__ )
1172 __cl_long8 v8;
1173#endif
1174}cl_long8;
1175
1176typedef union
1177{
1178 cl_long CL_ALIGNED(128) s[16];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001179#if __CL_HAS_ANON_STRUCT__
1180 __CL_ANON_STRUCT__ struct{ cl_long x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
1181 __CL_ANON_STRUCT__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
1182 __CL_ANON_STRUCT__ struct{ cl_long8 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001183#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001184#if defined( __CL_LONG2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001185 __cl_long2 v2[8];
1186#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001187#if defined( __CL_LONG4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001188 __cl_long4 v4[4];
1189#endif
1190#if defined( __CL_LONG8__ )
1191 __cl_long8 v8[2];
1192#endif
1193#if defined( __CL_LONG16__ )
1194 __cl_long16 v16;
1195#endif
1196}cl_long16;
1197
1198
1199/* ---- cl_ulongn ---- */
1200typedef union
1201{
1202 cl_ulong CL_ALIGNED(16) s[2];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001203#if __CL_HAS_ANON_STRUCT__
1204 __CL_ANON_STRUCT__ struct{ cl_ulong x, y; };
1205 __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1; };
1206 __CL_ANON_STRUCT__ struct{ cl_ulong lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001207#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001208#if defined( __CL_ULONG2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001209 __cl_ulong2 v2;
1210#endif
1211}cl_ulong2;
1212
1213typedef union
1214{
1215 cl_ulong CL_ALIGNED(32) s[4];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001216#if __CL_HAS_ANON_STRUCT__
1217 __CL_ANON_STRUCT__ struct{ cl_ulong x, y, z, w; };
1218 __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1, s2, s3; };
1219 __CL_ANON_STRUCT__ struct{ cl_ulong2 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001220#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001221#if defined( __CL_ULONG2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001222 __cl_ulong2 v2[2];
1223#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001224#if defined( __CL_ULONG4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001225 __cl_ulong4 v4;
1226#endif
1227}cl_ulong4;
1228
1229/* cl_ulong3 is identical in size, alignment and behavior to cl_ulong4. See section 6.1.5. */
1230typedef cl_ulong4 cl_ulong3;
1231
1232typedef union
1233{
1234 cl_ulong CL_ALIGNED(64) s[8];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001235#if __CL_HAS_ANON_STRUCT__
1236 __CL_ANON_STRUCT__ struct{ cl_ulong x, y, z, w; };
1237 __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7; };
1238 __CL_ANON_STRUCT__ struct{ cl_ulong4 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001239#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001240#if defined( __CL_ULONG2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001241 __cl_ulong2 v2[4];
1242#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001243#if defined( __CL_ULONG4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001244 __cl_ulong4 v4[2];
1245#endif
1246#if defined( __CL_ULONG8__ )
1247 __cl_ulong8 v8;
1248#endif
1249}cl_ulong8;
1250
1251typedef union
1252{
1253 cl_ulong CL_ALIGNED(128) s[16];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001254#if __CL_HAS_ANON_STRUCT__
1255 __CL_ANON_STRUCT__ struct{ cl_ulong x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
1256 __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
1257 __CL_ANON_STRUCT__ struct{ cl_ulong8 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001258#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001259#if defined( __CL_ULONG2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001260 __cl_ulong2 v2[8];
1261#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001262#if defined( __CL_ULONG4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001263 __cl_ulong4 v4[4];
1264#endif
1265#if defined( __CL_ULONG8__ )
1266 __cl_ulong8 v8[2];
1267#endif
1268#if defined( __CL_ULONG16__ )
1269 __cl_ulong16 v16;
1270#endif
1271}cl_ulong16;
1272
1273
1274/* --- cl_floatn ---- */
1275
1276typedef union
1277{
1278 cl_float CL_ALIGNED(8) s[2];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001279#if __CL_HAS_ANON_STRUCT__
1280 __CL_ANON_STRUCT__ struct{ cl_float x, y; };
1281 __CL_ANON_STRUCT__ struct{ cl_float s0, s1; };
1282 __CL_ANON_STRUCT__ struct{ cl_float lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001283#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001284#if defined( __CL_FLOAT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001285 __cl_float2 v2;
1286#endif
1287}cl_float2;
1288
1289typedef union
1290{
1291 cl_float CL_ALIGNED(16) s[4];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001292#if __CL_HAS_ANON_STRUCT__
1293 __CL_ANON_STRUCT__ struct{ cl_float x, y, z, w; };
1294 __CL_ANON_STRUCT__ struct{ cl_float s0, s1, s2, s3; };
1295 __CL_ANON_STRUCT__ struct{ cl_float2 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001296#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001297#if defined( __CL_FLOAT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001298 __cl_float2 v2[2];
1299#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001300#if defined( __CL_FLOAT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001301 __cl_float4 v4;
1302#endif
1303}cl_float4;
1304
1305/* cl_float3 is identical in size, alignment and behavior to cl_float4. See section 6.1.5. */
1306typedef cl_float4 cl_float3;
1307
1308typedef union
1309{
1310 cl_float CL_ALIGNED(32) s[8];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001311#if __CL_HAS_ANON_STRUCT__
1312 __CL_ANON_STRUCT__ struct{ cl_float x, y, z, w; };
1313 __CL_ANON_STRUCT__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7; };
1314 __CL_ANON_STRUCT__ struct{ cl_float4 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001315#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001316#if defined( __CL_FLOAT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001317 __cl_float2 v2[4];
1318#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001319#if defined( __CL_FLOAT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001320 __cl_float4 v4[2];
1321#endif
1322#if defined( __CL_FLOAT8__ )
1323 __cl_float8 v8;
1324#endif
1325}cl_float8;
1326
1327typedef union
1328{
1329 cl_float CL_ALIGNED(64) s[16];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001330#if __CL_HAS_ANON_STRUCT__
1331 __CL_ANON_STRUCT__ struct{ cl_float x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
1332 __CL_ANON_STRUCT__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
1333 __CL_ANON_STRUCT__ struct{ cl_float8 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001334#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001335#if defined( __CL_FLOAT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001336 __cl_float2 v2[8];
1337#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001338#if defined( __CL_FLOAT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001339 __cl_float4 v4[4];
1340#endif
1341#if defined( __CL_FLOAT8__ )
1342 __cl_float8 v8[2];
1343#endif
1344#if defined( __CL_FLOAT16__ )
1345 __cl_float16 v16;
1346#endif
1347}cl_float16;
1348
1349/* --- cl_doublen ---- */
1350
1351typedef union
1352{
1353 cl_double CL_ALIGNED(16) s[2];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001354#if __CL_HAS_ANON_STRUCT__
1355 __CL_ANON_STRUCT__ struct{ cl_double x, y; };
1356 __CL_ANON_STRUCT__ struct{ cl_double s0, s1; };
1357 __CL_ANON_STRUCT__ struct{ cl_double lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001358#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001359#if defined( __CL_DOUBLE2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001360 __cl_double2 v2;
1361#endif
1362}cl_double2;
1363
1364typedef union
1365{
1366 cl_double CL_ALIGNED(32) s[4];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001367#if __CL_HAS_ANON_STRUCT__
1368 __CL_ANON_STRUCT__ struct{ cl_double x, y, z, w; };
1369 __CL_ANON_STRUCT__ struct{ cl_double s0, s1, s2, s3; };
1370 __CL_ANON_STRUCT__ struct{ cl_double2 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001371#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001372#if defined( __CL_DOUBLE2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001373 __cl_double2 v2[2];
1374#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001375#if defined( __CL_DOUBLE4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001376 __cl_double4 v4;
1377#endif
1378}cl_double4;
1379
1380/* cl_double3 is identical in size, alignment and behavior to cl_double4. See section 6.1.5. */
1381typedef cl_double4 cl_double3;
1382
1383typedef union
1384{
1385 cl_double CL_ALIGNED(64) s[8];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001386#if __CL_HAS_ANON_STRUCT__
1387 __CL_ANON_STRUCT__ struct{ cl_double x, y, z, w; };
1388 __CL_ANON_STRUCT__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7; };
1389 __CL_ANON_STRUCT__ struct{ cl_double4 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001390#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001391#if defined( __CL_DOUBLE2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001392 __cl_double2 v2[4];
1393#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001394#if defined( __CL_DOUBLE4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001395 __cl_double4 v4[2];
1396#endif
1397#if defined( __CL_DOUBLE8__ )
1398 __cl_double8 v8;
1399#endif
1400}cl_double8;
1401
1402typedef union
1403{
1404 cl_double CL_ALIGNED(128) s[16];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001405#if __CL_HAS_ANON_STRUCT__
1406 __CL_ANON_STRUCT__ struct{ cl_double x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
1407 __CL_ANON_STRUCT__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
1408 __CL_ANON_STRUCT__ struct{ cl_double8 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001409#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001410#if defined( __CL_DOUBLE2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001411 __cl_double2 v2[8];
1412#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001413#if defined( __CL_DOUBLE4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001414 __cl_double4 v4[4];
1415#endif
1416#if defined( __CL_DOUBLE8__ )
1417 __cl_double8 v8[2];
1418#endif
1419#if defined( __CL_DOUBLE16__ )
1420 __cl_double16 v16;
1421#endif
1422}cl_double16;
1423
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001424/* Macro to facilitate debugging
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001425 * Usage:
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001426 * Place CL_PROGRAM_STRING_DEBUG_INFO on the line before the first line of your source.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001427 * The first line ends with: CL_PROGRAM_STRING_DEBUG_INFO \"
1428 * Each line thereafter of OpenCL C source must end with: \n\
1429 * The last line ends in ";
1430 *
1431 * Example:
1432 *
1433 * const char *my_program = CL_PROGRAM_STRING_DEBUG_INFO "\
1434 * kernel void foo( int a, float * b ) \n\
1435 * { \n\
1436 * // my comment \n\
1437 * *b[ get_global_id(0)] = a; \n\
1438 * } \n\
1439 * ";
1440 *
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001441 * This should correctly set up the line, (column) and file information for your source
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001442 * string so you can do source level debugging.
1443 */
1444#define __CL_STRINGIFY( _x ) # _x
1445#define _CL_STRINGIFY( _x ) __CL_STRINGIFY( _x )
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001446#define CL_PROGRAM_STRING_DEBUG_INFO "#line " _CL_STRINGIFY(__LINE__) " \"" __FILE__ "\" \n\n"
1447
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001448#ifdef __cplusplus
1449}
1450#endif
1451
Pablo Telloe86a09f2018-01-11 15:44:48 +00001452#undef __CL_HAS_ANON_STRUCT__
1453#undef __CL_ANON_STRUCT__
1454#if defined( _WIN32) && defined(_MSC_VER)
1455 #if _MSC_VER >=1500
1456 #pragma warning( pop )
1457 #endif
1458#endif
1459
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001460#endif /* __CL_PLATFORM_H */