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