1 //===----- opencl-c-base.h - OpenCL C language base definitions -----------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef _OPENCL_BASE_H_ 10 #define _OPENCL_BASE_H_ 11 12 // Define extension macros 13 14 #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) 15 // For SPIR all extensions are supported. 16 #if defined(__SPIR__) 17 #define cl_khr_subgroup_extended_types 1 18 #define cl_khr_subgroup_non_uniform_vote 1 19 #define cl_khr_subgroup_ballot 1 20 #define cl_khr_subgroup_non_uniform_arithmetic 1 21 #define cl_khr_subgroup_shuffle 1 22 #define cl_khr_subgroup_shuffle_relative 1 23 #define cl_khr_subgroup_clustered_reduce 1 24 #define cl_khr_extended_bit_ops 1 25 #define cl_khr_integer_dot_product 1 26 #define __opencl_c_integer_dot_product_input_4x8bit 1 27 #define __opencl_c_integer_dot_product_input_4x8bit_packed 1 28 29 #endif // defined(__SPIR__) 30 #endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) 31 32 // Define feature macros for OpenCL C 2.0 33 #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200) 34 #define __opencl_c_pipes 1 35 #define __opencl_c_generic_address_space 1 36 #define __opencl_c_work_group_collective_functions 1 37 #define __opencl_c_atomic_order_acq_rel 1 38 #define __opencl_c_atomic_order_seq_cst 1 39 #define __opencl_c_atomic_scope_device 1 40 #define __opencl_c_atomic_scope_all_devices 1 41 #define __opencl_c_device_enqueue 1 42 #define __opencl_c_read_write_images 1 43 #define __opencl_c_program_scope_global_variables 1 44 #define __opencl_c_images 1 45 #endif 46 47 // Define header-only feature macros for OpenCL C 3.0. 48 #if (__OPENCL_C_VERSION__ == 300) 49 // For the SPIR target all features are supported. 50 #if defined(__SPIR__) 51 #define __opencl_c_atomic_scope_all_devices 1 52 #endif // defined(__SPIR__) 53 #endif // (__OPENCL_C_VERSION__ == 300) 54 55 // built-in scalar data types: 56 57 /** 58 * An unsigned 8-bit integer. 59 */ 60 typedef unsigned char uchar; 61 62 /** 63 * An unsigned 16-bit integer. 64 */ 65 typedef unsigned short ushort; 66 67 /** 68 * An unsigned 32-bit integer. 69 */ 70 typedef unsigned int uint; 71 72 /** 73 * An unsigned 64-bit integer. 74 */ 75 typedef unsigned long ulong; 76 77 /** 78 * The unsigned integer type of the result of the sizeof operator. This 79 * is a 32-bit unsigned integer if CL_DEVICE_ADDRESS_BITS 80 * defined in table 4.3 is 32-bits and is a 64-bit unsigned integer if 81 * CL_DEVICE_ADDRESS_BITS is 64-bits. 82 */ 83 typedef __SIZE_TYPE__ size_t; 84 85 /** 86 * A signed integer type that is the result of subtracting two pointers. 87 * This is a 32-bit signed integer if CL_DEVICE_ADDRESS_BITS 88 * defined in table 4.3 is 32-bits and is a 64-bit signed integer if 89 * CL_DEVICE_ADDRESS_BITS is 64-bits. 90 */ 91 typedef __PTRDIFF_TYPE__ ptrdiff_t; 92 93 /** 94 * A signed integer type with the property that any valid pointer to 95 * void can be converted to this type, then converted back to pointer 96 * to void, and the result will compare equal to the original pointer. 97 */ 98 typedef __INTPTR_TYPE__ intptr_t; 99 100 /** 101 * An unsigned integer type with the property that any valid pointer to 102 * void can be converted to this type, then converted back to pointer 103 * to void, and the result will compare equal to the original pointer. 104 */ 105 typedef __UINTPTR_TYPE__ uintptr_t; 106 107 // built-in vector data types: 108 typedef char char2 __attribute__((ext_vector_type(2))); 109 typedef char char3 __attribute__((ext_vector_type(3))); 110 typedef char char4 __attribute__((ext_vector_type(4))); 111 typedef char char8 __attribute__((ext_vector_type(8))); 112 typedef char char16 __attribute__((ext_vector_type(16))); 113 typedef uchar uchar2 __attribute__((ext_vector_type(2))); 114 typedef uchar uchar3 __attribute__((ext_vector_type(3))); 115 typedef uchar uchar4 __attribute__((ext_vector_type(4))); 116 typedef uchar uchar8 __attribute__((ext_vector_type(8))); 117 typedef uchar uchar16 __attribute__((ext_vector_type(16))); 118 typedef short short2 __attribute__((ext_vector_type(2))); 119 typedef short short3 __attribute__((ext_vector_type(3))); 120 typedef short short4 __attribute__((ext_vector_type(4))); 121 typedef short short8 __attribute__((ext_vector_type(8))); 122 typedef short short16 __attribute__((ext_vector_type(16))); 123 typedef ushort ushort2 __attribute__((ext_vector_type(2))); 124 typedef ushort ushort3 __attribute__((ext_vector_type(3))); 125 typedef ushort ushort4 __attribute__((ext_vector_type(4))); 126 typedef ushort ushort8 __attribute__((ext_vector_type(8))); 127 typedef ushort ushort16 __attribute__((ext_vector_type(16))); 128 typedef int int2 __attribute__((ext_vector_type(2))); 129 typedef int int3 __attribute__((ext_vector_type(3))); 130 typedef int int4 __attribute__((ext_vector_type(4))); 131 typedef int int8 __attribute__((ext_vector_type(8))); 132 typedef int int16 __attribute__((ext_vector_type(16))); 133 typedef uint uint2 __attribute__((ext_vector_type(2))); 134 typedef uint uint3 __attribute__((ext_vector_type(3))); 135 typedef uint uint4 __attribute__((ext_vector_type(4))); 136 typedef uint uint8 __attribute__((ext_vector_type(8))); 137 typedef uint uint16 __attribute__((ext_vector_type(16))); 138 typedef long long2 __attribute__((ext_vector_type(2))); 139 typedef long long3 __attribute__((ext_vector_type(3))); 140 typedef long long4 __attribute__((ext_vector_type(4))); 141 typedef long long8 __attribute__((ext_vector_type(8))); 142 typedef long long16 __attribute__((ext_vector_type(16))); 143 typedef ulong ulong2 __attribute__((ext_vector_type(2))); 144 typedef ulong ulong3 __attribute__((ext_vector_type(3))); 145 typedef ulong ulong4 __attribute__((ext_vector_type(4))); 146 typedef ulong ulong8 __attribute__((ext_vector_type(8))); 147 typedef ulong ulong16 __attribute__((ext_vector_type(16))); 148 typedef float float2 __attribute__((ext_vector_type(2))); 149 typedef float float3 __attribute__((ext_vector_type(3))); 150 typedef float float4 __attribute__((ext_vector_type(4))); 151 typedef float float8 __attribute__((ext_vector_type(8))); 152 typedef float float16 __attribute__((ext_vector_type(16))); 153 #ifdef cl_khr_fp16 154 #pragma OPENCL EXTENSION cl_khr_fp16 : enable 155 typedef half half2 __attribute__((ext_vector_type(2))); 156 typedef half half3 __attribute__((ext_vector_type(3))); 157 typedef half half4 __attribute__((ext_vector_type(4))); 158 typedef half half8 __attribute__((ext_vector_type(8))); 159 typedef half half16 __attribute__((ext_vector_type(16))); 160 #endif 161 #ifdef cl_khr_fp64 162 #if __OPENCL_C_VERSION__ < CL_VERSION_1_2 163 #pragma OPENCL EXTENSION cl_khr_fp64 : enable 164 #endif 165 typedef double double2 __attribute__((ext_vector_type(2))); 166 typedef double double3 __attribute__((ext_vector_type(3))); 167 typedef double double4 __attribute__((ext_vector_type(4))); 168 typedef double double8 __attribute__((ext_vector_type(8))); 169 typedef double double16 __attribute__((ext_vector_type(16))); 170 #endif 171 172 #if defined(__OPENCL_CPP_VERSION__) 173 #define NULL nullptr 174 #elif defined(__OPENCL_C_VERSION__) 175 #define NULL ((void*)0) 176 #endif 177 178 /** 179 * Value of maximum non-infinite single-precision floating-point 180 * number. 181 */ 182 #define MAXFLOAT 0x1.fffffep127f 183 184 /** 185 * A positive float constant expression. HUGE_VALF evaluates 186 * to +infinity. Used as an error value returned by the built-in 187 * math functions. 188 */ 189 #define HUGE_VALF (__builtin_huge_valf()) 190 191 /** 192 * A positive double constant expression. HUGE_VAL evaluates 193 * to +infinity. Used as an error value returned by the built-in 194 * math functions. 195 */ 196 #define HUGE_VAL (__builtin_huge_val()) 197 198 /** 199 * A constant expression of type float representing positive or 200 * unsigned infinity. 201 */ 202 #define INFINITY (__builtin_inff()) 203 204 /** 205 * A constant expression of type float representing a quiet NaN. 206 */ 207 #define NAN as_float(INT_MAX) 208 209 #define FP_ILOGB0 INT_MIN 210 #define FP_ILOGBNAN INT_MAX 211 212 #define FLT_DIG 6 213 #define FLT_MANT_DIG 24 214 #define FLT_MAX_10_EXP +38 215 #define FLT_MAX_EXP +128 216 #define FLT_MIN_10_EXP -37 217 #define FLT_MIN_EXP -125 218 #define FLT_RADIX 2 219 #define FLT_MAX 0x1.fffffep127f 220 #define FLT_MIN 0x1.0p-126f 221 #define FLT_EPSILON 0x1.0p-23f 222 223 #define M_E_F 2.71828182845904523536028747135266250f 224 #define M_LOG2E_F 1.44269504088896340735992468100189214f 225 #define M_LOG10E_F 0.434294481903251827651128918916605082f 226 #define M_LN2_F 0.693147180559945309417232121458176568f 227 #define M_LN10_F 2.30258509299404568401799145468436421f 228 #define M_PI_F 3.14159265358979323846264338327950288f 229 #define M_PI_2_F 1.57079632679489661923132169163975144f 230 #define M_PI_4_F 0.785398163397448309615660845819875721f 231 #define M_1_PI_F 0.318309886183790671537767526745028724f 232 #define M_2_PI_F 0.636619772367581343075535053490057448f 233 #define M_2_SQRTPI_F 1.12837916709551257389615890312154517f 234 #define M_SQRT2_F 1.41421356237309504880168872420969808f 235 #define M_SQRT1_2_F 0.707106781186547524400844362104849039f 236 237 #define DBL_DIG 15 238 #define DBL_MANT_DIG 53 239 #define DBL_MAX_10_EXP +308 240 #define DBL_MAX_EXP +1024 241 #define DBL_MIN_10_EXP -307 242 #define DBL_MIN_EXP -1021 243 #define DBL_RADIX 2 244 #define DBL_MAX 0x1.fffffffffffffp1023 245 #define DBL_MIN 0x1.0p-1022 246 #define DBL_EPSILON 0x1.0p-52 247 248 #define M_E 0x1.5bf0a8b145769p+1 249 #define M_LOG2E 0x1.71547652b82fep+0 250 #define M_LOG10E 0x1.bcb7b1526e50ep-2 251 #define M_LN2 0x1.62e42fefa39efp-1 252 #define M_LN10 0x1.26bb1bbb55516p+1 253 #define M_PI 0x1.921fb54442d18p+1 254 #define M_PI_2 0x1.921fb54442d18p+0 255 #define M_PI_4 0x1.921fb54442d18p-1 256 #define M_1_PI 0x1.45f306dc9c883p-2 257 #define M_2_PI 0x1.45f306dc9c883p-1 258 #define M_2_SQRTPI 0x1.20dd750429b6dp+0 259 #define M_SQRT2 0x1.6a09e667f3bcdp+0 260 #define M_SQRT1_2 0x1.6a09e667f3bcdp-1 261 262 #ifdef cl_khr_fp16 263 264 #define HALF_DIG 3 265 #define HALF_MANT_DIG 11 266 #define HALF_MAX_10_EXP +4 267 #define HALF_MAX_EXP +16 268 #define HALF_MIN_10_EXP -4 269 #define HALF_MIN_EXP -13 270 #define HALF_RADIX 2 271 #define HALF_MAX ((0x1.ffcp15h)) 272 #define HALF_MIN ((0x1.0p-14h)) 273 #define HALF_EPSILON ((0x1.0p-10h)) 274 275 #define M_E_H 2.71828182845904523536028747135266250h 276 #define M_LOG2E_H 1.44269504088896340735992468100189214h 277 #define M_LOG10E_H 0.434294481903251827651128918916605082h 278 #define M_LN2_H 0.693147180559945309417232121458176568h 279 #define M_LN10_H 2.30258509299404568401799145468436421h 280 #define M_PI_H 3.14159265358979323846264338327950288h 281 #define M_PI_2_H 1.57079632679489661923132169163975144h 282 #define M_PI_4_H 0.785398163397448309615660845819875721h 283 #define M_1_PI_H 0.318309886183790671537767526745028724h 284 #define M_2_PI_H 0.636619772367581343075535053490057448h 285 #define M_2_SQRTPI_H 1.12837916709551257389615890312154517h 286 #define M_SQRT2_H 1.41421356237309504880168872420969808h 287 #define M_SQRT1_2_H 0.707106781186547524400844362104849039h 288 289 #endif //cl_khr_fp16 290 291 #define CHAR_BIT 8 292 #define SCHAR_MAX 127 293 #define SCHAR_MIN (-128) 294 #define UCHAR_MAX 255 295 #define CHAR_MAX SCHAR_MAX 296 #define CHAR_MIN SCHAR_MIN 297 #define USHRT_MAX 65535 298 #define SHRT_MAX 32767 299 #define SHRT_MIN (-32768) 300 #define UINT_MAX 0xffffffff 301 #define INT_MAX 2147483647 302 #define INT_MIN (-2147483647-1) 303 #define ULONG_MAX 0xffffffffffffffffUL 304 #define LONG_MAX 0x7fffffffffffffffL 305 #define LONG_MIN (-0x7fffffffffffffffL-1) 306 307 // OpenCL v1.1 s6.11.8, v1.2 s6.12.8, v2.0 s6.13.8 - Synchronization Functions 308 309 // Flag type and values for barrier, mem_fence, read_mem_fence, write_mem_fence 310 typedef uint cl_mem_fence_flags; 311 312 /** 313 * Queue a memory fence to ensure correct 314 * ordering of memory operations to local memory 315 */ 316 #define CLK_LOCAL_MEM_FENCE 0x01 317 318 /** 319 * Queue a memory fence to ensure correct 320 * ordering of memory operations to global memory 321 */ 322 #define CLK_GLOBAL_MEM_FENCE 0x02 323 324 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) 325 326 typedef enum memory_scope { 327 memory_scope_work_item = __OPENCL_MEMORY_SCOPE_WORK_ITEM, 328 memory_scope_work_group = __OPENCL_MEMORY_SCOPE_WORK_GROUP, 329 memory_scope_device = __OPENCL_MEMORY_SCOPE_DEVICE, 330 #if defined(__opencl_c_atomic_scope_all_devices) 331 memory_scope_all_svm_devices = __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES, 332 #if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0) 333 memory_scope_all_devices = memory_scope_all_svm_devices, 334 #endif // __OPENCL_C_VERSION__ >= CL_VERSION_3_0 335 #endif // defined(__opencl_c_atomic_scope_all_devices) 336 #if defined(cl_intel_subgroups) || defined(cl_khr_subgroups) 337 memory_scope_sub_group = __OPENCL_MEMORY_SCOPE_SUB_GROUP 338 #endif 339 } memory_scope; 340 341 /** 342 * Queue a memory fence to ensure correct ordering of memory 343 * operations between work-items of a work-group to 344 * image memory. 345 */ 346 #define CLK_IMAGE_MEM_FENCE 0x04 347 348 #ifndef ATOMIC_VAR_INIT 349 #define ATOMIC_VAR_INIT(x) (x) 350 #endif //ATOMIC_VAR_INIT 351 #define ATOMIC_FLAG_INIT 0 352 353 // enum values aligned with what clang uses in EmitAtomicExpr() 354 typedef enum memory_order 355 { 356 memory_order_relaxed = __ATOMIC_RELAXED, 357 memory_order_acquire = __ATOMIC_ACQUIRE, 358 memory_order_release = __ATOMIC_RELEASE, 359 memory_order_acq_rel = __ATOMIC_ACQ_REL, 360 #if defined(__opencl_c_atomic_order_seq_cst) 361 memory_order_seq_cst = __ATOMIC_SEQ_CST 362 #endif 363 } memory_order; 364 365 #endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) 366 367 // OpenCL v1.1 s6.11.3, v1.2 s6.12.14, v2.0 s6.13.14 - Image Read and Write Functions 368 369 // These values need to match the runtime equivalent 370 // 371 // Addressing Mode. 372 // 373 #define CLK_ADDRESS_NONE 0 374 #define CLK_ADDRESS_CLAMP_TO_EDGE 2 375 #define CLK_ADDRESS_CLAMP 4 376 #define CLK_ADDRESS_REPEAT 6 377 #define CLK_ADDRESS_MIRRORED_REPEAT 8 378 379 // 380 // Coordination Normalization 381 // 382 #define CLK_NORMALIZED_COORDS_FALSE 0 383 #define CLK_NORMALIZED_COORDS_TRUE 1 384 385 // 386 // Filtering Mode. 387 // 388 #define CLK_FILTER_NEAREST 0x10 389 #define CLK_FILTER_LINEAR 0x20 390 391 #ifdef cl_khr_gl_msaa_sharing 392 #pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing : enable 393 #endif //cl_khr_gl_msaa_sharing 394 395 // 396 // Channel Datatype. 397 // 398 #define CLK_SNORM_INT8 0x10D0 399 #define CLK_SNORM_INT16 0x10D1 400 #define CLK_UNORM_INT8 0x10D2 401 #define CLK_UNORM_INT16 0x10D3 402 #define CLK_UNORM_SHORT_565 0x10D4 403 #define CLK_UNORM_SHORT_555 0x10D5 404 #define CLK_UNORM_INT_101010 0x10D6 405 #define CLK_SIGNED_INT8 0x10D7 406 #define CLK_SIGNED_INT16 0x10D8 407 #define CLK_SIGNED_INT32 0x10D9 408 #define CLK_UNSIGNED_INT8 0x10DA 409 #define CLK_UNSIGNED_INT16 0x10DB 410 #define CLK_UNSIGNED_INT32 0x10DC 411 #define CLK_HALF_FLOAT 0x10DD 412 #define CLK_FLOAT 0x10DE 413 #define CLK_UNORM_INT24 0x10DF 414 415 // Channel order, numbering must be aligned with cl_channel_order in cl.h 416 // 417 #define CLK_R 0x10B0 418 #define CLK_A 0x10B1 419 #define CLK_RG 0x10B2 420 #define CLK_RA 0x10B3 421 #define CLK_RGB 0x10B4 422 #define CLK_RGBA 0x10B5 423 #define CLK_BGRA 0x10B6 424 #define CLK_ARGB 0x10B7 425 #define CLK_INTENSITY 0x10B8 426 #define CLK_LUMINANCE 0x10B9 427 #define CLK_Rx 0x10BA 428 #define CLK_RGx 0x10BB 429 #define CLK_RGBx 0x10BC 430 #define CLK_DEPTH 0x10BD 431 #define CLK_DEPTH_STENCIL 0x10BE 432 #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0 433 #define CLK_sRGB 0x10BF 434 #define CLK_sRGBx 0x10C0 435 #define CLK_sRGBA 0x10C1 436 #define CLK_sBGRA 0x10C2 437 #define CLK_ABGR 0x10C3 438 #endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0 439 440 // OpenCL v2.0 s6.13.16 - Pipe Functions 441 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) 442 #define CLK_NULL_RESERVE_ID (__builtin_astype(((void*)(__SIZE_MAX__)), reserve_id_t)) 443 444 // OpenCL v2.0 s6.13.17 - Enqueue Kernels 445 #define CL_COMPLETE 0x0 446 #define CL_RUNNING 0x1 447 #define CL_SUBMITTED 0x2 448 #define CL_QUEUED 0x3 449 450 #define CLK_SUCCESS 0 451 #define CLK_ENQUEUE_FAILURE -101 452 #define CLK_INVALID_QUEUE -102 453 #define CLK_INVALID_NDRANGE -160 454 #define CLK_INVALID_EVENT_WAIT_LIST -57 455 #define CLK_DEVICE_QUEUE_FULL -161 456 #define CLK_INVALID_ARG_SIZE -51 457 #define CLK_EVENT_ALLOCATION_FAILURE -100 458 #define CLK_OUT_OF_RESOURCES -5 459 460 #define CLK_NULL_QUEUE 0 461 #define CLK_NULL_EVENT (__builtin_astype(((__SIZE_MAX__)), clk_event_t)) 462 463 // execution model related definitions 464 #define CLK_ENQUEUE_FLAGS_NO_WAIT 0x0 465 #define CLK_ENQUEUE_FLAGS_WAIT_KERNEL 0x1 466 #define CLK_ENQUEUE_FLAGS_WAIT_WORK_GROUP 0x2 467 468 typedef int kernel_enqueue_flags_t; 469 typedef int clk_profiling_info; 470 471 // Profiling info name (see capture_event_profiling_info) 472 #define CLK_PROFILING_COMMAND_EXEC_TIME 0x1 473 474 #define MAX_WORK_DIM 3 475 476 typedef struct { 477 unsigned int workDimension; 478 size_t globalWorkOffset[MAX_WORK_DIM]; 479 size_t globalWorkSize[MAX_WORK_DIM]; 480 size_t localWorkSize[MAX_WORK_DIM]; 481 } ndrange_t; 482 483 #endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) 484 485 /** 486 * OpenCL v1.1/1.2/2.0 s6.2.4.2 - as_type operators 487 * Reinterprets a data type as another data type of the same size 488 */ 489 #define as_char(x) __builtin_astype((x), char) 490 #define as_char2(x) __builtin_astype((x), char2) 491 #define as_char3(x) __builtin_astype((x), char3) 492 #define as_char4(x) __builtin_astype((x), char4) 493 #define as_char8(x) __builtin_astype((x), char8) 494 #define as_char16(x) __builtin_astype((x), char16) 495 496 #define as_uchar(x) __builtin_astype((x), uchar) 497 #define as_uchar2(x) __builtin_astype((x), uchar2) 498 #define as_uchar3(x) __builtin_astype((x), uchar3) 499 #define as_uchar4(x) __builtin_astype((x), uchar4) 500 #define as_uchar8(x) __builtin_astype((x), uchar8) 501 #define as_uchar16(x) __builtin_astype((x), uchar16) 502 503 #define as_short(x) __builtin_astype((x), short) 504 #define as_short2(x) __builtin_astype((x), short2) 505 #define as_short3(x) __builtin_astype((x), short3) 506 #define as_short4(x) __builtin_astype((x), short4) 507 #define as_short8(x) __builtin_astype((x), short8) 508 #define as_short16(x) __builtin_astype((x), short16) 509 510 #define as_ushort(x) __builtin_astype((x), ushort) 511 #define as_ushort2(x) __builtin_astype((x), ushort2) 512 #define as_ushort3(x) __builtin_astype((x), ushort3) 513 #define as_ushort4(x) __builtin_astype((x), ushort4) 514 #define as_ushort8(x) __builtin_astype((x), ushort8) 515 #define as_ushort16(x) __builtin_astype((x), ushort16) 516 517 #define as_int(x) __builtin_astype((x), int) 518 #define as_int2(x) __builtin_astype((x), int2) 519 #define as_int3(x) __builtin_astype((x), int3) 520 #define as_int4(x) __builtin_astype((x), int4) 521 #define as_int8(x) __builtin_astype((x), int8) 522 #define as_int16(x) __builtin_astype((x), int16) 523 524 #define as_uint(x) __builtin_astype((x), uint) 525 #define as_uint2(x) __builtin_astype((x), uint2) 526 #define as_uint3(x) __builtin_astype((x), uint3) 527 #define as_uint4(x) __builtin_astype((x), uint4) 528 #define as_uint8(x) __builtin_astype((x), uint8) 529 #define as_uint16(x) __builtin_astype((x), uint16) 530 531 #define as_long(x) __builtin_astype((x), long) 532 #define as_long2(x) __builtin_astype((x), long2) 533 #define as_long3(x) __builtin_astype((x), long3) 534 #define as_long4(x) __builtin_astype((x), long4) 535 #define as_long8(x) __builtin_astype((x), long8) 536 #define as_long16(x) __builtin_astype((x), long16) 537 538 #define as_ulong(x) __builtin_astype((x), ulong) 539 #define as_ulong2(x) __builtin_astype((x), ulong2) 540 #define as_ulong3(x) __builtin_astype((x), ulong3) 541 #define as_ulong4(x) __builtin_astype((x), ulong4) 542 #define as_ulong8(x) __builtin_astype((x), ulong8) 543 #define as_ulong16(x) __builtin_astype((x), ulong16) 544 545 #define as_float(x) __builtin_astype((x), float) 546 #define as_float2(x) __builtin_astype((x), float2) 547 #define as_float3(x) __builtin_astype((x), float3) 548 #define as_float4(x) __builtin_astype((x), float4) 549 #define as_float8(x) __builtin_astype((x), float8) 550 #define as_float16(x) __builtin_astype((x), float16) 551 552 #ifdef cl_khr_fp64 553 #define as_double(x) __builtin_astype((x), double) 554 #define as_double2(x) __builtin_astype((x), double2) 555 #define as_double3(x) __builtin_astype((x), double3) 556 #define as_double4(x) __builtin_astype((x), double4) 557 #define as_double8(x) __builtin_astype((x), double8) 558 #define as_double16(x) __builtin_astype((x), double16) 559 #endif // cl_khr_fp64 560 561 #ifdef cl_khr_fp16 562 #define as_half(x) __builtin_astype((x), half) 563 #define as_half2(x) __builtin_astype((x), half2) 564 #define as_half3(x) __builtin_astype((x), half3) 565 #define as_half4(x) __builtin_astype((x), half4) 566 #define as_half8(x) __builtin_astype((x), half8) 567 #define as_half16(x) __builtin_astype((x), half16) 568 #endif // cl_khr_fp16 569 570 #define as_size_t(x) __builtin_astype((x), size_t) 571 #define as_ptrdiff_t(x) __builtin_astype((x), ptrdiff_t) 572 #define as_intptr_t(x) __builtin_astype((x), intptr_t) 573 #define as_uintptr_t(x) __builtin_astype((x), uintptr_t) 574 575 // OpenCL v1.1 s6.9, v1.2/2.0 s6.10 - Function qualifiers 576 577 #define __kernel_exec(X, typen) __kernel \ 578 __attribute__((work_group_size_hint(X, 1, 1))) \ 579 __attribute__((vec_type_hint(typen))) 580 581 #define kernel_exec(X, typen) __kernel \ 582 __attribute__((work_group_size_hint(X, 1, 1))) \ 583 __attribute__((vec_type_hint(typen))) 584 585 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2) 586 // OpenCL v1.2 s6.12.13, v2.0 s6.13.13 - printf 587 588 int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 2))); 589 #endif 590 591 #ifdef cl_intel_device_side_avc_motion_estimation 592 593 #define CLK_AVC_ME_MAJOR_16x16_INTEL 0x0 594 #define CLK_AVC_ME_MAJOR_16x8_INTEL 0x1 595 #define CLK_AVC_ME_MAJOR_8x16_INTEL 0x2 596 #define CLK_AVC_ME_MAJOR_8x8_INTEL 0x3 597 598 #define CLK_AVC_ME_MINOR_8x8_INTEL 0x0 599 #define CLK_AVC_ME_MINOR_8x4_INTEL 0x1 600 #define CLK_AVC_ME_MINOR_4x8_INTEL 0x2 601 #define CLK_AVC_ME_MINOR_4x4_INTEL 0x3 602 603 #define CLK_AVC_ME_MAJOR_FORWARD_INTEL 0x0 604 #define CLK_AVC_ME_MAJOR_BACKWARD_INTEL 0x1 605 #define CLK_AVC_ME_MAJOR_BIDIRECTIONAL_INTEL 0x2 606 607 #define CLK_AVC_ME_PARTITION_MASK_ALL_INTEL 0x0 608 #define CLK_AVC_ME_PARTITION_MASK_16x16_INTEL 0x7E 609 #define CLK_AVC_ME_PARTITION_MASK_16x8_INTEL 0x7D 610 #define CLK_AVC_ME_PARTITION_MASK_8x16_INTEL 0x7B 611 #define CLK_AVC_ME_PARTITION_MASK_8x8_INTEL 0x77 612 #define CLK_AVC_ME_PARTITION_MASK_8x4_INTEL 0x6F 613 #define CLK_AVC_ME_PARTITION_MASK_4x8_INTEL 0x5F 614 #define CLK_AVC_ME_PARTITION_MASK_4x4_INTEL 0x3F 615 616 #define CLK_AVC_ME_SLICE_TYPE_PRED_INTEL 0x0 617 #define CLK_AVC_ME_SLICE_TYPE_BPRED_INTEL 0x1 618 #define CLK_AVC_ME_SLICE_TYPE_INTRA_INTEL 0x2 619 620 #define CLK_AVC_ME_SEARCH_WINDOW_EXHAUSTIVE_INTEL 0x0 621 #define CLK_AVC_ME_SEARCH_WINDOW_SMALL_INTEL 0x1 622 #define CLK_AVC_ME_SEARCH_WINDOW_TINY_INTEL 0x2 623 #define CLK_AVC_ME_SEARCH_WINDOW_EXTRA_TINY_INTEL 0x3 624 #define CLK_AVC_ME_SEARCH_WINDOW_DIAMOND_INTEL 0x4 625 #define CLK_AVC_ME_SEARCH_WINDOW_LARGE_DIAMOND_INTEL 0x5 626 #define CLK_AVC_ME_SEARCH_WINDOW_RESERVED0_INTEL 0x6 627 #define CLK_AVC_ME_SEARCH_WINDOW_RESERVED1_INTEL 0x7 628 #define CLK_AVC_ME_SEARCH_WINDOW_CUSTOM_INTEL 0x8 629 630 #define CLK_AVC_ME_SAD_ADJUST_MODE_NONE_INTEL 0x0 631 #define CLK_AVC_ME_SAD_ADJUST_MODE_HAAR_INTEL 0x2 632 633 #define CLK_AVC_ME_SUBPIXEL_MODE_INTEGER_INTEL 0x0 634 #define CLK_AVC_ME_SUBPIXEL_MODE_HPEL_INTEL 0x1 635 #define CLK_AVC_ME_SUBPIXEL_MODE_QPEL_INTEL 0x3 636 637 #define CLK_AVC_ME_COST_PRECISION_QPEL_INTEL 0x0 638 #define CLK_AVC_ME_COST_PRECISION_HPEL_INTEL 0x1 639 #define CLK_AVC_ME_COST_PRECISION_PEL_INTEL 0x2 640 #define CLK_AVC_ME_COST_PRECISION_DPEL_INTEL 0x3 641 642 #define CLK_AVC_ME_BIDIR_WEIGHT_QUARTER_INTEL 0x10 643 #define CLK_AVC_ME_BIDIR_WEIGHT_THIRD_INTEL 0x15 644 #define CLK_AVC_ME_BIDIR_WEIGHT_HALF_INTEL 0x20 645 #define CLK_AVC_ME_BIDIR_WEIGHT_TWO_THIRD_INTEL 0x2B 646 #define CLK_AVC_ME_BIDIR_WEIGHT_THREE_QUARTER_INTEL 0x30 647 648 #define CLK_AVC_ME_BORDER_REACHED_LEFT_INTEL 0x0 649 #define CLK_AVC_ME_BORDER_REACHED_RIGHT_INTEL 0x2 650 #define CLK_AVC_ME_BORDER_REACHED_TOP_INTEL 0x4 651 #define CLK_AVC_ME_BORDER_REACHED_BOTTOM_INTEL 0x8 652 653 #define CLK_AVC_ME_INTRA_16x16_INTEL 0x0 654 #define CLK_AVC_ME_INTRA_8x8_INTEL 0x1 655 #define CLK_AVC_ME_INTRA_4x4_INTEL 0x2 656 657 #define CLK_AVC_ME_SKIP_BLOCK_PARTITION_16x16_INTEL 0x0 658 #define CLK_AVC_ME_SKIP_BLOCK_PARTITION_8x8_INTEL 0x4000 659 660 #define CLK_AVC_ME_SKIP_BLOCK_16x16_FORWARD_ENABLE_INTEL (0x1 << 24) 661 #define CLK_AVC_ME_SKIP_BLOCK_16x16_BACKWARD_ENABLE_INTEL (0x2 << 24) 662 #define CLK_AVC_ME_SKIP_BLOCK_16x16_DUAL_ENABLE_INTEL (0x3 << 24) 663 #define CLK_AVC_ME_SKIP_BLOCK_8x8_FORWARD_ENABLE_INTEL (0x55 << 24) 664 #define CLK_AVC_ME_SKIP_BLOCK_8x8_BACKWARD_ENABLE_INTEL (0xAA << 24) 665 #define CLK_AVC_ME_SKIP_BLOCK_8x8_DUAL_ENABLE_INTEL (0xFF << 24) 666 #define CLK_AVC_ME_SKIP_BLOCK_8x8_0_FORWARD_ENABLE_INTEL (0x1 << 24) 667 #define CLK_AVC_ME_SKIP_BLOCK_8x8_0_BACKWARD_ENABLE_INTEL (0x2 << 24) 668 #define CLK_AVC_ME_SKIP_BLOCK_8x8_1_FORWARD_ENABLE_INTEL (0x1 << 26) 669 #define CLK_AVC_ME_SKIP_BLOCK_8x8_1_BACKWARD_ENABLE_INTEL (0x2 << 26) 670 #define CLK_AVC_ME_SKIP_BLOCK_8x8_2_FORWARD_ENABLE_INTEL (0x1 << 28) 671 #define CLK_AVC_ME_SKIP_BLOCK_8x8_2_BACKWARD_ENABLE_INTEL (0x2 << 28) 672 #define CLK_AVC_ME_SKIP_BLOCK_8x8_3_FORWARD_ENABLE_INTEL (0x1 << 30) 673 #define CLK_AVC_ME_SKIP_BLOCK_8x8_3_BACKWARD_ENABLE_INTEL (0x2 << 30) 674 675 #define CLK_AVC_ME_BLOCK_BASED_SKIP_4x4_INTEL 0x00 676 #define CLK_AVC_ME_BLOCK_BASED_SKIP_8x8_INTEL 0x80 677 678 #define CLK_AVC_ME_INTRA_LUMA_PARTITION_MASK_ALL_INTEL 0x0 679 #define CLK_AVC_ME_INTRA_LUMA_PARTITION_MASK_16x16_INTEL 0x6 680 #define CLK_AVC_ME_INTRA_LUMA_PARTITION_MASK_8x8_INTEL 0x5 681 #define CLK_AVC_ME_INTRA_LUMA_PARTITION_MASK_4x4_INTEL 0x3 682 683 #define CLK_AVC_ME_INTRA_NEIGHBOR_LEFT_MASK_ENABLE_INTEL 0x60 684 #define CLK_AVC_ME_INTRA_NEIGHBOR_UPPER_MASK_ENABLE_INTEL 0x10 685 #define CLK_AVC_ME_INTRA_NEIGHBOR_UPPER_RIGHT_MASK_ENABLE_INTEL 0x8 686 #define CLK_AVC_ME_INTRA_NEIGHBOR_UPPER_LEFT_MASK_ENABLE_INTEL 0x4 687 688 #define CLK_AVC_ME_LUMA_PREDICTOR_MODE_VERTICAL_INTEL 0x0 689 #define CLK_AVC_ME_LUMA_PREDICTOR_MODE_HORIZONTAL_INTEL 0x1 690 #define CLK_AVC_ME_LUMA_PREDICTOR_MODE_DC_INTEL 0x2 691 #define CLK_AVC_ME_LUMA_PREDICTOR_MODE_DIAGONAL_DOWN_LEFT_INTEL 0x3 692 #define CLK_AVC_ME_LUMA_PREDICTOR_MODE_DIAGONAL_DOWN_RIGHT_INTEL 0x4 693 #define CLK_AVC_ME_LUMA_PREDICTOR_MODE_PLANE_INTEL 0x4 694 #define CLK_AVC_ME_LUMA_PREDICTOR_MODE_VERTICAL_RIGHT_INTEL 0x5 695 #define CLK_AVC_ME_LUMA_PREDICTOR_MODE_HORIZONTAL_DOWN_INTEL 0x6 696 #define CLK_AVC_ME_LUMA_PREDICTOR_MODE_VERTICAL_LEFT_INTEL 0x7 697 #define CLK_AVC_ME_LUMA_PREDICTOR_MODE_HORIZONTAL_UP_INTEL 0x8 698 #define CLK_AVC_ME_CHROMA_PREDICTOR_MODE_DC_INTEL 0x0 699 #define CLK_AVC_ME_CHROMA_PREDICTOR_MODE_HORIZONTAL_INTEL 0x1 700 #define CLK_AVC_ME_CHROMA_PREDICTOR_MODE_VERTICAL_INTEL 0x2 701 #define CLK_AVC_ME_CHROMA_PREDICTOR_MODE_PLANE_INTEL 0x3 702 703 #define CLK_AVC_ME_FRAME_FORWARD_INTEL 0x1 704 #define CLK_AVC_ME_FRAME_BACKWARD_INTEL 0x2 705 #define CLK_AVC_ME_FRAME_DUAL_INTEL 0x3 706 707 #define CLK_AVC_ME_INTERLACED_SCAN_TOP_FIELD_INTEL 0x0 708 #define CLK_AVC_ME_INTERLACED_SCAN_BOTTOM_FIELD_INTEL 0x1 709 710 #define CLK_AVC_ME_INITIALIZE_INTEL 0x0 711 712 #define CLK_AVC_IME_PAYLOAD_INITIALIZE_INTEL 0x0 713 #define CLK_AVC_REF_PAYLOAD_INITIALIZE_INTEL 0x0 714 #define CLK_AVC_SIC_PAYLOAD_INITIALIZE_INTEL 0x0 715 716 #define CLK_AVC_IME_RESULT_INITIALIZE_INTEL 0x0 717 #define CLK_AVC_REF_RESULT_INITIALIZE_INTEL 0x0 718 #define CLK_AVC_SIC_RESULT_INITIALIZE_INTEL 0x0 719 720 #define CLK_AVC_IME_RESULT_SINGLE_REFERENCE_STREAMOUT_INITIALIZE_INTEL 0x0 721 #define CLK_AVC_IME_RESULT_SINGLE_REFERENCE_STREAMIN_INITIALIZE_INTEL 0x0 722 #define CLK_AVC_IME_RESULT_DUAL_REFERENCE_STREAMOUT_INITIALIZE_INTEL 0x0 723 #define CLK_AVC_IME_RESULT_DUAL_REFERENCE_STREAMIN_INITIALIZE_INTEL 0x0 724 725 #endif // cl_intel_device_side_avc_motion_estimation 726 727 // Disable any extensions we may have enabled previously. 728 #pragma OPENCL EXTENSION all : disable 729 730 #endif //_OPENCL_BASE_H_ 731