cl_platform.h 40 KB

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