cl_platform.h 42 KB

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