cl_platform.h 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254
  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 defined(_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 alignment keys */
  415. #if defined( __GNUC__ )
  416. #define CL_ALIGNED(_x) __attribute__ ((aligned(_x)))
  417. #elif defined( _WIN32) && defined(_MSC_VER)
  418. /* Alignment keys neutered on windows because MSVC can't swallow function arguments with alignment requirements */
  419. /* http://msdn.microsoft.com/en-us/library/373ak2y1%28VS.71%29.aspx */
  420. /* #include <crtdefs.h> */
  421. /* #define CL_ALIGNED(_x) _CRT_ALIGN(_x) */
  422. #define CL_ALIGNED(_x)
  423. #else
  424. #warning Need to implement some method to align data here
  425. #define CL_ALIGNED(_x)
  426. #endif
  427. /* Indicate whether .xyzw, .s0123 and .hi.lo are supported */
  428. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  429. /* .xyzw and .s0123...{f|F} are supported */
  430. #define CL_HAS_NAMED_VECTOR_FIELDS 1
  431. /* .hi and .lo are supported */
  432. #define CL_HAS_HI_LO_VECTOR_FIELDS 1
  433. #endif
  434. /* Define cl_vector types */
  435. /* ---- cl_charn ---- */
  436. typedef union
  437. {
  438. cl_char CL_ALIGNED(2) s[2];
  439. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  440. __extension__ struct{ cl_char x, y; };
  441. __extension__ struct{ cl_char s0, s1; };
  442. __extension__ struct{ cl_char lo, hi; };
  443. #endif
  444. #if defined( __CL_CHAR2__)
  445. __cl_char2 v2;
  446. #endif
  447. }cl_char2;
  448. typedef union
  449. {
  450. cl_char CL_ALIGNED(4) s[4];
  451. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  452. __extension__ struct{ cl_char x, y, z, w; };
  453. __extension__ struct{ cl_char s0, s1, s2, s3; };
  454. __extension__ struct{ cl_char2 lo, hi; };
  455. #endif
  456. #if defined( __CL_CHAR2__)
  457. __cl_char2 v2[2];
  458. #endif
  459. #if defined( __CL_CHAR4__)
  460. __cl_char4 v4;
  461. #endif
  462. }cl_char4;
  463. /* cl_char3 is identical in size, alignment and behavior to cl_char4. See section 6.1.5. */
  464. typedef cl_char4 cl_char3;
  465. typedef union
  466. {
  467. cl_char CL_ALIGNED(8) s[8];
  468. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  469. __extension__ struct{ cl_char x, y, z, w; };
  470. __extension__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7; };
  471. __extension__ struct{ cl_char4 lo, hi; };
  472. #endif
  473. #if defined( __CL_CHAR2__)
  474. __cl_char2 v2[4];
  475. #endif
  476. #if defined( __CL_CHAR4__)
  477. __cl_char4 v4[2];
  478. #endif
  479. #if defined( __CL_CHAR8__ )
  480. __cl_char8 v8;
  481. #endif
  482. }cl_char8;
  483. typedef union
  484. {
  485. cl_char CL_ALIGNED(16) s[16];
  486. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  487. __extension__ struct{ cl_char x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
  488. __extension__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
  489. __extension__ struct{ cl_char8 lo, hi; };
  490. #endif
  491. #if defined( __CL_CHAR2__)
  492. __cl_char2 v2[8];
  493. #endif
  494. #if defined( __CL_CHAR4__)
  495. __cl_char4 v4[4];
  496. #endif
  497. #if defined( __CL_CHAR8__ )
  498. __cl_char8 v8[2];
  499. #endif
  500. #if defined( __CL_CHAR16__ )
  501. __cl_char16 v16;
  502. #endif
  503. }cl_char16;
  504. /* ---- cl_ucharn ---- */
  505. typedef union
  506. {
  507. cl_uchar CL_ALIGNED(2) s[2];
  508. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  509. __extension__ struct{ cl_uchar x, y; };
  510. __extension__ struct{ cl_uchar s0, s1; };
  511. __extension__ struct{ cl_uchar lo, hi; };
  512. #endif
  513. #if defined( __cl_uchar2__)
  514. __cl_uchar2 v2;
  515. #endif
  516. }cl_uchar2;
  517. typedef union
  518. {
  519. cl_uchar CL_ALIGNED(4) s[4];
  520. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  521. __extension__ struct{ cl_uchar x, y, z, w; };
  522. __extension__ struct{ cl_uchar s0, s1, s2, s3; };
  523. __extension__ struct{ cl_uchar2 lo, hi; };
  524. #endif
  525. #if defined( __CL_UCHAR2__)
  526. __cl_uchar2 v2[2];
  527. #endif
  528. #if defined( __CL_UCHAR4__)
  529. __cl_uchar4 v4;
  530. #endif
  531. }cl_uchar4;
  532. /* cl_uchar3 is identical in size, alignment and behavior to cl_uchar4. See section 6.1.5. */
  533. typedef cl_uchar4 cl_uchar3;
  534. typedef union
  535. {
  536. cl_uchar CL_ALIGNED(8) s[8];
  537. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  538. __extension__ struct{ cl_uchar x, y, z, w; };
  539. __extension__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7; };
  540. __extension__ struct{ cl_uchar4 lo, hi; };
  541. #endif
  542. #if defined( __CL_UCHAR2__)
  543. __cl_uchar2 v2[4];
  544. #endif
  545. #if defined( __CL_UCHAR4__)
  546. __cl_uchar4 v4[2];
  547. #endif
  548. #if defined( __CL_UCHAR8__ )
  549. __cl_uchar8 v8;
  550. #endif
  551. }cl_uchar8;
  552. typedef union
  553. {
  554. cl_uchar CL_ALIGNED(16) s[16];
  555. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  556. __extension__ struct{ cl_uchar x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
  557. __extension__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
  558. __extension__ struct{ cl_uchar8 lo, hi; };
  559. #endif
  560. #if defined( __CL_UCHAR2__)
  561. __cl_uchar2 v2[8];
  562. #endif
  563. #if defined( __CL_UCHAR4__)
  564. __cl_uchar4 v4[4];
  565. #endif
  566. #if defined( __CL_UCHAR8__ )
  567. __cl_uchar8 v8[2];
  568. #endif
  569. #if defined( __CL_UCHAR16__ )
  570. __cl_uchar16 v16;
  571. #endif
  572. }cl_uchar16;
  573. /* ---- cl_shortn ---- */
  574. typedef union
  575. {
  576. cl_short CL_ALIGNED(4) s[2];
  577. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  578. __extension__ struct{ cl_short x, y; };
  579. __extension__ struct{ cl_short s0, s1; };
  580. __extension__ struct{ cl_short lo, hi; };
  581. #endif
  582. #if defined( __CL_SHORT2__)
  583. __cl_short2 v2;
  584. #endif
  585. }cl_short2;
  586. typedef union
  587. {
  588. cl_short CL_ALIGNED(8) s[4];
  589. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  590. __extension__ struct{ cl_short x, y, z, w; };
  591. __extension__ struct{ cl_short s0, s1, s2, s3; };
  592. __extension__ struct{ cl_short2 lo, hi; };
  593. #endif
  594. #if defined( __CL_SHORT2__)
  595. __cl_short2 v2[2];
  596. #endif
  597. #if defined( __CL_SHORT4__)
  598. __cl_short4 v4;
  599. #endif
  600. }cl_short4;
  601. /* cl_short3 is identical in size, alignment and behavior to cl_short4. See section 6.1.5. */
  602. typedef cl_short4 cl_short3;
  603. typedef union
  604. {
  605. cl_short CL_ALIGNED(16) s[8];
  606. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  607. __extension__ struct{ cl_short x, y, z, w; };
  608. __extension__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7; };
  609. __extension__ struct{ cl_short4 lo, hi; };
  610. #endif
  611. #if defined( __CL_SHORT2__)
  612. __cl_short2 v2[4];
  613. #endif
  614. #if defined( __CL_SHORT4__)
  615. __cl_short4 v4[2];
  616. #endif
  617. #if defined( __CL_SHORT8__ )
  618. __cl_short8 v8;
  619. #endif
  620. }cl_short8;
  621. typedef union
  622. {
  623. cl_short CL_ALIGNED(32) s[16];
  624. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  625. __extension__ struct{ cl_short x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
  626. __extension__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
  627. __extension__ struct{ cl_short8 lo, hi; };
  628. #endif
  629. #if defined( __CL_SHORT2__)
  630. __cl_short2 v2[8];
  631. #endif
  632. #if defined( __CL_SHORT4__)
  633. __cl_short4 v4[4];
  634. #endif
  635. #if defined( __CL_SHORT8__ )
  636. __cl_short8 v8[2];
  637. #endif
  638. #if defined( __CL_SHORT16__ )
  639. __cl_short16 v16;
  640. #endif
  641. }cl_short16;
  642. /* ---- cl_ushortn ---- */
  643. typedef union
  644. {
  645. cl_ushort CL_ALIGNED(4) s[2];
  646. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  647. __extension__ struct{ cl_ushort x, y; };
  648. __extension__ struct{ cl_ushort s0, s1; };
  649. __extension__ struct{ cl_ushort lo, hi; };
  650. #endif
  651. #if defined( __CL_USHORT2__)
  652. __cl_ushort2 v2;
  653. #endif
  654. }cl_ushort2;
  655. typedef union
  656. {
  657. cl_ushort CL_ALIGNED(8) s[4];
  658. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  659. __extension__ struct{ cl_ushort x, y, z, w; };
  660. __extension__ struct{ cl_ushort s0, s1, s2, s3; };
  661. __extension__ struct{ cl_ushort2 lo, hi; };
  662. #endif
  663. #if defined( __CL_USHORT2__)
  664. __cl_ushort2 v2[2];
  665. #endif
  666. #if defined( __CL_USHORT4__)
  667. __cl_ushort4 v4;
  668. #endif
  669. }cl_ushort4;
  670. /* cl_ushort3 is identical in size, alignment and behavior to cl_ushort4. See section 6.1.5. */
  671. typedef cl_ushort4 cl_ushort3;
  672. typedef union
  673. {
  674. cl_ushort CL_ALIGNED(16) s[8];
  675. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  676. __extension__ struct{ cl_ushort x, y, z, w; };
  677. __extension__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7; };
  678. __extension__ struct{ cl_ushort4 lo, hi; };
  679. #endif
  680. #if defined( __CL_USHORT2__)
  681. __cl_ushort2 v2[4];
  682. #endif
  683. #if defined( __CL_USHORT4__)
  684. __cl_ushort4 v4[2];
  685. #endif
  686. #if defined( __CL_USHORT8__ )
  687. __cl_ushort8 v8;
  688. #endif
  689. }cl_ushort8;
  690. typedef union
  691. {
  692. cl_ushort CL_ALIGNED(32) s[16];
  693. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  694. __extension__ struct{ cl_ushort x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
  695. __extension__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
  696. __extension__ struct{ cl_ushort8 lo, hi; };
  697. #endif
  698. #if defined( __CL_USHORT2__)
  699. __cl_ushort2 v2[8];
  700. #endif
  701. #if defined( __CL_USHORT4__)
  702. __cl_ushort4 v4[4];
  703. #endif
  704. #if defined( __CL_USHORT8__ )
  705. __cl_ushort8 v8[2];
  706. #endif
  707. #if defined( __CL_USHORT16__ )
  708. __cl_ushort16 v16;
  709. #endif
  710. }cl_ushort16;
  711. /* ---- cl_intn ---- */
  712. typedef union
  713. {
  714. cl_int CL_ALIGNED(8) s[2];
  715. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  716. __extension__ struct{ cl_int x, y; };
  717. __extension__ struct{ cl_int s0, s1; };
  718. __extension__ struct{ cl_int lo, hi; };
  719. #endif
  720. #if defined( __CL_INT2__)
  721. __cl_int2 v2;
  722. #endif
  723. }cl_int2;
  724. typedef union
  725. {
  726. cl_int CL_ALIGNED(16) s[4];
  727. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  728. __extension__ struct{ cl_int x, y, z, w; };
  729. __extension__ struct{ cl_int s0, s1, s2, s3; };
  730. __extension__ struct{ cl_int2 lo, hi; };
  731. #endif
  732. #if defined( __CL_INT2__)
  733. __cl_int2 v2[2];
  734. #endif
  735. #if defined( __CL_INT4__)
  736. __cl_int4 v4;
  737. #endif
  738. }cl_int4;
  739. /* cl_int3 is identical in size, alignment and behavior to cl_int4. See section 6.1.5. */
  740. typedef cl_int4 cl_int3;
  741. typedef union
  742. {
  743. cl_int CL_ALIGNED(32) s[8];
  744. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  745. __extension__ struct{ cl_int x, y, z, w; };
  746. __extension__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7; };
  747. __extension__ struct{ cl_int4 lo, hi; };
  748. #endif
  749. #if defined( __CL_INT2__)
  750. __cl_int2 v2[4];
  751. #endif
  752. #if defined( __CL_INT4__)
  753. __cl_int4 v4[2];
  754. #endif
  755. #if defined( __CL_INT8__ )
  756. __cl_int8 v8;
  757. #endif
  758. }cl_int8;
  759. typedef union
  760. {
  761. cl_int CL_ALIGNED(64) s[16];
  762. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  763. __extension__ struct{ cl_int x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
  764. __extension__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
  765. __extension__ struct{ cl_int8 lo, hi; };
  766. #endif
  767. #if defined( __CL_INT2__)
  768. __cl_int2 v2[8];
  769. #endif
  770. #if defined( __CL_INT4__)
  771. __cl_int4 v4[4];
  772. #endif
  773. #if defined( __CL_INT8__ )
  774. __cl_int8 v8[2];
  775. #endif
  776. #if defined( __CL_INT16__ )
  777. __cl_int16 v16;
  778. #endif
  779. }cl_int16;
  780. /* ---- cl_uintn ---- */
  781. typedef union
  782. {
  783. cl_uint CL_ALIGNED(8) s[2];
  784. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  785. __extension__ struct{ cl_uint x, y; };
  786. __extension__ struct{ cl_uint s0, s1; };
  787. __extension__ struct{ cl_uint lo, hi; };
  788. #endif
  789. #if defined( __CL_UINT2__)
  790. __cl_uint2 v2;
  791. #endif
  792. }cl_uint2;
  793. typedef union
  794. {
  795. cl_uint CL_ALIGNED(16) s[4];
  796. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  797. __extension__ struct{ cl_uint x, y, z, w; };
  798. __extension__ struct{ cl_uint s0, s1, s2, s3; };
  799. __extension__ struct{ cl_uint2 lo, hi; };
  800. #endif
  801. #if defined( __CL_UINT2__)
  802. __cl_uint2 v2[2];
  803. #endif
  804. #if defined( __CL_UINT4__)
  805. __cl_uint4 v4;
  806. #endif
  807. }cl_uint4;
  808. /* cl_uint3 is identical in size, alignment and behavior to cl_uint4. See section 6.1.5. */
  809. typedef cl_uint4 cl_uint3;
  810. typedef union
  811. {
  812. cl_uint CL_ALIGNED(32) s[8];
  813. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  814. __extension__ struct{ cl_uint x, y, z, w; };
  815. __extension__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7; };
  816. __extension__ struct{ cl_uint4 lo, hi; };
  817. #endif
  818. #if defined( __CL_UINT2__)
  819. __cl_uint2 v2[4];
  820. #endif
  821. #if defined( __CL_UINT4__)
  822. __cl_uint4 v4[2];
  823. #endif
  824. #if defined( __CL_UINT8__ )
  825. __cl_uint8 v8;
  826. #endif
  827. }cl_uint8;
  828. typedef union
  829. {
  830. cl_uint CL_ALIGNED(64) s[16];
  831. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  832. __extension__ struct{ cl_uint x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
  833. __extension__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
  834. __extension__ struct{ cl_uint8 lo, hi; };
  835. #endif
  836. #if defined( __CL_UINT2__)
  837. __cl_uint2 v2[8];
  838. #endif
  839. #if defined( __CL_UINT4__)
  840. __cl_uint4 v4[4];
  841. #endif
  842. #if defined( __CL_UINT8__ )
  843. __cl_uint8 v8[2];
  844. #endif
  845. #if defined( __CL_UINT16__ )
  846. __cl_uint16 v16;
  847. #endif
  848. }cl_uint16;
  849. /* ---- cl_longn ---- */
  850. typedef union
  851. {
  852. cl_long CL_ALIGNED(16) s[2];
  853. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  854. __extension__ struct{ cl_long x, y; };
  855. __extension__ struct{ cl_long s0, s1; };
  856. __extension__ struct{ cl_long lo, hi; };
  857. #endif
  858. #if defined( __CL_LONG2__)
  859. __cl_long2 v2;
  860. #endif
  861. }cl_long2;
  862. typedef union
  863. {
  864. cl_long CL_ALIGNED(32) s[4];
  865. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  866. __extension__ struct{ cl_long x, y, z, w; };
  867. __extension__ struct{ cl_long s0, s1, s2, s3; };
  868. __extension__ struct{ cl_long2 lo, hi; };
  869. #endif
  870. #if defined( __CL_LONG2__)
  871. __cl_long2 v2[2];
  872. #endif
  873. #if defined( __CL_LONG4__)
  874. __cl_long4 v4;
  875. #endif
  876. }cl_long4;
  877. /* cl_long3 is identical in size, alignment and behavior to cl_long4. See section 6.1.5. */
  878. typedef cl_long4 cl_long3;
  879. typedef union
  880. {
  881. cl_long CL_ALIGNED(64) s[8];
  882. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  883. __extension__ struct{ cl_long x, y, z, w; };
  884. __extension__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7; };
  885. __extension__ struct{ cl_long4 lo, hi; };
  886. #endif
  887. #if defined( __CL_LONG2__)
  888. __cl_long2 v2[4];
  889. #endif
  890. #if defined( __CL_LONG4__)
  891. __cl_long4 v4[2];
  892. #endif
  893. #if defined( __CL_LONG8__ )
  894. __cl_long8 v8;
  895. #endif
  896. }cl_long8;
  897. typedef union
  898. {
  899. cl_long CL_ALIGNED(128) s[16];
  900. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  901. __extension__ struct{ cl_long x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
  902. __extension__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
  903. __extension__ struct{ cl_long8 lo, hi; };
  904. #endif
  905. #if defined( __CL_LONG2__)
  906. __cl_long2 v2[8];
  907. #endif
  908. #if defined( __CL_LONG4__)
  909. __cl_long4 v4[4];
  910. #endif
  911. #if defined( __CL_LONG8__ )
  912. __cl_long8 v8[2];
  913. #endif
  914. #if defined( __CL_LONG16__ )
  915. __cl_long16 v16;
  916. #endif
  917. }cl_long16;
  918. /* ---- cl_ulongn ---- */
  919. typedef union
  920. {
  921. cl_ulong CL_ALIGNED(16) s[2];
  922. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  923. __extension__ struct{ cl_ulong x, y; };
  924. __extension__ struct{ cl_ulong s0, s1; };
  925. __extension__ struct{ cl_ulong lo, hi; };
  926. #endif
  927. #if defined( __CL_ULONG2__)
  928. __cl_ulong2 v2;
  929. #endif
  930. }cl_ulong2;
  931. typedef union
  932. {
  933. cl_ulong CL_ALIGNED(32) s[4];
  934. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  935. __extension__ struct{ cl_ulong x, y, z, w; };
  936. __extension__ struct{ cl_ulong s0, s1, s2, s3; };
  937. __extension__ struct{ cl_ulong2 lo, hi; };
  938. #endif
  939. #if defined( __CL_ULONG2__)
  940. __cl_ulong2 v2[2];
  941. #endif
  942. #if defined( __CL_ULONG4__)
  943. __cl_ulong4 v4;
  944. #endif
  945. }cl_ulong4;
  946. /* cl_ulong3 is identical in size, alignment and behavior to cl_ulong4. See section 6.1.5. */
  947. typedef cl_ulong4 cl_ulong3;
  948. typedef union
  949. {
  950. cl_ulong CL_ALIGNED(64) s[8];
  951. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  952. __extension__ struct{ cl_ulong x, y, z, w; };
  953. __extension__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7; };
  954. __extension__ struct{ cl_ulong4 lo, hi; };
  955. #endif
  956. #if defined( __CL_ULONG2__)
  957. __cl_ulong2 v2[4];
  958. #endif
  959. #if defined( __CL_ULONG4__)
  960. __cl_ulong4 v4[2];
  961. #endif
  962. #if defined( __CL_ULONG8__ )
  963. __cl_ulong8 v8;
  964. #endif
  965. }cl_ulong8;
  966. typedef union
  967. {
  968. cl_ulong CL_ALIGNED(128) s[16];
  969. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  970. __extension__ struct{ cl_ulong x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
  971. __extension__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
  972. __extension__ struct{ cl_ulong8 lo, hi; };
  973. #endif
  974. #if defined( __CL_ULONG2__)
  975. __cl_ulong2 v2[8];
  976. #endif
  977. #if defined( __CL_ULONG4__)
  978. __cl_ulong4 v4[4];
  979. #endif
  980. #if defined( __CL_ULONG8__ )
  981. __cl_ulong8 v8[2];
  982. #endif
  983. #if defined( __CL_ULONG16__ )
  984. __cl_ulong16 v16;
  985. #endif
  986. }cl_ulong16;
  987. /* --- cl_floatn ---- */
  988. typedef union
  989. {
  990. cl_float CL_ALIGNED(8) s[2];
  991. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  992. __extension__ struct{ cl_float x, y; };
  993. __extension__ struct{ cl_float s0, s1; };
  994. __extension__ struct{ cl_float lo, hi; };
  995. #endif
  996. #if defined( __CL_FLOAT2__)
  997. __cl_float2 v2;
  998. #endif
  999. }cl_float2;
  1000. typedef union
  1001. {
  1002. cl_float CL_ALIGNED(16) s[4];
  1003. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  1004. __extension__ struct{ cl_float x, y, z, w; };
  1005. __extension__ struct{ cl_float s0, s1, s2, s3; };
  1006. __extension__ struct{ cl_float2 lo, hi; };
  1007. #endif
  1008. #if defined( __CL_FLOAT2__)
  1009. __cl_float2 v2[2];
  1010. #endif
  1011. #if defined( __CL_FLOAT4__)
  1012. __cl_float4 v4;
  1013. #endif
  1014. }cl_float4;
  1015. /* cl_float3 is identical in size, alignment and behavior to cl_float4. See section 6.1.5. */
  1016. typedef cl_float4 cl_float3;
  1017. typedef union
  1018. {
  1019. cl_float CL_ALIGNED(32) s[8];
  1020. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  1021. __extension__ struct{ cl_float x, y, z, w; };
  1022. __extension__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7; };
  1023. __extension__ struct{ cl_float4 lo, hi; };
  1024. #endif
  1025. #if defined( __CL_FLOAT2__)
  1026. __cl_float2 v2[4];
  1027. #endif
  1028. #if defined( __CL_FLOAT4__)
  1029. __cl_float4 v4[2];
  1030. #endif
  1031. #if defined( __CL_FLOAT8__ )
  1032. __cl_float8 v8;
  1033. #endif
  1034. }cl_float8;
  1035. typedef union
  1036. {
  1037. cl_float CL_ALIGNED(64) s[16];
  1038. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  1039. __extension__ struct{ cl_float x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
  1040. __extension__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
  1041. __extension__ struct{ cl_float8 lo, hi; };
  1042. #endif
  1043. #if defined( __CL_FLOAT2__)
  1044. __cl_float2 v2[8];
  1045. #endif
  1046. #if defined( __CL_FLOAT4__)
  1047. __cl_float4 v4[4];
  1048. #endif
  1049. #if defined( __CL_FLOAT8__ )
  1050. __cl_float8 v8[2];
  1051. #endif
  1052. #if defined( __CL_FLOAT16__ )
  1053. __cl_float16 v16;
  1054. #endif
  1055. }cl_float16;
  1056. /* --- cl_doublen ---- */
  1057. typedef union
  1058. {
  1059. cl_double CL_ALIGNED(16) s[2];
  1060. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  1061. __extension__ struct{ cl_double x, y; };
  1062. __extension__ struct{ cl_double s0, s1; };
  1063. __extension__ struct{ cl_double lo, hi; };
  1064. #endif
  1065. #if defined( __CL_DOUBLE2__)
  1066. __cl_double2 v2;
  1067. #endif
  1068. }cl_double2;
  1069. typedef union
  1070. {
  1071. cl_double CL_ALIGNED(32) s[4];
  1072. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  1073. __extension__ struct{ cl_double x, y, z, w; };
  1074. __extension__ struct{ cl_double s0, s1, s2, s3; };
  1075. __extension__ struct{ cl_double2 lo, hi; };
  1076. #endif
  1077. #if defined( __CL_DOUBLE2__)
  1078. __cl_double2 v2[2];
  1079. #endif
  1080. #if defined( __CL_DOUBLE4__)
  1081. __cl_double4 v4;
  1082. #endif
  1083. }cl_double4;
  1084. /* cl_double3 is identical in size, alignment and behavior to cl_double4. See section 6.1.5. */
  1085. typedef cl_double4 cl_double3;
  1086. typedef union
  1087. {
  1088. cl_double CL_ALIGNED(64) s[8];
  1089. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  1090. __extension__ struct{ cl_double x, y, z, w; };
  1091. __extension__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7; };
  1092. __extension__ struct{ cl_double4 lo, hi; };
  1093. #endif
  1094. #if defined( __CL_DOUBLE2__)
  1095. __cl_double2 v2[4];
  1096. #endif
  1097. #if defined( __CL_DOUBLE4__)
  1098. __cl_double4 v4[2];
  1099. #endif
  1100. #if defined( __CL_DOUBLE8__ )
  1101. __cl_double8 v8;
  1102. #endif
  1103. }cl_double8;
  1104. typedef union
  1105. {
  1106. cl_double CL_ALIGNED(128) s[16];
  1107. #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
  1108. __extension__ struct{ cl_double x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
  1109. __extension__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
  1110. __extension__ struct{ cl_double8 lo, hi; };
  1111. #endif
  1112. #if defined( __CL_DOUBLE2__)
  1113. __cl_double2 v2[8];
  1114. #endif
  1115. #if defined( __CL_DOUBLE4__)
  1116. __cl_double4 v4[4];
  1117. #endif
  1118. #if defined( __CL_DOUBLE8__ )
  1119. __cl_double8 v8[2];
  1120. #endif
  1121. #if defined( __CL_DOUBLE16__ )
  1122. __cl_double16 v16;
  1123. #endif
  1124. }cl_double16;
  1125. /* Macro to facilitate debugging
  1126. * Usage:
  1127. * Place CL_PROGRAM_STRING_DEBUG_INFO on the line before the first line of your source.
  1128. * The first line ends with: CL_PROGRAM_STRING_DEBUG_INFO \"
  1129. * Each line thereafter of OpenCL C source must end with: \n\
  1130. * The last line ends in ";
  1131. *
  1132. * Example:
  1133. *
  1134. * const char *my_program = CL_PROGRAM_STRING_DEBUG_INFO "\
  1135. * kernel void foo( int a, float * b ) \n\
  1136. * { \n\
  1137. * // my comment \n\
  1138. * *b[ get_global_id(0)] = a; \n\
  1139. * } \n\
  1140. * ";
  1141. *
  1142. * This should correctly set up the line, (column) and file information for your source
  1143. * string so you can do source level debugging.
  1144. */
  1145. #define __CL_STRINGIFY( _x ) # _x
  1146. #define _CL_STRINGIFY( _x ) __CL_STRINGIFY( _x )
  1147. #define CL_PROGRAM_STRING_DEBUG_INFO "#line " _CL_STRINGIFY(__LINE__) " \"" __FILE__ "\" \n\n"
  1148. #ifdef __cplusplus
  1149. }
  1150. #endif
  1151. #endif /* __CL_PLATFORM_H */