1/**********************************************************************************
2 * Copyright (c) 2008-2012 The Khronos Group Inc.
3 *
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 *
15 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
22 **********************************************************************************/
23
24/* $Revision: 11803 $ on $Date: 2010-06-25 10:02:12 -0700 (Fri, 25 Jun 2010) $ */
25
26#ifndef __CL_PLATFORM_H
27#define __CL_PLATFORM_H
28
29#ifdef __APPLE__
30    /* Contains #defines for AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER below */
31    #include <AvailabilityMacros.h>
32#endif
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38#if defined(_WIN32)
39    #define CL_API_ENTRY
40    #define CL_API_CALL     __stdcall
41    #define CL_CALLBACK     __stdcall
42#else
43    #define CL_API_ENTRY
44    #define CL_API_CALL
45    #define CL_CALLBACK
46#endif
47
48#ifdef __APPLE__
49    #define CL_EXTENSION_WEAK_LINK       __attribute__((weak_import))
50    #define CL_API_SUFFIX__VERSION_1_0                  AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
51    #define CL_EXT_SUFFIX__VERSION_1_0                  CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
52    #define CL_API_SUFFIX__VERSION_1_1                  AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
53    #define GCL_API_SUFFIX__VERSION_1_1                 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
54    #define CL_EXT_SUFFIX__VERSION_1_1                  CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
55    #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
56
57    #ifdef AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
58        #define CL_API_SUFFIX__VERSION_1_2              AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
59        #define GCL_API_SUFFIX__VERSION_1_2             AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
60        #define CL_EXT_SUFFIX__VERSION_1_2              CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
61        #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
62        #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
63    #else
64        #warning  This path should never happen outside of internal operating system development.  AvailabilityMacros do not function correctly here!
65        #define CL_API_SUFFIX__VERSION_1_2              AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
66        #define GCL_API_SUFFIX__VERSION_1_2             AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
67        #define CL_EXT_SUFFIX__VERSION_1_2              CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
68        #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED   CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
69    #endif
70#else
71    #define CL_EXTENSION_WEAK_LINK
72    #define CL_API_SUFFIX__VERSION_1_0
73    #define CL_EXT_SUFFIX__VERSION_1_0
74    #define CL_API_SUFFIX__VERSION_1_1
75    #define CL_EXT_SUFFIX__VERSION_1_1
76    #define CL_API_SUFFIX__VERSION_1_2
77    #define CL_EXT_SUFFIX__VERSION_1_2
78
79    #ifdef __GNUC__
80        #ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS
81            #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
82            #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
83        #else
84            #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED __attribute__((deprecated))
85            #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
86        #endif
87
88        #ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS
89            #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
90            #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
91        #else
92            #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED __attribute__((deprecated))
93            #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
94        #endif
95    #elif _WIN32
96        #ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS
97            #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
98            #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
99        #else
100            #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
101            #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED __declspec(deprecated)
102        #endif
103
104        #ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS
105            #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
106            #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
107        #else
108            #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
109            #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED __declspec(deprecated)
110        #endif
111    #else
112        #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
113        #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
114
115        #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
116        #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
117    #endif
118#endif
119
120#if (defined (_WIN32) && defined(_MSC_VER))
121
122/* scalar types  */
123typedef signed   __int8         cl_char;
124typedef unsigned __int8         cl_uchar;
125typedef signed   __int16        cl_short;
126typedef unsigned __int16        cl_ushort;
127typedef signed   __int32        cl_int;
128typedef unsigned __int32        cl_uint;
129typedef signed   __int64        cl_long;
130typedef unsigned __int64        cl_ulong;
131
132typedef unsigned __int16        cl_half;
133typedef float                   cl_float;
134typedef double                  cl_double;
135
136/* Macro names and corresponding values defined by OpenCL */
137#define CL_CHAR_BIT         8
138#define CL_SCHAR_MAX        127
139#define CL_SCHAR_MIN        (-127-1)
140#define CL_CHAR_MAX         CL_SCHAR_MAX
141#define CL_CHAR_MIN         CL_SCHAR_MIN
142#define CL_UCHAR_MAX        255
143#define CL_SHRT_MAX         32767
144#define CL_SHRT_MIN         (-32767-1)
145#define CL_USHRT_MAX        65535
146#define CL_INT_MAX          2147483647
147#define CL_INT_MIN          (-2147483647-1)
148#define CL_UINT_MAX         0xffffffffU
149#define CL_LONG_MAX         ((cl_long) 0x7FFFFFFFFFFFFFFFLL)
150#define CL_LONG_MIN         ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL)
151#define CL_ULONG_MAX        ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL)
152
153#define CL_FLT_DIG          6
154#define CL_FLT_MANT_DIG     24
155#define CL_FLT_MAX_10_EXP   +38
156#define CL_FLT_MAX_EXP      +128
157#define CL_FLT_MIN_10_EXP   -37
158#define CL_FLT_MIN_EXP      -125
159#define CL_FLT_RADIX        2
160#define CL_FLT_MAX          340282346638528859811704183484516925440.0f
161#define CL_FLT_MIN          1.175494350822287507969e-38f
162#define CL_FLT_EPSILON      0x1.0p-23f
163
164#define CL_DBL_DIG          15
165#define CL_DBL_MANT_DIG     53
166#define CL_DBL_MAX_10_EXP   +308
167#define CL_DBL_MAX_EXP      +1024
168#define CL_DBL_MIN_10_EXP   -307
169#define CL_DBL_MIN_EXP      -1021
170#define CL_DBL_RADIX        2
171#define CL_DBL_MAX          179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0
172#define CL_DBL_MIN          2.225073858507201383090e-308
173#define CL_DBL_EPSILON      2.220446049250313080847e-16
174
175#define  CL_M_E             2.718281828459045090796
176#define  CL_M_LOG2E         1.442695040888963387005
177#define  CL_M_LOG10E        0.434294481903251816668
178#define  CL_M_LN2           0.693147180559945286227
179#define  CL_M_LN10          2.302585092994045901094
180#define  CL_M_PI            3.141592653589793115998
181#define  CL_M_PI_2          1.570796326794896557999
182#define  CL_M_PI_4          0.785398163397448278999
183#define  CL_M_1_PI          0.318309886183790691216
184#define  CL_M_2_PI          0.636619772367581382433
185#define  CL_M_2_SQRTPI      1.128379167095512558561
186#define  CL_M_SQRT2         1.414213562373095145475
187#define  CL_M_SQRT1_2       0.707106781186547572737
188
189#define  CL_M_E_F           2.71828174591064f
190#define  CL_M_LOG2E_F       1.44269502162933f
191#define  CL_M_LOG10E_F      0.43429449200630f
192#define  CL_M_LN2_F         0.69314718246460f
193#define  CL_M_LN10_F        2.30258512496948f
194#define  CL_M_PI_F          3.14159274101257f
195#define  CL_M_PI_2_F        1.57079637050629f
196#define  CL_M_PI_4_F        0.78539818525314f
197#define  CL_M_1_PI_F        0.31830987334251f
198#define  CL_M_2_PI_F        0.63661974668503f
199#define  CL_M_2_SQRTPI_F    1.12837922573090f
200#define  CL_M_SQRT2_F       1.41421353816986f
201#define  CL_M_SQRT1_2_F     0.70710676908493f
202
203#define CL_NAN              (CL_INFINITY - CL_INFINITY)
204#define CL_HUGE_VALF        ((cl_float) 1e50)
205#define CL_HUGE_VAL         ((cl_double) 1e500)
206#define CL_MAXFLOAT         CL_FLT_MAX
207#define CL_INFINITY         CL_HUGE_VALF
208
209#else
210
211#include <stdint.h>
212
213/* scalar types  */
214typedef int8_t          cl_char;
215typedef uint8_t         cl_uchar;
216typedef int16_t         cl_short    __attribute__((aligned(2)));
217typedef uint16_t        cl_ushort   __attribute__((aligned(2)));
218typedef int32_t         cl_int      __attribute__((aligned(4)));
219typedef uint32_t        cl_uint     __attribute__((aligned(4)));
220typedef int64_t         cl_long     __attribute__((aligned(8)));
221typedef uint64_t        cl_ulong    __attribute__((aligned(8)));
222
223typedef uint16_t        cl_half     __attribute__((aligned(2)));
224typedef float           cl_float    __attribute__((aligned(4)));
225typedef double          cl_double   __attribute__((aligned(8)));
226
227/* Macro names and corresponding values defined by OpenCL */
228#define CL_CHAR_BIT         8
229#define CL_SCHAR_MAX        127
230#define CL_SCHAR_MIN        (-127-1)
231#define CL_CHAR_MAX         CL_SCHAR_MAX
232#define CL_CHAR_MIN         CL_SCHAR_MIN
233#define CL_UCHAR_MAX        255
234#define CL_SHRT_MAX         32767
235#define CL_SHRT_MIN         (-32767-1)
236#define CL_USHRT_MAX        65535
237#define CL_INT_MAX          2147483647
238#define CL_INT_MIN          (-2147483647-1)
239#define CL_UINT_MAX         0xffffffffU
240#define CL_LONG_MAX         ((cl_long) 0x7FFFFFFFFFFFFFFFLL)
241#define CL_LONG_MIN         ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL)
242#define CL_ULONG_MAX        ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL)
243
244#define CL_FLT_DIG          6
245#define CL_FLT_MANT_DIG     24
246#define CL_FLT_MAX_10_EXP   +38
247#define CL_FLT_MAX_EXP      +128
248#define CL_FLT_MIN_10_EXP   -37
249#define CL_FLT_MIN_EXP      -125
250#define CL_FLT_RADIX        2
251#define CL_FLT_MAX          0x1.fffffep127f
252#define CL_FLT_MIN          0x1.0p-126f
253#define CL_FLT_EPSILON      0x1.0p-23f
254
255#define CL_DBL_DIG          15
256#define CL_DBL_MANT_DIG     53
257#define CL_DBL_MAX_10_EXP   +308
258#define CL_DBL_MAX_EXP      +1024
259#define CL_DBL_MIN_10_EXP   -307
260#define CL_DBL_MIN_EXP      -1021
261#define CL_DBL_RADIX        2
262#define CL_DBL_MAX          0x1.fffffffffffffp1023
263#define CL_DBL_MIN          0x1.0p-1022
264#define CL_DBL_EPSILON      0x1.0p-52
265
266#define  CL_M_E             2.718281828459045090796
267#define  CL_M_LOG2E         1.442695040888963387005
268#define  CL_M_LOG10E        0.434294481903251816668
269#define  CL_M_LN2           0.693147180559945286227
270#define  CL_M_LN10          2.302585092994045901094
271#define  CL_M_PI            3.141592653589793115998
272#define  CL_M_PI_2          1.570796326794896557999
273#define  CL_M_PI_4          0.785398163397448278999
274#define  CL_M_1_PI          0.318309886183790691216
275#define  CL_M_2_PI          0.636619772367581382433
276#define  CL_M_2_SQRTPI      1.128379167095512558561
277#define  CL_M_SQRT2         1.414213562373095145475
278#define  CL_M_SQRT1_2       0.707106781186547572737
279
280#define  CL_M_E_F           2.71828174591064f
281#define  CL_M_LOG2E_F       1.44269502162933f
282#define  CL_M_LOG10E_F      0.43429449200630f
283#define  CL_M_LN2_F         0.69314718246460f
284#define  CL_M_LN10_F        2.30258512496948f
285#define  CL_M_PI_F          3.14159274101257f
286#define  CL_M_PI_2_F        1.57079637050629f
287#define  CL_M_PI_4_F        0.78539818525314f
288#define  CL_M_1_PI_F        0.31830987334251f
289#define  CL_M_2_PI_F        0.63661974668503f
290#define  CL_M_2_SQRTPI_F    1.12837922573090f
291#define  CL_M_SQRT2_F       1.41421353816986f
292#define  CL_M_SQRT1_2_F     0.70710676908493f
293
294#if defined( __GNUC__ )
295   #define CL_HUGE_VALF     __builtin_huge_valf()
296   #define CL_HUGE_VAL      __builtin_huge_val()
297   #define CL_NAN           __builtin_nanf( "" )
298#else
299   #define CL_HUGE_VALF     ((cl_float) 1e50)
300   #define CL_HUGE_VAL      ((cl_double) 1e500)
301   float nanf( const char * );
302   #define CL_NAN           nanf( "" )
303#endif
304#define CL_MAXFLOAT         CL_FLT_MAX
305#define CL_INFINITY         CL_HUGE_VALF
306
307#endif
308
309#include <stddef.h>
310
311/* 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. */
312typedef unsigned int cl_GLuint;
313typedef int          cl_GLint;
314typedef unsigned int cl_GLenum;
315
316/*
317 * Vector types
318 *
319 *  Note:   OpenCL requires that all types be naturally aligned.
320 *          This means that vector types must be naturally aligned.
321 *          For example, a vector of four floats must be aligned to
322 *          a 16 byte boundary (calculated as 4 * the natural 4-byte
323 *          alignment of the float).  The alignment qualifiers here
324 *          will only function properly if your compiler supports them
325 *          and if you don't actively work to defeat them.  For example,
326 *          in order for a cl_float4 to be 16 byte aligned in a struct,
327 *          the start of the struct must itself be 16-byte aligned.
328 *
329 *          Maintaining proper alignment is the user's responsibility.
330 */
331
332/* Define basic vector types */
333#if defined( __VEC__ )
334   #include <altivec.h>   /* may be omitted depending on compiler. AltiVec spec provides no way to detect whether the header is required. */
335   typedef vector unsigned char     __cl_uchar16;
336   typedef vector signed char       __cl_char16;
337   typedef vector unsigned short    __cl_ushort8;
338   typedef vector signed short      __cl_short8;
339   typedef vector unsigned int      __cl_uint4;
340   typedef vector signed int        __cl_int4;
341   typedef vector float             __cl_float4;
342   #define  __CL_UCHAR16__  1
343   #define  __CL_CHAR16__   1
344   #define  __CL_USHORT8__  1
345   #define  __CL_SHORT8__   1
346   #define  __CL_UINT4__    1
347   #define  __CL_INT4__     1
348   #define  __CL_FLOAT4__   1
349#endif
350
351#if defined( __SSE__ )
352    #if defined( __MINGW64__ )
353        #include <intrin.h>
354    #else
355        #include <xmmintrin.h>
356    #endif
357    #if defined( __GNUC__ )
358        typedef float __cl_float4   __attribute__((vector_size(16)));
359    #else
360        typedef __m128 __cl_float4;
361    #endif
362    #define __CL_FLOAT4__   1
363#endif
364
365#if defined( __SSE2__ )
366    #if defined( __MINGW64__ )
367        #include <intrin.h>
368    #else
369        #include <emmintrin.h>
370    #endif
371    #if defined( __GNUC__ )
372        typedef cl_uchar    __cl_uchar16    __attribute__((vector_size(16)));
373        typedef cl_char     __cl_char16     __attribute__((vector_size(16)));
374        typedef cl_ushort   __cl_ushort8    __attribute__((vector_size(16)));
375        typedef cl_short    __cl_short8     __attribute__((vector_size(16)));
376        typedef cl_uint     __cl_uint4      __attribute__((vector_size(16)));
377        typedef cl_int      __cl_int4       __attribute__((vector_size(16)));
378        typedef cl_ulong    __cl_ulong2     __attribute__((vector_size(16)));
379        typedef cl_long     __cl_long2      __attribute__((vector_size(16)));
380        typedef cl_double   __cl_double2    __attribute__((vector_size(16)));
381    #else
382        typedef __m128i __cl_uchar16;
383        typedef __m128i __cl_char16;
384        typedef __m128i __cl_ushort8;
385        typedef __m128i __cl_short8;
386        typedef __m128i __cl_uint4;
387        typedef __m128i __cl_int4;
388        typedef __m128i __cl_ulong2;
389        typedef __m128i __cl_long2;
390        typedef __m128d __cl_double2;
391    #endif
392    #define __CL_UCHAR16__  1
393    #define __CL_CHAR16__   1
394    #define __CL_USHORT8__  1
395    #define __CL_SHORT8__   1
396    #define __CL_INT4__     1
397    #define __CL_UINT4__    1
398    #define __CL_ULONG2__   1
399    #define __CL_LONG2__    1
400    #define __CL_DOUBLE2__  1
401#endif
402
403#if defined( __MMX__ )
404    #include <mmintrin.h>
405    #if defined( __GNUC__ )
406        typedef cl_uchar    __cl_uchar8     __attribute__((vector_size(8)));
407        typedef cl_char     __cl_char8      __attribute__((vector_size(8)));
408        typedef cl_ushort   __cl_ushort4    __attribute__((vector_size(8)));
409        typedef cl_short    __cl_short4     __attribute__((vector_size(8)));
410        typedef cl_uint     __cl_uint2      __attribute__((vector_size(8)));
411        typedef cl_int      __cl_int2       __attribute__((vector_size(8)));
412        typedef cl_ulong    __cl_ulong1     __attribute__((vector_size(8)));
413        typedef cl_long     __cl_long1      __attribute__((vector_size(8)));
414        typedef cl_float    __cl_float2     __attribute__((vector_size(8)));
415    #else
416        typedef __m64       __cl_uchar8;
417        typedef __m64       __cl_char8;
418        typedef __m64       __cl_ushort4;
419        typedef __m64       __cl_short4;
420        typedef __m64       __cl_uint2;
421        typedef __m64       __cl_int2;
422        typedef __m64       __cl_ulong1;
423        typedef __m64       __cl_long1;
424        typedef __m64       __cl_float2;
425    #endif
426    #define __CL_UCHAR8__   1
427    #define __CL_CHAR8__    1
428    #define __CL_USHORT4__  1
429    #define __CL_SHORT4__   1
430    #define __CL_INT2__     1
431    #define __CL_UINT2__    1
432    #define __CL_ULONG1__   1
433    #define __CL_LONG1__    1
434    #define __CL_FLOAT2__   1
435#endif
436
437#if defined( __AVX__ )
438    #if defined( __MINGW64__ )
439        #include <intrin.h>
440    #else
441        #include <immintrin.h>
442    #endif
443    #if defined( __GNUC__ )
444        typedef cl_float    __cl_float8     __attribute__((vector_size(32)));
445        typedef cl_double   __cl_double4    __attribute__((vector_size(32)));
446    #else
447        typedef __m256      __cl_float8;
448        typedef __m256d     __cl_double4;
449    #endif
450    #define __CL_FLOAT8__   1
451    #define __CL_DOUBLE4__  1
452#endif
453
454/* Define capabilities for anonymous struct members. */
455#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
456#define  __CL_HAS_ANON_STRUCT__ 1
457#define  __CL_ANON_STRUCT__ __extension__
458#elif defined( _WIN32) && (_MSC_VER >= 1500)
459   /* Microsoft Developer Studio 2008 supports anonymous structs, but
460    * complains by default. */
461#define  __CL_HAS_ANON_STRUCT__ 1
462#define  __CL_ANON_STRUCT__
463   /* Disable warning C4201: nonstandard extension used : nameless
464    * struct/union */
465#pragma warning( push )
466#pragma warning( disable : 4201 )
467#else
468#define  __CL_HAS_ANON_STRUCT__ 0
469#define  __CL_ANON_STRUCT__
470#endif
471
472/* Define alignment keys */
473#if defined( __GNUC__ )
474    #define CL_ALIGNED(_x)          __attribute__ ((aligned(_x)))
475#elif defined( _WIN32) && (_MSC_VER)
476    /* Alignment keys neutered on windows because MSVC can't swallow function arguments with alignment requirements     */
477    /* http://msdn.microsoft.com/en-us/library/373ak2y1%28VS.71%29.aspx                                                 */
478    /* #include <crtdefs.h>                                                                                             */
479    /* #define CL_ALIGNED(_x)          _CRT_ALIGN(_x)                                                                   */
480    #define CL_ALIGNED(_x)
481#else
482   #warning  Need to implement some method to align data here
483   #define  CL_ALIGNED(_x)
484#endif
485
486/* Indicate whether .xyzw, .s0123 and .hi.lo are supported */
487#if __CL_HAS_ANON_STRUCT__
488    /* .xyzw and .s0123...{f|F} are supported */
489    #define CL_HAS_NAMED_VECTOR_FIELDS 1
490    /* .hi and .lo are supported */
491    #define CL_HAS_HI_LO_VECTOR_FIELDS 1
492#endif
493
494/* Define cl_vector types */
495
496/* ---- cl_charn ---- */
497typedef union
498{
499    cl_char  CL_ALIGNED(2) s[2];
500#if __CL_HAS_ANON_STRUCT__
501   __CL_ANON_STRUCT__ struct{ cl_char  x, y; };
502   __CL_ANON_STRUCT__ struct{ cl_char  s0, s1; };
503   __CL_ANON_STRUCT__ struct{ cl_char  lo, hi; };
504#endif
505#if defined( __CL_CHAR2__)
506    __cl_char2     v2;
507#endif
508}cl_char2;
509
510typedef union
511{
512    cl_char  CL_ALIGNED(4) s[4];
513#if __CL_HAS_ANON_STRUCT__
514   __CL_ANON_STRUCT__ struct{ cl_char  x, y, z, w; };
515   __CL_ANON_STRUCT__ struct{ cl_char  s0, s1, s2, s3; };
516   __CL_ANON_STRUCT__ struct{ cl_char2 lo, hi; };
517#endif
518#if defined( __CL_CHAR2__)
519    __cl_char2     v2[2];
520#endif
521#if defined( __CL_CHAR4__)
522    __cl_char4     v4;
523#endif
524}cl_char4;
525
526/* cl_char3 is identical in size, alignment and behavior to cl_char4. See section 6.1.5. */
527typedef  cl_char4  cl_char3;
528
529typedef union
530{
531    cl_char   CL_ALIGNED(8) s[8];
532#if __CL_HAS_ANON_STRUCT__
533   __CL_ANON_STRUCT__ struct{ cl_char  x, y, z, w; };
534   __CL_ANON_STRUCT__ struct{ cl_char  s0, s1, s2, s3, s4, s5, s6, s7; };
535   __CL_ANON_STRUCT__ struct{ cl_char4 lo, hi; };
536#endif
537#if defined( __CL_CHAR2__)
538    __cl_char2     v2[4];
539#endif
540#if defined( __CL_CHAR4__)
541    __cl_char4     v4[2];
542#endif
543#if defined( __CL_CHAR8__ )
544    __cl_char8     v8;
545#endif
546}cl_char8;
547
548typedef union
549{
550    cl_char  CL_ALIGNED(16) s[16];
551#if __CL_HAS_ANON_STRUCT__
552   __CL_ANON_STRUCT__ struct{ cl_char  x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
553   __CL_ANON_STRUCT__ struct{ cl_char  s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
554   __CL_ANON_STRUCT__ struct{ cl_char8 lo, hi; };
555#endif
556#if defined( __CL_CHAR2__)
557    __cl_char2     v2[8];
558#endif
559#if defined( __CL_CHAR4__)
560    __cl_char4     v4[4];
561#endif
562#if defined( __CL_CHAR8__ )
563    __cl_char8     v8[2];
564#endif
565#if defined( __CL_CHAR16__ )
566    __cl_char16    v16;
567#endif
568}cl_char16;
569
570
571/* ---- cl_ucharn ---- */
572typedef union
573{
574    cl_uchar  CL_ALIGNED(2) s[2];
575#if __CL_HAS_ANON_STRUCT__
576   __CL_ANON_STRUCT__ struct{ cl_uchar  x, y; };
577   __CL_ANON_STRUCT__ struct{ cl_uchar  s0, s1; };
578   __CL_ANON_STRUCT__ struct{ cl_uchar  lo, hi; };
579#endif
580#if defined( __cl_uchar2__)
581    __cl_uchar2     v2;
582#endif
583}cl_uchar2;
584
585typedef union
586{
587    cl_uchar  CL_ALIGNED(4) s[4];
588#if __CL_HAS_ANON_STRUCT__
589   __CL_ANON_STRUCT__ struct{ cl_uchar  x, y, z, w; };
590   __CL_ANON_STRUCT__ struct{ cl_uchar  s0, s1, s2, s3; };
591   __CL_ANON_STRUCT__ struct{ cl_uchar2 lo, hi; };
592#endif
593#if defined( __CL_UCHAR2__)
594    __cl_uchar2     v2[2];
595#endif
596#if defined( __CL_UCHAR4__)
597    __cl_uchar4     v4;
598#endif
599}cl_uchar4;
600
601/* cl_uchar3 is identical in size, alignment and behavior to cl_uchar4. See section 6.1.5. */
602typedef  cl_uchar4  cl_uchar3;
603
604typedef union
605{
606    cl_uchar   CL_ALIGNED(8) s[8];
607#if __CL_HAS_ANON_STRUCT__
608   __CL_ANON_STRUCT__ struct{ cl_uchar  x, y, z, w; };
609   __CL_ANON_STRUCT__ struct{ cl_uchar  s0, s1, s2, s3, s4, s5, s6, s7; };
610   __CL_ANON_STRUCT__ struct{ cl_uchar4 lo, hi; };
611#endif
612#if defined( __CL_UCHAR2__)
613    __cl_uchar2     v2[4];
614#endif
615#if defined( __CL_UCHAR4__)
616    __cl_uchar4     v4[2];
617#endif
618#if defined( __CL_UCHAR8__ )
619    __cl_uchar8     v8;
620#endif
621}cl_uchar8;
622
623typedef union
624{
625    cl_uchar  CL_ALIGNED(16) s[16];
626#if __CL_HAS_ANON_STRUCT__
627   __CL_ANON_STRUCT__ struct{ cl_uchar  x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
628   __CL_ANON_STRUCT__ struct{ cl_uchar  s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
629   __CL_ANON_STRUCT__ struct{ cl_uchar8 lo, hi; };
630#endif
631#if defined( __CL_UCHAR2__)
632    __cl_uchar2     v2[8];
633#endif
634#if defined( __CL_UCHAR4__)
635    __cl_uchar4     v4[4];
636#endif
637#if defined( __CL_UCHAR8__ )
638    __cl_uchar8     v8[2];
639#endif
640#if defined( __CL_UCHAR16__ )
641    __cl_uchar16    v16;
642#endif
643}cl_uchar16;
644
645
646/* ---- cl_shortn ---- */
647typedef union
648{
649    cl_short  CL_ALIGNED(4) s[2];
650#if __CL_HAS_ANON_STRUCT__
651   __CL_ANON_STRUCT__ struct{ cl_short  x, y; };
652   __CL_ANON_STRUCT__ struct{ cl_short  s0, s1; };
653   __CL_ANON_STRUCT__ struct{ cl_short  lo, hi; };
654#endif
655#if defined( __CL_SHORT2__)
656    __cl_short2     v2;
657#endif
658}cl_short2;
659
660typedef union
661{
662    cl_short  CL_ALIGNED(8) s[4];
663#if __CL_HAS_ANON_STRUCT__
664   __CL_ANON_STRUCT__ struct{ cl_short  x, y, z, w; };
665   __CL_ANON_STRUCT__ struct{ cl_short  s0, s1, s2, s3; };
666   __CL_ANON_STRUCT__ struct{ cl_short2 lo, hi; };
667#endif
668#if defined( __CL_SHORT2__)
669    __cl_short2     v2[2];
670#endif
671#if defined( __CL_SHORT4__)
672    __cl_short4     v4;
673#endif
674}cl_short4;
675
676/* cl_short3 is identical in size, alignment and behavior to cl_short4. See section 6.1.5. */
677typedef  cl_short4  cl_short3;
678
679typedef union
680{
681    cl_short   CL_ALIGNED(16) s[8];
682#if __CL_HAS_ANON_STRUCT__
683   __CL_ANON_STRUCT__ struct{ cl_short  x, y, z, w; };
684   __CL_ANON_STRUCT__ struct{ cl_short  s0, s1, s2, s3, s4, s5, s6, s7; };
685   __CL_ANON_STRUCT__ struct{ cl_short4 lo, hi; };
686#endif
687#if defined( __CL_SHORT2__)
688    __cl_short2     v2[4];
689#endif
690#if defined( __CL_SHORT4__)
691    __cl_short4     v4[2];
692#endif
693#if defined( __CL_SHORT8__ )
694    __cl_short8     v8;
695#endif
696}cl_short8;
697
698typedef union
699{
700    cl_short  CL_ALIGNED(32) s[16];
701#if __CL_HAS_ANON_STRUCT__
702   __CL_ANON_STRUCT__ struct{ cl_short  x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
703   __CL_ANON_STRUCT__ struct{ cl_short  s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
704   __CL_ANON_STRUCT__ struct{ cl_short8 lo, hi; };
705#endif
706#if defined( __CL_SHORT2__)
707    __cl_short2     v2[8];
708#endif
709#if defined( __CL_SHORT4__)
710    __cl_short4     v4[4];
711#endif
712#if defined( __CL_SHORT8__ )
713    __cl_short8     v8[2];
714#endif
715#if defined( __CL_SHORT16__ )
716    __cl_short16    v16;
717#endif
718}cl_short16;
719
720
721/* ---- cl_ushortn ---- */
722typedef union
723{
724    cl_ushort  CL_ALIGNED(4) s[2];
725#if __CL_HAS_ANON_STRUCT__
726   __CL_ANON_STRUCT__ struct{ cl_ushort  x, y; };
727   __CL_ANON_STRUCT__ struct{ cl_ushort  s0, s1; };
728   __CL_ANON_STRUCT__ struct{ cl_ushort  lo, hi; };
729#endif
730#if defined( __CL_USHORT2__)
731    __cl_ushort2     v2;
732#endif
733}cl_ushort2;
734
735typedef union
736{
737    cl_ushort  CL_ALIGNED(8) s[4];
738#if __CL_HAS_ANON_STRUCT__
739   __CL_ANON_STRUCT__ struct{ cl_ushort  x, y, z, w; };
740   __CL_ANON_STRUCT__ struct{ cl_ushort  s0, s1, s2, s3; };
741   __CL_ANON_STRUCT__ struct{ cl_ushort2 lo, hi; };
742#endif
743#if defined( __CL_USHORT2__)
744    __cl_ushort2     v2[2];
745#endif
746#if defined( __CL_USHORT4__)
747    __cl_ushort4     v4;
748#endif
749}cl_ushort4;
750
751/* cl_ushort3 is identical in size, alignment and behavior to cl_ushort4. See section 6.1.5. */
752typedef  cl_ushort4  cl_ushort3;
753
754typedef union
755{
756    cl_ushort   CL_ALIGNED(16) s[8];
757#if __CL_HAS_ANON_STRUCT__
758   __CL_ANON_STRUCT__ struct{ cl_ushort  x, y, z, w; };
759   __CL_ANON_STRUCT__ struct{ cl_ushort  s0, s1, s2, s3, s4, s5, s6, s7; };
760   __CL_ANON_STRUCT__ struct{ cl_ushort4 lo, hi; };
761#endif
762#if defined( __CL_USHORT2__)
763    __cl_ushort2     v2[4];
764#endif
765#if defined( __CL_USHORT4__)
766    __cl_ushort4     v4[2];
767#endif
768#if defined( __CL_USHORT8__ )
769    __cl_ushort8     v8;
770#endif
771}cl_ushort8;
772
773typedef union
774{
775    cl_ushort  CL_ALIGNED(32) s[16];
776#if __CL_HAS_ANON_STRUCT__
777   __CL_ANON_STRUCT__ struct{ cl_ushort  x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
778   __CL_ANON_STRUCT__ struct{ cl_ushort  s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
779   __CL_ANON_STRUCT__ struct{ cl_ushort8 lo, hi; };
780#endif
781#if defined( __CL_USHORT2__)
782    __cl_ushort2     v2[8];
783#endif
784#if defined( __CL_USHORT4__)
785    __cl_ushort4     v4[4];
786#endif
787#if defined( __CL_USHORT8__ )
788    __cl_ushort8     v8[2];
789#endif
790#if defined( __CL_USHORT16__ )
791    __cl_ushort16    v16;
792#endif
793}cl_ushort16;
794
795/* ---- cl_intn ---- */
796typedef union
797{
798    cl_int  CL_ALIGNED(8) s[2];
799#if __CL_HAS_ANON_STRUCT__
800   __CL_ANON_STRUCT__ struct{ cl_int  x, y; };
801   __CL_ANON_STRUCT__ struct{ cl_int  s0, s1; };
802   __CL_ANON_STRUCT__ struct{ cl_int  lo, hi; };
803#endif
804#if defined( __CL_INT2__)
805    __cl_int2     v2;
806#endif
807}cl_int2;
808
809typedef union
810{
811    cl_int  CL_ALIGNED(16) s[4];
812#if __CL_HAS_ANON_STRUCT__
813   __CL_ANON_STRUCT__ struct{ cl_int  x, y, z, w; };
814   __CL_ANON_STRUCT__ struct{ cl_int  s0, s1, s2, s3; };
815   __CL_ANON_STRUCT__ struct{ cl_int2 lo, hi; };
816#endif
817#if defined( __CL_INT2__)
818    __cl_int2     v2[2];
819#endif
820#if defined( __CL_INT4__)
821    __cl_int4     v4;
822#endif
823}cl_int4;
824
825/* cl_int3 is identical in size, alignment and behavior to cl_int4. See section 6.1.5. */
826typedef  cl_int4  cl_int3;
827
828typedef union
829{
830    cl_int   CL_ALIGNED(32) s[8];
831#if __CL_HAS_ANON_STRUCT__
832   __CL_ANON_STRUCT__ struct{ cl_int  x, y, z, w; };
833   __CL_ANON_STRUCT__ struct{ cl_int  s0, s1, s2, s3, s4, s5, s6, s7; };
834   __CL_ANON_STRUCT__ struct{ cl_int4 lo, hi; };
835#endif
836#if defined( __CL_INT2__)
837    __cl_int2     v2[4];
838#endif
839#if defined( __CL_INT4__)
840    __cl_int4     v4[2];
841#endif
842#if defined( __CL_INT8__ )
843    __cl_int8     v8;
844#endif
845}cl_int8;
846
847typedef union
848{
849    cl_int  CL_ALIGNED(64) s[16];
850#if __CL_HAS_ANON_STRUCT__
851   __CL_ANON_STRUCT__ struct{ cl_int  x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
852   __CL_ANON_STRUCT__ struct{ cl_int  s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
853   __CL_ANON_STRUCT__ struct{ cl_int8 lo, hi; };
854#endif
855#if defined( __CL_INT2__)
856    __cl_int2     v2[8];
857#endif
858#if defined( __CL_INT4__)
859    __cl_int4     v4[4];
860#endif
861#if defined( __CL_INT8__ )
862    __cl_int8     v8[2];
863#endif
864#if defined( __CL_INT16__ )
865    __cl_int16    v16;
866#endif
867}cl_int16;
868
869
870/* ---- cl_uintn ---- */
871typedef union
872{
873    cl_uint  CL_ALIGNED(8) s[2];
874#if __CL_HAS_ANON_STRUCT__
875   __CL_ANON_STRUCT__ struct{ cl_uint  x, y; };
876   __CL_ANON_STRUCT__ struct{ cl_uint  s0, s1; };
877   __CL_ANON_STRUCT__ struct{ cl_uint  lo, hi; };
878#endif
879#if defined( __CL_UINT2__)
880    __cl_uint2     v2;
881#endif
882}cl_uint2;
883
884typedef union
885{
886    cl_uint  CL_ALIGNED(16) s[4];
887#if __CL_HAS_ANON_STRUCT__
888   __CL_ANON_STRUCT__ struct{ cl_uint  x, y, z, w; };
889   __CL_ANON_STRUCT__ struct{ cl_uint  s0, s1, s2, s3; };
890   __CL_ANON_STRUCT__ struct{ cl_uint2 lo, hi; };
891#endif
892#if defined( __CL_UINT2__)
893    __cl_uint2     v2[2];
894#endif
895#if defined( __CL_UINT4__)
896    __cl_uint4     v4;
897#endif
898}cl_uint4;
899
900/* cl_uint3 is identical in size, alignment and behavior to cl_uint4. See section 6.1.5. */
901typedef  cl_uint4  cl_uint3;
902
903typedef union
904{
905    cl_uint   CL_ALIGNED(32) s[8];
906#if __CL_HAS_ANON_STRUCT__
907   __CL_ANON_STRUCT__ struct{ cl_uint  x, y, z, w; };
908   __CL_ANON_STRUCT__ struct{ cl_uint  s0, s1, s2, s3, s4, s5, s6, s7; };
909   __CL_ANON_STRUCT__ struct{ cl_uint4 lo, hi; };
910#endif
911#if defined( __CL_UINT2__)
912    __cl_uint2     v2[4];
913#endif
914#if defined( __CL_UINT4__)
915    __cl_uint4     v4[2];
916#endif
917#if defined( __CL_UINT8__ )
918    __cl_uint8     v8;
919#endif
920}cl_uint8;
921
922typedef union
923{
924    cl_uint  CL_ALIGNED(64) s[16];
925#if __CL_HAS_ANON_STRUCT__
926   __CL_ANON_STRUCT__ struct{ cl_uint  x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
927   __CL_ANON_STRUCT__ struct{ cl_uint  s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
928   __CL_ANON_STRUCT__ struct{ cl_uint8 lo, hi; };
929#endif
930#if defined( __CL_UINT2__)
931    __cl_uint2     v2[8];
932#endif
933#if defined( __CL_UINT4__)
934    __cl_uint4     v4[4];
935#endif
936#if defined( __CL_UINT8__ )
937    __cl_uint8     v8[2];
938#endif
939#if defined( __CL_UINT16__ )
940    __cl_uint16    v16;
941#endif
942}cl_uint16;
943
944/* ---- cl_longn ---- */
945typedef union
946{
947    cl_long  CL_ALIGNED(16) s[2];
948#if __CL_HAS_ANON_STRUCT__
949   __CL_ANON_STRUCT__ struct{ cl_long  x, y; };
950   __CL_ANON_STRUCT__ struct{ cl_long  s0, s1; };
951   __CL_ANON_STRUCT__ struct{ cl_long  lo, hi; };
952#endif
953#if defined( __CL_LONG2__)
954    __cl_long2     v2;
955#endif
956}cl_long2;
957
958typedef union
959{
960    cl_long  CL_ALIGNED(32) s[4];
961#if __CL_HAS_ANON_STRUCT__
962   __CL_ANON_STRUCT__ struct{ cl_long  x, y, z, w; };
963   __CL_ANON_STRUCT__ struct{ cl_long  s0, s1, s2, s3; };
964   __CL_ANON_STRUCT__ struct{ cl_long2 lo, hi; };
965#endif
966#if defined( __CL_LONG2__)
967    __cl_long2     v2[2];
968#endif
969#if defined( __CL_LONG4__)
970    __cl_long4     v4;
971#endif
972}cl_long4;
973
974/* cl_long3 is identical in size, alignment and behavior to cl_long4. See section 6.1.5. */
975typedef  cl_long4  cl_long3;
976
977typedef union
978{
979    cl_long   CL_ALIGNED(64) s[8];
980#if __CL_HAS_ANON_STRUCT__
981   __CL_ANON_STRUCT__ struct{ cl_long  x, y, z, w; };
982   __CL_ANON_STRUCT__ struct{ cl_long  s0, s1, s2, s3, s4, s5, s6, s7; };
983   __CL_ANON_STRUCT__ struct{ cl_long4 lo, hi; };
984#endif
985#if defined( __CL_LONG2__)
986    __cl_long2     v2[4];
987#endif
988#if defined( __CL_LONG4__)
989    __cl_long4     v4[2];
990#endif
991#if defined( __CL_LONG8__ )
992    __cl_long8     v8;
993#endif
994}cl_long8;
995
996typedef union
997{
998    cl_long  CL_ALIGNED(128) s[16];
999#if __CL_HAS_ANON_STRUCT__
1000   __CL_ANON_STRUCT__ struct{ cl_long  x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
1001   __CL_ANON_STRUCT__ struct{ cl_long  s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
1002   __CL_ANON_STRUCT__ struct{ cl_long8 lo, hi; };
1003#endif
1004#if defined( __CL_LONG2__)
1005    __cl_long2     v2[8];
1006#endif
1007#if defined( __CL_LONG4__)
1008    __cl_long4     v4[4];
1009#endif
1010#if defined( __CL_LONG8__ )
1011    __cl_long8     v8[2];
1012#endif
1013#if defined( __CL_LONG16__ )
1014    __cl_long16    v16;
1015#endif
1016}cl_long16;
1017
1018
1019/* ---- cl_ulongn ---- */
1020typedef union
1021{
1022    cl_ulong  CL_ALIGNED(16) s[2];
1023#if __CL_HAS_ANON_STRUCT__
1024   __CL_ANON_STRUCT__ struct{ cl_ulong  x, y; };
1025   __CL_ANON_STRUCT__ struct{ cl_ulong  s0, s1; };
1026   __CL_ANON_STRUCT__ struct{ cl_ulong  lo, hi; };
1027#endif
1028#if defined( __CL_ULONG2__)
1029    __cl_ulong2     v2;
1030#endif
1031}cl_ulong2;
1032
1033typedef union
1034{
1035    cl_ulong  CL_ALIGNED(32) s[4];
1036#if __CL_HAS_ANON_STRUCT__
1037   __CL_ANON_STRUCT__ struct{ cl_ulong  x, y, z, w; };
1038   __CL_ANON_STRUCT__ struct{ cl_ulong  s0, s1, s2, s3; };
1039   __CL_ANON_STRUCT__ struct{ cl_ulong2 lo, hi; };
1040#endif
1041#if defined( __CL_ULONG2__)
1042    __cl_ulong2     v2[2];
1043#endif
1044#if defined( __CL_ULONG4__)
1045    __cl_ulong4     v4;
1046#endif
1047}cl_ulong4;
1048
1049/* cl_ulong3 is identical in size, alignment and behavior to cl_ulong4. See section 6.1.5. */
1050typedef  cl_ulong4  cl_ulong3;
1051
1052typedef union
1053{
1054    cl_ulong   CL_ALIGNED(64) s[8];
1055#if __CL_HAS_ANON_STRUCT__
1056   __CL_ANON_STRUCT__ struct{ cl_ulong  x, y, z, w; };
1057   __CL_ANON_STRUCT__ struct{ cl_ulong  s0, s1, s2, s3, s4, s5, s6, s7; };
1058   __CL_ANON_STRUCT__ struct{ cl_ulong4 lo, hi; };
1059#endif
1060#if defined( __CL_ULONG2__)
1061    __cl_ulong2     v2[4];
1062#endif
1063#if defined( __CL_ULONG4__)
1064    __cl_ulong4     v4[2];
1065#endif
1066#if defined( __CL_ULONG8__ )
1067    __cl_ulong8     v8;
1068#endif
1069}cl_ulong8;
1070
1071typedef union
1072{
1073    cl_ulong  CL_ALIGNED(128) s[16];
1074#if __CL_HAS_ANON_STRUCT__
1075   __CL_ANON_STRUCT__ struct{ cl_ulong  x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
1076   __CL_ANON_STRUCT__ struct{ cl_ulong  s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
1077   __CL_ANON_STRUCT__ struct{ cl_ulong8 lo, hi; };
1078#endif
1079#if defined( __CL_ULONG2__)
1080    __cl_ulong2     v2[8];
1081#endif
1082#if defined( __CL_ULONG4__)
1083    __cl_ulong4     v4[4];
1084#endif
1085#if defined( __CL_ULONG8__ )
1086    __cl_ulong8     v8[2];
1087#endif
1088#if defined( __CL_ULONG16__ )
1089    __cl_ulong16    v16;
1090#endif
1091}cl_ulong16;
1092
1093
1094/* --- cl_floatn ---- */
1095
1096typedef union
1097{
1098    cl_float  CL_ALIGNED(8) s[2];
1099#if __CL_HAS_ANON_STRUCT__
1100   __CL_ANON_STRUCT__ struct{ cl_float  x, y; };
1101   __CL_ANON_STRUCT__ struct{ cl_float  s0, s1; };
1102   __CL_ANON_STRUCT__ struct{ cl_float  lo, hi; };
1103#endif
1104#if defined( __CL_FLOAT2__)
1105    __cl_float2     v2;
1106#endif
1107}cl_float2;
1108
1109typedef union
1110{
1111    cl_float  CL_ALIGNED(16) s[4];
1112#if __CL_HAS_ANON_STRUCT__
1113   __CL_ANON_STRUCT__ struct{ cl_float   x, y, z, w; };
1114   __CL_ANON_STRUCT__ struct{ cl_float   s0, s1, s2, s3; };
1115   __CL_ANON_STRUCT__ struct{ cl_float2  lo, hi; };
1116#endif
1117#if defined( __CL_FLOAT2__)
1118    __cl_float2     v2[2];
1119#endif
1120#if defined( __CL_FLOAT4__)
1121    __cl_float4     v4;
1122#endif
1123}cl_float4;
1124
1125/* cl_float3 is identical in size, alignment and behavior to cl_float4. See section 6.1.5. */
1126typedef  cl_float4  cl_float3;
1127
1128typedef union
1129{
1130    cl_float   CL_ALIGNED(32) s[8];
1131#if __CL_HAS_ANON_STRUCT__
1132   __CL_ANON_STRUCT__ struct{ cl_float   x, y, z, w; };
1133   __CL_ANON_STRUCT__ struct{ cl_float   s0, s1, s2, s3, s4, s5, s6, s7; };
1134   __CL_ANON_STRUCT__ struct{ cl_float4  lo, hi; };
1135#endif
1136#if defined( __CL_FLOAT2__)
1137    __cl_float2     v2[4];
1138#endif
1139#if defined( __CL_FLOAT4__)
1140    __cl_float4     v4[2];
1141#endif
1142#if defined( __CL_FLOAT8__ )
1143    __cl_float8     v8;
1144#endif
1145}cl_float8;
1146
1147typedef union
1148{
1149    cl_float  CL_ALIGNED(64) s[16];
1150#if __CL_HAS_ANON_STRUCT__
1151   __CL_ANON_STRUCT__ struct{ cl_float  x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
1152   __CL_ANON_STRUCT__ struct{ cl_float  s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
1153   __CL_ANON_STRUCT__ struct{ cl_float8 lo, hi; };
1154#endif
1155#if defined( __CL_FLOAT2__)
1156    __cl_float2     v2[8];
1157#endif
1158#if defined( __CL_FLOAT4__)
1159    __cl_float4     v4[4];
1160#endif
1161#if defined( __CL_FLOAT8__ )
1162    __cl_float8     v8[2];
1163#endif
1164#if defined( __CL_FLOAT16__ )
1165    __cl_float16    v16;
1166#endif
1167}cl_float16;
1168
1169/* --- cl_doublen ---- */
1170
1171typedef union
1172{
1173    cl_double  CL_ALIGNED(16) s[2];
1174#if __CL_HAS_ANON_STRUCT__
1175   __CL_ANON_STRUCT__ struct{ cl_double  x, y; };
1176   __CL_ANON_STRUCT__ struct{ cl_double s0, s1; };
1177   __CL_ANON_STRUCT__ struct{ cl_double lo, hi; };
1178#endif
1179#if defined( __CL_DOUBLE2__)
1180    __cl_double2     v2;
1181#endif
1182}cl_double2;
1183
1184typedef union
1185{
1186    cl_double  CL_ALIGNED(32) s[4];
1187#if __CL_HAS_ANON_STRUCT__
1188   __CL_ANON_STRUCT__ struct{ cl_double  x, y, z, w; };
1189   __CL_ANON_STRUCT__ struct{ cl_double  s0, s1, s2, s3; };
1190   __CL_ANON_STRUCT__ struct{ cl_double2 lo, hi; };
1191#endif
1192#if defined( __CL_DOUBLE2__)
1193    __cl_double2     v2[2];
1194#endif
1195#if defined( __CL_DOUBLE4__)
1196    __cl_double4     v4;
1197#endif
1198}cl_double4;
1199
1200/* cl_double3 is identical in size, alignment and behavior to cl_double4. See section 6.1.5. */
1201typedef  cl_double4  cl_double3;
1202
1203typedef union
1204{
1205    cl_double   CL_ALIGNED(64) s[8];
1206#if __CL_HAS_ANON_STRUCT__
1207   __CL_ANON_STRUCT__ struct{ cl_double  x, y, z, w; };
1208   __CL_ANON_STRUCT__ struct{ cl_double  s0, s1, s2, s3, s4, s5, s6, s7; };
1209   __CL_ANON_STRUCT__ struct{ cl_double4 lo, hi; };
1210#endif
1211#if defined( __CL_DOUBLE2__)
1212    __cl_double2     v2[4];
1213#endif
1214#if defined( __CL_DOUBLE4__)
1215    __cl_double4     v4[2];
1216#endif
1217#if defined( __CL_DOUBLE8__ )
1218    __cl_double8     v8;
1219#endif
1220}cl_double8;
1221
1222typedef union
1223{
1224    cl_double  CL_ALIGNED(128) s[16];
1225#if __CL_HAS_ANON_STRUCT__
1226   __CL_ANON_STRUCT__ struct{ cl_double  x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
1227   __CL_ANON_STRUCT__ struct{ cl_double  s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
1228   __CL_ANON_STRUCT__ struct{ cl_double8 lo, hi; };
1229#endif
1230#if defined( __CL_DOUBLE2__)
1231    __cl_double2     v2[8];
1232#endif
1233#if defined( __CL_DOUBLE4__)
1234    __cl_double4     v4[4];
1235#endif
1236#if defined( __CL_DOUBLE8__ )
1237    __cl_double8     v8[2];
1238#endif
1239#if defined( __CL_DOUBLE16__ )
1240    __cl_double16    v16;
1241#endif
1242}cl_double16;
1243
1244/* Macro to facilitate debugging
1245 * Usage:
1246 *   Place CL_PROGRAM_STRING_DEBUG_INFO on the line before the first line of your source.
1247 *   The first line ends with:   CL_PROGRAM_STRING_DEBUG_INFO \"
1248 *   Each line thereafter of OpenCL C source must end with: \n\
1249 *   The last line ends in ";
1250 *
1251 *   Example:
1252 *
1253 *   const char *my_program = CL_PROGRAM_STRING_DEBUG_INFO "\
1254 *   kernel void foo( int a, float * b )             \n\
1255 *   {                                               \n\
1256 *      // my comment                                \n\
1257 *      *b[ get_global_id(0)] = a;                   \n\
1258 *   }                                               \n\
1259 *   ";
1260 *
1261 * This should correctly set up the line, (column) and file information for your source
1262 * string so you can do source level debugging.
1263 */
1264#define  __CL_STRINGIFY( _x )               # _x
1265#define  _CL_STRINGIFY( _x )                __CL_STRINGIFY( _x )
1266#define  CL_PROGRAM_STRING_DEBUG_INFO       "#line "  _CL_STRINGIFY(__LINE__) " \"" __FILE__ "\" \n\n"
1267
1268#ifdef __cplusplus
1269}
1270#endif
1271
1272#undef __CL_HAS_ANON_STRUCT__
1273#undef __CL_ANON_STRUCT__
1274#if defined( _WIN32) && (_MSC_VER >= 1500)
1275#pragma warning( pop )
1276#endif
1277
1278#endif  /* __CL_PLATFORM_H  */
1279