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