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