cl_platform.h 41 KB

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