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