blob: e7a0d6f4761771a1e4d54ce185ed47e3861639dc [file] [log] [blame]
Sheri Zhang79cb9452021-09-07 14:51:49 +01001/*******************************************************************************
2 * Copyright (c) 2008-2020 The Khronos Group Inc.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003 *
Sheri Zhang79cb9452021-09-07 14:51:49 +01004 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
Anthony Barbier6ff3b192017-09-04 18:44:23 +01007 *
Sheri Zhang79cb9452021-09-07 14:51:49 +01008 * http://www.apache.org/licenses/LICENSE-2.0
Anthony Barbier6ff3b192017-09-04 18:44:23 +01009 *
Sheri Zhang79cb9452021-09-07 14:51:49 +010010 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 ******************************************************************************/
Anthony Barbier6ff3b192017-09-04 18:44:23 +010016
Anthony Barbier6ff3b192017-09-04 18:44:23 +010017#ifndef __CL_PLATFORM_H
18#define __CL_PLATFORM_H
19
Sheri Zhang67354e02021-06-30 16:08:29 +010020#include <CL/cl_version.h>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010021
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#if defined(_WIN32)
Pablo Marquez Tellodc2282f2021-11-23 15:16:00 +000027 #if !defined(CL_API_ENTRY)
28 #define CL_API_ENTRY
29 #endif
30 #if !defined(CL_API_CALL)
31 #define CL_API_CALL __stdcall
32 #endif
33 #if !defined(CL_CALLBACK)
34 #define CL_CALLBACK __stdcall
35 #endif
Anthony Barbier6ff3b192017-09-04 18:44:23 +010036#else
Pablo Marquez Tellodc2282f2021-11-23 15:16:00 +000037 #if !defined(CL_API_ENTRY)
38 #define CL_API_ENTRY
39 #endif
40 #if !defined(CL_API_CALL)
41 #define CL_API_CALL
42 #endif
43 #if !defined(CL_CALLBACK)
44 #define CL_CALLBACK
45 #endif
Anthony Barbier6ff3b192017-09-04 18:44:23 +010046#endif
47
Pablo Telloe86a09f2018-01-11 15:44:48 +000048/*
49 * Deprecation flags refer to the last version of the header in which the
50 * feature was not deprecated.
51 *
52 * E.g. VERSION_1_1_DEPRECATED means the feature is present in 1.1 without
53 * deprecation but is deprecated in versions later than 1.1.
54 */
55
Pablo Marquez Tellodc2282f2021-11-23 15:16:00 +000056#ifndef CL_API_SUFFIX_USER
57#define CL_API_SUFFIX_USER
58#endif
59
60#ifndef CL_API_PREFIX_USER
61#define CL_API_PREFIX_USER
62#endif
63
64#define CL_API_SUFFIX_COMMON CL_API_SUFFIX_USER
65#define CL_API_PREFIX_COMMON CL_API_PREFIX_USER
66
67#define CL_API_SUFFIX__VERSION_1_0 CL_API_SUFFIX_COMMON
68#define CL_API_SUFFIX__VERSION_1_1 CL_API_SUFFIX_COMMON
69#define CL_API_SUFFIX__VERSION_1_2 CL_API_SUFFIX_COMMON
70#define CL_API_SUFFIX__VERSION_2_0 CL_API_SUFFIX_COMMON
71#define CL_API_SUFFIX__VERSION_2_1 CL_API_SUFFIX_COMMON
72#define CL_API_SUFFIX__VERSION_2_2 CL_API_SUFFIX_COMMON
73#define CL_API_SUFFIX__VERSION_3_0 CL_API_SUFFIX_COMMON
74#define CL_API_SUFFIX__EXPERIMENTAL CL_API_SUFFIX_COMMON
Anthony Barbier8b2fdc92018-08-09 11:42:38 +010075
Sheri Zhang67354e02021-06-30 16:08:29 +010076
77#ifdef __GNUC__
Pablo Marquez Tellodc2282f2021-11-23 15:16:00 +000078 #define CL_API_SUFFIX_DEPRECATED __attribute__((deprecated))
79 #define CL_API_PREFIX_DEPRECATED
Sheri Zhang67354e02021-06-30 16:08:29 +010080#elif defined(_WIN32)
Pablo Marquez Tellodc2282f2021-11-23 15:16:00 +000081 #define CL_API_SUFFIX_DEPRECATED
82 #define CL_API_PREFIX_DEPRECATED __declspec(deprecated)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010083#else
Pablo Marquez Tellodc2282f2021-11-23 15:16:00 +000084 #define CL_API_SUFFIX_DEPRECATED
85 #define CL_API_PREFIX_DEPRECATED
Sheri Zhang67354e02021-06-30 16:08:29 +010086#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +010087
Sheri Zhang67354e02021-06-30 16:08:29 +010088#ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS
Pablo Marquez Tellodc2282f2021-11-23 15:16:00 +000089 #define CL_API_SUFFIX__VERSION_1_0_DEPRECATED CL_API_SUFFIX_COMMON
90 #define CL_API_PREFIX__VERSION_1_0_DEPRECATED CL_API_PREFIX_COMMON
Sheri Zhang67354e02021-06-30 16:08:29 +010091#else
Pablo Marquez Tellodc2282f2021-11-23 15:16:00 +000092 #define CL_API_SUFFIX__VERSION_1_0_DEPRECATED CL_API_SUFFIX_COMMON CL_API_SUFFIX_DEPRECATED
93 #define CL_API_PREFIX__VERSION_1_0_DEPRECATED CL_API_PREFIX_COMMON CL_API_PREFIX_DEPRECATED
Sheri Zhang67354e02021-06-30 16:08:29 +010094#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +010095
Sheri Zhang67354e02021-06-30 16:08:29 +010096#ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS
Pablo Marquez Tellodc2282f2021-11-23 15:16:00 +000097 #define CL_API_SUFFIX__VERSION_1_1_DEPRECATED CL_API_SUFFIX_COMMON
98 #define CL_API_PREFIX__VERSION_1_1_DEPRECATED CL_API_PREFIX_COMMON
Sheri Zhang67354e02021-06-30 16:08:29 +010099#else
Pablo Marquez Tellodc2282f2021-11-23 15:16:00 +0000100 #define CL_API_SUFFIX__VERSION_1_1_DEPRECATED CL_API_SUFFIX_COMMON CL_API_SUFFIX_DEPRECATED
101 #define CL_API_PREFIX__VERSION_1_1_DEPRECATED CL_API_PREFIX_COMMON CL_API_PREFIX_DEPRECATED
Sheri Zhang67354e02021-06-30 16:08:29 +0100102#endif
Pablo Telloe86a09f2018-01-11 15:44:48 +0000103
Sheri Zhang67354e02021-06-30 16:08:29 +0100104#ifdef CL_USE_DEPRECATED_OPENCL_1_2_APIS
Pablo Marquez Tellodc2282f2021-11-23 15:16:00 +0000105 #define CL_API_SUFFIX__VERSION_1_2_DEPRECATED CL_API_SUFFIX_COMMON
106 #define CL_API_PREFIX__VERSION_1_2_DEPRECATED CL_API_PREFIX_COMMON
Sheri Zhang67354e02021-06-30 16:08:29 +0100107#else
Pablo Marquez Tellodc2282f2021-11-23 15:16:00 +0000108 #define CL_API_SUFFIX__VERSION_1_2_DEPRECATED CL_API_SUFFIX_COMMON CL_API_SUFFIX_DEPRECATED
109 #define CL_API_PREFIX__VERSION_1_2_DEPRECATED CL_API_PREFIX_COMMON CL_API_PREFIX_DEPRECATED
Sheri Zhang67354e02021-06-30 16:08:29 +0100110 #endif
Pablo Telloe86a09f2018-01-11 15:44:48 +0000111
Sheri Zhang67354e02021-06-30 16:08:29 +0100112#ifdef CL_USE_DEPRECATED_OPENCL_2_0_APIS
Pablo Marquez Tellodc2282f2021-11-23 15:16:00 +0000113 #define CL_API_SUFFIX__VERSION_2_0_DEPRECATED CL_API_SUFFIX_COMMON
114 #define CL_API_PREFIX__VERSION_2_0_DEPRECATED CL_API_PREFIX_COMMON
Sheri Zhang67354e02021-06-30 16:08:29 +0100115#else
Pablo Marquez Tellodc2282f2021-11-23 15:16:00 +0000116 #define CL_API_SUFFIX__VERSION_2_0_DEPRECATED CL_API_SUFFIX_COMMON CL_API_SUFFIX_DEPRECATED
117 #define CL_API_PREFIX__VERSION_2_0_DEPRECATED CL_API_PREFIX_COMMON CL_API_PREFIX_DEPRECATED
Sheri Zhang67354e02021-06-30 16:08:29 +0100118#endif
Pablo Telloe86a09f2018-01-11 15:44:48 +0000119
Sheri Zhang67354e02021-06-30 16:08:29 +0100120#ifdef CL_USE_DEPRECATED_OPENCL_2_1_APIS
Pablo Marquez Tellodc2282f2021-11-23 15:16:00 +0000121 #define CL_API_SUFFIX__VERSION_2_1_DEPRECATED CL_API_SUFFIX_COMMON
122 #define CL_API_PREFIX__VERSION_2_1_DEPRECATED CL_API_PREFIX_COMMON
Sheri Zhang67354e02021-06-30 16:08:29 +0100123#else
Pablo Marquez Tellodc2282f2021-11-23 15:16:00 +0000124 #define CL_API_SUFFIX__VERSION_2_1_DEPRECATED CL_API_SUFFIX_COMMON CL_API_SUFFIX_DEPRECATED
125 #define CL_API_PREFIX__VERSION_2_1_DEPRECATED CL_API_PREFIX_COMMON CL_API_PREFIX_DEPRECATED
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100126#endif
127
Sheri Zhang79cb9452021-09-07 14:51:49 +0100128#ifdef CL_USE_DEPRECATED_OPENCL_2_2_APIS
Pablo Marquez Tellodc2282f2021-11-23 15:16:00 +0000129 #define CL_API_SUFFIX__VERSION_2_2_DEPRECATED CL_API_SUFFIX_COMMON
130 #define CL_API_PREFIX__VERSION_2_2_DEPRECATED CL_API_PREFIX_COMMON
Sheri Zhang79cb9452021-09-07 14:51:49 +0100131#else
Pablo Marquez Tellodc2282f2021-11-23 15:16:00 +0000132 #define CL_API_SUFFIX__VERSION_2_2_DEPRECATED CL_API_SUFFIX_COMMON CL_API_SUFFIX_DEPRECATED
133 #define CL_API_PREFIX__VERSION_2_2_DEPRECATED CL_API_PREFIX_COMMON CL_API_PREFIX_DEPRECATED
Sheri Zhang79cb9452021-09-07 14:51:49 +0100134#endif
135
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100136#if (defined (_WIN32) && defined(_MSC_VER))
137
Viet-Hoa Do633ebd12023-08-11 12:27:59 +0100138#if defined(__clang__)
139#pragma clang diagnostic push
140#pragma clang diagnostic ignored "-Wlanguage-extension-token"
141#endif
142
Pablo Marquez Tellodc2282f2021-11-23 15:16:00 +0000143/* intptr_t is used in cl.h and provided by stddef.h in Visual C++, but not in clang */
144/* stdint.h was missing before Visual Studio 2010, include it for later versions and for clang */
145#if defined(__clang__) || _MSC_VER >= 1600
146 #include <stdint.h>
147#endif
148
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100149/* scalar types */
150typedef signed __int8 cl_char;
151typedef unsigned __int8 cl_uchar;
152typedef signed __int16 cl_short;
153typedef unsigned __int16 cl_ushort;
154typedef signed __int32 cl_int;
155typedef unsigned __int32 cl_uint;
156typedef signed __int64 cl_long;
157typedef unsigned __int64 cl_ulong;
158
159typedef unsigned __int16 cl_half;
160typedef float cl_float;
161typedef double cl_double;
162
Viet-Hoa Do633ebd12023-08-11 12:27:59 +0100163#if defined(__clang__)
164#pragma clang diagnostic pop
165#endif
166
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100167/* Macro names and corresponding values defined by OpenCL */
168#define CL_CHAR_BIT 8
169#define CL_SCHAR_MAX 127
170#define CL_SCHAR_MIN (-127-1)
171#define CL_CHAR_MAX CL_SCHAR_MAX
172#define CL_CHAR_MIN CL_SCHAR_MIN
173#define CL_UCHAR_MAX 255
174#define CL_SHRT_MAX 32767
175#define CL_SHRT_MIN (-32767-1)
176#define CL_USHRT_MAX 65535
177#define CL_INT_MAX 2147483647
178#define CL_INT_MIN (-2147483647-1)
179#define CL_UINT_MAX 0xffffffffU
180#define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL)
181#define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL)
182#define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL)
183
184#define CL_FLT_DIG 6
185#define CL_FLT_MANT_DIG 24
186#define CL_FLT_MAX_10_EXP +38
187#define CL_FLT_MAX_EXP +128
188#define CL_FLT_MIN_10_EXP -37
189#define CL_FLT_MIN_EXP -125
190#define CL_FLT_RADIX 2
191#define CL_FLT_MAX 340282346638528859811704183484516925440.0f
192#define CL_FLT_MIN 1.175494350822287507969e-38f
Pablo Telloe86a09f2018-01-11 15:44:48 +0000193#define CL_FLT_EPSILON 1.1920928955078125e-7f
194
195#define CL_HALF_DIG 3
196#define CL_HALF_MANT_DIG 11
197#define CL_HALF_MAX_10_EXP +4
198#define CL_HALF_MAX_EXP +16
199#define CL_HALF_MIN_10_EXP -4
200#define CL_HALF_MIN_EXP -13
201#define CL_HALF_RADIX 2
202#define CL_HALF_MAX 65504.0f
203#define CL_HALF_MIN 6.103515625e-05f
204#define CL_HALF_EPSILON 9.765625e-04f
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100205
206#define CL_DBL_DIG 15
207#define CL_DBL_MANT_DIG 53
208#define CL_DBL_MAX_10_EXP +308
209#define CL_DBL_MAX_EXP +1024
210#define CL_DBL_MIN_10_EXP -307
211#define CL_DBL_MIN_EXP -1021
212#define CL_DBL_RADIX 2
Pablo Telloe86a09f2018-01-11 15:44:48 +0000213#define CL_DBL_MAX 1.7976931348623158e+308
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100214#define CL_DBL_MIN 2.225073858507201383090e-308
215#define CL_DBL_EPSILON 2.220446049250313080847e-16
216
Pablo Telloe86a09f2018-01-11 15:44:48 +0000217#define CL_M_E 2.7182818284590452354
218#define CL_M_LOG2E 1.4426950408889634074
219#define CL_M_LOG10E 0.43429448190325182765
220#define CL_M_LN2 0.69314718055994530942
221#define CL_M_LN10 2.30258509299404568402
222#define CL_M_PI 3.14159265358979323846
223#define CL_M_PI_2 1.57079632679489661923
224#define CL_M_PI_4 0.78539816339744830962
225#define CL_M_1_PI 0.31830988618379067154
226#define CL_M_2_PI 0.63661977236758134308
227#define CL_M_2_SQRTPI 1.12837916709551257390
228#define CL_M_SQRT2 1.41421356237309504880
229#define CL_M_SQRT1_2 0.70710678118654752440
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100230
Pablo Telloe86a09f2018-01-11 15:44:48 +0000231#define CL_M_E_F 2.718281828f
232#define CL_M_LOG2E_F 1.442695041f
233#define CL_M_LOG10E_F 0.434294482f
234#define CL_M_LN2_F 0.693147181f
235#define CL_M_LN10_F 2.302585093f
236#define CL_M_PI_F 3.141592654f
237#define CL_M_PI_2_F 1.570796327f
238#define CL_M_PI_4_F 0.785398163f
239#define CL_M_1_PI_F 0.318309886f
240#define CL_M_2_PI_F 0.636619772f
241#define CL_M_2_SQRTPI_F 1.128379167f
242#define CL_M_SQRT2_F 1.414213562f
243#define CL_M_SQRT1_2_F 0.707106781f
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100244
245#define CL_NAN (CL_INFINITY - CL_INFINITY)
246#define CL_HUGE_VALF ((cl_float) 1e50)
247#define CL_HUGE_VAL ((cl_double) 1e500)
248#define CL_MAXFLOAT CL_FLT_MAX
249#define CL_INFINITY CL_HUGE_VALF
250
251#else
252
253#include <stdint.h>
254
255/* scalar types */
256typedef int8_t cl_char;
257typedef uint8_t cl_uchar;
Sheri Zhang67354e02021-06-30 16:08:29 +0100258typedef int16_t cl_short;
259typedef uint16_t cl_ushort;
260typedef int32_t cl_int;
261typedef uint32_t cl_uint;
262typedef int64_t cl_long;
263typedef uint64_t cl_ulong;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100264
Sheri Zhang67354e02021-06-30 16:08:29 +0100265typedef uint16_t cl_half;
266typedef float cl_float;
267typedef double cl_double;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100268
269/* Macro names and corresponding values defined by OpenCL */
270#define CL_CHAR_BIT 8
271#define CL_SCHAR_MAX 127
272#define CL_SCHAR_MIN (-127-1)
273#define CL_CHAR_MAX CL_SCHAR_MAX
274#define CL_CHAR_MIN CL_SCHAR_MIN
275#define CL_UCHAR_MAX 255
276#define CL_SHRT_MAX 32767
277#define CL_SHRT_MIN (-32767-1)
278#define CL_USHRT_MAX 65535
279#define CL_INT_MAX 2147483647
280#define CL_INT_MIN (-2147483647-1)
281#define CL_UINT_MAX 0xffffffffU
282#define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL)
283#define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL)
284#define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL)
285
286#define CL_FLT_DIG 6
287#define CL_FLT_MANT_DIG 24
288#define CL_FLT_MAX_10_EXP +38
289#define CL_FLT_MAX_EXP +128
290#define CL_FLT_MIN_10_EXP -37
291#define CL_FLT_MIN_EXP -125
292#define CL_FLT_RADIX 2
Pablo Telloe86a09f2018-01-11 15:44:48 +0000293#define CL_FLT_MAX 340282346638528859811704183484516925440.0f
294#define CL_FLT_MIN 1.175494350822287507969e-38f
295#define CL_FLT_EPSILON 1.1920928955078125e-7f
296
297#define CL_HALF_DIG 3
298#define CL_HALF_MANT_DIG 11
299#define CL_HALF_MAX_10_EXP +4
300#define CL_HALF_MAX_EXP +16
301#define CL_HALF_MIN_10_EXP -4
302#define CL_HALF_MIN_EXP -13
303#define CL_HALF_RADIX 2
304#define CL_HALF_MAX 65504.0f
305#define CL_HALF_MIN 6.103515625e-05f
306#define CL_HALF_EPSILON 9.765625e-04f
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100307
308#define CL_DBL_DIG 15
309#define CL_DBL_MANT_DIG 53
310#define CL_DBL_MAX_10_EXP +308
311#define CL_DBL_MAX_EXP +1024
312#define CL_DBL_MIN_10_EXP -307
313#define CL_DBL_MIN_EXP -1021
314#define CL_DBL_RADIX 2
Pablo Telloe86a09f2018-01-11 15:44:48 +0000315#define CL_DBL_MAX 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0
316#define CL_DBL_MIN 2.225073858507201383090e-308
317#define CL_DBL_EPSILON 2.220446049250313080847e-16
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100318
Pablo Telloe86a09f2018-01-11 15:44:48 +0000319#define CL_M_E 2.7182818284590452354
320#define CL_M_LOG2E 1.4426950408889634074
321#define CL_M_LOG10E 0.43429448190325182765
322#define CL_M_LN2 0.69314718055994530942
323#define CL_M_LN10 2.30258509299404568402
324#define CL_M_PI 3.14159265358979323846
325#define CL_M_PI_2 1.57079632679489661923
326#define CL_M_PI_4 0.78539816339744830962
327#define CL_M_1_PI 0.31830988618379067154
328#define CL_M_2_PI 0.63661977236758134308
329#define CL_M_2_SQRTPI 1.12837916709551257390
330#define CL_M_SQRT2 1.41421356237309504880
331#define CL_M_SQRT1_2 0.70710678118654752440
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100332
Pablo Telloe86a09f2018-01-11 15:44:48 +0000333#define CL_M_E_F 2.718281828f
334#define CL_M_LOG2E_F 1.442695041f
335#define CL_M_LOG10E_F 0.434294482f
336#define CL_M_LN2_F 0.693147181f
337#define CL_M_LN10_F 2.302585093f
338#define CL_M_PI_F 3.141592654f
339#define CL_M_PI_2_F 1.570796327f
340#define CL_M_PI_4_F 0.785398163f
341#define CL_M_1_PI_F 0.318309886f
342#define CL_M_2_PI_F 0.636619772f
343#define CL_M_2_SQRTPI_F 1.128379167f
344#define CL_M_SQRT2_F 1.414213562f
345#define CL_M_SQRT1_2_F 0.707106781f
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100346
347#if defined( __GNUC__ )
348 #define CL_HUGE_VALF __builtin_huge_valf()
349 #define CL_HUGE_VAL __builtin_huge_val()
350 #define CL_NAN __builtin_nanf( "" )
351#else
352 #define CL_HUGE_VALF ((cl_float) 1e50)
353 #define CL_HUGE_VAL ((cl_double) 1e500)
354 float nanf( const char * );
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100355 #define CL_NAN nanf( "" )
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100356#endif
357#define CL_MAXFLOAT CL_FLT_MAX
358#define CL_INFINITY CL_HUGE_VALF
359
360#endif
361
362#include <stddef.h>
363
364/* 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. */
365typedef unsigned int cl_GLuint;
366typedef int cl_GLint;
367typedef unsigned int cl_GLenum;
368
369/*
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100370 * Vector types
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100371 *
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100372 * Note: OpenCL requires that all types be naturally aligned.
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100373 * This means that vector types must be naturally aligned.
374 * For example, a vector of four floats must be aligned to
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100375 * a 16 byte boundary (calculated as 4 * the natural 4-byte
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100376 * alignment of the float). The alignment qualifiers here
377 * will only function properly if your compiler supports them
378 * and if you don't actively work to defeat them. For example,
379 * in order for a cl_float4 to be 16 byte aligned in a struct,
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100380 * the start of the struct must itself be 16-byte aligned.
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100381 *
382 * Maintaining proper alignment is the user's responsibility.
383 */
384
385/* Define basic vector types */
386#if defined( __VEC__ )
Sheri Zhang79cb9452021-09-07 14:51:49 +0100387 #if !defined(__clang__)
388 #include <altivec.h> /* may be omitted depending on compiler. AltiVec spec provides no way to detect whether the header is required. */
389 #endif
Sheri Zhang67354e02021-06-30 16:08:29 +0100390 typedef __vector unsigned char __cl_uchar16;
391 typedef __vector signed char __cl_char16;
392 typedef __vector unsigned short __cl_ushort8;
393 typedef __vector signed short __cl_short8;
394 typedef __vector unsigned int __cl_uint4;
395 typedef __vector signed int __cl_int4;
396 typedef __vector float __cl_float4;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100397 #define __CL_UCHAR16__ 1
398 #define __CL_CHAR16__ 1
399 #define __CL_USHORT8__ 1
400 #define __CL_SHORT8__ 1
401 #define __CL_UINT4__ 1
402 #define __CL_INT4__ 1
403 #define __CL_FLOAT4__ 1
404#endif
405
406#if defined( __SSE__ )
407 #if defined( __MINGW64__ )
408 #include <intrin.h>
409 #else
410 #include <xmmintrin.h>
411 #endif
412 #if defined( __GNUC__ )
413 typedef float __cl_float4 __attribute__((vector_size(16)));
414 #else
415 typedef __m128 __cl_float4;
416 #endif
417 #define __CL_FLOAT4__ 1
418#endif
419
420#if defined( __SSE2__ )
421 #if defined( __MINGW64__ )
422 #include <intrin.h>
423 #else
424 #include <emmintrin.h>
425 #endif
426 #if defined( __GNUC__ )
427 typedef cl_uchar __cl_uchar16 __attribute__((vector_size(16)));
428 typedef cl_char __cl_char16 __attribute__((vector_size(16)));
429 typedef cl_ushort __cl_ushort8 __attribute__((vector_size(16)));
430 typedef cl_short __cl_short8 __attribute__((vector_size(16)));
431 typedef cl_uint __cl_uint4 __attribute__((vector_size(16)));
432 typedef cl_int __cl_int4 __attribute__((vector_size(16)));
433 typedef cl_ulong __cl_ulong2 __attribute__((vector_size(16)));
434 typedef cl_long __cl_long2 __attribute__((vector_size(16)));
435 typedef cl_double __cl_double2 __attribute__((vector_size(16)));
436 #else
437 typedef __m128i __cl_uchar16;
438 typedef __m128i __cl_char16;
439 typedef __m128i __cl_ushort8;
440 typedef __m128i __cl_short8;
441 typedef __m128i __cl_uint4;
442 typedef __m128i __cl_int4;
443 typedef __m128i __cl_ulong2;
444 typedef __m128i __cl_long2;
445 typedef __m128d __cl_double2;
446 #endif
447 #define __CL_UCHAR16__ 1
448 #define __CL_CHAR16__ 1
449 #define __CL_USHORT8__ 1
450 #define __CL_SHORT8__ 1
451 #define __CL_INT4__ 1
452 #define __CL_UINT4__ 1
453 #define __CL_ULONG2__ 1
454 #define __CL_LONG2__ 1
455 #define __CL_DOUBLE2__ 1
456#endif
457
458#if defined( __MMX__ )
459 #include <mmintrin.h>
460 #if defined( __GNUC__ )
461 typedef cl_uchar __cl_uchar8 __attribute__((vector_size(8)));
462 typedef cl_char __cl_char8 __attribute__((vector_size(8)));
463 typedef cl_ushort __cl_ushort4 __attribute__((vector_size(8)));
464 typedef cl_short __cl_short4 __attribute__((vector_size(8)));
465 typedef cl_uint __cl_uint2 __attribute__((vector_size(8)));
466 typedef cl_int __cl_int2 __attribute__((vector_size(8)));
467 typedef cl_ulong __cl_ulong1 __attribute__((vector_size(8)));
468 typedef cl_long __cl_long1 __attribute__((vector_size(8)));
469 typedef cl_float __cl_float2 __attribute__((vector_size(8)));
470 #else
471 typedef __m64 __cl_uchar8;
472 typedef __m64 __cl_char8;
473 typedef __m64 __cl_ushort4;
474 typedef __m64 __cl_short4;
475 typedef __m64 __cl_uint2;
476 typedef __m64 __cl_int2;
477 typedef __m64 __cl_ulong1;
478 typedef __m64 __cl_long1;
479 typedef __m64 __cl_float2;
480 #endif
481 #define __CL_UCHAR8__ 1
482 #define __CL_CHAR8__ 1
483 #define __CL_USHORT4__ 1
484 #define __CL_SHORT4__ 1
485 #define __CL_INT2__ 1
486 #define __CL_UINT2__ 1
487 #define __CL_ULONG1__ 1
488 #define __CL_LONG1__ 1
489 #define __CL_FLOAT2__ 1
490#endif
491
492#if defined( __AVX__ )
493 #if defined( __MINGW64__ )
494 #include <intrin.h>
495 #else
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100496 #include <immintrin.h>
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100497 #endif
498 #if defined( __GNUC__ )
499 typedef cl_float __cl_float8 __attribute__((vector_size(32)));
500 typedef cl_double __cl_double4 __attribute__((vector_size(32)));
501 #else
502 typedef __m256 __cl_float8;
503 typedef __m256d __cl_double4;
504 #endif
505 #define __CL_FLOAT8__ 1
506 #define __CL_DOUBLE4__ 1
507#endif
508
Pablo Telloe86a09f2018-01-11 15:44:48 +0000509/* Define capabilities for anonymous struct members. */
510#if !defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
511#define __CL_HAS_ANON_STRUCT__ 1
512#define __CL_ANON_STRUCT__
Viet-Hoa Do633ebd12023-08-11 12:27:59 +0100513#elif defined(_WIN32) && defined(_MSC_VER) && !defined(__STDC__)
514#define __CL_HAS_ANON_STRUCT__ 1
515#define __CL_ANON_STRUCT__
516#elif defined(__GNUC__) && ! defined(__STRICT_ANSI__)
Pablo Telloe86a09f2018-01-11 15:44:48 +0000517#define __CL_HAS_ANON_STRUCT__ 1
518#define __CL_ANON_STRUCT__ __extension__
Viet-Hoa Do633ebd12023-08-11 12:27:59 +0100519#elif defined(__clang__)
520#define __CL_HAS_ANON_STRUCT__ 1
521#define __CL_ANON_STRUCT__ __extension__
Pablo Telloe86a09f2018-01-11 15:44:48 +0000522#else
523#define __CL_HAS_ANON_STRUCT__ 0
524#define __CL_ANON_STRUCT__
525#endif
526
Viet-Hoa Do633ebd12023-08-11 12:27:59 +0100527#if defined(_WIN32) && defined(_MSC_VER) && __CL_HAS_ANON_STRUCT__
528 /* Disable warning C4201: nonstandard extension used : nameless struct/union */
529 #pragma warning( push )
530 #pragma warning( disable : 4201 )
531#endif
532
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100533/* Define alignment keys */
Sheri Zhang79cb9452021-09-07 14:51:49 +0100534#if defined( __GNUC__ ) || defined(__INTEGRITY)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100535 #define CL_ALIGNED(_x) __attribute__ ((aligned(_x)))
536#elif defined( _WIN32) && (_MSC_VER)
537 /* Alignment keys neutered on windows because MSVC can't swallow function arguments with alignment requirements */
538 /* http://msdn.microsoft.com/en-us/library/373ak2y1%28VS.71%29.aspx */
539 /* #include <crtdefs.h> */
540 /* #define CL_ALIGNED(_x) _CRT_ALIGN(_x) */
541 #define CL_ALIGNED(_x)
542#else
543 #warning Need to implement some method to align data here
544 #define CL_ALIGNED(_x)
545#endif
546
547/* Indicate whether .xyzw, .s0123 and .hi.lo are supported */
Pablo Telloe86a09f2018-01-11 15:44:48 +0000548#if __CL_HAS_ANON_STRUCT__
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100549 /* .xyzw and .s0123...{f|F} are supported */
550 #define CL_HAS_NAMED_VECTOR_FIELDS 1
551 /* .hi and .lo are supported */
552 #define CL_HAS_HI_LO_VECTOR_FIELDS 1
553#endif
554
555/* Define cl_vector types */
556
557/* ---- cl_charn ---- */
558typedef union
559{
560 cl_char CL_ALIGNED(2) s[2];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000561#if __CL_HAS_ANON_STRUCT__
562 __CL_ANON_STRUCT__ struct{ cl_char x, y; };
563 __CL_ANON_STRUCT__ struct{ cl_char s0, s1; };
564 __CL_ANON_STRUCT__ struct{ cl_char lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100565#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100566#if defined( __CL_CHAR2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100567 __cl_char2 v2;
568#endif
569}cl_char2;
570
571typedef union
572{
573 cl_char CL_ALIGNED(4) s[4];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000574#if __CL_HAS_ANON_STRUCT__
575 __CL_ANON_STRUCT__ struct{ cl_char x, y, z, w; };
576 __CL_ANON_STRUCT__ struct{ cl_char s0, s1, s2, s3; };
577 __CL_ANON_STRUCT__ struct{ cl_char2 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100578#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100579#if defined( __CL_CHAR2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100580 __cl_char2 v2[2];
581#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100582#if defined( __CL_CHAR4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100583 __cl_char4 v4;
584#endif
585}cl_char4;
586
587/* cl_char3 is identical in size, alignment and behavior to cl_char4. See section 6.1.5. */
588typedef cl_char4 cl_char3;
589
590typedef union
591{
592 cl_char CL_ALIGNED(8) s[8];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000593#if __CL_HAS_ANON_STRUCT__
594 __CL_ANON_STRUCT__ struct{ cl_char x, y, z, w; };
595 __CL_ANON_STRUCT__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7; };
596 __CL_ANON_STRUCT__ struct{ cl_char4 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100597#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100598#if defined( __CL_CHAR2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100599 __cl_char2 v2[4];
600#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100601#if defined( __CL_CHAR4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100602 __cl_char4 v4[2];
603#endif
604#if defined( __CL_CHAR8__ )
605 __cl_char8 v8;
606#endif
607}cl_char8;
608
609typedef union
610{
611 cl_char CL_ALIGNED(16) s[16];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000612#if __CL_HAS_ANON_STRUCT__
613 __CL_ANON_STRUCT__ struct{ cl_char x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
614 __CL_ANON_STRUCT__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
615 __CL_ANON_STRUCT__ struct{ cl_char8 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100616#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100617#if defined( __CL_CHAR2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100618 __cl_char2 v2[8];
619#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100620#if defined( __CL_CHAR4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100621 __cl_char4 v4[4];
622#endif
623#if defined( __CL_CHAR8__ )
624 __cl_char8 v8[2];
625#endif
626#if defined( __CL_CHAR16__ )
627 __cl_char16 v16;
628#endif
629}cl_char16;
630
631
632/* ---- cl_ucharn ---- */
633typedef union
634{
635 cl_uchar CL_ALIGNED(2) s[2];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000636#if __CL_HAS_ANON_STRUCT__
637 __CL_ANON_STRUCT__ struct{ cl_uchar x, y; };
638 __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1; };
639 __CL_ANON_STRUCT__ struct{ cl_uchar lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100640#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100641#if defined( __cl_uchar2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100642 __cl_uchar2 v2;
643#endif
644}cl_uchar2;
645
646typedef union
647{
648 cl_uchar CL_ALIGNED(4) s[4];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000649#if __CL_HAS_ANON_STRUCT__
650 __CL_ANON_STRUCT__ struct{ cl_uchar x, y, z, w; };
651 __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1, s2, s3; };
652 __CL_ANON_STRUCT__ struct{ cl_uchar2 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100653#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100654#if defined( __CL_UCHAR2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100655 __cl_uchar2 v2[2];
656#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100657#if defined( __CL_UCHAR4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100658 __cl_uchar4 v4;
659#endif
660}cl_uchar4;
661
662/* cl_uchar3 is identical in size, alignment and behavior to cl_uchar4. See section 6.1.5. */
663typedef cl_uchar4 cl_uchar3;
664
665typedef union
666{
667 cl_uchar CL_ALIGNED(8) s[8];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000668#if __CL_HAS_ANON_STRUCT__
669 __CL_ANON_STRUCT__ struct{ cl_uchar x, y, z, w; };
670 __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7; };
671 __CL_ANON_STRUCT__ struct{ cl_uchar4 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100672#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100673#if defined( __CL_UCHAR2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100674 __cl_uchar2 v2[4];
675#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100676#if defined( __CL_UCHAR4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100677 __cl_uchar4 v4[2];
678#endif
679#if defined( __CL_UCHAR8__ )
680 __cl_uchar8 v8;
681#endif
682}cl_uchar8;
683
684typedef union
685{
686 cl_uchar CL_ALIGNED(16) s[16];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000687#if __CL_HAS_ANON_STRUCT__
688 __CL_ANON_STRUCT__ struct{ cl_uchar x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
689 __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
690 __CL_ANON_STRUCT__ struct{ cl_uchar8 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100691#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100692#if defined( __CL_UCHAR2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100693 __cl_uchar2 v2[8];
694#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100695#if defined( __CL_UCHAR4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100696 __cl_uchar4 v4[4];
697#endif
698#if defined( __CL_UCHAR8__ )
699 __cl_uchar8 v8[2];
700#endif
701#if defined( __CL_UCHAR16__ )
702 __cl_uchar16 v16;
703#endif
704}cl_uchar16;
705
706
707/* ---- cl_shortn ---- */
708typedef union
709{
710 cl_short CL_ALIGNED(4) s[2];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000711#if __CL_HAS_ANON_STRUCT__
712 __CL_ANON_STRUCT__ struct{ cl_short x, y; };
713 __CL_ANON_STRUCT__ struct{ cl_short s0, s1; };
714 __CL_ANON_STRUCT__ struct{ cl_short lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100715#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100716#if defined( __CL_SHORT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100717 __cl_short2 v2;
718#endif
719}cl_short2;
720
721typedef union
722{
723 cl_short CL_ALIGNED(8) s[4];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000724#if __CL_HAS_ANON_STRUCT__
725 __CL_ANON_STRUCT__ struct{ cl_short x, y, z, w; };
726 __CL_ANON_STRUCT__ struct{ cl_short s0, s1, s2, s3; };
727 __CL_ANON_STRUCT__ struct{ cl_short2 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100728#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100729#if defined( __CL_SHORT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100730 __cl_short2 v2[2];
731#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100732#if defined( __CL_SHORT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100733 __cl_short4 v4;
734#endif
735}cl_short4;
736
737/* cl_short3 is identical in size, alignment and behavior to cl_short4. See section 6.1.5. */
738typedef cl_short4 cl_short3;
739
740typedef union
741{
742 cl_short CL_ALIGNED(16) s[8];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000743#if __CL_HAS_ANON_STRUCT__
744 __CL_ANON_STRUCT__ struct{ cl_short x, y, z, w; };
745 __CL_ANON_STRUCT__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7; };
746 __CL_ANON_STRUCT__ struct{ cl_short4 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100747#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100748#if defined( __CL_SHORT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100749 __cl_short2 v2[4];
750#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100751#if defined( __CL_SHORT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100752 __cl_short4 v4[2];
753#endif
754#if defined( __CL_SHORT8__ )
755 __cl_short8 v8;
756#endif
757}cl_short8;
758
759typedef union
760{
761 cl_short CL_ALIGNED(32) s[16];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000762#if __CL_HAS_ANON_STRUCT__
763 __CL_ANON_STRUCT__ struct{ cl_short x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
764 __CL_ANON_STRUCT__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
765 __CL_ANON_STRUCT__ struct{ cl_short8 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100766#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100767#if defined( __CL_SHORT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100768 __cl_short2 v2[8];
769#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100770#if defined( __CL_SHORT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100771 __cl_short4 v4[4];
772#endif
773#if defined( __CL_SHORT8__ )
774 __cl_short8 v8[2];
775#endif
776#if defined( __CL_SHORT16__ )
777 __cl_short16 v16;
778#endif
779}cl_short16;
780
781
782/* ---- cl_ushortn ---- */
783typedef union
784{
785 cl_ushort CL_ALIGNED(4) s[2];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000786#if __CL_HAS_ANON_STRUCT__
787 __CL_ANON_STRUCT__ struct{ cl_ushort x, y; };
788 __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1; };
789 __CL_ANON_STRUCT__ struct{ cl_ushort lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100790#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100791#if defined( __CL_USHORT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100792 __cl_ushort2 v2;
793#endif
794}cl_ushort2;
795
796typedef union
797{
798 cl_ushort CL_ALIGNED(8) s[4];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000799#if __CL_HAS_ANON_STRUCT__
800 __CL_ANON_STRUCT__ struct{ cl_ushort x, y, z, w; };
801 __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1, s2, s3; };
802 __CL_ANON_STRUCT__ struct{ cl_ushort2 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100803#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100804#if defined( __CL_USHORT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100805 __cl_ushort2 v2[2];
806#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100807#if defined( __CL_USHORT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100808 __cl_ushort4 v4;
809#endif
810}cl_ushort4;
811
812/* cl_ushort3 is identical in size, alignment and behavior to cl_ushort4. See section 6.1.5. */
813typedef cl_ushort4 cl_ushort3;
814
815typedef union
816{
817 cl_ushort CL_ALIGNED(16) s[8];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000818#if __CL_HAS_ANON_STRUCT__
819 __CL_ANON_STRUCT__ struct{ cl_ushort x, y, z, w; };
820 __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7; };
821 __CL_ANON_STRUCT__ struct{ cl_ushort4 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100822#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100823#if defined( __CL_USHORT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100824 __cl_ushort2 v2[4];
825#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100826#if defined( __CL_USHORT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100827 __cl_ushort4 v4[2];
828#endif
829#if defined( __CL_USHORT8__ )
830 __cl_ushort8 v8;
831#endif
832}cl_ushort8;
833
834typedef union
835{
836 cl_ushort CL_ALIGNED(32) s[16];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000837#if __CL_HAS_ANON_STRUCT__
838 __CL_ANON_STRUCT__ struct{ cl_ushort x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
839 __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
840 __CL_ANON_STRUCT__ struct{ cl_ushort8 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100841#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100842#if defined( __CL_USHORT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100843 __cl_ushort2 v2[8];
844#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100845#if defined( __CL_USHORT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100846 __cl_ushort4 v4[4];
847#endif
848#if defined( __CL_USHORT8__ )
849 __cl_ushort8 v8[2];
850#endif
851#if defined( __CL_USHORT16__ )
852 __cl_ushort16 v16;
853#endif
854}cl_ushort16;
855
Pablo Telloe86a09f2018-01-11 15:44:48 +0000856
857/* ---- cl_halfn ---- */
858typedef union
859{
860 cl_half CL_ALIGNED(4) s[2];
861#if __CL_HAS_ANON_STRUCT__
862 __CL_ANON_STRUCT__ struct{ cl_half x, y; };
863 __CL_ANON_STRUCT__ struct{ cl_half s0, s1; };
864 __CL_ANON_STRUCT__ struct{ cl_half lo, hi; };
865#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100866#if defined( __CL_HALF2__)
Pablo Telloe86a09f2018-01-11 15:44:48 +0000867 __cl_half2 v2;
868#endif
869}cl_half2;
870
871typedef union
872{
873 cl_half CL_ALIGNED(8) s[4];
874#if __CL_HAS_ANON_STRUCT__
875 __CL_ANON_STRUCT__ struct{ cl_half x, y, z, w; };
876 __CL_ANON_STRUCT__ struct{ cl_half s0, s1, s2, s3; };
877 __CL_ANON_STRUCT__ struct{ cl_half2 lo, hi; };
878#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100879#if defined( __CL_HALF2__)
Pablo Telloe86a09f2018-01-11 15:44:48 +0000880 __cl_half2 v2[2];
881#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100882#if defined( __CL_HALF4__)
Pablo Telloe86a09f2018-01-11 15:44:48 +0000883 __cl_half4 v4;
884#endif
885}cl_half4;
886
887/* cl_half3 is identical in size, alignment and behavior to cl_half4. See section 6.1.5. */
888typedef cl_half4 cl_half3;
889
890typedef union
891{
892 cl_half CL_ALIGNED(16) s[8];
893#if __CL_HAS_ANON_STRUCT__
894 __CL_ANON_STRUCT__ struct{ cl_half x, y, z, w; };
895 __CL_ANON_STRUCT__ struct{ cl_half s0, s1, s2, s3, s4, s5, s6, s7; };
896 __CL_ANON_STRUCT__ struct{ cl_half4 lo, hi; };
897#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100898#if defined( __CL_HALF2__)
Pablo Telloe86a09f2018-01-11 15:44:48 +0000899 __cl_half2 v2[4];
900#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100901#if defined( __CL_HALF4__)
Pablo Telloe86a09f2018-01-11 15:44:48 +0000902 __cl_half4 v4[2];
903#endif
904#if defined( __CL_HALF8__ )
905 __cl_half8 v8;
906#endif
907}cl_half8;
908
909typedef union
910{
911 cl_half CL_ALIGNED(32) s[16];
912#if __CL_HAS_ANON_STRUCT__
913 __CL_ANON_STRUCT__ struct{ cl_half x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
914 __CL_ANON_STRUCT__ struct{ cl_half s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
915 __CL_ANON_STRUCT__ struct{ cl_half8 lo, hi; };
916#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100917#if defined( __CL_HALF2__)
Pablo Telloe86a09f2018-01-11 15:44:48 +0000918 __cl_half2 v2[8];
919#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100920#if defined( __CL_HALF4__)
Pablo Telloe86a09f2018-01-11 15:44:48 +0000921 __cl_half4 v4[4];
922#endif
923#if defined( __CL_HALF8__ )
924 __cl_half8 v8[2];
925#endif
926#if defined( __CL_HALF16__ )
927 __cl_half16 v16;
928#endif
929}cl_half16;
930
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100931/* ---- cl_intn ---- */
932typedef union
933{
934 cl_int CL_ALIGNED(8) s[2];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000935#if __CL_HAS_ANON_STRUCT__
936 __CL_ANON_STRUCT__ struct{ cl_int x, y; };
937 __CL_ANON_STRUCT__ struct{ cl_int s0, s1; };
938 __CL_ANON_STRUCT__ struct{ cl_int lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100939#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100940#if defined( __CL_INT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100941 __cl_int2 v2;
942#endif
943}cl_int2;
944
945typedef union
946{
947 cl_int CL_ALIGNED(16) s[4];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000948#if __CL_HAS_ANON_STRUCT__
949 __CL_ANON_STRUCT__ struct{ cl_int x, y, z, w; };
950 __CL_ANON_STRUCT__ struct{ cl_int s0, s1, s2, s3; };
951 __CL_ANON_STRUCT__ struct{ cl_int2 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100952#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100953#if defined( __CL_INT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100954 __cl_int2 v2[2];
955#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100956#if defined( __CL_INT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100957 __cl_int4 v4;
958#endif
959}cl_int4;
960
961/* cl_int3 is identical in size, alignment and behavior to cl_int4. See section 6.1.5. */
962typedef cl_int4 cl_int3;
963
964typedef union
965{
966 cl_int CL_ALIGNED(32) s[8];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000967#if __CL_HAS_ANON_STRUCT__
968 __CL_ANON_STRUCT__ struct{ cl_int x, y, z, w; };
969 __CL_ANON_STRUCT__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7; };
970 __CL_ANON_STRUCT__ struct{ cl_int4 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100971#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100972#if defined( __CL_INT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100973 __cl_int2 v2[4];
974#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100975#if defined( __CL_INT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100976 __cl_int4 v4[2];
977#endif
978#if defined( __CL_INT8__ )
979 __cl_int8 v8;
980#endif
981}cl_int8;
982
983typedef union
984{
985 cl_int CL_ALIGNED(64) s[16];
Pablo Telloe86a09f2018-01-11 15:44:48 +0000986#if __CL_HAS_ANON_STRUCT__
987 __CL_ANON_STRUCT__ struct{ cl_int x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
988 __CL_ANON_STRUCT__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
989 __CL_ANON_STRUCT__ struct{ cl_int8 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100990#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100991#if defined( __CL_INT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100992 __cl_int2 v2[8];
993#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +0100994#if defined( __CL_INT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100995 __cl_int4 v4[4];
996#endif
997#if defined( __CL_INT8__ )
998 __cl_int8 v8[2];
999#endif
1000#if defined( __CL_INT16__ )
1001 __cl_int16 v16;
1002#endif
1003}cl_int16;
1004
1005
1006/* ---- cl_uintn ---- */
1007typedef union
1008{
1009 cl_uint CL_ALIGNED(8) s[2];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001010#if __CL_HAS_ANON_STRUCT__
1011 __CL_ANON_STRUCT__ struct{ cl_uint x, y; };
1012 __CL_ANON_STRUCT__ struct{ cl_uint s0, s1; };
1013 __CL_ANON_STRUCT__ struct{ cl_uint lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001014#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001015#if defined( __CL_UINT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001016 __cl_uint2 v2;
1017#endif
1018}cl_uint2;
1019
1020typedef union
1021{
1022 cl_uint CL_ALIGNED(16) s[4];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001023#if __CL_HAS_ANON_STRUCT__
1024 __CL_ANON_STRUCT__ struct{ cl_uint x, y, z, w; };
1025 __CL_ANON_STRUCT__ struct{ cl_uint s0, s1, s2, s3; };
1026 __CL_ANON_STRUCT__ struct{ cl_uint2 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001027#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001028#if defined( __CL_UINT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001029 __cl_uint2 v2[2];
1030#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001031#if defined( __CL_UINT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001032 __cl_uint4 v4;
1033#endif
1034}cl_uint4;
1035
1036/* cl_uint3 is identical in size, alignment and behavior to cl_uint4. See section 6.1.5. */
1037typedef cl_uint4 cl_uint3;
1038
1039typedef union
1040{
1041 cl_uint CL_ALIGNED(32) s[8];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001042#if __CL_HAS_ANON_STRUCT__
1043 __CL_ANON_STRUCT__ struct{ cl_uint x, y, z, w; };
1044 __CL_ANON_STRUCT__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7; };
1045 __CL_ANON_STRUCT__ struct{ cl_uint4 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001046#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001047#if defined( __CL_UINT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001048 __cl_uint2 v2[4];
1049#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001050#if defined( __CL_UINT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001051 __cl_uint4 v4[2];
1052#endif
1053#if defined( __CL_UINT8__ )
1054 __cl_uint8 v8;
1055#endif
1056}cl_uint8;
1057
1058typedef union
1059{
1060 cl_uint CL_ALIGNED(64) s[16];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001061#if __CL_HAS_ANON_STRUCT__
1062 __CL_ANON_STRUCT__ struct{ cl_uint x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
1063 __CL_ANON_STRUCT__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
1064 __CL_ANON_STRUCT__ struct{ cl_uint8 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001065#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001066#if defined( __CL_UINT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001067 __cl_uint2 v2[8];
1068#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001069#if defined( __CL_UINT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001070 __cl_uint4 v4[4];
1071#endif
1072#if defined( __CL_UINT8__ )
1073 __cl_uint8 v8[2];
1074#endif
1075#if defined( __CL_UINT16__ )
1076 __cl_uint16 v16;
1077#endif
1078}cl_uint16;
1079
1080/* ---- cl_longn ---- */
1081typedef union
1082{
1083 cl_long CL_ALIGNED(16) s[2];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001084#if __CL_HAS_ANON_STRUCT__
1085 __CL_ANON_STRUCT__ struct{ cl_long x, y; };
1086 __CL_ANON_STRUCT__ struct{ cl_long s0, s1; };
1087 __CL_ANON_STRUCT__ struct{ cl_long lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001088#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001089#if defined( __CL_LONG2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001090 __cl_long2 v2;
1091#endif
1092}cl_long2;
1093
1094typedef union
1095{
1096 cl_long CL_ALIGNED(32) s[4];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001097#if __CL_HAS_ANON_STRUCT__
1098 __CL_ANON_STRUCT__ struct{ cl_long x, y, z, w; };
1099 __CL_ANON_STRUCT__ struct{ cl_long s0, s1, s2, s3; };
1100 __CL_ANON_STRUCT__ struct{ cl_long2 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001101#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001102#if defined( __CL_LONG2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001103 __cl_long2 v2[2];
1104#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001105#if defined( __CL_LONG4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001106 __cl_long4 v4;
1107#endif
1108}cl_long4;
1109
1110/* cl_long3 is identical in size, alignment and behavior to cl_long4. See section 6.1.5. */
1111typedef cl_long4 cl_long3;
1112
1113typedef union
1114{
1115 cl_long CL_ALIGNED(64) s[8];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001116#if __CL_HAS_ANON_STRUCT__
1117 __CL_ANON_STRUCT__ struct{ cl_long x, y, z, w; };
1118 __CL_ANON_STRUCT__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7; };
1119 __CL_ANON_STRUCT__ struct{ cl_long4 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001120#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001121#if defined( __CL_LONG2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001122 __cl_long2 v2[4];
1123#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001124#if defined( __CL_LONG4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001125 __cl_long4 v4[2];
1126#endif
1127#if defined( __CL_LONG8__ )
1128 __cl_long8 v8;
1129#endif
1130}cl_long8;
1131
1132typedef union
1133{
1134 cl_long CL_ALIGNED(128) s[16];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001135#if __CL_HAS_ANON_STRUCT__
1136 __CL_ANON_STRUCT__ struct{ cl_long x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
1137 __CL_ANON_STRUCT__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
1138 __CL_ANON_STRUCT__ struct{ cl_long8 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001139#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001140#if defined( __CL_LONG2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001141 __cl_long2 v2[8];
1142#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001143#if defined( __CL_LONG4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001144 __cl_long4 v4[4];
1145#endif
1146#if defined( __CL_LONG8__ )
1147 __cl_long8 v8[2];
1148#endif
1149#if defined( __CL_LONG16__ )
1150 __cl_long16 v16;
1151#endif
1152}cl_long16;
1153
1154
1155/* ---- cl_ulongn ---- */
1156typedef union
1157{
1158 cl_ulong CL_ALIGNED(16) s[2];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001159#if __CL_HAS_ANON_STRUCT__
1160 __CL_ANON_STRUCT__ struct{ cl_ulong x, y; };
1161 __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1; };
1162 __CL_ANON_STRUCT__ struct{ cl_ulong lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001163#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001164#if defined( __CL_ULONG2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001165 __cl_ulong2 v2;
1166#endif
1167}cl_ulong2;
1168
1169typedef union
1170{
1171 cl_ulong CL_ALIGNED(32) s[4];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001172#if __CL_HAS_ANON_STRUCT__
1173 __CL_ANON_STRUCT__ struct{ cl_ulong x, y, z, w; };
1174 __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1, s2, s3; };
1175 __CL_ANON_STRUCT__ struct{ cl_ulong2 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001176#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001177#if defined( __CL_ULONG2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001178 __cl_ulong2 v2[2];
1179#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001180#if defined( __CL_ULONG4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001181 __cl_ulong4 v4;
1182#endif
1183}cl_ulong4;
1184
1185/* cl_ulong3 is identical in size, alignment and behavior to cl_ulong4. See section 6.1.5. */
1186typedef cl_ulong4 cl_ulong3;
1187
1188typedef union
1189{
1190 cl_ulong CL_ALIGNED(64) s[8];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001191#if __CL_HAS_ANON_STRUCT__
1192 __CL_ANON_STRUCT__ struct{ cl_ulong x, y, z, w; };
1193 __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7; };
1194 __CL_ANON_STRUCT__ struct{ cl_ulong4 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001195#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001196#if defined( __CL_ULONG2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001197 __cl_ulong2 v2[4];
1198#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001199#if defined( __CL_ULONG4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001200 __cl_ulong4 v4[2];
1201#endif
1202#if defined( __CL_ULONG8__ )
1203 __cl_ulong8 v8;
1204#endif
1205}cl_ulong8;
1206
1207typedef union
1208{
1209 cl_ulong CL_ALIGNED(128) s[16];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001210#if __CL_HAS_ANON_STRUCT__
1211 __CL_ANON_STRUCT__ struct{ cl_ulong x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
1212 __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
1213 __CL_ANON_STRUCT__ struct{ cl_ulong8 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001214#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001215#if defined( __CL_ULONG2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001216 __cl_ulong2 v2[8];
1217#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001218#if defined( __CL_ULONG4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001219 __cl_ulong4 v4[4];
1220#endif
1221#if defined( __CL_ULONG8__ )
1222 __cl_ulong8 v8[2];
1223#endif
1224#if defined( __CL_ULONG16__ )
1225 __cl_ulong16 v16;
1226#endif
1227}cl_ulong16;
1228
1229
1230/* --- cl_floatn ---- */
1231
1232typedef union
1233{
1234 cl_float CL_ALIGNED(8) s[2];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001235#if __CL_HAS_ANON_STRUCT__
1236 __CL_ANON_STRUCT__ struct{ cl_float x, y; };
1237 __CL_ANON_STRUCT__ struct{ cl_float s0, s1; };
1238 __CL_ANON_STRUCT__ struct{ cl_float lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001239#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001240#if defined( __CL_FLOAT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001241 __cl_float2 v2;
1242#endif
1243}cl_float2;
1244
1245typedef union
1246{
1247 cl_float CL_ALIGNED(16) s[4];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001248#if __CL_HAS_ANON_STRUCT__
1249 __CL_ANON_STRUCT__ struct{ cl_float x, y, z, w; };
1250 __CL_ANON_STRUCT__ struct{ cl_float s0, s1, s2, s3; };
1251 __CL_ANON_STRUCT__ struct{ cl_float2 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001252#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001253#if defined( __CL_FLOAT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001254 __cl_float2 v2[2];
1255#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001256#if defined( __CL_FLOAT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001257 __cl_float4 v4;
1258#endif
1259}cl_float4;
1260
1261/* cl_float3 is identical in size, alignment and behavior to cl_float4. See section 6.1.5. */
1262typedef cl_float4 cl_float3;
1263
1264typedef union
1265{
1266 cl_float CL_ALIGNED(32) s[8];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001267#if __CL_HAS_ANON_STRUCT__
1268 __CL_ANON_STRUCT__ struct{ cl_float x, y, z, w; };
1269 __CL_ANON_STRUCT__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7; };
1270 __CL_ANON_STRUCT__ struct{ cl_float4 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001271#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001272#if defined( __CL_FLOAT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001273 __cl_float2 v2[4];
1274#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001275#if defined( __CL_FLOAT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001276 __cl_float4 v4[2];
1277#endif
1278#if defined( __CL_FLOAT8__ )
1279 __cl_float8 v8;
1280#endif
1281}cl_float8;
1282
1283typedef union
1284{
1285 cl_float CL_ALIGNED(64) s[16];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001286#if __CL_HAS_ANON_STRUCT__
1287 __CL_ANON_STRUCT__ struct{ cl_float x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
1288 __CL_ANON_STRUCT__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
1289 __CL_ANON_STRUCT__ struct{ cl_float8 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001290#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001291#if defined( __CL_FLOAT2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001292 __cl_float2 v2[8];
1293#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001294#if defined( __CL_FLOAT4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001295 __cl_float4 v4[4];
1296#endif
1297#if defined( __CL_FLOAT8__ )
1298 __cl_float8 v8[2];
1299#endif
1300#if defined( __CL_FLOAT16__ )
1301 __cl_float16 v16;
1302#endif
1303}cl_float16;
1304
1305/* --- cl_doublen ---- */
1306
1307typedef union
1308{
1309 cl_double CL_ALIGNED(16) s[2];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001310#if __CL_HAS_ANON_STRUCT__
1311 __CL_ANON_STRUCT__ struct{ cl_double x, y; };
1312 __CL_ANON_STRUCT__ struct{ cl_double s0, s1; };
1313 __CL_ANON_STRUCT__ struct{ cl_double lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001314#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001315#if defined( __CL_DOUBLE2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001316 __cl_double2 v2;
1317#endif
1318}cl_double2;
1319
1320typedef union
1321{
1322 cl_double CL_ALIGNED(32) s[4];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001323#if __CL_HAS_ANON_STRUCT__
1324 __CL_ANON_STRUCT__ struct{ cl_double x, y, z, w; };
1325 __CL_ANON_STRUCT__ struct{ cl_double s0, s1, s2, s3; };
1326 __CL_ANON_STRUCT__ struct{ cl_double2 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001327#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001328#if defined( __CL_DOUBLE2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001329 __cl_double2 v2[2];
1330#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001331#if defined( __CL_DOUBLE4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001332 __cl_double4 v4;
1333#endif
1334}cl_double4;
1335
1336/* cl_double3 is identical in size, alignment and behavior to cl_double4. See section 6.1.5. */
1337typedef cl_double4 cl_double3;
1338
1339typedef union
1340{
1341 cl_double CL_ALIGNED(64) s[8];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001342#if __CL_HAS_ANON_STRUCT__
1343 __CL_ANON_STRUCT__ struct{ cl_double x, y, z, w; };
1344 __CL_ANON_STRUCT__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7; };
1345 __CL_ANON_STRUCT__ struct{ cl_double4 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001346#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001347#if defined( __CL_DOUBLE2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001348 __cl_double2 v2[4];
1349#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001350#if defined( __CL_DOUBLE4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001351 __cl_double4 v4[2];
1352#endif
1353#if defined( __CL_DOUBLE8__ )
1354 __cl_double8 v8;
1355#endif
1356}cl_double8;
1357
1358typedef union
1359{
1360 cl_double CL_ALIGNED(128) s[16];
Pablo Telloe86a09f2018-01-11 15:44:48 +00001361#if __CL_HAS_ANON_STRUCT__
1362 __CL_ANON_STRUCT__ struct{ cl_double x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
1363 __CL_ANON_STRUCT__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
1364 __CL_ANON_STRUCT__ struct{ cl_double8 lo, hi; };
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001365#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001366#if defined( __CL_DOUBLE2__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001367 __cl_double2 v2[8];
1368#endif
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001369#if defined( __CL_DOUBLE4__)
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001370 __cl_double4 v4[4];
1371#endif
1372#if defined( __CL_DOUBLE8__ )
1373 __cl_double8 v8[2];
1374#endif
1375#if defined( __CL_DOUBLE16__ )
1376 __cl_double16 v16;
1377#endif
1378}cl_double16;
1379
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001380/* Macro to facilitate debugging
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001381 * Usage:
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001382 * Place CL_PROGRAM_STRING_DEBUG_INFO on the line before the first line of your source.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001383 * The first line ends with: CL_PROGRAM_STRING_DEBUG_INFO \"
1384 * Each line thereafter of OpenCL C source must end with: \n\
1385 * The last line ends in ";
1386 *
1387 * Example:
1388 *
1389 * const char *my_program = CL_PROGRAM_STRING_DEBUG_INFO "\
1390 * kernel void foo( int a, float * b ) \n\
1391 * { \n\
1392 * // my comment \n\
1393 * *b[ get_global_id(0)] = a; \n\
1394 * } \n\
1395 * ";
1396 *
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001397 * This should correctly set up the line, (column) and file information for your source
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001398 * string so you can do source level debugging.
1399 */
1400#define __CL_STRINGIFY( _x ) # _x
1401#define _CL_STRINGIFY( _x ) __CL_STRINGIFY( _x )
Anthony Barbier8b2fdc92018-08-09 11:42:38 +01001402#define CL_PROGRAM_STRING_DEBUG_INFO "#line " _CL_STRINGIFY(__LINE__) " \"" __FILE__ "\" \n\n"
1403
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001404#ifdef __cplusplus
1405}
1406#endif
1407
Viet-Hoa Do633ebd12023-08-11 12:27:59 +01001408#if defined(_WIN32) && defined(_MSC_VER) && __CL_HAS_ANON_STRUCT__
Pablo Telloe86a09f2018-01-11 15:44:48 +00001409 #pragma warning( pop )
Pablo Telloe86a09f2018-01-11 15:44:48 +00001410#endif
1411
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001412#endif /* __CL_PLATFORM_H */