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