summaryrefslogtreecommitdiffstats
path: root/dynamic-layers/clang-layer
diff options
context:
space:
mode:
authorAnuj Mittal <anuj.mittal@intel.com>2021-10-13 00:07:17 +0800
committerAnuj Mittal <anuj.mittal@intel.com>2021-10-13 11:23:41 +0800
commita809b8c531f6f0176f7148977b1237319abdd660 (patch)
tree88ce637013b0ea30224d778413417c5fe9e972cf /dynamic-layers/clang-layer
parent467d15d57afea208fb7bc35e486ee274700dca70 (diff)
downloadmeta-intel-a809b8c531f6f0176f7148977b1237319abdd660.tar.gz
Remove support for gatesgarth
Building with oe-core gatesgarth is no longer supported. Remove from LAYERSERIES_COMPAT and remove the LLVM 11 patches as well. Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Diffstat (limited to 'dynamic-layers/clang-layer')
-rw-r--r--dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0001-OpenCL-3.0-support.patch8451
-rw-r--r--dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0001-llvm-spirv-skip-building-tests.patch51
-rw-r--r--dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0002-Add-support-for-cl_ext_float_atomics-in-SPIRVWriter.patch433
-rw-r--r--dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0002-Memory-leak-fix-for-Managed-Static-Mutex.patch35
-rw-r--r--dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0003-Remove-repo-name-in-LLVM-IR.patch49
-rw-r--r--dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0004-Remove-__IMAGE_SUPPORT__-macro-for-SPIR-since-SPIR-d.patch51
-rw-r--r--dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0005-Avoid-calling-ParseCommandLineOptions-in-BackendUtil.patch52
-rw-r--r--dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0006-OpenCL-support-cl_ext_float_atomics.patch353
-rw-r--r--dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0007-ispc-11_0_11_1_disable-A-B-A-B-in-InstCombine.patch47
-rw-r--r--dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0008-ispc-11_0_11_1_packed_load_store_avx512.patch95
-rw-r--r--dynamic-layers/clang-layer/recipes-devtools/clang/llvm-project-source.bbappend22
-rw-r--r--dynamic-layers/clang-layer/recipes-opencl/opencl-clang/opencl-clang_11.0.0.bb15
12 files changed, 1 insertions, 9653 deletions
diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0001-OpenCL-3.0-support.patch b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0001-OpenCL-3.0-support.patch
deleted file mode 100644
index af433e14..00000000
--- a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0001-OpenCL-3.0-support.patch
+++ /dev/null
@@ -1,8451 +0,0 @@
1From 36d87f69fee9c3d3f399f8e4027ab707ad050e80 Mon Sep 17 00:00:00 2001
2From: Anton Zabaznov <anton.zabaznov@intel.com>
3Date: Tue, 22 Sep 2020 19:03:50 +0300
4Subject: [PATCH 1/6] OpenCL 3.0 support
5
6Upstream-Status: Backport [Taken from opencl-clang patches, https://github.com/intel/opencl-clang/blob/ocl-open-110/patches/clang/0001-OpenCL-3.0-support.patch]
7Signed-off-by: Anton Zabaznov <anton.zabaznov@intel.com>
8Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
9---
10 clang/include/clang/Basic/Builtins.def | 65 +-
11 clang/include/clang/Basic/Builtins.h | 13 +-
12 .../clang/Basic/DiagnosticParseKinds.td | 2 +
13 .../clang/Basic/DiagnosticSemaKinds.td | 7 +
14 clang/include/clang/Basic/LangOptions.def | 2 +
15 clang/include/clang/Basic/LangStandards.def | 4 +
16 .../include/clang/Basic/OpenCLExtensions.def | 15 +
17 clang/include/clang/Basic/OpenCLOptions.h | 174 +-
18 clang/include/clang/Driver/Options.td | 2 +-
19 clang/include/clang/Sema/Sema.h | 9 +
20 clang/lib/AST/ASTContext.cpp | 3 +-
21 clang/lib/Basic/Builtins.cpp | 28 +-
22 clang/lib/Basic/TargetInfo.cpp | 11 +
23 clang/lib/Basic/Targets.cpp | 1 -
24 clang/lib/CodeGen/CodeGenFunction.cpp | 6 +-
25 clang/lib/Frontend/CompilerInvocation.cpp | 22 +-
26 clang/lib/Frontend/InitPreprocessor.cpp | 6 +-
27 clang/lib/Headers/opencl-c-base.h | 75 +-
28 clang/lib/Headers/opencl-c.h | 3216 ++++++++++++++---
29 clang/lib/Parse/ParseDecl.cpp | 12 +-
30 clang/lib/Parse/ParsePragma.cpp | 10 +-
31 clang/lib/Sema/OpenCLBuiltins.td | 153 +-
32 clang/lib/Sema/Sema.cpp | 47 +-
33 clang/lib/Sema/SemaChecking.cpp | 38 +-
34 clang/lib/Sema/SemaDecl.cpp | 18 +-
35 clang/lib/Sema/SemaDeclAttr.cpp | 9 +-
36 clang/lib/Sema/SemaDeclCXX.cpp | 12 +-
37 clang/lib/Sema/SemaLookup.cpp | 19 +-
38 clang/lib/Sema/SemaType.cpp | 14 +-
39 .../CodeGenOpenCL/addr-space-struct-arg.cl | 7 +-
40 .../address-spaces-conversions.cl | 2 +
41 .../CodeGenOpenCL/address-spaces-mangling.cl | 3 +-
42 clang/test/CodeGenOpenCL/address-spaces.cl | 4 +
43 .../amdgcn-automatic-variable.cl | 1 +
44 .../CodeGenOpenCL/amdgpu-sizeof-alignof.cl | 21 +-
45 .../CodeGenOpenCL/arm-integer-dot-product.cl | 1 +
46 .../test/CodeGenOpenCL/cl-uniform-wg-size.cl | 2 +
47 clang/test/CodeGenOpenCL/fpmath.cl | 2 +
48 .../generic-address-space-feature.cl | 28 +
49 .../intel-subgroups-avc-ext-types.cl | 1 +
50 .../kernels-have-spir-cc-by-default.cl | 3 +
51 clang/test/CodeGenOpenCL/logical-ops.cl | 1 +
52 clang/test/CodeGenOpenCL/no-half.cl | 1 +
53 clang/test/CodeGenOpenCL/pipe_builtin.cl | 3 +
54 clang/test/CodeGenOpenCL/pipe_types.cl | 1 +
55 clang/test/CodeGenOpenCL/printf.cl | 2 +
56 clang/test/CodeGenOpenCL/unroll-hint.cl | 1 +
57 clang/test/Driver/autocomplete.c | 2 +
58 clang/test/Driver/opencl.cl | 2 +
59 clang/test/Driver/unknown-std.cl | 1 +
60 clang/test/Frontend/stdlang.c | 1 +
61 clang/test/Headers/opencl-c-header.cl | 7 +-
62 clang/test/Index/pipe-size.cl | 7 +
63 clang/test/Preprocessor/init-aarch64.c | 12 +-
64 clang/test/Preprocessor/predefined-macros.c | 13 +
65 .../Sema/feature-extensions-simult-support.cl | 75 +
66 clang/test/Sema/features-ignore-pragma.cl | 24 +
67 clang/test/Sema/opencl-features-pipes.cl | 18 +
68 clang/test/Sema/opencl-features.cl | 128 +
69 clang/test/Sema/pipe_builtins_feature.cl | 21 +
70 .../address-spaces-conversions-cl2.0.cl | 3 +
71 clang/test/SemaOpenCL/address-spaces.cl | 1 +
72 .../SemaOpenCL/cl20-device-side-enqueue.cl | 16 +-
73 .../SemaOpenCL/forget-unsupported-builtins.cl | 22 +
74 clang/test/SemaOpenCL/image-features.cl | 20 +
75 .../SemaOpenCL/invalid-pipe-builtin-cl2.0.cl | 1 +
76 clang/test/SemaOpenCL/storageclass-cl20.cl | 1 +
77 .../TableGen/ClangOpenCLBuiltinEmitter.cpp | 35 +-
78 68 files changed, 3749 insertions(+), 738 deletions(-)
79 create mode 100644 clang/test/CodeGenOpenCL/generic-address-space-feature.cl
80 create mode 100644 clang/test/Sema/feature-extensions-simult-support.cl
81 create mode 100644 clang/test/Sema/features-ignore-pragma.cl
82 create mode 100644 clang/test/Sema/opencl-features-pipes.cl
83 create mode 100644 clang/test/Sema/opencl-features.cl
84 create mode 100644 clang/test/Sema/pipe_builtins_feature.cl
85 create mode 100644 clang/test/SemaOpenCL/forget-unsupported-builtins.cl
86 create mode 100644 clang/test/SemaOpenCL/image-features.cl
87
88diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def
89index 5463b7dfc18c..e094beab9a6c 100644
90--- a/clang/include/clang/Basic/Builtins.def
91+++ b/clang/include/clang/Basic/Builtins.def
92@@ -111,6 +111,10 @@
93 # define LANGBUILTIN(ID, TYPE, ATTRS, BUILTIN_LANG) BUILTIN(ID, TYPE, ATTRS)
94 #endif
95
96+#if defined(BUILTIN) && !defined(OPENCLBUILTIN)
97+# define OPENCLBUILTIN(ID, TYPE, ATTRS, BUILTIN_LANG, FEATURE) BUILTIN(ID, TYPE, ATTRS)
98+#endif
99+
100 // Standard libc/libm functions:
101 BUILTIN(__builtin_atan2 , "ddd" , "Fne")
102 BUILTIN(__builtin_atan2f, "fff" , "Fne")
103@@ -1529,50 +1533,54 @@ BUILTIN(__builtin_coro_param, "bv*v*", "n")
104
105 // OpenCL v2.0 s6.13.16, s9.17.3.5 - Pipe functions.
106 // We need the generic prototype, since the packet type could be anything.
107-LANGBUILTIN(read_pipe, "i.", "tn", OCLC20_LANG)
108-LANGBUILTIN(write_pipe, "i.", "tn", OCLC20_LANG)
109+OPENCLBUILTIN(read_pipe, "i.", "tn", OCLC2P_LANG, "__opencl_c_pipes")
110+OPENCLBUILTIN(write_pipe, "i.", "tn", OCLC2P_LANG, "__opencl_c_pipes")
111
112-LANGBUILTIN(reserve_read_pipe, "i.", "tn", OCLC20_LANG)
113-LANGBUILTIN(reserve_write_pipe, "i.", "tn", OCLC20_LANG)
114+OPENCLBUILTIN(reserve_read_pipe, "i.", "tn", OCLC2P_LANG, "__opencl_c_pipes")
115+OPENCLBUILTIN(reserve_write_pipe, "i.", "tn", OCLC2P_LANG, "__opencl_c_pipes")
116
117-LANGBUILTIN(commit_write_pipe, "v.", "tn", OCLC20_LANG)
118-LANGBUILTIN(commit_read_pipe, "v.", "tn", OCLC20_LANG)
119+OPENCLBUILTIN(commit_write_pipe, "v.", "tn", OCLC2P_LANG, "__opencl_c_pipes")
120+OPENCLBUILTIN(commit_read_pipe, "v.", "tn", OCLC2P_LANG, "__opencl_c_pipes")
121
122-LANGBUILTIN(sub_group_reserve_read_pipe, "i.", "tn", OCLC20_LANG)
123-LANGBUILTIN(sub_group_reserve_write_pipe, "i.", "tn", OCLC20_LANG)
124+OPENCLBUILTIN(sub_group_reserve_read_pipe, "i.", "tn", OCLC2P_LANG, "__opencl_c_pipes")
125+OPENCLBUILTIN(sub_group_reserve_write_pipe, "i.", "tn", OCLC2P_LANG, "__opencl_c_pipes")
126
127-LANGBUILTIN(sub_group_commit_read_pipe, "v.", "tn", OCLC20_LANG)
128-LANGBUILTIN(sub_group_commit_write_pipe, "v.", "tn", OCLC20_LANG)
129+OPENCLBUILTIN(sub_group_commit_read_pipe, "v.", "tn", OCLC2P_LANG, "__opencl_c_pipes")
130+OPENCLBUILTIN(sub_group_commit_write_pipe, "v.", "tn", OCLC2P_LANG, "__opencl_c_pipes")
131
132-LANGBUILTIN(work_group_reserve_read_pipe, "i.", "tn", OCLC20_LANG)
133-LANGBUILTIN(work_group_reserve_write_pipe, "i.", "tn", OCLC20_LANG)
134+OPENCLBUILTIN(work_group_reserve_read_pipe, "i.", "tn", OCLC2P_LANG, "__opencl_c_pipes")
135+OPENCLBUILTIN(work_group_reserve_write_pipe, "i.", "tn", OCLC2P_LANG, "__opencl_c_pipes")
136
137-LANGBUILTIN(work_group_commit_read_pipe, "v.", "tn", OCLC20_LANG)
138-LANGBUILTIN(work_group_commit_write_pipe, "v.", "tn", OCLC20_LANG)
139+OPENCLBUILTIN(work_group_commit_read_pipe, "v.", "tn", OCLC2P_LANG, "__opencl_c_pipes")
140+OPENCLBUILTIN(work_group_commit_write_pipe, "v.", "tn", OCLC2P_LANG, "__opencl_c_pipes")
141
142-LANGBUILTIN(get_pipe_num_packets, "Ui.", "tn", OCLC20_LANG)
143-LANGBUILTIN(get_pipe_max_packets, "Ui.", "tn", OCLC20_LANG)
144+OPENCLBUILTIN(get_pipe_num_packets, "Ui.", "tn", OCLC2P_LANG, "__opencl_c_pipes")
145+OPENCLBUILTIN(get_pipe_max_packets, "Ui.", "tn", OCLC2P_LANG, "__opencl_c_pipes")
146
147 // OpenCL v2.0 s6.13.17 - Enqueue kernel functions.
148 // Custom builtin check allows to perform special check of passed block arguments.
149-LANGBUILTIN(enqueue_kernel, "i.", "tn", OCLC20_LANG)
150-LANGBUILTIN(get_kernel_work_group_size, "Ui.", "tn", OCLC20_LANG)
151-LANGBUILTIN(get_kernel_preferred_work_group_size_multiple, "Ui.", "tn", OCLC20_LANG)
152-LANGBUILTIN(get_kernel_max_sub_group_size_for_ndrange, "Ui.", "tn", OCLC20_LANG)
153-LANGBUILTIN(get_kernel_sub_group_count_for_ndrange, "Ui.", "tn", OCLC20_LANG)
154+OPENCLBUILTIN(enqueue_kernel, "i.", "tn", OCLC2P_LANG,
155+ "__opencl_c_device_enqueue")
156+OPENCLBUILTIN(get_kernel_work_group_size, "Ui.", "tn", OCLC2P_LANG,
157+ "__opencl_c_device_enqueue")
158+OPENCLBUILTIN(get_kernel_preferred_work_group_size_multiple, "Ui.", "tn",
159+ OCLC2P_LANG, "__opencl_c_device_enqueue")
160+OPENCLBUILTIN(get_kernel_max_sub_group_size_for_ndrange, "Ui.", "tn",
161+ OCLC2P_LANG, "__opencl_c_device_enqueue")
162+OPENCLBUILTIN(get_kernel_sub_group_count_for_ndrange, "Ui.", "tn", OCLC2P_LANG, "__opencl_c_device_enqueue")
163
164 // OpenCL v2.0 s6.13.9 - Address space qualifier functions.
165 // FIXME: Pointer parameters of OpenCL builtins should have their address space
166 // requirement defined.
167-LANGBUILTIN(to_global, "v*v*", "tn", OCLC20_LANG)
168-LANGBUILTIN(to_local, "v*v*", "tn", OCLC20_LANG)
169-LANGBUILTIN(to_private, "v*v*", "tn", OCLC20_LANG)
170+OPENCLBUILTIN(to_global, "v*v*", "tn", OCLC2P_LANG, "__opencl_c_generic_address_space")
171+OPENCLBUILTIN(to_local, "v*v*", "tn", OCLC2P_LANG, "__opencl_c_generic_address_space")
172+OPENCLBUILTIN(to_private, "v*v*", "tn", OCLC2P_LANG, "__opencl_c_generic_address_space")
173
174 // OpenCL half load/store builtin
175-LANGBUILTIN(__builtin_store_half, "vdh*", "n", ALL_OCLC_LANGUAGES)
176-LANGBUILTIN(__builtin_store_halff, "vfh*", "n", ALL_OCLC_LANGUAGES)
177-LANGBUILTIN(__builtin_load_half, "dhC*", "nc", ALL_OCLC_LANGUAGES)
178-LANGBUILTIN(__builtin_load_halff, "fhC*", "nc", ALL_OCLC_LANGUAGES)
179+OPENCLBUILTIN(__builtin_store_half, "vdh*", "n", ALL_OCLC_LANGUAGES, "")
180+OPENCLBUILTIN(__builtin_store_halff, "vfh*", "n", ALL_OCLC_LANGUAGES, "")
181+OPENCLBUILTIN(__builtin_load_half, "dhC*", "nc", ALL_OCLC_LANGUAGES, "")
182+OPENCLBUILTIN(__builtin_load_halff, "fhC*", "nc", ALL_OCLC_LANGUAGES, "")
183
184 // Builtins for os_log/os_trace
185 BUILTIN(__builtin_os_log_format_buffer_size, "zcC*.", "p:0:nut")
186@@ -1593,3 +1601,4 @@ BUILTIN(__builtin_ms_va_copy, "vc*&c*&", "n")
187 #undef BUILTIN
188 #undef LIBBUILTIN
189 #undef LANGBUILTIN
190+#undef OPENCLBUILTIN
191diff --git a/clang/include/clang/Basic/Builtins.h b/clang/include/clang/Basic/Builtins.h
192index 15bfcf797917..ba3e7853444c 100644
193--- a/clang/include/clang/Basic/Builtins.h
194+++ b/clang/include/clang/Basic/Builtins.h
195@@ -33,13 +33,13 @@ enum LanguageID {
196 CXX_LANG = 0x4, // builtin for cplusplus only.
197 OBJC_LANG = 0x8, // builtin for objective-c and objective-c++
198 MS_LANG = 0x10, // builtin requires MS mode.
199- OCLC20_LANG = 0x20, // builtin for OpenCL C 2.0 only.
200+ OCLC2P_LANG = 0x20, // builtin for OpenCL C 2.0+ versions.
201 OCLC1X_LANG = 0x40, // builtin for OpenCL C 1.x only.
202 OMP_LANG = 0x80, // builtin requires OpenMP.
203 ALL_LANGUAGES = C_LANG | CXX_LANG | OBJC_LANG, // builtin for all languages.
204 ALL_GNU_LANGUAGES = ALL_LANGUAGES | GNU_LANG, // builtin requires GNU mode.
205 ALL_MS_LANGUAGES = ALL_LANGUAGES | MS_LANG, // builtin requires MS mode.
206- ALL_OCLC_LANGUAGES = OCLC1X_LANG | OCLC20_LANG // builtin for OCLC languages.
207+ ALL_OCLC_LANGUAGES = OCLC1X_LANG | OCLC2P_LANG // builtin for OCLC languages.
208 };
209
210 namespace Builtin {
211@@ -235,6 +235,10 @@ public:
212 /// for non-builtins.
213 bool canBeRedeclared(unsigned ID) const;
214
215+ bool requiresFeatures(unsigned ID) const {
216+ return requiresFeatures(getRecord(ID));
217+ }
218+
219 private:
220 const Info &getRecord(unsigned ID) const;
221
222@@ -242,6 +246,11 @@ private:
223 bool builtinIsSupported(const Builtin::Info &BuiltinInfo,
224 const LangOptions &LangOpts);
225
226+ bool OclBuiltinIsSupported(const Builtin::Info &BuiltinInfo,
227+ const LangOptions &LangOpts) const;
228+
229+ bool requiresFeatures(const Builtin::Info &BuiltinInfo) const;
230+
231 /// Helper function for isPrintfLike and isScanfLike.
232 bool isLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg,
233 const char *Fmt) const;
234diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td
235index 1038a4119d4c..ba1b1b67a131 100644
236--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
237+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
238@@ -1206,6 +1206,8 @@ def warn_pragma_unsupported_extension : Warning<
239 "unsupported OpenCL extension %0 - ignoring">, InGroup<IgnoredPragmas>;
240 def warn_pragma_extension_is_core : Warning<
241 "OpenCL extension %0 is core feature or supported optional core feature - ignoring">, InGroup<DiagGroup<"pedantic-core-features">>, DefaultIgnore;
242+def warn_opencl_pragma_feature_ignore : Warning<
243+ "OpenCL feature support can't be controlled via pragma, ignoring">, InGroup<IgnoredPragmas>;
244
245 // OpenCL errors.
246 def err_opencl_taking_function_address_parser : Error<
247diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
248index 941f2cafc372..aa9e8b7b011b 100644
249--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
250+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
251@@ -9741,6 +9741,13 @@ def ext_opencl_ext_vector_type_rgba_selector: ExtWarn<
252 def err_openclcxx_placement_new : Error<
253 "use of placement new requires explicit declaration">;
254
255+def err_opencl_pipes_require_feat : Error<
256+ "usage of OpenCL pipes requires feature support">;
257+def err_opencl_memory_scope_require_feat : Error<
258+ "usage of memory scope requires feature support">;
259+def err_opencl_memory_ordering_require_feat : Error<
260+ "usage of memory ordering requires feature support">;
261+
262 // MIG routine annotations.
263 def warn_mig_server_routine_does_not_return_kern_return_t : Warning<
264 "'mig_server_routine' attribute only applies to routines that return a kern_return_t">,
265diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def
266index 70f68d664bb7..e683f5956975 100644
267--- a/clang/include/clang/Basic/LangOptions.def
268+++ b/clang/include/clang/Basic/LangOptions.def
269@@ -215,6 +215,8 @@ LANGOPT(OpenCL , 1, 0, "OpenCL")
270 LANGOPT(OpenCLVersion , 32, 0, "OpenCL C version")
271 LANGOPT(OpenCLCPlusPlus , 1, 0, "C++ for OpenCL")
272 LANGOPT(OpenCLCPlusPlusVersion , 32, 0, "C++ for OpenCL version")
273+LANGOPT(OpenCLGenericKeyword , 1, 0, "OpenCL generic keyword")
274+LANGOPT(OpenCLPipeKeyword , 1, 0, "OpenCL pipe keyword")
275 LANGOPT(NativeHalfType , 1, 0, "Native half type support")
276 LANGOPT(NativeHalfArgsAndReturns, 1, 0, "Native half args and returns")
277 LANGOPT(HalfArgsAndReturns, 1, 0, "half args and returns")
278diff --git a/clang/include/clang/Basic/LangStandards.def b/clang/include/clang/Basic/LangStandards.def
279index b09568e8b3e8..7b915c312746 100644
280--- a/clang/include/clang/Basic/LangStandards.def
281+++ b/clang/include/clang/Basic/LangStandards.def
282@@ -167,6 +167,9 @@ LANGSTANDARD(opencl12, "cl1.2",
283 LANGSTANDARD(opencl20, "cl2.0",
284 OpenCL, "OpenCL 2.0",
285 LineComment | C99 | Digraphs | HexFloat | OpenCL)
286+LANGSTANDARD(opencl30, "cl3.0",
287+ OpenCL, "OpenCL 3.0",
288+ LineComment | C99 | Digraphs | HexFloat | OpenCL)
289 LANGSTANDARD(openclcpp, "clc++",
290 OpenCL, "C++ for OpenCL",
291 LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus17 |
292@@ -176,6 +179,7 @@ LANGSTANDARD_ALIAS_DEPR(opencl10, "CL")
293 LANGSTANDARD_ALIAS_DEPR(opencl11, "CL1.1")
294 LANGSTANDARD_ALIAS_DEPR(opencl12, "CL1.2")
295 LANGSTANDARD_ALIAS_DEPR(opencl20, "CL2.0")
296+LANGSTANDARD_ALIAS_DEPR(opencl30, "CL3.0")
297 LANGSTANDARD_ALIAS_DEPR(openclcpp, "CLC++")
298
299 // CUDA
300diff --git a/clang/include/clang/Basic/OpenCLExtensions.def b/clang/include/clang/Basic/OpenCLExtensions.def
301index 1ae36b32fb0a..d1574164f9b2 100644
302--- a/clang/include/clang/Basic/OpenCLExtensions.def
303+++ b/clang/include/clang/Basic/OpenCLExtensions.def
304@@ -100,6 +100,21 @@ OPENCLEXT_INTERNAL(cl_intel_subgroups, 120, ~0U)
305 OPENCLEXT_INTERNAL(cl_intel_subgroups_short, 120, ~0U)
306 OPENCLEXT_INTERNAL(cl_intel_device_side_avc_motion_estimation, 120, ~0U)
307
308+OPENCLEXT_INTERNAL(__opencl_c_pipes, 200, ~0U)
309+OPENCLEXT_INTERNAL(__opencl_c_generic_address_space, 200, ~0U)
310+OPENCLEXT_INTERNAL(__opencl_c_work_group_collective_functions, 200, ~0U)
311+OPENCLEXT_INTERNAL(__opencl_c_atomic_order_acq_rel, 200, ~0U)
312+OPENCLEXT_INTERNAL(__opencl_c_atomic_order_seq_cst, 200, ~0U)
313+OPENCLEXT_INTERNAL(__opencl_c_atomic_scope_device, 200, ~0U)
314+OPENCLEXT_INTERNAL(__opencl_c_atomic_scope_all_devices, 200, ~0U)
315+OPENCLEXT_INTERNAL(__opencl_c_subgroups, 200, ~0U)
316+OPENCLEXT_INTERNAL(__opencl_c_3d_image_writes, 100, ~0U)
317+OPENCLEXT_INTERNAL(__opencl_c_device_enqueue, 200, ~0U)
318+OPENCLEXT_INTERNAL(__opencl_c_read_write_images, 200, ~0U)
319+OPENCLEXT_INTERNAL(__opencl_c_program_scope_global_variables, 200, ~0U)
320+OPENCLEXT_INTERNAL(__opencl_c_fp64, 120, ~0U)
321+OPENCLEXT_INTERNAL(__opencl_c_int64, 100, ~0U)
322+OPENCLEXT_INTERNAL(__opencl_c_images, 100, ~0U)
323 #undef OPENCLEXT_INTERNAL
324
325 #ifdef OPENCLEXT
326diff --git a/clang/include/clang/Basic/OpenCLOptions.h b/clang/include/clang/Basic/OpenCLOptions.h
327index 15661154eab5..d5800f5611c6 100644
328--- a/clang/include/clang/Basic/OpenCLOptions.h
329+++ b/clang/include/clang/Basic/OpenCLOptions.h
330@@ -21,6 +21,10 @@ namespace clang {
331
332 /// OpenCL supported extensions and optional core features
333 class OpenCLOptions {
334+ // OpenCL Version
335+ unsigned CLVer = 120;
336+ bool IsOpenCLCPlusPlus = false;
337+
338 struct Info {
339 bool Supported; // Is this option supported
340 bool Enabled; // Is this option enabled
341@@ -31,7 +35,38 @@ class OpenCLOptions {
342 :Supported(S), Enabled(E), Avail(A), Core(C){}
343 };
344 llvm::StringMap<Info> OptMap;
345+
346 public:
347+ void setOpenCLVersion(const LangOptions &LO) {
348+ IsOpenCLCPlusPlus = LO.OpenCLCPlusPlus;
349+ CLVer = IsOpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
350+ }
351+
352+ // Get extension which is semantically equivalent to a given feature
353+ // if exists (e.g. __opencl_c_subgroups -> cl_khr_subgroups)
354+ llvm::Optional<StringRef> getEquivalentExtension(StringRef Feature) const {
355+ return llvm::StringSwitch<llvm::Optional<StringRef>>(Feature)
356+ .Case("__opencl_c_3d_image_writes",
357+ Optional<StringRef>("cl_khr_3d_image_writes"))
358+ .Case("__opencl_c_subgroups", Optional<StringRef>("cl_khr_subgroups"))
359+ .Case("__opencl_c_fp64", Optional<StringRef>("cl_khr_fp64"))
360+ .Default(Optional<StringRef>());
361+ }
362+
363+ // Same as above but for extensions
364+ llvm::Optional<StringRef> getEquivalentFeature(StringRef Extension) const {
365+ return llvm::StringSwitch<llvm::Optional<StringRef>>(Extension)
366+ .Case("cl_khr_3d_image_writes",
367+ Optional<StringRef>("__opencl_c_3d_image_writes"))
368+ .Case("cl_khr_subgroups", Optional<StringRef>("__opencl_c_subgroups"))
369+ .Case("cl_khr_fp64", Optional<StringRef>("__opencl_c_fp64"))
370+ .Default(Optional<StringRef>());
371+ }
372+
373+ bool isFeature(llvm::StringRef Ext) const {
374+ return Ext.startswith("__opencl_c");
375+ }
376+
377 bool isKnown(llvm::StringRef Ext) const {
378 return OptMap.find(Ext) != OptMap.end();
379 }
380@@ -42,32 +77,88 @@ public:
381
382 // Is supported as either an extension or an (optional) core feature for
383 // OpenCL version \p CLVer.
384- bool isSupported(llvm::StringRef Ext, const LangOptions &LO) const {
385+ bool isSupported(llvm::StringRef Ext) const {
386 // In C++ mode all extensions should work at least as in v2.0.
387- auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
388 auto I = OptMap.find(Ext)->getValue();
389 return I.Supported && I.Avail <= CLVer;
390 }
391
392 // Is supported (optional) OpenCL core features for OpenCL version \p CLVer.
393 // For supported extension, return false.
394- bool isSupportedCore(llvm::StringRef Ext, const LangOptions &LO) const {
395+ bool isSupportedCore(llvm::StringRef Ext) const {
396 // In C++ mode all extensions should work at least as in v2.0.
397- auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
398 auto I = OptMap.find(Ext)->getValue();
399 return I.Supported && I.Avail <= CLVer && I.Core != ~0U && CLVer >= I.Core;
400 }
401
402 // Is supported OpenCL extension for OpenCL version \p CLVer.
403 // For supported (optional) core feature, return false.
404- bool isSupportedExtension(llvm::StringRef Ext, const LangOptions &LO) const {
405+ bool isSupportedExtension(llvm::StringRef Ext) const {
406 // In C++ mode all extensions should work at least as in v2.0.
407- auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
408 auto I = OptMap.find(Ext)->getValue();
409 return I.Supported && I.Avail <= CLVer && (I.Core == ~0U || CLVer < I.Core);
410 }
411
412+ // Support features whose support is directly related to the
413+ // specific OpenCL version. For example, OpenCL 2.0 supports
414+ // all features that are optional in 3.0
415+ void adjustFeatures() {
416+ // Support int64 by default (assume compiling for FULL profile)
417+ OptMap["__opencl_c_int64"].Supported = true;
418+
419+ if (CLVer >= 300) {
420+ // Simultaneously support extension and corresponding feature
421+ for (llvm::StringRef F :
422+ {"__opencl_c_subgroups", "__opencl_c_3d_image_writes",
423+ "__opencl_c_fp64"}) {
424+ auto Ext = getEquivalentExtension(F);
425+ OptMap[*Ext].Supported = OptMap[F].Supported;
426+ }
427+
428+ // OpenCL C compilers that define the feature macro __opencl_c_pipes or
429+ // or __opencl_c_device_enqueue must also define the
430+ // feature macro __opencl_c_generic_address_space.
431+ if (OptMap["__opencl_c_pipes"].Supported ||
432+ OptMap["__opencl_c_device_enqueue"].Supported)
433+ OptMap["__opencl_c_generic_address_space"].Supported = true;
434+
435+ // OpenCL C compilers that define the feature macro
436+ // __opencl_c_3d_image_writes or __opencl_c_read_write_images must also
437+ // define the feature macro __opencl_c_images
438+ if (OptMap["__opencl_c_3d_image_writes"].Supported ||
439+ OptMap["__opencl_c_read_write_images"].Supported)
440+ OptMap["__opencl_c_images"].Supported = true;
441+
442+ // All other features are already supported with options
443+ // or in target settings
444+ return;
445+ }
446+
447+ auto FeaturesRange = llvm::make_filter_range(
448+ OptMap, [&](llvm::StringMapEntry<Info> &OptVal) {
449+ auto Opt = OptVal.getKey();
450+ return isFeature(Opt);
451+ });
452+
453+ for (auto &It : FeaturesRange) {
454+ auto &Info = It.getValue();
455+ // For OpenCL version less then 3.0 some
456+ // features should be supported simulateneously
457+ // with specific extension
458+ if (Optional<llvm::StringRef> Ext = getEquivalentExtension(It.getKey()))
459+ Info.Supported = Info.Enabled = OptMap[*Ext].Supported;
460+ else if (Info.Avail <= CLVer)
461+ Info.Supported = Info.Enabled = true;
462+ }
463+ }
464+
465 void enable(llvm::StringRef Ext, bool V = true) {
466+ // Ignore disabling extensions if corresponding features
467+ // already supported for OpenCL version higher then 3.0
468+ if (CLVer >= 300)
469+ if (Optional<llvm::StringRef> F = getEquivalentFeature(Ext))
470+ if (V != OptMap[*F].Enabled)
471+ return;
472 OptMap[Ext].Enabled = V;
473 }
474
475@@ -96,7 +187,7 @@ public:
476 OptMap[Ext].Supported = V;
477 }
478
479- OpenCLOptions(){
480+ OpenCLOptions() {
481 #define OPENCLEXT_INTERNAL(Ext, AvailVer, CoreVer) \
482 OptMap[#Ext].Avail = AvailVer; \
483 OptMap[#Ext].Core = CoreVer;
484@@ -104,35 +195,86 @@ public:
485 }
486
487 void addSupport(const OpenCLOptions &Opts) {
488+ assert(IsOpenCLCPlusPlus == Opts.IsOpenCLCPlusPlus && CLVer == Opts.CLVer);
489 for (auto &I:Opts.OptMap)
490- if (I.second.Supported)
491+ if (I.second.Supported) {
492 OptMap[I.getKey()].Supported = true;
493+ // All features are enabled as they are supported
494+ if (isFeature(I.getKey()))
495+ OptMap[I.getKey()].Enabled = true;
496+ }
497+ if (CLVer >= 300) {
498+ // Enabling extensions with respect to features
499+ for (llvm::StringRef Ext :
500+ {"cl_khr_3d_image_writes", "cl_khr_subgroups", "cl_khr_fp64"}) {
501+ auto Feature = getEquivalentFeature(Ext);
502+ enable(Ext, OptMap[*Feature].Enabled);
503+ }
504+ }
505 }
506
507 void copy(const OpenCLOptions &Opts) {
508+ CLVer = Opts.CLVer;
509+ IsOpenCLCPlusPlus = Opts.IsOpenCLCPlusPlus;
510 OptMap = Opts.OptMap;
511 }
512
513 // Turn on or off support of all options.
514 void supportAll(bool On = true) {
515- for (llvm::StringMap<Info>::iterator I = OptMap.begin(),
516- E = OptMap.end(); I != E; ++I)
517- I->second.Supported = On;
518+ for (llvm::StringMap<Info>::iterator I = OptMap.begin(), E = OptMap.end();
519+ I != E; ++I)
520+ if (!isFeature(I->getKey()))
521+ I->second.Supported = On;
522 }
523
524 void disableAll() {
525- for (llvm::StringMap<Info>::iterator I = OptMap.begin(),
526- E = OptMap.end(); I != E; ++I)
527- I->second.Enabled = false;
528+ for (llvm::StringMap<Info>::iterator I = OptMap.begin(), E = OptMap.end();
529+ I != E; ++I) {
530+ auto Ext = I->getKey();
531+ if (!isFeature(Ext))
532+ enable(Ext, false);
533+ }
534 }
535
536- void enableSupportedCore(LangOptions LO) {
537+ void enableSupportedCore() {
538 for (llvm::StringMap<Info>::iterator I = OptMap.begin(), E = OptMap.end();
539 I != E; ++I)
540- if (isSupportedCore(I->getKey(), LO))
541+ if (isSupportedCore(I->getKey()))
542 I->second.Enabled = true;
543 }
544
545+ // This enum specifies how OpenCL versions map into values
546+ // for encoding. This is used when generating built-ins
547+ // from tablegen
548+ enum OpenCLVersionsEncodings : unsigned short {
549+ OPENCL_C_100_CODE = 0x1,
550+ OPENCL_C_110_CODE = 0x2,
551+ OPENCL_C_120_CODE = 0x4,
552+ OPENCL_C_200_CODE = 0x8,
553+ OPENCL_C_300_CODE = 0x10,
554+ OPENCL_C_ALL_CODE = 0x1f
555+ };
556+
557+ // Encode version into single integer
558+ static unsigned short EncodeVersion(unsigned OpenCLVersion) {
559+ switch (OpenCLVersion) {
560+ default:
561+ llvm_unreachable("Unknown OpenCL version");
562+ case 0:
563+ return OpenCLVersionsEncodings::OPENCL_C_ALL_CODE;
564+ case 100:
565+ return OpenCLVersionsEncodings::OPENCL_C_100_CODE;
566+ case 110:
567+ return OpenCLVersionsEncodings::OPENCL_C_110_CODE;
568+ case 120:
569+ return OpenCLVersionsEncodings::OPENCL_C_120_CODE;
570+ case 200:
571+ return OpenCLVersionsEncodings::OPENCL_C_200_CODE;
572+ case 300:
573+ return OpenCLVersionsEncodings::OPENCL_C_300_CODE;
574+ }
575+ }
576+
577 friend class ASTWriter;
578 friend class ASTReader;
579 };
580diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
581index 966cb907b7e2..62536f2470c2 100644
582--- a/clang/include/clang/Driver/Options.td
583+++ b/clang/include/clang/Driver/Options.td
584@@ -557,7 +557,7 @@ def cl_mad_enable : Flag<["-"], "cl-mad-enable">, Group<opencl_Group>, Flags<[CC
585 def cl_no_signed_zeros : Flag<["-"], "cl-no-signed-zeros">, Group<opencl_Group>, Flags<[CC1Option]>,
586 HelpText<"OpenCL only. Allow use of less precise no signed zeros computations in the generated binary.">;
587 def cl_std_EQ : Joined<["-"], "cl-std=">, Group<opencl_Group>, Flags<[CC1Option]>,
588- HelpText<"OpenCL language standard to compile for.">, Values<"cl,CL,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,clc++,CLC++">;
589+ HelpText<"OpenCL language standard to compile for.">, Values<"cl,CL,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,cl3.0,CL3.0,clc++,CLC++">;
590 def cl_denorms_are_zero : Flag<["-"], "cl-denorms-are-zero">, Group<opencl_Group>,
591 HelpText<"OpenCL only. Allow denormals to be flushed to zero.">;
592 def cl_fp32_correctly_rounded_divide_sqrt : Flag<["-"], "cl-fp32-correctly-rounded-divide-sqrt">, Group<opencl_Group>, Flags<[CC1Option]>,
593diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
594index 16a7084f6b08..5920c27229d8 100644
595--- a/clang/include/clang/Sema/Sema.h
596+++ b/clang/include/clang/Sema/Sema.h
597@@ -9930,6 +9930,10 @@ public:
598 /// \return true if type is disabled.
599 bool checkOpenCLDisabledDecl(const NamedDecl &D, const Expr &E);
600
601+ bool checkOpenCLSubgroupExtForCallExpr(CallExpr *Call);
602+
603+ bool isSupportedOpenCLOMemoryOrdering(int64_t Ordering) const;
604+
605 //===--------------------------------------------------------------------===//
606 // OpenMP directives and clauses.
607 //
608@@ -11527,6 +11531,11 @@ public:
609 /// that the user intended an assignment used as condition.
610 void DiagnoseEqualityWithExtraParens(ParenExpr *ParenE);
611
612+ template <typename DiagLocT, typename DiagInfoT>
613+ void DiagnoseOpenCLRequiresOption(llvm::StringRef OpenCLOptName,
614+ DiagLocT DiagLoc, DiagInfoT DiagInfo,
615+ unsigned Selector, SourceRange SrcRange);
616+
617 /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
618 ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr = false);
619
620diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
621index bf51d35d9693..a54ea8475d7d 100644
622--- a/clang/lib/AST/ASTContext.cpp
623+++ b/clang/lib/AST/ASTContext.cpp
624@@ -1433,7 +1433,8 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target,
625 ObjCSuperType = QualType();
626
627 // void * type
628- if (LangOpts.OpenCLVersion >= 200) {
629+ if (Target.getSupportedOpenCLOpts().isEnabled(
630+ "__opencl_c_generic_address_space")) {
631 auto Q = VoidTy.getQualifiers();
632 Q.setAddressSpace(LangAS::opencl_generic);
633 VoidPtrTy = getPointerType(getCanonicalType(
634diff --git a/clang/lib/Basic/Builtins.cpp b/clang/lib/Basic/Builtins.cpp
635index 0cd89df41b67..7a3067345098 100644
636--- a/clang/lib/Basic/Builtins.cpp
637+++ b/clang/lib/Basic/Builtins.cpp
638@@ -23,6 +23,8 @@ static const Builtin::Info BuiltinInfo[] = {
639 { #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
640 #define LANGBUILTIN(ID, TYPE, ATTRS, LANGS) \
641 { #ID, TYPE, ATTRS, nullptr, LANGS, nullptr },
642+#define OPENCLBUILTIN(ID, TYPE, ATTRS, LANGS, FEATURE) \
643+ {#ID, TYPE, ATTRS, nullptr, LANGS, FEATURE},
644 #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER, LANGS) \
645 { #ID, TYPE, ATTRS, HEADER, LANGS, nullptr },
646 #include "clang/Basic/Builtins.def"
647@@ -69,16 +71,17 @@ bool Builtin::Context::builtinIsSupported(const Builtin::Info &BuiltinInfo,
648 bool ObjCUnsupported = !LangOpts.ObjC && BuiltinInfo.Langs == OBJC_LANG;
649 bool OclC1Unsupported = (LangOpts.OpenCLVersion / 100) != 1 &&
650 (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES ) == OCLC1X_LANG;
651- bool OclC2Unsupported =
652- (LangOpts.OpenCLVersion != 200 && !LangOpts.OpenCLCPlusPlus) &&
653- (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES) == OCLC20_LANG;
654+ bool OclC2PUnsupported =
655+ (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES) == OCLC2P_LANG &&
656+ ((LangOpts.OpenCLVersion < 200 && !LangOpts.OpenCLCPlusPlus) ||
657+ !OclBuiltinIsSupported(BuiltinInfo, LangOpts));
658 bool OclCUnsupported = !LangOpts.OpenCL &&
659 (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES);
660 bool OpenMPUnsupported = !LangOpts.OpenMP && BuiltinInfo.Langs == OMP_LANG;
661 bool CPlusPlusUnsupported =
662 !LangOpts.CPlusPlus && BuiltinInfo.Langs == CXX_LANG;
663 return !BuiltinsUnsupported && !MathBuiltinsUnsupported && !OclCUnsupported &&
664- !OclC1Unsupported && !OclC2Unsupported && !OpenMPUnsupported &&
665+ !OclC1Unsupported && !OclC2PUnsupported && !OpenMPUnsupported &&
666 !GnuModeUnsupported && !MSModeUnsupported && !ObjCUnsupported &&
667 !CPlusPlusUnsupported;
668 }
669@@ -191,3 +194,20 @@ bool Builtin::Context::canBeRedeclared(unsigned ID) const {
670 (!hasReferenceArgsOrResult(ID) &&
671 !hasCustomTypechecking(ID));
672 }
673+
674+bool Builtin::Context::OclBuiltinIsSupported(
675+ const Builtin::Info &BuiltinInfo, const LangOptions &LangOpts) const {
676+ if (!requiresFeatures(BuiltinInfo))
677+ return true;
678+
679+ return llvm::StringSwitch<bool>(BuiltinInfo.Features)
680+ .Case("__opencl_c_device_enqueue", LangOpts.Blocks)
681+ .Case("__opencl_c_generic_address_space", LangOpts.OpenCLGenericKeyword)
682+ .Case("__opencl_c_pipes", LangOpts.OpenCLPipeKeyword)
683+ .Default(false);
684+}
685+
686+bool Builtin::Context::requiresFeatures(
687+ const Builtin::Info &BuiltinInfo) const {
688+ return BuiltinInfo.Features && llvm::StringRef(BuiltinInfo.Features) != "";
689+}
690diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
691index eccdc21d724a..6b4f524d5271 100644
692--- a/clang/lib/Basic/TargetInfo.cpp
693+++ b/clang/lib/Basic/TargetInfo.cpp
694@@ -387,6 +387,17 @@ void TargetInfo::adjust(LangOptions &Opts) {
695 HalfFormat = &llvm::APFloat::IEEEhalf();
696 FloatFormat = &llvm::APFloat::IEEEsingle();
697 LongDoubleFormat = &llvm::APFloat::IEEEquad();
698+
699+ auto &SupportedOCLOpts = getTargetOpts().SupportedOpenCLOptions;
700+
701+ SupportedOCLOpts.setOpenCLVersion(Opts);
702+ SupportedOCLOpts.adjustFeatures();
703+
704+ if (!Opts.OpenCLCPlusPlus && Opts.OpenCLVersion >= 200)
705+ Opts.Blocks = SupportedOCLOpts.isSupported("__opencl_c_device_enqueue");
706+ Opts.OpenCLGenericKeyword =
707+ SupportedOCLOpts.isSupported("__opencl_c_generic_address_space");
708+ Opts.OpenCLPipeKeyword = SupportedOCLOpts.isSupported("__opencl_c_pipes");
709 }
710
711 if (Opts.DoubleSize) {
712diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
713index 965f273892bd..046d7c15f835 100644
714--- a/clang/lib/Basic/Targets.cpp
715+++ b/clang/lib/Basic/Targets.cpp
716@@ -40,7 +40,6 @@
717 #include "clang/Basic/Diagnostic.h"
718 #include "llvm/ADT/StringExtras.h"
719 #include "llvm/ADT/Triple.h"
720-
721 using namespace clang;
722
723 namespace clang {
724diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
725index 8ce488f35dd3..ca4cb0fbf018 100644
726--- a/clang/lib/CodeGen/CodeGenFunction.cpp
727+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
728@@ -2306,11 +2306,11 @@ void CodeGenFunction::checkTargetFeatures(SourceLocation Loc,
729 std::string MissingFeature;
730 if (BuiltinID) {
731 SmallVector<StringRef, 1> ReqFeatures;
732- const char *FeatureList =
733- CGM.getContext().BuiltinInfo.getRequiredFeatures(BuiltinID);
734 // Return if the builtin doesn't have any required features.
735- if (!FeatureList || StringRef(FeatureList) == "")
736+ if (!CGM.getContext().BuiltinInfo.requiresFeatures(BuiltinID))
737 return;
738+ const char *FeatureList =
739+ CGM.getContext().BuiltinInfo.getRequiredFeatures(BuiltinID);
740 StringRef(FeatureList).split(ReqFeatures, ',');
741 if (!hasRequiredFeatures(ReqFeatures, CGM, FD, MissingFeature))
742 CGM.getDiags().Report(Loc, diag::err_builtin_needs_feature)
743diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
744index 73114c6d76cb..bc54d231b97a 100644
745--- a/clang/lib/Frontend/CompilerInvocation.cpp
746+++ b/clang/lib/Frontend/CompilerInvocation.cpp
747@@ -2344,6 +2344,8 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
748 Opts.OpenCLVersion = 120;
749 else if (LangStd == LangStandard::lang_opencl20)
750 Opts.OpenCLVersion = 200;
751+ else if (LangStd == LangStandard::lang_opencl30)
752+ Opts.OpenCLVersion = 300;
753 else if (LangStd == LangStandard::lang_openclcpp)
754 Opts.OpenCLCPlusPlusVersion = 100;
755
756@@ -2544,14 +2546,15 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
757 // -cl-std only applies for OpenCL language standards.
758 // Override the -std option in this case.
759 if (const Arg *A = Args.getLastArg(OPT_cl_std_EQ)) {
760- LangStandard::Kind OpenCLLangStd
761- = llvm::StringSwitch<LangStandard::Kind>(A->getValue())
762- .Cases("cl", "CL", LangStandard::lang_opencl10)
763- .Cases("cl1.1", "CL1.1", LangStandard::lang_opencl11)
764- .Cases("cl1.2", "CL1.2", LangStandard::lang_opencl12)
765- .Cases("cl2.0", "CL2.0", LangStandard::lang_opencl20)
766- .Cases("clc++", "CLC++", LangStandard::lang_openclcpp)
767- .Default(LangStandard::lang_unspecified);
768+ LangStandard::Kind OpenCLLangStd =
769+ llvm::StringSwitch<LangStandard::Kind>(A->getValue())
770+ .Cases("cl", "CL", LangStandard::lang_opencl10)
771+ .Cases("cl1.1", "CL1.1", LangStandard::lang_opencl11)
772+ .Cases("cl1.2", "CL1.2", LangStandard::lang_opencl12)
773+ .Cases("cl2.0", "CL2.0", LangStandard::lang_opencl20)
774+ .Cases("cl3.0", "CL3.0", LangStandard::lang_opencl30)
775+ .Cases("clc++", "CLC++", LangStandard::lang_openclcpp)
776+ .Default(LangStandard::lang_unspecified);
777
778 if (OpenCLLangStd == LangStandard::lang_unspecified) {
779 Diags.Report(diag::err_drv_invalid_value)
780@@ -2852,8 +2855,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
781
782 Opts.RTTI = Opts.CPlusPlus && !Args.hasArg(OPT_fno_rtti);
783 Opts.RTTIData = Opts.RTTI && !Args.hasArg(OPT_fno_rtti_data);
784- Opts.Blocks = Args.hasArg(OPT_fblocks) || (Opts.OpenCL
785- && Opts.OpenCLVersion == 200);
786+ Opts.Blocks = Args.hasArg(OPT_fblocks);
787 Opts.BlocksRuntimeOptional = Args.hasArg(OPT_fblocks_runtime_optional);
788 Opts.Coroutines = Opts.CPlusPlus20 || Args.hasArg(OPT_fcoroutines_ts);
789
790diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
791index 6eef1e2376f6..5bb489c11909 100644
792--- a/clang/lib/Frontend/InitPreprocessor.cpp
793+++ b/clang/lib/Frontend/InitPreprocessor.cpp
794@@ -445,6 +445,9 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
795 case 200:
796 Builder.defineMacro("__OPENCL_C_VERSION__", "200");
797 break;
798+ case 300:
799+ Builder.defineMacro("__OPENCL_C_VERSION__", "300");
800+ break;
801 default:
802 llvm_unreachable("Unsupported OpenCL version");
803 }
804@@ -453,6 +456,7 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
805 Builder.defineMacro("CL_VERSION_1_1", "110");
806 Builder.defineMacro("CL_VERSION_1_2", "120");
807 Builder.defineMacro("CL_VERSION_2_0", "200");
808+ Builder.defineMacro("CL_VERSION_3_0", "300");
809
810 if (TI.isLittleEndian())
811 Builder.defineMacro("__ENDIAN_LITTLE__");
812@@ -1108,7 +1112,7 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
813 // OpenCL definitions.
814 if (LangOpts.OpenCL) {
815 #define OPENCLEXT(Ext) \
816- if (TI.getSupportedOpenCLOpts().isSupported(#Ext, LangOpts)) \
817+ if (TI.getSupportedOpenCLOpts().isSupported(#Ext)) \
818 Builder.defineMacro(#Ext);
819 #include "clang/Basic/OpenCLExtensions.def"
820
821diff --git a/clang/lib/Headers/opencl-c-base.h b/clang/lib/Headers/opencl-c-base.h
822index 430e07d36f62..afa900ab24d9 100644
823--- a/clang/lib/Headers/opencl-c-base.h
824+++ b/clang/lib/Headers/opencl-c-base.h
825@@ -9,6 +9,59 @@
826 #ifndef _OPENCL_BASE_H_
827 #define _OPENCL_BASE_H_
828
829+// Add predefined macros to build headers with standalone executable
830+#ifndef CL_VERSION_3_0
831+ #define CL_VERSION_3_0 300
832+#endif
833+
834+// Define features for 2.0 for header backward compatibility
835+#ifndef __opencl_c_int64
836+ #define __opencl_c_int64 1
837+#endif
838+#if __OPENCL_C_VERSION__ != CL_VERSION_3_0
839+ #ifndef __opencl_c_images
840+ #define __opencl_c_images 1
841+ #endif
842+#endif
843+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
844+#ifndef __opencl_c_pipes
845+ #define __opencl_c_pipes 1
846+#endif
847+#ifndef __opencl_c_generic_address_space
848+ #define __opencl_c_generic_address_space 1
849+#endif
850+#ifndef __opencl_c_work_group_collective_functions
851+ #define __opencl_c_work_group_collective_functions 1
852+#endif
853+#ifndef __opencl_c_atomic_order_acq_rel
854+ #define __opencl_c_atomic_order_acq_rel 1
855+#endif
856+#ifndef __opencl_c_atomic_order_seq_cst
857+ #define __opencl_c_atomic_order_seq_cst 1
858+#endif
859+#ifndef __opencl_c_atomic_scope_device
860+ #define __opencl_c_atomic_scope_device 1
861+#endif
862+#ifndef __opencl_c_atomic_scope_all_devices
863+ #define __opencl_c_atomic_scope_all_devices 1
864+#endif
865+#ifndef __opencl_c_subgroups
866+ #define __opencl_c_subgroups 1
867+#endif
868+#ifndef __opencl_c_3d_image_writes
869+ #define __opencl_c_3d_image_writes 1
870+#endif
871+#ifndef __opencl_c_device_enqueue
872+ #define __opencl_c_device_enqueue 1
873+#endif
874+#ifndef __opencl_c_read_write_images
875+ #define __opencl_c_read_write_images 1
876+#endif
877+#ifndef __opencl_c_program_scope_global_variables
878+ #define __opencl_c_program_scope_global_variables 1
879+#endif
880+#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
881+
882 // built-in scalar data types:
883
884 /**
885@@ -115,7 +168,12 @@ typedef half half4 __attribute__((ext_vector_type(4)));
886 typedef half half8 __attribute__((ext_vector_type(8)));
887 typedef half half16 __attribute__((ext_vector_type(16)));
888 #endif
889-#ifdef cl_khr_fp64
890+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
891+
892+#ifndef __opencl_c_fp64
893+ #define __opencl_c_fp64 1
894+#endif
895+
896 #if __OPENCL_C_VERSION__ < CL_VERSION_1_2
897 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
898 #endif
899@@ -281,9 +339,17 @@ typedef uint cl_mem_fence_flags;
900 typedef enum memory_scope {
901 memory_scope_work_item = __OPENCL_MEMORY_SCOPE_WORK_ITEM,
902 memory_scope_work_group = __OPENCL_MEMORY_SCOPE_WORK_GROUP,
903+#ifdef __opencl_c_atomic_scope_device
904 memory_scope_device = __OPENCL_MEMORY_SCOPE_DEVICE,
905+#endif
906+#ifdef __opencl_c_atomic_scope_all_devices
907+ #if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
908+ memory_scope_all_devices = __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES,
909+ #endif //(__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
910 memory_scope_all_svm_devices = __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES,
911-#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
912+#endif // __opencl_c_atomic_scope_all_devices
913+#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups) || \
914+ defined(__opencl_c_subgroups)
915 memory_scope_sub_group = __OPENCL_MEMORY_SCOPE_SUB_GROUP
916 #endif
917 } memory_scope;
918@@ -301,13 +367,14 @@ typedef enum memory_scope {
919 #define ATOMIC_FLAG_INIT 0
920
921 // enum values aligned with what clang uses in EmitAtomicExpr()
922-typedef enum memory_order
923-{
924+typedef enum memory_order {
925 memory_order_relaxed = __ATOMIC_RELAXED,
926 memory_order_acquire = __ATOMIC_ACQUIRE,
927 memory_order_release = __ATOMIC_RELEASE,
928 memory_order_acq_rel = __ATOMIC_ACQ_REL,
929+#ifdef __opencl_c_atomic_order_seq_cst
930 memory_order_seq_cst = __ATOMIC_SEQ_CST
931+#endif //__opencl_c_atomic_order_seq_cst
932 } memory_order;
933
934 #endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
935diff --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
936index 66e18bdd47bb..67d900eb1c3d 100644
937--- a/clang/lib/Headers/opencl-c.h
938+++ b/clang/lib/Headers/opencl-c.h
939@@ -35,7 +35,6 @@
940 #define __purefn __attribute__((pure))
941 #define __cnfn __attribute__((const))
942
943-
944 // OpenCL v1.1/1.2/2.0 s6.2.3 - Explicit conversions
945
946 char __ovld __cnfn convert_char_rte(char);
947@@ -4632,7 +4631,7 @@ float16 __ovld __cnfn convert_float16(float16);
948
949 // Conversions with double data type parameters or return value.
950
951-#ifdef cl_khr_fp64
952+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
953 char __ovld __cnfn convert_char(double);
954 char __ovld __cnfn convert_char_rte(double);
955 char __ovld __cnfn convert_char_rtn(double);
956@@ -5452,7 +5451,7 @@ double16 __ovld __cnfn convert_double16_rtz(uchar16);
957 double16 __ovld __cnfn convert_double16_rtz(uint16);
958 double16 __ovld __cnfn convert_double16_rtz(ulong16);
959 double16 __ovld __cnfn convert_double16_rtz(ushort16);
960-#endif //cl_khr_fp64
961+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
962
963 #ifdef cl_khr_fp16
964 // Convert half types to non-double types.
965@@ -6270,7 +6269,7 @@ half16 __ovld __cnfn convert_half16_rtz(float16);
966 half16 __ovld __cnfn convert_half16_rtz(half16);
967
968 // Convert half types to double types.
969-#ifdef cl_khr_fp64
970+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
971 double __ovld __cnfn convert_double(half);
972 double __ovld __cnfn convert_double_rte(half);
973 double __ovld __cnfn convert_double_rtp(half);
974@@ -6333,7 +6332,7 @@ half16 __ovld __cnfn convert_half16_rte(double16);
975 half16 __ovld __cnfn convert_half16_rtp(double16);
976 half16 __ovld __cnfn convert_half16_rtn(double16);
977 half16 __ovld __cnfn convert_half16_rtz(double16);
978-#endif //cl_khr_fp64
979+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
980
981 #endif // cl_khr_fp16
982
983@@ -6404,14 +6403,14 @@ half16 __ovld __cnfn convert_half16_rtz(double16);
984 #define as_float8(x) __builtin_astype((x), float8)
985 #define as_float16(x) __builtin_astype((x), float16)
986
987-#ifdef cl_khr_fp64
988+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
989 #define as_double(x) __builtin_astype((x), double)
990 #define as_double2(x) __builtin_astype((x), double2)
991 #define as_double3(x) __builtin_astype((x), double3)
992 #define as_double4(x) __builtin_astype((x), double4)
993 #define as_double8(x) __builtin_astype((x), double8)
994 #define as_double16(x) __builtin_astype((x), double16)
995-#endif //cl_khr_fp64
996+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
997
998 #ifdef cl_khr_fp16
999 #define as_half(x) __builtin_astype((x), half)
1000@@ -6534,14 +6533,14 @@ float3 __ovld __cnfn acos(float3);
1001 float4 __ovld __cnfn acos(float4);
1002 float8 __ovld __cnfn acos(float8);
1003 float16 __ovld __cnfn acos(float16);
1004-#ifdef cl_khr_fp64
1005+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1006 double __ovld __cnfn acos(double);
1007 double2 __ovld __cnfn acos(double2);
1008 double3 __ovld __cnfn acos(double3);
1009 double4 __ovld __cnfn acos(double4);
1010 double8 __ovld __cnfn acos(double8);
1011 double16 __ovld __cnfn acos(double16);
1012-#endif //cl_khr_fp64
1013+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1014 #ifdef cl_khr_fp16
1015 half __ovld __cnfn acos(half);
1016 half2 __ovld __cnfn acos(half2);
1017@@ -6560,14 +6559,14 @@ float3 __ovld __cnfn acosh(float3);
1018 float4 __ovld __cnfn acosh(float4);
1019 float8 __ovld __cnfn acosh(float8);
1020 float16 __ovld __cnfn acosh(float16);
1021-#ifdef cl_khr_fp64
1022+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1023 double __ovld __cnfn acosh(double);
1024 double2 __ovld __cnfn acosh(double2);
1025 double3 __ovld __cnfn acosh(double3);
1026 double4 __ovld __cnfn acosh(double4);
1027 double8 __ovld __cnfn acosh(double8);
1028 double16 __ovld __cnfn acosh(double16);
1029-#endif //cl_khr_fp64
1030+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1031 #ifdef cl_khr_fp16
1032 half __ovld __cnfn acosh(half);
1033 half2 __ovld __cnfn acosh(half2);
1034@@ -6586,14 +6585,14 @@ float3 __ovld __cnfn acospi(float3 x);
1035 float4 __ovld __cnfn acospi(float4 x);
1036 float8 __ovld __cnfn acospi(float8 x);
1037 float16 __ovld __cnfn acospi(float16 x);
1038-#ifdef cl_khr_fp64
1039+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1040 double __ovld __cnfn acospi(double x);
1041 double2 __ovld __cnfn acospi(double2 x);
1042 double3 __ovld __cnfn acospi(double3 x);
1043 double4 __ovld __cnfn acospi(double4 x);
1044 double8 __ovld __cnfn acospi(double8 x);
1045 double16 __ovld __cnfn acospi(double16 x);
1046-#endif //cl_khr_fp64
1047+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1048 #ifdef cl_khr_fp16
1049 half __ovld __cnfn acospi(half x);
1050 half2 __ovld __cnfn acospi(half2 x);
1051@@ -6612,14 +6611,14 @@ float3 __ovld __cnfn asin(float3);
1052 float4 __ovld __cnfn asin(float4);
1053 float8 __ovld __cnfn asin(float8);
1054 float16 __ovld __cnfn asin(float16);
1055-#ifdef cl_khr_fp64
1056+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1057 double __ovld __cnfn asin(double);
1058 double2 __ovld __cnfn asin(double2);
1059 double3 __ovld __cnfn asin(double3);
1060 double4 __ovld __cnfn asin(double4);
1061 double8 __ovld __cnfn asin(double8);
1062 double16 __ovld __cnfn asin(double16);
1063-#endif //cl_khr_fp64
1064+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1065 #ifdef cl_khr_fp16
1066 half __ovld __cnfn asin(half);
1067 half2 __ovld __cnfn asin(half2);
1068@@ -6638,14 +6637,14 @@ float3 __ovld __cnfn asinh(float3);
1069 float4 __ovld __cnfn asinh(float4);
1070 float8 __ovld __cnfn asinh(float8);
1071 float16 __ovld __cnfn asinh(float16);
1072-#ifdef cl_khr_fp64
1073+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1074 double __ovld __cnfn asinh(double);
1075 double2 __ovld __cnfn asinh(double2);
1076 double3 __ovld __cnfn asinh(double3);
1077 double4 __ovld __cnfn asinh(double4);
1078 double8 __ovld __cnfn asinh(double8);
1079 double16 __ovld __cnfn asinh(double16);
1080-#endif //cl_khr_fp64
1081+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1082 #ifdef cl_khr_fp16
1083 half __ovld __cnfn asinh(half);
1084 half2 __ovld __cnfn asinh(half2);
1085@@ -6664,14 +6663,14 @@ float3 __ovld __cnfn asinpi(float3 x);
1086 float4 __ovld __cnfn asinpi(float4 x);
1087 float8 __ovld __cnfn asinpi(float8 x);
1088 float16 __ovld __cnfn asinpi(float16 x);
1089-#ifdef cl_khr_fp64
1090+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1091 double __ovld __cnfn asinpi(double x);
1092 double2 __ovld __cnfn asinpi(double2 x);
1093 double3 __ovld __cnfn asinpi(double3 x);
1094 double4 __ovld __cnfn asinpi(double4 x);
1095 double8 __ovld __cnfn asinpi(double8 x);
1096 double16 __ovld __cnfn asinpi(double16 x);
1097-#endif //cl_khr_fp64
1098+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1099 #ifdef cl_khr_fp16
1100 half __ovld __cnfn asinpi(half x);
1101 half2 __ovld __cnfn asinpi(half2 x);
1102@@ -6690,14 +6689,14 @@ float3 __ovld __cnfn atan(float3 y_over_x);
1103 float4 __ovld __cnfn atan(float4 y_over_x);
1104 float8 __ovld __cnfn atan(float8 y_over_x);
1105 float16 __ovld __cnfn atan(float16 y_over_x);
1106-#ifdef cl_khr_fp64
1107+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1108 double __ovld __cnfn atan(double y_over_x);
1109 double2 __ovld __cnfn atan(double2 y_over_x);
1110 double3 __ovld __cnfn atan(double3 y_over_x);
1111 double4 __ovld __cnfn atan(double4 y_over_x);
1112 double8 __ovld __cnfn atan(double8 y_over_x);
1113 double16 __ovld __cnfn atan(double16 y_over_x);
1114-#endif //cl_khr_fp64
1115+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1116 #ifdef cl_khr_fp16
1117 half __ovld __cnfn atan(half y_over_x);
1118 half2 __ovld __cnfn atan(half2 y_over_x);
1119@@ -6716,14 +6715,14 @@ float3 __ovld __cnfn atan2(float3 y, float3 x);
1120 float4 __ovld __cnfn atan2(float4 y, float4 x);
1121 float8 __ovld __cnfn atan2(float8 y, float8 x);
1122 float16 __ovld __cnfn atan2(float16 y, float16 x);
1123-#ifdef cl_khr_fp64
1124+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1125 double __ovld __cnfn atan2(double y, double x);
1126 double2 __ovld __cnfn atan2(double2 y, double2 x);
1127 double3 __ovld __cnfn atan2(double3 y, double3 x);
1128 double4 __ovld __cnfn atan2(double4 y, double4 x);
1129 double8 __ovld __cnfn atan2(double8 y, double8 x);
1130 double16 __ovld __cnfn atan2(double16 y, double16 x);
1131-#endif //cl_khr_fp64
1132+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1133 #ifdef cl_khr_fp16
1134 half __ovld __cnfn atan2(half y, half x);
1135 half2 __ovld __cnfn atan2(half2 y, half2 x);
1136@@ -6742,14 +6741,14 @@ float3 __ovld __cnfn atanh(float3);
1137 float4 __ovld __cnfn atanh(float4);
1138 float8 __ovld __cnfn atanh(float8);
1139 float16 __ovld __cnfn atanh(float16);
1140-#ifdef cl_khr_fp64
1141+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1142 double __ovld __cnfn atanh(double);
1143 double2 __ovld __cnfn atanh(double2);
1144 double3 __ovld __cnfn atanh(double3);
1145 double4 __ovld __cnfn atanh(double4);
1146 double8 __ovld __cnfn atanh(double8);
1147 double16 __ovld __cnfn atanh(double16);
1148-#endif //cl_khr_fp64
1149+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1150 #ifdef cl_khr_fp16
1151 half __ovld __cnfn atanh(half);
1152 half2 __ovld __cnfn atanh(half2);
1153@@ -6768,14 +6767,14 @@ float3 __ovld __cnfn atanpi(float3 x);
1154 float4 __ovld __cnfn atanpi(float4 x);
1155 float8 __ovld __cnfn atanpi(float8 x);
1156 float16 __ovld __cnfn atanpi(float16 x);
1157-#ifdef cl_khr_fp64
1158+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1159 double __ovld __cnfn atanpi(double x);
1160 double2 __ovld __cnfn atanpi(double2 x);
1161 double3 __ovld __cnfn atanpi(double3 x);
1162 double4 __ovld __cnfn atanpi(double4 x);
1163 double8 __ovld __cnfn atanpi(double8 x);
1164 double16 __ovld __cnfn atanpi(double16 x);
1165-#endif //cl_khr_fp64
1166+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1167 #ifdef cl_khr_fp16
1168 half __ovld __cnfn atanpi(half x);
1169 half2 __ovld __cnfn atanpi(half2 x);
1170@@ -6794,14 +6793,14 @@ float3 __ovld __cnfn atan2pi(float3 y, float3 x);
1171 float4 __ovld __cnfn atan2pi(float4 y, float4 x);
1172 float8 __ovld __cnfn atan2pi(float8 y, float8 x);
1173 float16 __ovld __cnfn atan2pi(float16 y, float16 x);
1174-#ifdef cl_khr_fp64
1175+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1176 double __ovld __cnfn atan2pi(double y, double x);
1177 double2 __ovld __cnfn atan2pi(double2 y, double2 x);
1178 double3 __ovld __cnfn atan2pi(double3 y, double3 x);
1179 double4 __ovld __cnfn atan2pi(double4 y, double4 x);
1180 double8 __ovld __cnfn atan2pi(double8 y, double8 x);
1181 double16 __ovld __cnfn atan2pi(double16 y, double16 x);
1182-#endif //cl_khr_fp64
1183+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1184 #ifdef cl_khr_fp16
1185 half __ovld __cnfn atan2pi(half y, half x);
1186 half2 __ovld __cnfn atan2pi(half2 y, half2 x);
1187@@ -6820,14 +6819,14 @@ float3 __ovld __cnfn cbrt(float3);
1188 float4 __ovld __cnfn cbrt(float4);
1189 float8 __ovld __cnfn cbrt(float8);
1190 float16 __ovld __cnfn cbrt(float16);
1191-#ifdef cl_khr_fp64
1192+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1193 double __ovld __cnfn cbrt(double);
1194 double2 __ovld __cnfn cbrt(double2);
1195 double3 __ovld __cnfn cbrt(double3);
1196 double4 __ovld __cnfn cbrt(double4);
1197 double8 __ovld __cnfn cbrt(double8);
1198 double16 __ovld __cnfn cbrt(double16);
1199-#endif //cl_khr_fp64
1200+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1201 #ifdef cl_khr_fp16
1202 half __ovld __cnfn cbrt(half);
1203 half2 __ovld __cnfn cbrt(half2);
1204@@ -6847,14 +6846,14 @@ float3 __ovld __cnfn ceil(float3);
1205 float4 __ovld __cnfn ceil(float4);
1206 float8 __ovld __cnfn ceil(float8);
1207 float16 __ovld __cnfn ceil(float16);
1208-#ifdef cl_khr_fp64
1209+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1210 double __ovld __cnfn ceil(double);
1211 double2 __ovld __cnfn ceil(double2);
1212 double3 __ovld __cnfn ceil(double3);
1213 double4 __ovld __cnfn ceil(double4);
1214 double8 __ovld __cnfn ceil(double8);
1215 double16 __ovld __cnfn ceil(double16);
1216-#endif //cl_khr_fp64
1217+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1218 #ifdef cl_khr_fp16
1219 half __ovld __cnfn ceil(half);
1220 half2 __ovld __cnfn ceil(half2);
1221@@ -6873,14 +6872,14 @@ float3 __ovld __cnfn copysign(float3 x, float3 y);
1222 float4 __ovld __cnfn copysign(float4 x, float4 y);
1223 float8 __ovld __cnfn copysign(float8 x, float8 y);
1224 float16 __ovld __cnfn copysign(float16 x, float16 y);
1225-#ifdef cl_khr_fp64
1226+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1227 double __ovld __cnfn copysign(double x, double y);
1228 double2 __ovld __cnfn copysign(double2 x, double2 y);
1229 double3 __ovld __cnfn copysign(double3 x, double3 y);
1230 double4 __ovld __cnfn copysign(double4 x, double4 y);
1231 double8 __ovld __cnfn copysign(double8 x, double8 y);
1232 double16 __ovld __cnfn copysign(double16 x, double16 y);
1233-#endif //cl_khr_fp64
1234+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1235 #ifdef cl_khr_fp16
1236 half __ovld __cnfn copysign(half x, half y);
1237 half2 __ovld __cnfn copysign(half2 x, half2 y);
1238@@ -6899,14 +6898,14 @@ float3 __ovld __cnfn cos(float3);
1239 float4 __ovld __cnfn cos(float4);
1240 float8 __ovld __cnfn cos(float8);
1241 float16 __ovld __cnfn cos(float16);
1242-#ifdef cl_khr_fp64
1243+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1244 double __ovld __cnfn cos(double);
1245 double2 __ovld __cnfn cos(double2);
1246 double3 __ovld __cnfn cos(double3);
1247 double4 __ovld __cnfn cos(double4);
1248 double8 __ovld __cnfn cos(double8);
1249 double16 __ovld __cnfn cos(double16);
1250-#endif //cl_khr_fp64
1251+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1252 #ifdef cl_khr_fp16
1253 half __ovld __cnfn cos(half);
1254 half2 __ovld __cnfn cos(half2);
1255@@ -6925,14 +6924,14 @@ float3 __ovld __cnfn cosh(float3);
1256 float4 __ovld __cnfn cosh(float4);
1257 float8 __ovld __cnfn cosh(float8);
1258 float16 __ovld __cnfn cosh(float16);
1259-#ifdef cl_khr_fp64
1260+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1261 double __ovld __cnfn cosh(double);
1262 double2 __ovld __cnfn cosh(double2);
1263 double3 __ovld __cnfn cosh(double3);
1264 double4 __ovld __cnfn cosh(double4);
1265 double8 __ovld __cnfn cosh(double8);
1266 double16 __ovld __cnfn cosh(double16);
1267-#endif //cl_khr_fp64
1268+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1269 #ifdef cl_khr_fp16
1270 half __ovld __cnfn cosh(half);
1271 half2 __ovld __cnfn cosh(half2);
1272@@ -6951,14 +6950,14 @@ float3 __ovld __cnfn cospi(float3 x);
1273 float4 __ovld __cnfn cospi(float4 x);
1274 float8 __ovld __cnfn cospi(float8 x);
1275 float16 __ovld __cnfn cospi(float16 x);
1276-#ifdef cl_khr_fp64
1277+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1278 double __ovld __cnfn cospi(double x);
1279 double2 __ovld __cnfn cospi(double2 x);
1280 double3 __ovld __cnfn cospi(double3 x);
1281 double4 __ovld __cnfn cospi(double4 x);
1282 double8 __ovld __cnfn cospi(double8 x);
1283 double16 __ovld __cnfn cospi(double16 x);
1284-#endif //cl_khr_fp64
1285+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1286 #ifdef cl_khr_fp16
1287 half __ovld __cnfn cospi(half x);
1288 half2 __ovld __cnfn cospi(half2 x);
1289@@ -6977,14 +6976,14 @@ float3 __ovld __cnfn erfc(float3);
1290 float4 __ovld __cnfn erfc(float4);
1291 float8 __ovld __cnfn erfc(float8);
1292 float16 __ovld __cnfn erfc(float16);
1293-#ifdef cl_khr_fp64
1294+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1295 double __ovld __cnfn erfc(double);
1296 double2 __ovld __cnfn erfc(double2);
1297 double3 __ovld __cnfn erfc(double3);
1298 double4 __ovld __cnfn erfc(double4);
1299 double8 __ovld __cnfn erfc(double8);
1300 double16 __ovld __cnfn erfc(double16);
1301-#endif //cl_khr_fp64
1302+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1303 #ifdef cl_khr_fp16
1304 half __ovld __cnfn erfc(half);
1305 half2 __ovld __cnfn erfc(half2);
1306@@ -7004,14 +7003,14 @@ float3 __ovld __cnfn erf(float3);
1307 float4 __ovld __cnfn erf(float4);
1308 float8 __ovld __cnfn erf(float8);
1309 float16 __ovld __cnfn erf(float16);
1310-#ifdef cl_khr_fp64
1311+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1312 double __ovld __cnfn erf(double);
1313 double2 __ovld __cnfn erf(double2);
1314 double3 __ovld __cnfn erf(double3);
1315 double4 __ovld __cnfn erf(double4);
1316 double8 __ovld __cnfn erf(double8);
1317 double16 __ovld __cnfn erf(double16);
1318-#endif //cl_khr_fp64
1319+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1320 #ifdef cl_khr_fp16
1321 half __ovld __cnfn erf(half);
1322 half2 __ovld __cnfn erf(half2);
1323@@ -7030,14 +7029,14 @@ float3 __ovld __cnfn exp(float3 x);
1324 float4 __ovld __cnfn exp(float4 x);
1325 float8 __ovld __cnfn exp(float8 x);
1326 float16 __ovld __cnfn exp(float16 x);
1327-#ifdef cl_khr_fp64
1328+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1329 double __ovld __cnfn exp(double x);
1330 double2 __ovld __cnfn exp(double2 x);
1331 double3 __ovld __cnfn exp(double3 x);
1332 double4 __ovld __cnfn exp(double4 x);
1333 double8 __ovld __cnfn exp(double8 x);
1334 double16 __ovld __cnfn exp(double16 x);
1335-#endif //cl_khr_fp64
1336+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1337 #ifdef cl_khr_fp16
1338 half __ovld __cnfn exp(half x);
1339 half2 __ovld __cnfn exp(half2 x);
1340@@ -7056,14 +7055,14 @@ float3 __ovld __cnfn exp2(float3);
1341 float4 __ovld __cnfn exp2(float4);
1342 float8 __ovld __cnfn exp2(float8);
1343 float16 __ovld __cnfn exp2(float16);
1344-#ifdef cl_khr_fp64
1345+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1346 double __ovld __cnfn exp2(double);
1347 double2 __ovld __cnfn exp2(double2);
1348 double3 __ovld __cnfn exp2(double3);
1349 double4 __ovld __cnfn exp2(double4);
1350 double8 __ovld __cnfn exp2(double8);
1351 double16 __ovld __cnfn exp2(double16);
1352-#endif //cl_khr_fp64
1353+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1354 #ifdef cl_khr_fp16
1355 half __ovld __cnfn exp2(half);
1356 half2 __ovld __cnfn exp2(half2);
1357@@ -7082,14 +7081,14 @@ float3 __ovld __cnfn exp10(float3);
1358 float4 __ovld __cnfn exp10(float4);
1359 float8 __ovld __cnfn exp10(float8);
1360 float16 __ovld __cnfn exp10(float16);
1361-#ifdef cl_khr_fp64
1362+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1363 double __ovld __cnfn exp10(double);
1364 double2 __ovld __cnfn exp10(double2);
1365 double3 __ovld __cnfn exp10(double3);
1366 double4 __ovld __cnfn exp10(double4);
1367 double8 __ovld __cnfn exp10(double8);
1368 double16 __ovld __cnfn exp10(double16);
1369-#endif //cl_khr_fp64
1370+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1371 #ifdef cl_khr_fp16
1372 half __ovld __cnfn exp10(half);
1373 half2 __ovld __cnfn exp10(half2);
1374@@ -7108,14 +7107,14 @@ float3 __ovld __cnfn expm1(float3 x);
1375 float4 __ovld __cnfn expm1(float4 x);
1376 float8 __ovld __cnfn expm1(float8 x);
1377 float16 __ovld __cnfn expm1(float16 x);
1378-#ifdef cl_khr_fp64
1379+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1380 double __ovld __cnfn expm1(double x);
1381 double2 __ovld __cnfn expm1(double2 x);
1382 double3 __ovld __cnfn expm1(double3 x);
1383 double4 __ovld __cnfn expm1(double4 x);
1384 double8 __ovld __cnfn expm1(double8 x);
1385 double16 __ovld __cnfn expm1(double16 x);
1386-#endif //cl_khr_fp64
1387+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1388 #ifdef cl_khr_fp16
1389 half __ovld __cnfn expm1(half x);
1390 half2 __ovld __cnfn expm1(half2 x);
1391@@ -7134,14 +7133,14 @@ float3 __ovld __cnfn fabs(float3);
1392 float4 __ovld __cnfn fabs(float4);
1393 float8 __ovld __cnfn fabs(float8);
1394 float16 __ovld __cnfn fabs(float16);
1395-#ifdef cl_khr_fp64
1396+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1397 double __ovld __cnfn fabs(double);
1398 double2 __ovld __cnfn fabs(double2);
1399 double3 __ovld __cnfn fabs(double3);
1400 double4 __ovld __cnfn fabs(double4);
1401 double8 __ovld __cnfn fabs(double8);
1402 double16 __ovld __cnfn fabs(double16);
1403-#endif //cl_khr_fp64
1404+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1405 #ifdef cl_khr_fp16
1406 half __ovld __cnfn fabs(half);
1407 half2 __ovld __cnfn fabs(half2);
1408@@ -7160,14 +7159,14 @@ float3 __ovld __cnfn fdim(float3 x, float3 y);
1409 float4 __ovld __cnfn fdim(float4 x, float4 y);
1410 float8 __ovld __cnfn fdim(float8 x, float8 y);
1411 float16 __ovld __cnfn fdim(float16 x, float16 y);
1412-#ifdef cl_khr_fp64
1413+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1414 double __ovld __cnfn fdim(double x, double y);
1415 double2 __ovld __cnfn fdim(double2 x, double2 y);
1416 double3 __ovld __cnfn fdim(double3 x, double3 y);
1417 double4 __ovld __cnfn fdim(double4 x, double4 y);
1418 double8 __ovld __cnfn fdim(double8 x, double8 y);
1419 double16 __ovld __cnfn fdim(double16 x, double16 y);
1420-#endif //cl_khr_fp64
1421+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1422 #ifdef cl_khr_fp16
1423 half __ovld __cnfn fdim(half x, half y);
1424 half2 __ovld __cnfn fdim(half2 x, half2 y);
1425@@ -7187,14 +7186,14 @@ float3 __ovld __cnfn floor(float3);
1426 float4 __ovld __cnfn floor(float4);
1427 float8 __ovld __cnfn floor(float8);
1428 float16 __ovld __cnfn floor(float16);
1429-#ifdef cl_khr_fp64
1430+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1431 double __ovld __cnfn floor(double);
1432 double2 __ovld __cnfn floor(double2);
1433 double3 __ovld __cnfn floor(double3);
1434 double4 __ovld __cnfn floor(double4);
1435 double8 __ovld __cnfn floor(double8);
1436 double16 __ovld __cnfn floor(double16);
1437-#endif //cl_khr_fp64
1438+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1439 #ifdef cl_khr_fp16
1440 half __ovld __cnfn floor(half);
1441 half2 __ovld __cnfn floor(half2);
1442@@ -7217,14 +7216,14 @@ float3 __ovld __cnfn fma(float3 a, float3 b, float3 c);
1443 float4 __ovld __cnfn fma(float4 a, float4 b, float4 c);
1444 float8 __ovld __cnfn fma(float8 a, float8 b, float8 c);
1445 float16 __ovld __cnfn fma(float16 a, float16 b, float16 c);
1446-#ifdef cl_khr_fp64
1447+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1448 double __ovld __cnfn fma(double a, double b, double c);
1449 double2 __ovld __cnfn fma(double2 a, double2 b, double2 c);
1450 double3 __ovld __cnfn fma(double3 a, double3 b, double3 c);
1451 double4 __ovld __cnfn fma(double4 a, double4 b, double4 c);
1452 double8 __ovld __cnfn fma(double8 a, double8 b, double8 c);
1453 double16 __ovld __cnfn fma(double16 a, double16 b, double16 c);
1454-#endif //cl_khr_fp64
1455+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1456 #ifdef cl_khr_fp16
1457 half __ovld __cnfn fma(half a, half b, half c);
1458 half2 __ovld __cnfn fma(half2 a, half2 b, half2 c);
1459@@ -7251,7 +7250,7 @@ float3 __ovld __cnfn fmax(float3 x, float y);
1460 float4 __ovld __cnfn fmax(float4 x, float y);
1461 float8 __ovld __cnfn fmax(float8 x, float y);
1462 float16 __ovld __cnfn fmax(float16 x, float y);
1463-#ifdef cl_khr_fp64
1464+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1465 double __ovld __cnfn fmax(double x, double y);
1466 double2 __ovld __cnfn fmax(double2 x, double2 y);
1467 double3 __ovld __cnfn fmax(double3 x, double3 y);
1468@@ -7263,7 +7262,7 @@ double3 __ovld __cnfn fmax(double3 x, double y);
1469 double4 __ovld __cnfn fmax(double4 x, double y);
1470 double8 __ovld __cnfn fmax(double8 x, double y);
1471 double16 __ovld __cnfn fmax(double16 x, double y);
1472-#endif //cl_khr_fp64
1473+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1474 #ifdef cl_khr_fp16
1475 half __ovld __cnfn fmax(half x, half y);
1476 half2 __ovld __cnfn fmax(half2 x, half2 y);
1477@@ -7295,7 +7294,7 @@ float3 __ovld __cnfn fmin(float3 x, float y);
1478 float4 __ovld __cnfn fmin(float4 x, float y);
1479 float8 __ovld __cnfn fmin(float8 x, float y);
1480 float16 __ovld __cnfn fmin(float16 x, float y);
1481-#ifdef cl_khr_fp64
1482+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1483 double __ovld __cnfn fmin(double x, double y);
1484 double2 __ovld __cnfn fmin(double2 x, double2 y);
1485 double3 __ovld __cnfn fmin(double3 x, double3 y);
1486@@ -7307,7 +7306,7 @@ double3 __ovld __cnfn fmin(double3 x, double y);
1487 double4 __ovld __cnfn fmin(double4 x, double y);
1488 double8 __ovld __cnfn fmin(double8 x, double y);
1489 double16 __ovld __cnfn fmin(double16 x, double y);
1490-#endif //cl_khr_fp64
1491+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1492 #ifdef cl_khr_fp16
1493 half __ovld __cnfn fmin(half x, half y);
1494 half2 __ovld __cnfn fmin(half2 x, half2 y);
1495@@ -7331,14 +7330,14 @@ float3 __ovld __cnfn fmod(float3 x, float3 y);
1496 float4 __ovld __cnfn fmod(float4 x, float4 y);
1497 float8 __ovld __cnfn fmod(float8 x, float8 y);
1498 float16 __ovld __cnfn fmod(float16 x, float16 y);
1499-#ifdef cl_khr_fp64
1500+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1501 double __ovld __cnfn fmod(double x, double y);
1502 double2 __ovld __cnfn fmod(double2 x, double2 y);
1503 double3 __ovld __cnfn fmod(double3 x, double3 y);
1504 double4 __ovld __cnfn fmod(double4 x, double4 y);
1505 double8 __ovld __cnfn fmod(double8 x, double8 y);
1506 double16 __ovld __cnfn fmod(double16 x, double16 y);
1507-#endif //cl_khr_fp64
1508+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1509 #ifdef cl_khr_fp16
1510 half __ovld __cnfn fmod(half x, half y);
1511 half2 __ovld __cnfn fmod(half2 x, half2 y);
1512@@ -7352,21 +7351,21 @@ half16 __ovld __cnfn fmod(half16 x, half16 y);
1513 * Returns fmin(x - floor (x), 0x1.fffffep-1f ).
1514 * floor(x) is returned in iptr.
1515 */
1516-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
1517+#ifdef __opencl_c_generic_address_space
1518 float __ovld fract(float x, float *iptr);
1519 float2 __ovld fract(float2 x, float2 *iptr);
1520 float3 __ovld fract(float3 x, float3 *iptr);
1521 float4 __ovld fract(float4 x, float4 *iptr);
1522 float8 __ovld fract(float8 x, float8 *iptr);
1523 float16 __ovld fract(float16 x, float16 *iptr);
1524-#ifdef cl_khr_fp64
1525+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1526 double __ovld fract(double x, double *iptr);
1527 double2 __ovld fract(double2 x, double2 *iptr);
1528 double3 __ovld fract(double3 x, double3 *iptr);
1529 double4 __ovld fract(double4 x, double4 *iptr);
1530 double8 __ovld fract(double8 x, double8 *iptr);
1531 double16 __ovld fract(double16 x, double16 *iptr);
1532-#endif //cl_khr_fp64
1533+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1534 #ifdef cl_khr_fp16
1535 half __ovld fract(half x, half *iptr);
1536 half2 __ovld fract(half2 x, half2 *iptr);
1537@@ -7375,7 +7374,9 @@ half4 __ovld fract(half4 x, half4 *iptr);
1538 half8 __ovld fract(half8 x, half8 *iptr);
1539 half16 __ovld fract(half16 x, half16 *iptr);
1540 #endif //cl_khr_fp16
1541-#else
1542+#endif //__opencl_c_generic_address_space
1543+
1544+#if !defined(__OPENCL_CPP_VERSION__) && (__OPENCL_C_VERSION__ != CL_VERSION_2_0)
1545 float __ovld fract(float x, __global float *iptr);
1546 float2 __ovld fract(float2 x, __global float2 *iptr);
1547 float3 __ovld fract(float3 x, __global float3 *iptr);
1548@@ -7394,7 +7395,7 @@ float3 __ovld fract(float3 x, __private float3 *iptr);
1549 float4 __ovld fract(float4 x, __private float4 *iptr);
1550 float8 __ovld fract(float8 x, __private float8 *iptr);
1551 float16 __ovld fract(float16 x, __private float16 *iptr);
1552-#ifdef cl_khr_fp64
1553+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1554 double __ovld fract(double x, __global double *iptr);
1555 double2 __ovld fract(double2 x, __global double2 *iptr);
1556 double3 __ovld fract(double3 x, __global double3 *iptr);
1557@@ -7413,7 +7414,7 @@ double3 __ovld fract(double3 x, __private double3 *iptr);
1558 double4 __ovld fract(double4 x, __private double4 *iptr);
1559 double8 __ovld fract(double8 x, __private double8 *iptr);
1560 double16 __ovld fract(double16 x, __private double16 *iptr);
1561-#endif //cl_khr_fp64
1562+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1563 #ifdef cl_khr_fp16
1564 half __ovld fract(half x, __global half *iptr);
1565 half2 __ovld fract(half2 x, __global half2 *iptr);
1566@@ -7434,29 +7435,29 @@ half4 __ovld fract(half4 x, __private half4 *iptr);
1567 half8 __ovld fract(half8 x, __private half8 *iptr);
1568 half16 __ovld fract(half16 x, __private half16 *iptr);
1569 #endif //cl_khr_fp16
1570-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
1571-
1572+#endif //! defined(__OPENCL_CPP_VERSION__) && (__OPENCL_C_VERSION__ !=
1573+ //! CL_VERSION_2_0)
1574 /**
1575 * Extract mantissa and exponent from x. For each
1576 * component the mantissa returned is a float with
1577 * magnitude in the interval [1/2, 1) or 0. Each
1578 * component of x equals mantissa returned * 2^exp.
1579 */
1580-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
1581+#ifdef __opencl_c_generic_address_space
1582 float __ovld frexp(float x, int *exp);
1583 float2 __ovld frexp(float2 x, int2 *exp);
1584 float3 __ovld frexp(float3 x, int3 *exp);
1585 float4 __ovld frexp(float4 x, int4 *exp);
1586 float8 __ovld frexp(float8 x, int8 *exp);
1587 float16 __ovld frexp(float16 x, int16 *exp);
1588-#ifdef cl_khr_fp64
1589+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1590 double __ovld frexp(double x, int *exp);
1591 double2 __ovld frexp(double2 x, int2 *exp);
1592 double3 __ovld frexp(double3 x, int3 *exp);
1593 double4 __ovld frexp(double4 x, int4 *exp);
1594 double8 __ovld frexp(double8 x, int8 *exp);
1595 double16 __ovld frexp(double16 x, int16 *exp);
1596-#endif //cl_khr_fp64
1597+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1598 #ifdef cl_khr_fp16
1599 half __ovld frexp(half x, int *exp);
1600 half2 __ovld frexp(half2 x, int2 *exp);
1601@@ -7465,7 +7466,9 @@ half4 __ovld frexp(half4 x, int4 *exp);
1602 half8 __ovld frexp(half8 x, int8 *exp);
1603 half16 __ovld frexp(half16 x, int16 *exp);
1604 #endif //cl_khr_fp16
1605-#else
1606+#endif //__opencl_c_generic_address_space
1607+
1608+#if !defined(__OPENCL_CPP_VERSION__) && (__OPENCL_C_VERSION__ != CL_VERSION_2_0)
1609 float __ovld frexp(float x, __global int *exp);
1610 float2 __ovld frexp(float2 x, __global int2 *exp);
1611 float3 __ovld frexp(float3 x, __global int3 *exp);
1612@@ -7484,7 +7487,7 @@ float3 __ovld frexp(float3 x, __private int3 *exp);
1613 float4 __ovld frexp(float4 x, __private int4 *exp);
1614 float8 __ovld frexp(float8 x, __private int8 *exp);
1615 float16 __ovld frexp(float16 x, __private int16 *exp);
1616-#ifdef cl_khr_fp64
1617+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1618 double __ovld frexp(double x, __global int *exp);
1619 double2 __ovld frexp(double2 x, __global int2 *exp);
1620 double3 __ovld frexp(double3 x, __global int3 *exp);
1621@@ -7503,7 +7506,7 @@ double3 __ovld frexp(double3 x, __private int3 *exp);
1622 double4 __ovld frexp(double4 x, __private int4 *exp);
1623 double8 __ovld frexp(double8 x, __private int8 *exp);
1624 double16 __ovld frexp(double16 x, __private int16 *exp);
1625-#endif //cl_khr_fp64
1626+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1627 #ifdef cl_khr_fp16
1628 half __ovld frexp(half x, __global int *exp);
1629 half2 __ovld frexp(half2 x, __global int2 *exp);
1630@@ -7524,7 +7527,8 @@ half4 __ovld frexp(half4 x, __private int4 *exp);
1631 half8 __ovld frexp(half8 x, __private int8 *exp);
1632 half16 __ovld frexp(half16 x, __private int16 *exp);
1633 #endif //cl_khr_fp16
1634-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
1635+#endif //! defined(__OPENCL_CPP_VERSION__) && (__OPENCL_C_VERSION__ !=
1636+ //! CL_VERSION_2_0)
1637
1638 /**
1639 * Compute the value of the square root of x^2 + y^2
1640@@ -7536,14 +7540,14 @@ float3 __ovld __cnfn hypot(float3 x, float3 y);
1641 float4 __ovld __cnfn hypot(float4 x, float4 y);
1642 float8 __ovld __cnfn hypot(float8 x, float8 y);
1643 float16 __ovld __cnfn hypot(float16 x, float16 y);
1644-#ifdef cl_khr_fp64
1645+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1646 double __ovld __cnfn hypot(double x, double y);
1647 double2 __ovld __cnfn hypot(double2 x, double2 y);
1648 double3 __ovld __cnfn hypot(double3 x, double3 y);
1649 double4 __ovld __cnfn hypot(double4 x, double4 y);
1650 double8 __ovld __cnfn hypot(double8 x, double8 y);
1651 double16 __ovld __cnfn hypot(double16 x, double16 y);
1652-#endif //cl_khr_fp64
1653+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1654 #ifdef cl_khr_fp16
1655 half __ovld __cnfn hypot(half x, half y);
1656 half2 __ovld __cnfn hypot(half2 x, half2 y);
1657@@ -7562,14 +7566,14 @@ int3 __ovld __cnfn ilogb(float3 x);
1658 int4 __ovld __cnfn ilogb(float4 x);
1659 int8 __ovld __cnfn ilogb(float8 x);
1660 int16 __ovld __cnfn ilogb(float16 x);
1661-#ifdef cl_khr_fp64
1662+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1663 int __ovld __cnfn ilogb(double x);
1664 int2 __ovld __cnfn ilogb(double2 x);
1665 int3 __ovld __cnfn ilogb(double3 x);
1666 int4 __ovld __cnfn ilogb(double4 x);
1667 int8 __ovld __cnfn ilogb(double8 x);
1668 int16 __ovld __cnfn ilogb(double16 x);
1669-#endif //cl_khr_fp64
1670+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1671 #ifdef cl_khr_fp16
1672 int __ovld __cnfn ilogb(half x);
1673 int2 __ovld __cnfn ilogb(half2 x);
1674@@ -7593,7 +7597,7 @@ float3 __ovld __cnfn ldexp(float3 x, int n);
1675 float4 __ovld __cnfn ldexp(float4 x, int n);
1676 float8 __ovld __cnfn ldexp(float8 x, int n);
1677 float16 __ovld __cnfn ldexp(float16 x, int n);
1678-#ifdef cl_khr_fp64
1679+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1680 double __ovld __cnfn ldexp(double x, int n);
1681 double2 __ovld __cnfn ldexp(double2 x, int2 n);
1682 double3 __ovld __cnfn ldexp(double3 x, int3 n);
1683@@ -7605,7 +7609,7 @@ double3 __ovld __cnfn ldexp(double3 x, int n);
1684 double4 __ovld __cnfn ldexp(double4 x, int n);
1685 double8 __ovld __cnfn ldexp(double8 x, int n);
1686 double16 __ovld __cnfn ldexp(double16 x, int n);
1687-#endif //cl_khr_fp64
1688+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1689 #ifdef cl_khr_fp16
1690 half __ovld __cnfn ldexp(half x, int n);
1691 half2 __ovld __cnfn ldexp(half2 x, int2 n);
1692@@ -7632,14 +7636,14 @@ float3 __ovld __cnfn lgamma(float3 x);
1693 float4 __ovld __cnfn lgamma(float4 x);
1694 float8 __ovld __cnfn lgamma(float8 x);
1695 float16 __ovld __cnfn lgamma(float16 x);
1696-#ifdef cl_khr_fp64
1697+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1698 double __ovld __cnfn lgamma(double x);
1699 double2 __ovld __cnfn lgamma(double2 x);
1700 double3 __ovld __cnfn lgamma(double3 x);
1701 double4 __ovld __cnfn lgamma(double4 x);
1702 double8 __ovld __cnfn lgamma(double8 x);
1703 double16 __ovld __cnfn lgamma(double16 x);
1704-#endif //cl_khr_fp64
1705+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1706 #ifdef cl_khr_fp16
1707 half __ovld __cnfn lgamma(half x);
1708 half2 __ovld __cnfn lgamma(half2 x);
1709@@ -7649,21 +7653,21 @@ half8 __ovld __cnfn lgamma(half8 x);
1710 half16 __ovld __cnfn lgamma(half16 x);
1711 #endif //cl_khr_fp16
1712
1713-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
1714+#ifdef __opencl_c_generic_address_space
1715 float __ovld lgamma_r(float x, int *signp);
1716 float2 __ovld lgamma_r(float2 x, int2 *signp);
1717 float3 __ovld lgamma_r(float3 x, int3 *signp);
1718 float4 __ovld lgamma_r(float4 x, int4 *signp);
1719 float8 __ovld lgamma_r(float8 x, int8 *signp);
1720 float16 __ovld lgamma_r(float16 x, int16 *signp);
1721-#ifdef cl_khr_fp64
1722+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1723 double __ovld lgamma_r(double x, int *signp);
1724 double2 __ovld lgamma_r(double2 x, int2 *signp);
1725 double3 __ovld lgamma_r(double3 x, int3 *signp);
1726 double4 __ovld lgamma_r(double4 x, int4 *signp);
1727 double8 __ovld lgamma_r(double8 x, int8 *signp);
1728 double16 __ovld lgamma_r(double16 x, int16 *signp);
1729-#endif //cl_khr_fp64
1730+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1731 #ifdef cl_khr_fp16
1732 half __ovld lgamma_r(half x, int *signp);
1733 half2 __ovld lgamma_r(half2 x, int2 *signp);
1734@@ -7672,7 +7676,9 @@ half4 __ovld lgamma_r(half4 x, int4 *signp);
1735 half8 __ovld lgamma_r(half8 x, int8 *signp);
1736 half16 __ovld lgamma_r(half16 x, int16 *signp);
1737 #endif //cl_khr_fp16
1738-#else
1739+#endif //__opencl_c_generic_address_space
1740+
1741+#if !defined(__OPENCL_CPP_VERSION__) && (__OPENCL_C_VERSION__ != CL_VERSION_2_0)
1742 float __ovld lgamma_r(float x, __global int *signp);
1743 float2 __ovld lgamma_r(float2 x, __global int2 *signp);
1744 float3 __ovld lgamma_r(float3 x, __global int3 *signp);
1745@@ -7691,7 +7697,7 @@ float3 __ovld lgamma_r(float3 x, __private int3 *signp);
1746 float4 __ovld lgamma_r(float4 x, __private int4 *signp);
1747 float8 __ovld lgamma_r(float8 x, __private int8 *signp);
1748 float16 __ovld lgamma_r(float16 x, __private int16 *signp);
1749-#ifdef cl_khr_fp64
1750+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1751 double __ovld lgamma_r(double x, __global int *signp);
1752 double2 __ovld lgamma_r(double2 x, __global int2 *signp);
1753 double3 __ovld lgamma_r(double3 x, __global int3 *signp);
1754@@ -7710,7 +7716,7 @@ double3 __ovld lgamma_r(double3 x, __private int3 *signp);
1755 double4 __ovld lgamma_r(double4 x, __private int4 *signp);
1756 double8 __ovld lgamma_r(double8 x, __private int8 *signp);
1757 double16 __ovld lgamma_r(double16 x, __private int16 *signp);
1758-#endif //cl_khr_fp64
1759+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1760 #ifdef cl_khr_fp16
1761 half __ovld lgamma_r(half x, __global int *signp);
1762 half2 __ovld lgamma_r(half2 x, __global int2 *signp);
1763@@ -7731,8 +7737,8 @@ half4 __ovld lgamma_r(half4 x, __private int4 *signp);
1764 half8 __ovld lgamma_r(half8 x, __private int8 *signp);
1765 half16 __ovld lgamma_r(half16 x, __private int16 *signp);
1766 #endif //cl_khr_fp16
1767-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
1768-
1769+#endif //! defined(__OPENCL_CPP_VERSION__) && (__OPENCL_C_VERSION__ !=
1770+ //! CL_VERSION_2_0)
1771 /**
1772 * Compute natural logarithm.
1773 */
1774@@ -7742,14 +7748,14 @@ float3 __ovld __cnfn log(float3);
1775 float4 __ovld __cnfn log(float4);
1776 float8 __ovld __cnfn log(float8);
1777 float16 __ovld __cnfn log(float16);
1778-#ifdef cl_khr_fp64
1779+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1780 double __ovld __cnfn log(double);
1781 double2 __ovld __cnfn log(double2);
1782 double3 __ovld __cnfn log(double3);
1783 double4 __ovld __cnfn log(double4);
1784 double8 __ovld __cnfn log(double8);
1785 double16 __ovld __cnfn log(double16);
1786-#endif //cl_khr_fp64
1787+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1788 #ifdef cl_khr_fp16
1789 half __ovld __cnfn log(half);
1790 half2 __ovld __cnfn log(half2);
1791@@ -7760,7 +7766,7 @@ half16 __ovld __cnfn log(half16);
1792 #endif //cl_khr_fp16
1793
1794 /**
1795- * Compute a base 2 logarithm.
1796+ * Compute a base 2 logarithm
1797 */
1798 float __ovld __cnfn log2(float);
1799 float2 __ovld __cnfn log2(float2);
1800@@ -7768,14 +7774,14 @@ float3 __ovld __cnfn log2(float3);
1801 float4 __ovld __cnfn log2(float4);
1802 float8 __ovld __cnfn log2(float8);
1803 float16 __ovld __cnfn log2(float16);
1804-#ifdef cl_khr_fp64
1805+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1806 double __ovld __cnfn log2(double);
1807 double2 __ovld __cnfn log2(double2);
1808 double3 __ovld __cnfn log2(double3);
1809 double4 __ovld __cnfn log2(double4);
1810 double8 __ovld __cnfn log2(double8);
1811 double16 __ovld __cnfn log2(double16);
1812-#endif //cl_khr_fp64
1813+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1814 #ifdef cl_khr_fp16
1815 half __ovld __cnfn log2(half);
1816 half2 __ovld __cnfn log2(half2);
1817@@ -7794,14 +7800,14 @@ float3 __ovld __cnfn log10(float3);
1818 float4 __ovld __cnfn log10(float4);
1819 float8 __ovld __cnfn log10(float8);
1820 float16 __ovld __cnfn log10(float16);
1821-#ifdef cl_khr_fp64
1822+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1823 double __ovld __cnfn log10(double);
1824 double2 __ovld __cnfn log10(double2);
1825 double3 __ovld __cnfn log10(double3);
1826 double4 __ovld __cnfn log10(double4);
1827 double8 __ovld __cnfn log10(double8);
1828 double16 __ovld __cnfn log10(double16);
1829-#endif //cl_khr_fp64
1830+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1831 #ifdef cl_khr_fp16
1832 half __ovld __cnfn log10(half);
1833 half2 __ovld __cnfn log10(half2);
1834@@ -7820,14 +7826,14 @@ float3 __ovld __cnfn log1p(float3 x);
1835 float4 __ovld __cnfn log1p(float4 x);
1836 float8 __ovld __cnfn log1p(float8 x);
1837 float16 __ovld __cnfn log1p(float16 x);
1838-#ifdef cl_khr_fp64
1839+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1840 double __ovld __cnfn log1p(double x);
1841 double2 __ovld __cnfn log1p(double2 x);
1842 double3 __ovld __cnfn log1p(double3 x);
1843 double4 __ovld __cnfn log1p(double4 x);
1844 double8 __ovld __cnfn log1p(double8 x);
1845 double16 __ovld __cnfn log1p(double16 x);
1846-#endif //cl_khr_fp64
1847+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1848 #ifdef cl_khr_fp16
1849 half __ovld __cnfn log1p(half x);
1850 half2 __ovld __cnfn log1p(half2 x);
1851@@ -7847,14 +7853,14 @@ float3 __ovld __cnfn logb(float3 x);
1852 float4 __ovld __cnfn logb(float4 x);
1853 float8 __ovld __cnfn logb(float8 x);
1854 float16 __ovld __cnfn logb(float16 x);
1855-#ifdef cl_khr_fp64
1856+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1857 double __ovld __cnfn logb(double x);
1858 double2 __ovld __cnfn logb(double2 x);
1859 double3 __ovld __cnfn logb(double3 x);
1860 double4 __ovld __cnfn logb(double4 x);
1861 double8 __ovld __cnfn logb(double8 x);
1862 double16 __ovld __cnfn logb(double16 x);
1863-#endif //cl_khr_fp64
1864+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1865 #ifdef cl_khr_fp16
1866 half __ovld __cnfn logb(half x);
1867 half2 __ovld __cnfn logb(half2 x);
1868@@ -7877,14 +7883,14 @@ float3 __ovld __cnfn mad(float3 a, float3 b, float3 c);
1869 float4 __ovld __cnfn mad(float4 a, float4 b, float4 c);
1870 float8 __ovld __cnfn mad(float8 a, float8 b, float8 c);
1871 float16 __ovld __cnfn mad(float16 a, float16 b, float16 c);
1872-#ifdef cl_khr_fp64
1873+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1874 double __ovld __cnfn mad(double a, double b, double c);
1875 double2 __ovld __cnfn mad(double2 a, double2 b, double2 c);
1876 double3 __ovld __cnfn mad(double3 a, double3 b, double3 c);
1877 double4 __ovld __cnfn mad(double4 a, double4 b, double4 c);
1878 double8 __ovld __cnfn mad(double8 a, double8 b, double8 c);
1879 double16 __ovld __cnfn mad(double16 a, double16 b, double16 c);
1880-#endif //cl_khr_fp64
1881+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1882 #ifdef cl_khr_fp16
1883 half __ovld __cnfn mad(half a, half b, half c);
1884 half2 __ovld __cnfn mad(half2 a, half2 b, half2 c);
1885@@ -7904,14 +7910,14 @@ float3 __ovld __cnfn maxmag(float3 x, float3 y);
1886 float4 __ovld __cnfn maxmag(float4 x, float4 y);
1887 float8 __ovld __cnfn maxmag(float8 x, float8 y);
1888 float16 __ovld __cnfn maxmag(float16 x, float16 y);
1889-#ifdef cl_khr_fp64
1890+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1891 double __ovld __cnfn maxmag(double x, double y);
1892 double2 __ovld __cnfn maxmag(double2 x, double2 y);
1893 double3 __ovld __cnfn maxmag(double3 x, double3 y);
1894 double4 __ovld __cnfn maxmag(double4 x, double4 y);
1895 double8 __ovld __cnfn maxmag(double8 x, double8 y);
1896 double16 __ovld __cnfn maxmag(double16 x, double16 y);
1897-#endif //cl_khr_fp64
1898+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1899 #ifdef cl_khr_fp16
1900 half __ovld __cnfn maxmag(half x, half y);
1901 half2 __ovld __cnfn maxmag(half2 x, half2 y);
1902@@ -7931,14 +7937,14 @@ float3 __ovld __cnfn minmag(float3 x, float3 y);
1903 float4 __ovld __cnfn minmag(float4 x, float4 y);
1904 float8 __ovld __cnfn minmag(float8 x, float8 y);
1905 float16 __ovld __cnfn minmag(float16 x, float16 y);
1906-#ifdef cl_khr_fp64
1907+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1908 double __ovld __cnfn minmag(double x, double y);
1909 double2 __ovld __cnfn minmag(double2 x, double2 y);
1910 double3 __ovld __cnfn minmag(double3 x, double3 y);
1911 double4 __ovld __cnfn minmag(double4 x, double4 y);
1912 double8 __ovld __cnfn minmag(double8 x, double8 y);
1913 double16 __ovld __cnfn minmag(double16 x, double16 y);
1914-#endif //cl_khr_fp64
1915+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1916 #ifdef cl_khr_fp16
1917 half __ovld __cnfn minmag(half x, half y);
1918 half2 __ovld __cnfn minmag(half2 x, half2 y);
1919@@ -7955,21 +7961,21 @@ half16 __ovld __cnfn minmag(half16 x, half16 y);
1920 * the argument. It stores the integral part in the object
1921 * pointed to by iptr.
1922 */
1923-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
1924+#ifdef __opencl_c_generic_address_space
1925 float __ovld modf(float x, float *iptr);
1926 float2 __ovld modf(float2 x, float2 *iptr);
1927 float3 __ovld modf(float3 x, float3 *iptr);
1928 float4 __ovld modf(float4 x, float4 *iptr);
1929 float8 __ovld modf(float8 x, float8 *iptr);
1930 float16 __ovld modf(float16 x, float16 *iptr);
1931-#ifdef cl_khr_fp64
1932+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1933 double __ovld modf(double x, double *iptr);
1934 double2 __ovld modf(double2 x, double2 *iptr);
1935 double3 __ovld modf(double3 x, double3 *iptr);
1936 double4 __ovld modf(double4 x, double4 *iptr);
1937 double8 __ovld modf(double8 x, double8 *iptr);
1938 double16 __ovld modf(double16 x, double16 *iptr);
1939-#endif //cl_khr_fp64
1940+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1941 #ifdef cl_khr_fp16
1942 half __ovld modf(half x, half *iptr);
1943 half2 __ovld modf(half2 x, half2 *iptr);
1944@@ -7978,7 +7984,9 @@ half4 __ovld modf(half4 x, half4 *iptr);
1945 half8 __ovld modf(half8 x, half8 *iptr);
1946 half16 __ovld modf(half16 x, half16 *iptr);
1947 #endif //cl_khr_fp16
1948-#else
1949+#endif //__opencl_c_generic_address_space
1950+
1951+#if !defined(__OPENCL_CPP_VERSION__) && (__OPENCL_C_VERSION__ != CL_VERSION_2_0)
1952 float __ovld modf(float x, __global float *iptr);
1953 float2 __ovld modf(float2 x, __global float2 *iptr);
1954 float3 __ovld modf(float3 x, __global float3 *iptr);
1955@@ -7997,7 +8005,7 @@ float3 __ovld modf(float3 x, __private float3 *iptr);
1956 float4 __ovld modf(float4 x, __private float4 *iptr);
1957 float8 __ovld modf(float8 x, __private float8 *iptr);
1958 float16 __ovld modf(float16 x, __private float16 *iptr);
1959-#ifdef cl_khr_fp64
1960+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1961 double __ovld modf(double x, __global double *iptr);
1962 double2 __ovld modf(double2 x, __global double2 *iptr);
1963 double3 __ovld modf(double3 x, __global double3 *iptr);
1964@@ -8016,7 +8024,7 @@ double3 __ovld modf(double3 x, __private double3 *iptr);
1965 double4 __ovld modf(double4 x, __private double4 *iptr);
1966 double8 __ovld modf(double8 x, __private double8 *iptr);
1967 double16 __ovld modf(double16 x, __private double16 *iptr);
1968-#endif //cl_khr_fp64
1969+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1970 #ifdef cl_khr_fp16
1971 half __ovld modf(half x, __global half *iptr);
1972 half2 __ovld modf(half2 x, __global half2 *iptr);
1973@@ -8037,7 +8045,8 @@ half4 __ovld modf(half4 x, __private half4 *iptr);
1974 half8 __ovld modf(half8 x, __private half8 *iptr);
1975 half16 __ovld modf(half16 x, __private half16 *iptr);
1976 #endif //cl_khr_fp16
1977-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
1978+#endif //! defined(__OPENCL_CPP_VERSION__) && (__OPENCL_C_VERSION__ !=
1979+ //! CL_VERSION_2_0)
1980
1981 /**
1982 * Returns a quiet NaN. The nancode may be placed
1983@@ -8049,14 +8058,14 @@ float3 __ovld __cnfn nan(uint3 nancode);
1984 float4 __ovld __cnfn nan(uint4 nancode);
1985 float8 __ovld __cnfn nan(uint8 nancode);
1986 float16 __ovld __cnfn nan(uint16 nancode);
1987-#ifdef cl_khr_fp64
1988+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1989 double __ovld __cnfn nan(ulong nancode);
1990 double2 __ovld __cnfn nan(ulong2 nancode);
1991 double3 __ovld __cnfn nan(ulong3 nancode);
1992 double4 __ovld __cnfn nan(ulong4 nancode);
1993 double8 __ovld __cnfn nan(ulong8 nancode);
1994 double16 __ovld __cnfn nan(ulong16 nancode);
1995-#endif //cl_khr_fp64
1996+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
1997 #ifdef cl_khr_fp16
1998 half __ovld __cnfn nan(ushort nancode);
1999 half2 __ovld __cnfn nan(ushort2 nancode);
2000@@ -8079,14 +8088,14 @@ float3 __ovld __cnfn nextafter(float3 x, float3 y);
2001 float4 __ovld __cnfn nextafter(float4 x, float4 y);
2002 float8 __ovld __cnfn nextafter(float8 x, float8 y);
2003 float16 __ovld __cnfn nextafter(float16 x, float16 y);
2004-#ifdef cl_khr_fp64
2005+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2006 double __ovld __cnfn nextafter(double x, double y);
2007 double2 __ovld __cnfn nextafter(double2 x, double2 y);
2008 double3 __ovld __cnfn nextafter(double3 x, double3 y);
2009 double4 __ovld __cnfn nextafter(double4 x, double4 y);
2010 double8 __ovld __cnfn nextafter(double8 x, double8 y);
2011 double16 __ovld __cnfn nextafter(double16 x, double16 y);
2012-#endif //cl_khr_fp64
2013+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2014 #ifdef cl_khr_fp16
2015 half __ovld __cnfn nextafter(half x, half y);
2016 half2 __ovld __cnfn nextafter(half2 x, half2 y);
2017@@ -8105,14 +8114,14 @@ float3 __ovld __cnfn pow(float3 x, float3 y);
2018 float4 __ovld __cnfn pow(float4 x, float4 y);
2019 float8 __ovld __cnfn pow(float8 x, float8 y);
2020 float16 __ovld __cnfn pow(float16 x, float16 y);
2021-#ifdef cl_khr_fp64
2022+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2023 double __ovld __cnfn pow(double x, double y);
2024 double2 __ovld __cnfn pow(double2 x, double2 y);
2025 double3 __ovld __cnfn pow(double3 x, double3 y);
2026 double4 __ovld __cnfn pow(double4 x, double4 y);
2027 double8 __ovld __cnfn pow(double8 x, double8 y);
2028 double16 __ovld __cnfn pow(double16 x, double16 y);
2029-#endif //cl_khr_fp64
2030+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2031 #ifdef cl_khr_fp16
2032 half __ovld __cnfn pow(half x, half y);
2033 half2 __ovld __cnfn pow(half2 x, half2 y);
2034@@ -8131,14 +8140,14 @@ float3 __ovld __cnfn pown(float3 x, int3 y);
2035 float4 __ovld __cnfn pown(float4 x, int4 y);
2036 float8 __ovld __cnfn pown(float8 x, int8 y);
2037 float16 __ovld __cnfn pown(float16 x, int16 y);
2038-#ifdef cl_khr_fp64
2039+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2040 double __ovld __cnfn pown(double x, int y);
2041 double2 __ovld __cnfn pown(double2 x, int2 y);
2042 double3 __ovld __cnfn pown(double3 x, int3 y);
2043 double4 __ovld __cnfn pown(double4 x, int4 y);
2044 double8 __ovld __cnfn pown(double8 x, int8 y);
2045 double16 __ovld __cnfn pown(double16 x, int16 y);
2046-#endif //cl_khr_fp64
2047+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2048 #ifdef cl_khr_fp16
2049 half __ovld __cnfn pown(half x, int y);
2050 half2 __ovld __cnfn pown(half2 x, int2 y);
2051@@ -8157,14 +8166,14 @@ float3 __ovld __cnfn powr(float3 x, float3 y);
2052 float4 __ovld __cnfn powr(float4 x, float4 y);
2053 float8 __ovld __cnfn powr(float8 x, float8 y);
2054 float16 __ovld __cnfn powr(float16 x, float16 y);
2055-#ifdef cl_khr_fp64
2056+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2057 double __ovld __cnfn powr(double x, double y);
2058 double2 __ovld __cnfn powr(double2 x, double2 y);
2059 double3 __ovld __cnfn powr(double3 x, double3 y);
2060 double4 __ovld __cnfn powr(double4 x, double4 y);
2061 double8 __ovld __cnfn powr(double8 x, double8 y);
2062 double16 __ovld __cnfn powr(double16 x, double16 y);
2063-#endif //cl_khr_fp64
2064+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2065 #ifdef cl_khr_fp16
2066 half __ovld __cnfn powr(half x, half y);
2067 half2 __ovld __cnfn powr(half2 x, half2 y);
2068@@ -8186,14 +8195,14 @@ float3 __ovld __cnfn remainder(float3 x, float3 y);
2069 float4 __ovld __cnfn remainder(float4 x, float4 y);
2070 float8 __ovld __cnfn remainder(float8 x, float8 y);
2071 float16 __ovld __cnfn remainder(float16 x, float16 y);
2072-#ifdef cl_khr_fp64
2073+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2074 double __ovld __cnfn remainder(double x, double y);
2075 double2 __ovld __cnfn remainder(double2 x, double2 y);
2076 double3 __ovld __cnfn remainder(double3 x, double3 y);
2077 double4 __ovld __cnfn remainder(double4 x, double4 y);
2078 double8 __ovld __cnfn remainder(double8 x, double8 y);
2079 double16 __ovld __cnfn remainder(double16 x, double16 y);
2080-#endif //cl_khr_fp64
2081+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2082 #ifdef cl_khr_fp16
2083 half __ovld __cnfn remainder(half x, half y);
2084 half2 __ovld __cnfn remainder(half2 x, half2 y);
2085@@ -8215,21 +8224,21 @@ half16 __ovld __cnfn remainder(half16 x, half16 y);
2086 * sign as x/y. It stores this signed value in the object
2087 * pointed to by quo.
2088 */
2089-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
2090+#ifdef __opencl_c_generic_address_space
2091 float __ovld remquo(float x, float y, int *quo);
2092 float2 __ovld remquo(float2 x, float2 y, int2 *quo);
2093 float3 __ovld remquo(float3 x, float3 y, int3 *quo);
2094 float4 __ovld remquo(float4 x, float4 y, int4 *quo);
2095 float8 __ovld remquo(float8 x, float8 y, int8 *quo);
2096 float16 __ovld remquo(float16 x, float16 y, int16 *quo);
2097-#ifdef cl_khr_fp64
2098+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2099 double __ovld remquo(double x, double y, int *quo);
2100 double2 __ovld remquo(double2 x, double2 y, int2 *quo);
2101 double3 __ovld remquo(double3 x, double3 y, int3 *quo);
2102 double4 __ovld remquo(double4 x, double4 y, int4 *quo);
2103 double8 __ovld remquo(double8 x, double8 y, int8 *quo);
2104 double16 __ovld remquo(double16 x, double16 y, int16 *quo);
2105-#endif //cl_khr_fp64
2106+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2107 #ifdef cl_khr_fp16
2108 half __ovld remquo(half x, half y, int *quo);
2109 half2 __ovld remquo(half2 x, half2 y, int2 *quo);
2110@@ -8237,9 +8246,10 @@ half3 __ovld remquo(half3 x, half3 y, int3 *quo);
2111 half4 __ovld remquo(half4 x, half4 y, int4 *quo);
2112 half8 __ovld remquo(half8 x, half8 y, int8 *quo);
2113 half16 __ovld remquo(half16 x, half16 y, int16 *quo);
2114-
2115 #endif //cl_khr_fp16
2116-#else
2117+#endif //__opencl_c_generic_address_space
2118+
2119+#if !defined(__OPENCL_CPP_VERSION__) && (__OPENCL_C_VERSION__ != CL_VERSION_2_0)
2120 float __ovld remquo(float x, float y, __global int *quo);
2121 float2 __ovld remquo(float2 x, float2 y, __global int2 *quo);
2122 float3 __ovld remquo(float3 x, float3 y, __global int3 *quo);
2123@@ -8258,7 +8268,7 @@ float3 __ovld remquo(float3 x, float3 y, __private int3 *quo);
2124 float4 __ovld remquo(float4 x, float4 y, __private int4 *quo);
2125 float8 __ovld remquo(float8 x, float8 y, __private int8 *quo);
2126 float16 __ovld remquo(float16 x, float16 y, __private int16 *quo);
2127-#ifdef cl_khr_fp64
2128+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2129 double __ovld remquo(double x, double y, __global int *quo);
2130 double2 __ovld remquo(double2 x, double2 y, __global int2 *quo);
2131 double3 __ovld remquo(double3 x, double3 y, __global int3 *quo);
2132@@ -8277,7 +8287,7 @@ double3 __ovld remquo(double3 x, double3 y, __private int3 *quo);
2133 double4 __ovld remquo(double4 x, double4 y, __private int4 *quo);
2134 double8 __ovld remquo(double8 x, double8 y, __private int8 *quo);
2135 double16 __ovld remquo(double16 x, double16 y, __private int16 *quo);
2136-#endif //cl_khr_fp64
2137+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2138 #ifdef cl_khr_fp16
2139 half __ovld remquo(half x, half y, __global int *quo);
2140 half2 __ovld remquo(half2 x, half2 y, __global int2 *quo);
2141@@ -8298,7 +8308,8 @@ half4 __ovld remquo(half4 x, half4 y, __private int4 *quo);
2142 half8 __ovld remquo(half8 x, half8 y, __private int8 *quo);
2143 half16 __ovld remquo(half16 x, half16 y, __private int16 *quo);
2144 #endif //cl_khr_fp16
2145-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
2146+#endif //! defined(__OPENCL_CPP_VERSION__) && (__OPENCL_C_VERSION__ !=
2147+ //! CL_VERSION_2_0)
2148 /**
2149 * Round to integral value (using round to nearest
2150 * even rounding mode) in floating-point format.
2151@@ -8311,14 +8322,14 @@ float3 __ovld __cnfn rint(float3);
2152 float4 __ovld __cnfn rint(float4);
2153 float8 __ovld __cnfn rint(float8);
2154 float16 __ovld __cnfn rint(float16);
2155-#ifdef cl_khr_fp64
2156+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2157 double __ovld __cnfn rint(double);
2158 double2 __ovld __cnfn rint(double2);
2159 double3 __ovld __cnfn rint(double3);
2160 double4 __ovld __cnfn rint(double4);
2161 double8 __ovld __cnfn rint(double8);
2162 double16 __ovld __cnfn rint(double16);
2163-#endif //cl_khr_fp64
2164+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2165 #ifdef cl_khr_fp16
2166 half __ovld __cnfn rint(half);
2167 half2 __ovld __cnfn rint(half2);
2168@@ -8337,14 +8348,14 @@ float3 __ovld __cnfn rootn(float3 x, int3 y);
2169 float4 __ovld __cnfn rootn(float4 x, int4 y);
2170 float8 __ovld __cnfn rootn(float8 x, int8 y);
2171 float16 __ovld __cnfn rootn(float16 x, int16 y);
2172-#ifdef cl_khr_fp64
2173+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2174 double __ovld __cnfn rootn(double x, int y);
2175 double2 __ovld __cnfn rootn(double2 x, int2 y);
2176 double3 __ovld __cnfn rootn(double3 x, int3 y);
2177 double4 __ovld __cnfn rootn(double4 x, int4 y);
2178 double8 __ovld __cnfn rootn(double8 x, int8 y);
2179 double16 __ovld __cnfn rootn(double16 x, int16 y);
2180-#endif //cl_khr_fp64
2181+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2182 #ifdef cl_khr_fp16
2183 half __ovld __cnfn rootn(half x, int y);
2184 half2 __ovld __cnfn rootn(half2 x, int2 y);
2185@@ -8365,14 +8376,14 @@ float3 __ovld __cnfn round(float3 x);
2186 float4 __ovld __cnfn round(float4 x);
2187 float8 __ovld __cnfn round(float8 x);
2188 float16 __ovld __cnfn round(float16 x);
2189-#ifdef cl_khr_fp64
2190+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2191 double __ovld __cnfn round(double x);
2192 double2 __ovld __cnfn round(double2 x);
2193 double3 __ovld __cnfn round(double3 x);
2194 double4 __ovld __cnfn round(double4 x);
2195 double8 __ovld __cnfn round(double8 x);
2196 double16 __ovld __cnfn round(double16 x);
2197-#endif //cl_khr_fp64
2198+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2199 #ifdef cl_khr_fp16
2200 half __ovld __cnfn round(half x);
2201 half2 __ovld __cnfn round(half2 x);
2202@@ -8391,14 +8402,14 @@ float3 __ovld __cnfn rsqrt(float3);
2203 float4 __ovld __cnfn rsqrt(float4);
2204 float8 __ovld __cnfn rsqrt(float8);
2205 float16 __ovld __cnfn rsqrt(float16);
2206-#ifdef cl_khr_fp64
2207+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2208 double __ovld __cnfn rsqrt(double);
2209 double2 __ovld __cnfn rsqrt(double2);
2210 double3 __ovld __cnfn rsqrt(double3);
2211 double4 __ovld __cnfn rsqrt(double4);
2212 double8 __ovld __cnfn rsqrt(double8);
2213 double16 __ovld __cnfn rsqrt(double16);
2214-#endif //cl_khr_fp64
2215+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2216 #ifdef cl_khr_fp16
2217 half __ovld __cnfn rsqrt(half);
2218 half2 __ovld __cnfn rsqrt(half2);
2219@@ -8417,14 +8428,14 @@ float3 __ovld __cnfn sin(float3);
2220 float4 __ovld __cnfn sin(float4);
2221 float8 __ovld __cnfn sin(float8);
2222 float16 __ovld __cnfn sin(float16);
2223-#ifdef cl_khr_fp64
2224+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2225 double __ovld __cnfn sin(double);
2226 double2 __ovld __cnfn sin(double2);
2227 double3 __ovld __cnfn sin(double3);
2228 double4 __ovld __cnfn sin(double4);
2229 double8 __ovld __cnfn sin(double8);
2230 double16 __ovld __cnfn sin(double16);
2231-#endif //cl_khr_fp64
2232+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2233 #ifdef cl_khr_fp16
2234 half __ovld __cnfn sin(half);
2235 half2 __ovld __cnfn sin(half2);
2236@@ -8439,21 +8450,21 @@ half16 __ovld __cnfn sin(half16);
2237 * is the return value and computed cosine is returned
2238 * in cosval.
2239 */
2240-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
2241+#ifdef __opencl_c_generic_address_space
2242 float __ovld sincos(float x, float *cosval);
2243 float2 __ovld sincos(float2 x, float2 *cosval);
2244 float3 __ovld sincos(float3 x, float3 *cosval);
2245 float4 __ovld sincos(float4 x, float4 *cosval);
2246 float8 __ovld sincos(float8 x, float8 *cosval);
2247 float16 __ovld sincos(float16 x, float16 *cosval);
2248-#ifdef cl_khr_fp64
2249+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2250 double __ovld sincos(double x, double *cosval);
2251 double2 __ovld sincos(double2 x, double2 *cosval);
2252 double3 __ovld sincos(double3 x, double3 *cosval);
2253 double4 __ovld sincos(double4 x, double4 *cosval);
2254 double8 __ovld sincos(double8 x, double8 *cosval);
2255 double16 __ovld sincos(double16 x, double16 *cosval);
2256-#endif //cl_khr_fp64
2257+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2258 #ifdef cl_khr_fp16
2259 half __ovld sincos(half x, half *cosval);
2260 half2 __ovld sincos(half2 x, half2 *cosval);
2261@@ -8462,7 +8473,9 @@ half4 __ovld sincos(half4 x, half4 *cosval);
2262 half8 __ovld sincos(half8 x, half8 *cosval);
2263 half16 __ovld sincos(half16 x, half16 *cosval);
2264 #endif //cl_khr_fp16
2265-#else
2266+#endif //__opencl_c_generic_address_space
2267+
2268+#if !defined(__OPENCL_CPP_VERSION__) && (__OPENCL_C_VERSION__ != CL_VERSION_2_0)
2269 float __ovld sincos(float x, __global float *cosval);
2270 float2 __ovld sincos(float2 x, __global float2 *cosval);
2271 float3 __ovld sincos(float3 x, __global float3 *cosval);
2272@@ -8481,7 +8494,7 @@ float3 __ovld sincos(float3 x, __private float3 *cosval);
2273 float4 __ovld sincos(float4 x, __private float4 *cosval);
2274 float8 __ovld sincos(float8 x, __private float8 *cosval);
2275 float16 __ovld sincos(float16 x, __private float16 *cosval);
2276-#ifdef cl_khr_fp64
2277+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2278 double __ovld sincos(double x, __global double *cosval);
2279 double2 __ovld sincos(double2 x, __global double2 *cosval);
2280 double3 __ovld sincos(double3 x, __global double3 *cosval);
2281@@ -8500,7 +8513,7 @@ double3 __ovld sincos(double3 x, __private double3 *cosval);
2282 double4 __ovld sincos(double4 x, __private double4 *cosval);
2283 double8 __ovld sincos(double8 x, __private double8 *cosval);
2284 double16 __ovld sincos(double16 x, __private double16 *cosval);
2285-#endif //cl_khr_fp64
2286+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2287 #ifdef cl_khr_fp16
2288 half __ovld sincos(half x, __global half *cosval);
2289 half2 __ovld sincos(half2 x, __global half2 *cosval);
2290@@ -8521,8 +8534,8 @@ half4 __ovld sincos(half4 x, __private half4 *cosval);
2291 half8 __ovld sincos(half8 x, __private half8 *cosval);
2292 half16 __ovld sincos(half16 x, __private half16 *cosval);
2293 #endif //cl_khr_fp16
2294-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
2295-
2296+#endif //! defined(__OPENCL_CPP_VERSION__) && (__OPENCL_C_VERSION__ !=
2297+ //! CL_VERSION_2_0)
2298 /**
2299 * Compute hyperbolic sine.
2300 */
2301@@ -8532,14 +8545,14 @@ float3 __ovld __cnfn sinh(float3);
2302 float4 __ovld __cnfn sinh(float4);
2303 float8 __ovld __cnfn sinh(float8);
2304 float16 __ovld __cnfn sinh(float16);
2305-#ifdef cl_khr_fp64
2306+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2307 double __ovld __cnfn sinh(double);
2308 double2 __ovld __cnfn sinh(double2);
2309 double3 __ovld __cnfn sinh(double3);
2310 double4 __ovld __cnfn sinh(double4);
2311 double8 __ovld __cnfn sinh(double8);
2312 double16 __ovld __cnfn sinh(double16);
2313-#endif //cl_khr_fp64
2314+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2315 #ifdef cl_khr_fp16
2316 half __ovld __cnfn sinh(half);
2317 half2 __ovld __cnfn sinh(half2);
2318@@ -8558,14 +8571,14 @@ float3 __ovld __cnfn sinpi(float3 x);
2319 float4 __ovld __cnfn sinpi(float4 x);
2320 float8 __ovld __cnfn sinpi(float8 x);
2321 float16 __ovld __cnfn sinpi(float16 x);
2322-#ifdef cl_khr_fp64
2323+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2324 double __ovld __cnfn sinpi(double x);
2325 double2 __ovld __cnfn sinpi(double2 x);
2326 double3 __ovld __cnfn sinpi(double3 x);
2327 double4 __ovld __cnfn sinpi(double4 x);
2328 double8 __ovld __cnfn sinpi(double8 x);
2329 double16 __ovld __cnfn sinpi(double16 x);
2330-#endif //cl_khr_fp64
2331+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2332 #ifdef cl_khr_fp16
2333 half __ovld __cnfn sinpi(half x);
2334 half2 __ovld __cnfn sinpi(half2 x);
2335@@ -8584,14 +8597,14 @@ float3 __ovld __cnfn sqrt(float3);
2336 float4 __ovld __cnfn sqrt(float4);
2337 float8 __ovld __cnfn sqrt(float8);
2338 float16 __ovld __cnfn sqrt(float16);
2339-#ifdef cl_khr_fp64
2340+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2341 double __ovld __cnfn sqrt(double);
2342 double2 __ovld __cnfn sqrt(double2);
2343 double3 __ovld __cnfn sqrt(double3);
2344 double4 __ovld __cnfn sqrt(double4);
2345 double8 __ovld __cnfn sqrt(double8);
2346 double16 __ovld __cnfn sqrt(double16);
2347-#endif //cl_khr_fp64
2348+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2349 #ifdef cl_khr_fp16
2350 half __ovld __cnfn sqrt(half);
2351 half2 __ovld __cnfn sqrt(half2);
2352@@ -8610,14 +8623,14 @@ float3 __ovld __cnfn tan(float3);
2353 float4 __ovld __cnfn tan(float4);
2354 float8 __ovld __cnfn tan(float8);
2355 float16 __ovld __cnfn tan(float16);
2356-#ifdef cl_khr_fp64
2357+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2358 double __ovld __cnfn tan(double);
2359 double2 __ovld __cnfn tan(double2);
2360 double3 __ovld __cnfn tan(double3);
2361 double4 __ovld __cnfn tan(double4);
2362 double8 __ovld __cnfn tan(double8);
2363 double16 __ovld __cnfn tan(double16);
2364-#endif //cl_khr_fp64
2365+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2366 #ifdef cl_khr_fp16
2367 half __ovld __cnfn tan(half);
2368 half2 __ovld __cnfn tan(half2);
2369@@ -8636,14 +8649,14 @@ float3 __ovld __cnfn tanh(float3);
2370 float4 __ovld __cnfn tanh(float4);
2371 float8 __ovld __cnfn tanh(float8);
2372 float16 __ovld __cnfn tanh(float16);
2373-#ifdef cl_khr_fp64
2374+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2375 double __ovld __cnfn tanh(double);
2376 double2 __ovld __cnfn tanh(double2);
2377 double3 __ovld __cnfn tanh(double3);
2378 double4 __ovld __cnfn tanh(double4);
2379 double8 __ovld __cnfn tanh(double8);
2380 double16 __ovld __cnfn tanh(double16);
2381-#endif //cl_khr_fp64
2382+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2383 #ifdef cl_khr_fp16
2384 half __ovld __cnfn tanh(half);
2385 half2 __ovld __cnfn tanh(half2);
2386@@ -8662,14 +8675,14 @@ float3 __ovld __cnfn tanpi(float3 x);
2387 float4 __ovld __cnfn tanpi(float4 x);
2388 float8 __ovld __cnfn tanpi(float8 x);
2389 float16 __ovld __cnfn tanpi(float16 x);
2390-#ifdef cl_khr_fp64
2391+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2392 double __ovld __cnfn tanpi(double x);
2393 double2 __ovld __cnfn tanpi(double2 x);
2394 double3 __ovld __cnfn tanpi(double3 x);
2395 double4 __ovld __cnfn tanpi(double4 x);
2396 double8 __ovld __cnfn tanpi(double8 x);
2397 double16 __ovld __cnfn tanpi(double16 x);
2398-#endif //cl_khr_fp64
2399+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2400 #ifdef cl_khr_fp16
2401 half __ovld __cnfn tanpi(half x);
2402 half2 __ovld __cnfn tanpi(half2 x);
2403@@ -8688,14 +8701,14 @@ float3 __ovld __cnfn tgamma(float3);
2404 float4 __ovld __cnfn tgamma(float4);
2405 float8 __ovld __cnfn tgamma(float8);
2406 float16 __ovld __cnfn tgamma(float16);
2407-#ifdef cl_khr_fp64
2408+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2409 double __ovld __cnfn tgamma(double);
2410 double2 __ovld __cnfn tgamma(double2);
2411 double3 __ovld __cnfn tgamma(double3);
2412 double4 __ovld __cnfn tgamma(double4);
2413 double8 __ovld __cnfn tgamma(double8);
2414 double16 __ovld __cnfn tgamma(double16);
2415-#endif //cl_khr_fp64
2416+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2417 #ifdef cl_khr_fp16
2418 half __ovld __cnfn tgamma(half);
2419 half2 __ovld __cnfn tgamma(half2);
2420@@ -8715,14 +8728,14 @@ float3 __ovld __cnfn trunc(float3);
2421 float4 __ovld __cnfn trunc(float4);
2422 float8 __ovld __cnfn trunc(float8);
2423 float16 __ovld __cnfn trunc(float16);
2424-#ifdef cl_khr_fp64
2425+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2426 double __ovld __cnfn trunc(double);
2427 double2 __ovld __cnfn trunc(double2);
2428 double3 __ovld __cnfn trunc(double3);
2429 double4 __ovld __cnfn trunc(double4);
2430 double8 __ovld __cnfn trunc(double8);
2431 double16 __ovld __cnfn trunc(double16);
2432-#endif //cl_khr_fp64
2433+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2434 #ifdef cl_khr_fp16
2435 half __ovld __cnfn trunc(half);
2436 half2 __ovld __cnfn trunc(half2);
2437@@ -10108,7 +10121,7 @@ float3 __ovld __cnfn clamp(float3 x, float minval, float maxval);
2438 float4 __ovld __cnfn clamp(float4 x, float minval, float maxval);
2439 float8 __ovld __cnfn clamp(float8 x, float minval, float maxval);
2440 float16 __ovld __cnfn clamp(float16 x, float minval, float maxval);
2441-#ifdef cl_khr_fp64
2442+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2443 double __ovld __cnfn clamp(double x, double minval, double maxval);
2444 double2 __ovld __cnfn clamp(double2 x, double2 minval, double2 maxval);
2445 double3 __ovld __cnfn clamp(double3 x, double3 minval, double3 maxval);
2446@@ -10120,7 +10133,7 @@ double3 __ovld __cnfn clamp(double3 x, double minval, double maxval);
2447 double4 __ovld __cnfn clamp(double4 x, double minval, double maxval);
2448 double8 __ovld __cnfn clamp(double8 x, double minval, double maxval);
2449 double16 __ovld __cnfn clamp(double16 x, double minval, double maxval);
2450-#endif //cl_khr_fp64
2451+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2452 #ifdef cl_khr_fp16
2453 half __ovld __cnfn clamp(half x, half minval, half maxval);
2454 half2 __ovld __cnfn clamp(half2 x, half2 minval, half2 maxval);
2455@@ -10145,14 +10158,14 @@ float3 __ovld __cnfn degrees(float3 radians);
2456 float4 __ovld __cnfn degrees(float4 radians);
2457 float8 __ovld __cnfn degrees(float8 radians);
2458 float16 __ovld __cnfn degrees(float16 radians);
2459-#ifdef cl_khr_fp64
2460+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2461 double __ovld __cnfn degrees(double radians);
2462 double2 __ovld __cnfn degrees(double2 radians);
2463 double3 __ovld __cnfn degrees(double3 radians);
2464 double4 __ovld __cnfn degrees(double4 radians);
2465 double8 __ovld __cnfn degrees(double8 radians);
2466 double16 __ovld __cnfn degrees(double16 radians);
2467-#endif //cl_khr_fp64
2468+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2469 #ifdef cl_khr_fp16
2470 half __ovld __cnfn degrees(half radians);
2471 half2 __ovld __cnfn degrees(half2 radians);
2472@@ -10177,7 +10190,7 @@ float3 __ovld __cnfn max(float3 x, float y);
2473 float4 __ovld __cnfn max(float4 x, float y);
2474 float8 __ovld __cnfn max(float8 x, float y);
2475 float16 __ovld __cnfn max(float16 x, float y);
2476-#ifdef cl_khr_fp64
2477+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2478 double __ovld __cnfn max(double x, double y);
2479 double2 __ovld __cnfn max(double2 x, double2 y);
2480 double3 __ovld __cnfn max(double3 x, double3 y);
2481@@ -10189,7 +10202,7 @@ double3 __ovld __cnfn max(double3 x, double y);
2482 double4 __ovld __cnfn max(double4 x, double y);
2483 double8 __ovld __cnfn max(double8 x, double y);
2484 double16 __ovld __cnfn max(double16 x, double y);
2485-#endif //cl_khr_fp64
2486+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2487 #ifdef cl_khr_fp16
2488 half __ovld __cnfn max(half x, half y);
2489 half2 __ovld __cnfn max(half2 x, half2 y);
2490@@ -10219,7 +10232,7 @@ float3 __ovld __cnfn min(float3 x, float y);
2491 float4 __ovld __cnfn min(float4 x, float y);
2492 float8 __ovld __cnfn min(float8 x, float y);
2493 float16 __ovld __cnfn min(float16 x, float y);
2494-#ifdef cl_khr_fp64
2495+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2496 double __ovld __cnfn min(double x, double y);
2497 double2 __ovld __cnfn min(double2 x, double2 y);
2498 double3 __ovld __cnfn min(double3 x, double3 y);
2499@@ -10231,7 +10244,7 @@ double3 __ovld __cnfn min(double3 x, double y);
2500 double4 __ovld __cnfn min(double4 x, double y);
2501 double8 __ovld __cnfn min(double8 x, double y);
2502 double16 __ovld __cnfn min(double16 x, double y);
2503-#endif //cl_khr_fp64
2504+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2505 #ifdef cl_khr_fp16
2506 half __ovld __cnfn min(half x, half y);
2507 half2 __ovld __cnfn min(half2 x, half2 y);
2508@@ -10264,7 +10277,7 @@ float3 __ovld __cnfn mix(float3 x, float3 y, float a);
2509 float4 __ovld __cnfn mix(float4 x, float4 y, float a);
2510 float8 __ovld __cnfn mix(float8 x, float8 y, float a);
2511 float16 __ovld __cnfn mix(float16 x, float16 y, float a);
2512-#ifdef cl_khr_fp64
2513+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2514 double __ovld __cnfn mix(double x, double y, double a);
2515 double2 __ovld __cnfn mix(double2 x, double2 y, double2 a);
2516 double3 __ovld __cnfn mix(double3 x, double3 y, double3 a);
2517@@ -10276,7 +10289,7 @@ double3 __ovld __cnfn mix(double3 x, double3 y, double a);
2518 double4 __ovld __cnfn mix(double4 x, double4 y, double a);
2519 double8 __ovld __cnfn mix(double8 x, double8 y, double a);
2520 double16 __ovld __cnfn mix(double16 x, double16 y, double a);
2521-#endif //cl_khr_fp64
2522+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2523 #ifdef cl_khr_fp16
2524 half __ovld __cnfn mix(half x, half y, half a);
2525 half2 __ovld __cnfn mix(half2 x, half2 y, half2 a);
2526@@ -10301,14 +10314,14 @@ float3 __ovld __cnfn radians(float3 degrees);
2527 float4 __ovld __cnfn radians(float4 degrees);
2528 float8 __ovld __cnfn radians(float8 degrees);
2529 float16 __ovld __cnfn radians(float16 degrees);
2530-#ifdef cl_khr_fp64
2531+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2532 double __ovld __cnfn radians(double degrees);
2533 double2 __ovld __cnfn radians(double2 degrees);
2534 double3 __ovld __cnfn radians(double3 degrees);
2535 double4 __ovld __cnfn radians(double4 degrees);
2536 double8 __ovld __cnfn radians(double8 degrees);
2537 double16 __ovld __cnfn radians(double16 degrees);
2538-#endif //cl_khr_fp64
2539+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2540 #ifdef cl_khr_fp16
2541 half __ovld __cnfn radians(half degrees);
2542 half2 __ovld __cnfn radians(half2 degrees);
2543@@ -10332,7 +10345,7 @@ float3 __ovld __cnfn step(float edge, float3 x);
2544 float4 __ovld __cnfn step(float edge, float4 x);
2545 float8 __ovld __cnfn step(float edge, float8 x);
2546 float16 __ovld __cnfn step(float edge, float16 x);
2547-#ifdef cl_khr_fp64
2548+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2549 double __ovld __cnfn step(double edge, double x);
2550 double2 __ovld __cnfn step(double2 edge, double2 x);
2551 double3 __ovld __cnfn step(double3 edge, double3 x);
2552@@ -10344,7 +10357,7 @@ double3 __ovld __cnfn step(double edge, double3 x);
2553 double4 __ovld __cnfn step(double edge, double4 x);
2554 double8 __ovld __cnfn step(double edge, double8 x);
2555 double16 __ovld __cnfn step(double edge, double16 x);
2556-#endif //cl_khr_fp64
2557+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2558 #ifdef cl_khr_fp16
2559 half __ovld __cnfn step(half edge, half x);
2560 half2 __ovld __cnfn step(half2 edge, half2 x);
2561@@ -10383,7 +10396,7 @@ float3 __ovld __cnfn smoothstep(float edge0, float edge1, float3 x);
2562 float4 __ovld __cnfn smoothstep(float edge0, float edge1, float4 x);
2563 float8 __ovld __cnfn smoothstep(float edge0, float edge1, float8 x);
2564 float16 __ovld __cnfn smoothstep(float edge0, float edge1, float16 x);
2565-#ifdef cl_khr_fp64
2566+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2567 double __ovld __cnfn smoothstep(double edge0, double edge1, double x);
2568 double2 __ovld __cnfn smoothstep(double2 edge0, double2 edge1, double2 x);
2569 double3 __ovld __cnfn smoothstep(double3 edge0, double3 edge1, double3 x);
2570@@ -10395,7 +10408,7 @@ double3 __ovld __cnfn smoothstep(double edge0, double edge1, double3 x);
2571 double4 __ovld __cnfn smoothstep(double edge0, double edge1, double4 x);
2572 double8 __ovld __cnfn smoothstep(double edge0, double edge1, double8 x);
2573 double16 __ovld __cnfn smoothstep(double edge0, double edge1, double16 x);
2574-#endif //cl_khr_fp64
2575+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2576 #ifdef cl_khr_fp16
2577 half __ovld __cnfn smoothstep(half edge0, half edge1, half x);
2578 half2 __ovld __cnfn smoothstep(half2 edge0, half2 edge1, half2 x);
2579@@ -10420,14 +10433,14 @@ float3 __ovld __cnfn sign(float3 x);
2580 float4 __ovld __cnfn sign(float4 x);
2581 float8 __ovld __cnfn sign(float8 x);
2582 float16 __ovld __cnfn sign(float16 x);
2583-#ifdef cl_khr_fp64
2584+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2585 double __ovld __cnfn sign(double x);
2586 double2 __ovld __cnfn sign(double2 x);
2587 double3 __ovld __cnfn sign(double3 x);
2588 double4 __ovld __cnfn sign(double4 x);
2589 double8 __ovld __cnfn sign(double8 x);
2590 double16 __ovld __cnfn sign(double16 x);
2591-#endif //cl_khr_fp64
2592+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2593 #ifdef cl_khr_fp16
2594 half __ovld __cnfn sign(half x);
2595 half2 __ovld __cnfn sign(half2 x);
2596@@ -10445,10 +10458,10 @@ half16 __ovld __cnfn sign(half16 x);
2597 */
2598 float4 __ovld __cnfn cross(float4 p0, float4 p1);
2599 float3 __ovld __cnfn cross(float3 p0, float3 p1);
2600-#ifdef cl_khr_fp64
2601+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2602 double4 __ovld __cnfn cross(double4 p0, double4 p1);
2603 double3 __ovld __cnfn cross(double3 p0, double3 p1);
2604-#endif //cl_khr_fp64
2605+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2606 #ifdef cl_khr_fp16
2607 half4 __ovld __cnfn cross(half4 p0, half4 p1);
2608 half3 __ovld __cnfn cross(half3 p0, half3 p1);
2609@@ -10461,12 +10474,12 @@ float __ovld __cnfn dot(float p0, float p1);
2610 float __ovld __cnfn dot(float2 p0, float2 p1);
2611 float __ovld __cnfn dot(float3 p0, float3 p1);
2612 float __ovld __cnfn dot(float4 p0, float4 p1);
2613-#ifdef cl_khr_fp64
2614+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2615 double __ovld __cnfn dot(double p0, double p1);
2616 double __ovld __cnfn dot(double2 p0, double2 p1);
2617 double __ovld __cnfn dot(double3 p0, double3 p1);
2618 double __ovld __cnfn dot(double4 p0, double4 p1);
2619-#endif //cl_khr_fp64
2620+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2621 #ifdef cl_khr_fp16
2622 half __ovld __cnfn dot(half p0, half p1);
2623 half __ovld __cnfn dot(half2 p0, half2 p1);
2624@@ -10482,12 +10495,12 @@ float __ovld __cnfn distance(float p0, float p1);
2625 float __ovld __cnfn distance(float2 p0, float2 p1);
2626 float __ovld __cnfn distance(float3 p0, float3 p1);
2627 float __ovld __cnfn distance(float4 p0, float4 p1);
2628-#ifdef cl_khr_fp64
2629+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2630 double __ovld __cnfn distance(double p0, double p1);
2631 double __ovld __cnfn distance(double2 p0, double2 p1);
2632 double __ovld __cnfn distance(double3 p0, double3 p1);
2633 double __ovld __cnfn distance(double4 p0, double4 p1);
2634-#endif //cl_khr_fp64
2635+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2636 #ifdef cl_khr_fp16
2637 half __ovld __cnfn distance(half p0, half p1);
2638 half __ovld __cnfn distance(half2 p0, half2 p1);
2639@@ -10503,12 +10516,12 @@ float __ovld __cnfn length(float p);
2640 float __ovld __cnfn length(float2 p);
2641 float __ovld __cnfn length(float3 p);
2642 float __ovld __cnfn length(float4 p);
2643-#ifdef cl_khr_fp64
2644+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2645 double __ovld __cnfn length(double p);
2646 double __ovld __cnfn length(double2 p);
2647 double __ovld __cnfn length(double3 p);
2648 double __ovld __cnfn length(double4 p);
2649-#endif //cl_khr_fp64
2650+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2651 #ifdef cl_khr_fp16
2652 half __ovld __cnfn length(half p);
2653 half __ovld __cnfn length(half2 p);
2654@@ -10524,12 +10537,12 @@ float __ovld __cnfn normalize(float p);
2655 float2 __ovld __cnfn normalize(float2 p);
2656 float3 __ovld __cnfn normalize(float3 p);
2657 float4 __ovld __cnfn normalize(float4 p);
2658-#ifdef cl_khr_fp64
2659+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2660 double __ovld __cnfn normalize(double p);
2661 double2 __ovld __cnfn normalize(double2 p);
2662 double3 __ovld __cnfn normalize(double3 p);
2663 double4 __ovld __cnfn normalize(double4 p);
2664-#endif //cl_khr_fp64
2665+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2666 #ifdef cl_khr_fp16
2667 half __ovld __cnfn normalize(half p);
2668 half2 __ovld __cnfn normalize(half2 p);
2669@@ -10610,14 +10623,14 @@ int3 __ovld __cnfn isequal(float3 x, float3 y);
2670 int4 __ovld __cnfn isequal(float4 x, float4 y);
2671 int8 __ovld __cnfn isequal(float8 x, float8 y);
2672 int16 __ovld __cnfn isequal(float16 x, float16 y);
2673-#ifdef cl_khr_fp64
2674+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2675 int __ovld __cnfn isequal(double x, double y);
2676 long2 __ovld __cnfn isequal(double2 x, double2 y);
2677 long3 __ovld __cnfn isequal(double3 x, double3 y);
2678 long4 __ovld __cnfn isequal(double4 x, double4 y);
2679 long8 __ovld __cnfn isequal(double8 x, double8 y);
2680 long16 __ovld __cnfn isequal(double16 x, double16 y);
2681-#endif //cl_khr_fp64
2682+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2683 #ifdef cl_khr_fp16
2684 int __ovld __cnfn isequal(half x, half y);
2685 short2 __ovld __cnfn isequal(half2 x, half2 y);
2686@@ -10636,14 +10649,14 @@ int3 __ovld __cnfn isnotequal(float3 x, float3 y);
2687 int4 __ovld __cnfn isnotequal(float4 x, float4 y);
2688 int8 __ovld __cnfn isnotequal(float8 x, float8 y);
2689 int16 __ovld __cnfn isnotequal(float16 x, float16 y);
2690-#ifdef cl_khr_fp64
2691+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2692 int __ovld __cnfn isnotequal(double x, double y);
2693 long2 __ovld __cnfn isnotequal(double2 x, double2 y);
2694 long3 __ovld __cnfn isnotequal(double3 x, double3 y);
2695 long4 __ovld __cnfn isnotequal(double4 x, double4 y);
2696 long8 __ovld __cnfn isnotequal(double8 x, double8 y);
2697 long16 __ovld __cnfn isnotequal(double16 x, double16 y);
2698-#endif //cl_khr_fp64
2699+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2700 #ifdef cl_khr_fp16
2701 int __ovld __cnfn isnotequal(half x, half y);
2702 short2 __ovld __cnfn isnotequal(half2 x, half2 y);
2703@@ -10662,14 +10675,14 @@ int3 __ovld __cnfn isgreater(float3 x, float3 y);
2704 int4 __ovld __cnfn isgreater(float4 x, float4 y);
2705 int8 __ovld __cnfn isgreater(float8 x, float8 y);
2706 int16 __ovld __cnfn isgreater(float16 x, float16 y);
2707-#ifdef cl_khr_fp64
2708+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2709 int __ovld __cnfn isgreater(double x, double y);
2710 long2 __ovld __cnfn isgreater(double2 x, double2 y);
2711 long3 __ovld __cnfn isgreater(double3 x, double3 y);
2712 long4 __ovld __cnfn isgreater(double4 x, double4 y);
2713 long8 __ovld __cnfn isgreater(double8 x, double8 y);
2714 long16 __ovld __cnfn isgreater(double16 x, double16 y);
2715-#endif //cl_khr_fp64
2716+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2717 #ifdef cl_khr_fp16
2718 int __ovld __cnfn isgreater(half x, half y);
2719 short2 __ovld __cnfn isgreater(half2 x, half2 y);
2720@@ -10688,14 +10701,14 @@ int3 __ovld __cnfn isgreaterequal(float3 x, float3 y);
2721 int4 __ovld __cnfn isgreaterequal(float4 x, float4 y);
2722 int8 __ovld __cnfn isgreaterequal(float8 x, float8 y);
2723 int16 __ovld __cnfn isgreaterequal(float16 x, float16 y);
2724-#ifdef cl_khr_fp64
2725+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2726 int __ovld __cnfn isgreaterequal(double x, double y);
2727 long2 __ovld __cnfn isgreaterequal(double2 x, double2 y);
2728 long3 __ovld __cnfn isgreaterequal(double3 x, double3 y);
2729 long4 __ovld __cnfn isgreaterequal(double4 x, double4 y);
2730 long8 __ovld __cnfn isgreaterequal(double8 x, double8 y);
2731 long16 __ovld __cnfn isgreaterequal(double16 x, double16 y);
2732-#endif //cl_khr_fp64
2733+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2734 #ifdef cl_khr_fp16
2735 int __ovld __cnfn isgreaterequal(half x, half y);
2736 short2 __ovld __cnfn isgreaterequal(half2 x, half2 y);
2737@@ -10714,14 +10727,14 @@ int3 __ovld __cnfn isless(float3 x, float3 y);
2738 int4 __ovld __cnfn isless(float4 x, float4 y);
2739 int8 __ovld __cnfn isless(float8 x, float8 y);
2740 int16 __ovld __cnfn isless(float16 x, float16 y);
2741-#ifdef cl_khr_fp64
2742+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2743 int __ovld __cnfn isless(double x, double y);
2744 long2 __ovld __cnfn isless(double2 x, double2 y);
2745 long3 __ovld __cnfn isless(double3 x, double3 y);
2746 long4 __ovld __cnfn isless(double4 x, double4 y);
2747 long8 __ovld __cnfn isless(double8 x, double8 y);
2748 long16 __ovld __cnfn isless(double16 x, double16 y);
2749-#endif //cl_khr_fp64
2750+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2751 #ifdef cl_khr_fp16
2752 int __ovld __cnfn isless(half x, half y);
2753 short2 __ovld __cnfn isless(half2 x, half2 y);
2754@@ -10740,14 +10753,14 @@ int3 __ovld __cnfn islessequal(float3 x, float3 y);
2755 int4 __ovld __cnfn islessequal(float4 x, float4 y);
2756 int8 __ovld __cnfn islessequal(float8 x, float8 y);
2757 int16 __ovld __cnfn islessequal(float16 x, float16 y);
2758-#ifdef cl_khr_fp64
2759+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2760 int __ovld __cnfn islessequal(double x, double y);
2761 long2 __ovld __cnfn islessequal(double2 x, double2 y);
2762 long3 __ovld __cnfn islessequal(double3 x, double3 y);
2763 long4 __ovld __cnfn islessequal(double4 x, double4 y);
2764 long8 __ovld __cnfn islessequal(double8 x, double8 y);
2765 long16 __ovld __cnfn islessequal(double16 x, double16 y);
2766-#endif //cl_khr_fp64
2767+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2768 #ifdef cl_khr_fp16
2769 int __ovld __cnfn islessequal(half x, half y);
2770 short2 __ovld __cnfn islessequal(half2 x, half2 y);
2771@@ -10767,14 +10780,14 @@ int3 __ovld __cnfn islessgreater(float3 x, float3 y);
2772 int4 __ovld __cnfn islessgreater(float4 x, float4 y);
2773 int8 __ovld __cnfn islessgreater(float8 x, float8 y);
2774 int16 __ovld __cnfn islessgreater(float16 x, float16 y);
2775-#ifdef cl_khr_fp64
2776+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2777 int __ovld __cnfn islessgreater(double x, double y);
2778 long2 __ovld __cnfn islessgreater(double2 x, double2 y);
2779 long3 __ovld __cnfn islessgreater(double3 x, double3 y);
2780 long4 __ovld __cnfn islessgreater(double4 x, double4 y);
2781 long8 __ovld __cnfn islessgreater(double8 x, double8 y);
2782 long16 __ovld __cnfn islessgreater(double16 x, double16 y);
2783-#endif //cl_khr_fp64
2784+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2785 #ifdef cl_khr_fp16
2786 int __ovld __cnfn islessgreater(half x, half y);
2787 short2 __ovld __cnfn islessgreater(half2 x, half2 y);
2788@@ -10793,14 +10806,14 @@ int3 __ovld __cnfn isfinite(float3);
2789 int4 __ovld __cnfn isfinite(float4);
2790 int8 __ovld __cnfn isfinite(float8);
2791 int16 __ovld __cnfn isfinite(float16);
2792-#ifdef cl_khr_fp64
2793+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2794 int __ovld __cnfn isfinite(double);
2795 long2 __ovld __cnfn isfinite(double2);
2796 long3 __ovld __cnfn isfinite(double3);
2797 long4 __ovld __cnfn isfinite(double4);
2798 long8 __ovld __cnfn isfinite(double8);
2799 long16 __ovld __cnfn isfinite(double16);
2800-#endif //cl_khr_fp64
2801+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2802 #ifdef cl_khr_fp16
2803 int __ovld __cnfn isfinite(half);
2804 short2 __ovld __cnfn isfinite(half2);
2805@@ -10819,14 +10832,14 @@ int3 __ovld __cnfn isinf(float3);
2806 int4 __ovld __cnfn isinf(float4);
2807 int8 __ovld __cnfn isinf(float8);
2808 int16 __ovld __cnfn isinf(float16);
2809-#ifdef cl_khr_fp64
2810+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2811 int __ovld __cnfn isinf(double);
2812 long2 __ovld __cnfn isinf(double2);
2813 long3 __ovld __cnfn isinf(double3);
2814 long4 __ovld __cnfn isinf(double4);
2815 long8 __ovld __cnfn isinf(double8);
2816 long16 __ovld __cnfn isinf(double16);
2817-#endif //cl_khr_fp64
2818+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2819 #ifdef cl_khr_fp16
2820 int __ovld __cnfn isinf(half);
2821 short2 __ovld __cnfn isinf(half2);
2822@@ -10845,14 +10858,14 @@ int3 __ovld __cnfn isnan(float3);
2823 int4 __ovld __cnfn isnan(float4);
2824 int8 __ovld __cnfn isnan(float8);
2825 int16 __ovld __cnfn isnan(float16);
2826-#ifdef cl_khr_fp64
2827+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2828 int __ovld __cnfn isnan(double);
2829 long2 __ovld __cnfn isnan(double2);
2830 long3 __ovld __cnfn isnan(double3);
2831 long4 __ovld __cnfn isnan(double4);
2832 long8 __ovld __cnfn isnan(double8);
2833 long16 __ovld __cnfn isnan(double16);
2834-#endif //cl_khr_fp64
2835+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2836 #ifdef cl_khr_fp16
2837 int __ovld __cnfn isnan(half);
2838 short2 __ovld __cnfn isnan(half2);
2839@@ -10871,14 +10884,14 @@ int3 __ovld __cnfn isnormal(float3);
2840 int4 __ovld __cnfn isnormal(float4);
2841 int8 __ovld __cnfn isnormal(float8);
2842 int16 __ovld __cnfn isnormal(float16);
2843-#ifdef cl_khr_fp64
2844+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2845 int __ovld __cnfn isnormal(double);
2846 long2 __ovld __cnfn isnormal(double2);
2847 long3 __ovld __cnfn isnormal(double3);
2848 long4 __ovld __cnfn isnormal(double4);
2849 long8 __ovld __cnfn isnormal(double8);
2850 long16 __ovld __cnfn isnormal(double16);
2851-#endif //cl_khr_fp64
2852+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2853 #ifdef cl_khr_fp16
2854 int __ovld __cnfn isnormal(half);
2855 short2 __ovld __cnfn isnormal(half2);
2856@@ -10899,14 +10912,14 @@ int3 __ovld __cnfn isordered(float3 x, float3 y);
2857 int4 __ovld __cnfn isordered(float4 x, float4 y);
2858 int8 __ovld __cnfn isordered(float8 x, float8 y);
2859 int16 __ovld __cnfn isordered(float16 x, float16 y);
2860-#ifdef cl_khr_fp64
2861+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2862 int __ovld __cnfn isordered(double x, double y);
2863 long2 __ovld __cnfn isordered(double2 x, double2 y);
2864 long3 __ovld __cnfn isordered(double3 x, double3 y);
2865 long4 __ovld __cnfn isordered(double4 x, double4 y);
2866 long8 __ovld __cnfn isordered(double8 x, double8 y);
2867 long16 __ovld __cnfn isordered(double16 x, double16 y);
2868-#endif //cl_khr_fp64
2869+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2870 #ifdef cl_khr_fp16
2871 int __ovld __cnfn isordered(half x, half y);
2872 short2 __ovld __cnfn isordered(half2 x, half2 y);
2873@@ -10927,14 +10940,14 @@ int3 __ovld __cnfn isunordered(float3 x, float3 y);
2874 int4 __ovld __cnfn isunordered(float4 x, float4 y);
2875 int8 __ovld __cnfn isunordered(float8 x, float8 y);
2876 int16 __ovld __cnfn isunordered(float16 x, float16 y);
2877-#ifdef cl_khr_fp64
2878+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2879 int __ovld __cnfn isunordered(double x, double y);
2880 long2 __ovld __cnfn isunordered(double2 x, double2 y);
2881 long3 __ovld __cnfn isunordered(double3 x, double3 y);
2882 long4 __ovld __cnfn isunordered(double4 x, double4 y);
2883 long8 __ovld __cnfn isunordered(double8 x, double8 y);
2884 long16 __ovld __cnfn isunordered(double16 x, double16 y);
2885-#endif //cl_khr_fp64
2886+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2887 #ifdef cl_khr_fp16
2888 int __ovld __cnfn isunordered(half x, half y);
2889 short2 __ovld __cnfn isunordered(half2 x, half2 y);
2890@@ -10957,14 +10970,14 @@ int3 __ovld __cnfn signbit(float3);
2891 int4 __ovld __cnfn signbit(float4);
2892 int8 __ovld __cnfn signbit(float8);
2893 int16 __ovld __cnfn signbit(float16);
2894-#ifdef cl_khr_fp64
2895+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2896 int __ovld __cnfn signbit(double);
2897 long2 __ovld __cnfn signbit(double2);
2898 long3 __ovld __cnfn signbit(double3);
2899 long4 __ovld __cnfn signbit(double4);
2900 long8 __ovld __cnfn signbit(double8);
2901 long16 __ovld __cnfn signbit(double16);
2902-#endif //cl_khr_fp64
2903+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2904 #ifdef cl_khr_fp16
2905 int __ovld __cnfn signbit(half);
2906 short2 __ovld __cnfn signbit(half2);
2907@@ -11091,14 +11104,14 @@ float3 __ovld __cnfn bitselect(float3 a, float3 b, float3 c);
2908 float4 __ovld __cnfn bitselect(float4 a, float4 b, float4 c);
2909 float8 __ovld __cnfn bitselect(float8 a, float8 b, float8 c);
2910 float16 __ovld __cnfn bitselect(float16 a, float16 b, float16 c);
2911-#ifdef cl_khr_fp64
2912+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2913 double __ovld __cnfn bitselect(double a, double b, double c);
2914 double2 __ovld __cnfn bitselect(double2 a, double2 b, double2 c);
2915 double3 __ovld __cnfn bitselect(double3 a, double3 b, double3 c);
2916 double4 __ovld __cnfn bitselect(double4 a, double4 b, double4 c);
2917 double8 __ovld __cnfn bitselect(double8 a, double8 b, double8 c);
2918 double16 __ovld __cnfn bitselect(double16 a, double16 b, double16 c);
2919-#endif //cl_khr_fp64
2920+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2921 #ifdef cl_khr_fp16
2922 half __ovld __cnfn bitselect(half a, half b, half c);
2923 half2 __ovld __cnfn bitselect(half2 a, half2 b, half2 c);
2924@@ -11231,7 +11244,7 @@ ulong8 __ovld __cnfn select(ulong8 a, ulong8 b, ulong8 c);
2925 long16 __ovld __cnfn select(long16 a, long16 b, ulong16 c);
2926 ulong16 __ovld __cnfn select(ulong16 a, ulong16 b, ulong16 c);
2927
2928-#ifdef cl_khr_fp64
2929+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2930 double __ovld __cnfn select(double a, double b, long c);
2931 double2 __ovld __cnfn select(double2 a, double2 b, long2 c);
2932 double3 __ovld __cnfn select(double3 a, double3 b, long3 c);
2933@@ -11244,7 +11257,7 @@ double3 __ovld __cnfn select(double3 a, double3 b, ulong3 c);
2934 double4 __ovld __cnfn select(double4 a, double4 b, ulong4 c);
2935 double8 __ovld __cnfn select(double8 a, double8 b, ulong8 c);
2936 double16 __ovld __cnfn select(double16 a, double16 b, ulong16 c);
2937-#endif //cl_khr_fp64
2938+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2939 #ifdef cl_khr_fp16
2940 half __ovld __cnfn select(half a, half b, short c);
2941 half2 __ovld __cnfn select(half2 a, half2 b, short2 c);
2942@@ -11323,13 +11336,13 @@ uint16 __ovld vload16(size_t offset, const __constant uint *p);
2943 long16 __ovld vload16(size_t offset, const __constant long *p);
2944 ulong16 __ovld vload16(size_t offset, const __constant ulong *p);
2945 float16 __ovld vload16(size_t offset, const __constant float *p);
2946-#ifdef cl_khr_fp64
2947+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2948 double2 __ovld vload2(size_t offset, const __constant double *p);
2949 double3 __ovld vload3(size_t offset, const __constant double *p);
2950 double4 __ovld vload4(size_t offset, const __constant double *p);
2951 double8 __ovld vload8(size_t offset, const __constant double *p);
2952 double16 __ovld vload16(size_t offset, const __constant double *p);
2953-#endif //cl_khr_fp64
2954+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2955
2956 #ifdef cl_khr_fp16
2957 half __ovld vload(size_t offset, const __constant half *p);
2958@@ -11340,7 +11353,7 @@ half8 __ovld vload8(size_t offset, const __constant half *p);
2959 half16 __ovld vload16(size_t offset, const __constant half *p);
2960 #endif //cl_khr_fp16
2961
2962-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
2963+#ifdef __opencl_c_generic_address_space
2964 char2 __ovld vload2(size_t offset, const char *p);
2965 uchar2 __ovld vload2(size_t offset, const uchar *p);
2966 short2 __ovld vload2(size_t offset, const short *p);
2967@@ -11387,13 +11400,13 @@ long16 __ovld vload16(size_t offset, const long *p);
2968 ulong16 __ovld vload16(size_t offset, const ulong *p);
2969 float16 __ovld vload16(size_t offset, const float *p);
2970
2971-#ifdef cl_khr_fp64
2972+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2973 double2 __ovld vload2(size_t offset, const double *p);
2974 double3 __ovld vload3(size_t offset, const double *p);
2975 double4 __ovld vload4(size_t offset, const double *p);
2976 double8 __ovld vload8(size_t offset, const double *p);
2977 double16 __ovld vload16(size_t offset, const double *p);
2978-#endif //cl_khr_fp64
2979+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2980
2981 #ifdef cl_khr_fp16
2982 half __ovld vload(size_t offset, const half *p);
2983@@ -11403,7 +11416,7 @@ half4 __ovld vload4(size_t offset, const half *p);
2984 half8 __ovld vload8(size_t offset, const half *p);
2985 half16 __ovld vload16(size_t offset, const half *p);
2986 #endif //cl_khr_fp16
2987-#else
2988+#endif //__opencl_c_generic_address_space
2989 char2 __ovld vload2(size_t offset, const __global char *p);
2990 uchar2 __ovld vload2(size_t offset, const __global uchar *p);
2991 short2 __ovld vload2(size_t offset, const __global short *p);
2992@@ -11540,7 +11553,7 @@ long16 __ovld vload16(size_t offset, const __private long *p);
2993 ulong16 __ovld vload16(size_t offset, const __private ulong *p);
2994 float16 __ovld vload16(size_t offset, const __private float *p);
2995
2996-#ifdef cl_khr_fp64
2997+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
2998 double2 __ovld vload2(size_t offset, const __global double *p);
2999 double3 __ovld vload3(size_t offset, const __global double *p);
3000 double4 __ovld vload4(size_t offset, const __global double *p);
3001@@ -11556,7 +11569,7 @@ double3 __ovld vload3(size_t offset, const __private double *p);
3002 double4 __ovld vload4(size_t offset, const __private double *p);
3003 double8 __ovld vload8(size_t offset, const __private double *p);
3004 double16 __ovld vload16(size_t offset, const __private double *p);
3005-#endif //cl_khr_fp64
3006+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3007
3008 #ifdef cl_khr_fp16
3009 half __ovld vload(size_t offset, const __global half *p);
3010@@ -11578,9 +11591,8 @@ half4 __ovld vload4(size_t offset, const __private half *p);
3011 half8 __ovld vload8(size_t offset, const __private half *p);
3012 half16 __ovld vload16(size_t offset, const __private half *p);
3013 #endif //cl_khr_fp16
3014-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
3015
3016-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
3017+#ifdef __opencl_c_generic_address_space
3018 void __ovld vstore2(char2 data, size_t offset, char *p);
3019 void __ovld vstore2(uchar2 data, size_t offset, uchar *p);
3020 void __ovld vstore2(short2 data, size_t offset, short *p);
3021@@ -11626,13 +11638,13 @@ void __ovld vstore16(uint16 data, size_t offset, uint *p);
3022 void __ovld vstore16(long16 data, size_t offset, long *p);
3023 void __ovld vstore16(ulong16 data, size_t offset, ulong *p);
3024 void __ovld vstore16(float16 data, size_t offset, float *p);
3025-#ifdef cl_khr_fp64
3026+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3027 void __ovld vstore2(double2 data, size_t offset, double *p);
3028 void __ovld vstore3(double3 data, size_t offset, double *p);
3029 void __ovld vstore4(double4 data, size_t offset, double *p);
3030 void __ovld vstore8(double8 data, size_t offset, double *p);
3031 void __ovld vstore16(double16 data, size_t offset, double *p);
3032-#endif //cl_khr_fp64
3033+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3034 #ifdef cl_khr_fp16
3035 void __ovld vstore(half data, size_t offset, half *p);
3036 void __ovld vstore2(half2 data, size_t offset, half *p);
3037@@ -11641,7 +11653,7 @@ void __ovld vstore4(half4 data, size_t offset, half *p);
3038 void __ovld vstore8(half8 data, size_t offset, half *p);
3039 void __ovld vstore16(half16 data, size_t offset, half *p);
3040 #endif //cl_khr_fp16
3041-#else
3042+#endif //__opencl_c_generic_address_space
3043 void __ovld vstore2(char2 data, size_t offset, __global char *p);
3044 void __ovld vstore2(uchar2 data, size_t offset, __global uchar *p);
3045 void __ovld vstore2(short2 data, size_t offset, __global short *p);
3046@@ -11777,7 +11789,7 @@ void __ovld vstore16(uint16 data, size_t offset, __private uint *p);
3047 void __ovld vstore16(long16 data, size_t offset, __private long *p);
3048 void __ovld vstore16(ulong16 data, size_t offset, __private ulong *p);
3049 void __ovld vstore16(float16 data, size_t offset, __private float *p);
3050-#ifdef cl_khr_fp64
3051+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3052 void __ovld vstore2(double2 data, size_t offset, __global double *p);
3053 void __ovld vstore3(double3 data, size_t offset, __global double *p);
3054 void __ovld vstore4(double4 data, size_t offset, __global double *p);
3055@@ -11793,7 +11805,7 @@ void __ovld vstore3(double3 data, size_t offset, __private double *p);
3056 void __ovld vstore4(double4 data, size_t offset, __private double *p);
3057 void __ovld vstore8(double8 data, size_t offset, __private double *p);
3058 void __ovld vstore16(double16 data, size_t offset, __private double *p);
3059-#endif //cl_khr_fp64
3060+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3061 #ifdef cl_khr_fp16
3062 void __ovld vstore(half data, size_t offset, __global half *p);
3063 void __ovld vstore2(half2 data, size_t offset, __global half *p);
3064@@ -11814,7 +11826,6 @@ void __ovld vstore4(half4 data, size_t offset, __private half *p);
3065 void __ovld vstore8(half8 data, size_t offset, __private half *p);
3066 void __ovld vstore16(half16 data, size_t offset, __private half *p);
3067 #endif //cl_khr_fp16
3068-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
3069
3070 /**
3071 * Read sizeof (half) bytes of data from address
3072@@ -11825,13 +11836,12 @@ void __ovld vstore16(half16 data, size_t offset, __private half *p);
3073 * must be 16-bit aligned.
3074 */
3075 float __ovld vload_half(size_t offset, const __constant half *p);
3076-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
3077+#ifdef __opencl_c_generic_address_space
3078 float __ovld vload_half(size_t offset, const half *p);
3079-#else
3080+#endif //__opencl_c_generic_address_space
3081 float __ovld vload_half(size_t offset, const __global half *p);
3082 float __ovld vload_half(size_t offset, const __local half *p);
3083 float __ovld vload_half(size_t offset, const __private half *p);
3084-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
3085
3086 /**
3087 * Read sizeof (halfn) bytes of data from address
3088@@ -11846,13 +11856,13 @@ float3 __ovld vload_half3(size_t offset, const __constant half *p);
3089 float4 __ovld vload_half4(size_t offset, const __constant half *p);
3090 float8 __ovld vload_half8(size_t offset, const __constant half *p);
3091 float16 __ovld vload_half16(size_t offset, const __constant half *p);
3092-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
3093+#ifdef __opencl_c_generic_address_space
3094 float2 __ovld vload_half2(size_t offset, const half *p);
3095 float3 __ovld vload_half3(size_t offset, const half *p);
3096 float4 __ovld vload_half4(size_t offset, const half *p);
3097 float8 __ovld vload_half8(size_t offset, const half *p);
3098 float16 __ovld vload_half16(size_t offset, const half *p);
3099-#else
3100+#endif //__opencl_c_generic_address_space
3101 float2 __ovld vload_half2(size_t offset, const __global half *p);
3102 float3 __ovld vload_half3(size_t offset, const __global half *p);
3103 float4 __ovld vload_half4(size_t offset, const __global half *p);
3104@@ -11868,7 +11878,6 @@ float3 __ovld vload_half3(size_t offset, const __private half *p);
3105 float4 __ovld vload_half4(size_t offset, const __private half *p);
3106 float8 __ovld vload_half8(size_t offset, const __private half *p);
3107 float16 __ovld vload_half16(size_t offset, const __private half *p);
3108-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
3109
3110 /**
3111 * The float value given by data is first
3112@@ -11881,20 +11890,20 @@ float16 __ovld vload_half16(size_t offset, const __private half *p);
3113 * The default current rounding mode is round to
3114 * nearest even.
3115 */
3116-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
3117+#ifdef __opencl_c_generic_address_space
3118 void __ovld vstore_half(float data, size_t offset, half *p);
3119 void __ovld vstore_half_rte(float data, size_t offset, half *p);
3120 void __ovld vstore_half_rtz(float data, size_t offset, half *p);
3121 void __ovld vstore_half_rtp(float data, size_t offset, half *p);
3122 void __ovld vstore_half_rtn(float data, size_t offset, half *p);
3123-#ifdef cl_khr_fp64
3124+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3125 void __ovld vstore_half(double data, size_t offset, half *p);
3126 void __ovld vstore_half_rte(double data, size_t offset, half *p);
3127 void __ovld vstore_half_rtz(double data, size_t offset, half *p);
3128 void __ovld vstore_half_rtp(double data, size_t offset, half *p);
3129 void __ovld vstore_half_rtn(double data, size_t offset, half *p);
3130-#endif //cl_khr_fp64
3131-#else
3132+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3133+#endif //__opencl_c_generic_address_space
3134 void __ovld vstore_half(float data, size_t offset, __global half *p);
3135 void __ovld vstore_half_rte(float data, size_t offset, __global half *p);
3136 void __ovld vstore_half_rtz(float data, size_t offset, __global half *p);
3137@@ -11910,7 +11919,7 @@ void __ovld vstore_half_rte(float data, size_t offset, __private half *p);
3138 void __ovld vstore_half_rtz(float data, size_t offset, __private half *p);
3139 void __ovld vstore_half_rtp(float data, size_t offset, __private half *p);
3140 void __ovld vstore_half_rtn(float data, size_t offset, __private half *p);
3141-#ifdef cl_khr_fp64
3142+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3143 void __ovld vstore_half(double data, size_t offset, __global half *p);
3144 void __ovld vstore_half_rte(double data, size_t offset, __global half *p);
3145 void __ovld vstore_half_rtz(double data, size_t offset, __global half *p);
3146@@ -11926,8 +11935,7 @@ void __ovld vstore_half_rte(double data, size_t offset, __private half *p);
3147 void __ovld vstore_half_rtz(double data, size_t offset, __private half *p);
3148 void __ovld vstore_half_rtp(double data, size_t offset, __private half *p);
3149 void __ovld vstore_half_rtn(double data, size_t offset, __private half *p);
3150-#endif //cl_khr_fp64
3151-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
3152+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3153
3154 /**
3155 * The floatn value given by data is converted to
3156@@ -11940,7 +11948,7 @@ void __ovld vstore_half_rtn(double data, size_t offset, __private half *p);
3157 * The default current rounding mode is round to
3158 * nearest even.
3159 */
3160-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
3161+#ifdef __opencl_c_generic_address_space
3162 void __ovld vstore_half2(float2 data, size_t offset, half *p);
3163 void __ovld vstore_half3(float3 data, size_t offset, half *p);
3164 void __ovld vstore_half4(float4 data, size_t offset, half *p);
3165@@ -11966,7 +11974,7 @@ void __ovld vstore_half3_rtn(float3 data, size_t offset, half *p);
3166 void __ovld vstore_half4_rtn(float4 data, size_t offset, half *p);
3167 void __ovld vstore_half8_rtn(float8 data, size_t offset, half *p);
3168 void __ovld vstore_half16_rtn(float16 data, size_t offset, half *p);
3169-#ifdef cl_khr_fp64
3170+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3171 void __ovld vstore_half2(double2 data, size_t offset, half *p);
3172 void __ovld vstore_half3(double3 data, size_t offset, half *p);
3173 void __ovld vstore_half4(double4 data, size_t offset, half *p);
3174@@ -11992,8 +12000,8 @@ void __ovld vstore_half3_rtn(double3 data, size_t offset, half *p);
3175 void __ovld vstore_half4_rtn(double4 data, size_t offset, half *p);
3176 void __ovld vstore_half8_rtn(double8 data, size_t offset, half *p);
3177 void __ovld vstore_half16_rtn(double16 data, size_t offset, half *p);
3178-#endif //cl_khr_fp64
3179-#else
3180+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3181+#endif //__opencl_c_generic_address_space
3182 void __ovld vstore_half2(float2 data, size_t offset, __global half *p);
3183 void __ovld vstore_half3(float3 data, size_t offset, __global half *p);
3184 void __ovld vstore_half4(float4 data, size_t offset, __global half *p);
3185@@ -12069,7 +12077,7 @@ void __ovld vstore_half3_rtn(float3 data, size_t offset, __private half *p);
3186 void __ovld vstore_half4_rtn(float4 data, size_t offset, __private half *p);
3187 void __ovld vstore_half8_rtn(float8 data, size_t offset, __private half *p);
3188 void __ovld vstore_half16_rtn(float16 data, size_t offset, __private half *p);
3189-#ifdef cl_khr_fp64
3190+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3191 void __ovld vstore_half2(double2 data, size_t offset, __global half *p);
3192 void __ovld vstore_half3(double3 data, size_t offset, __global half *p);
3193 void __ovld vstore_half4(double4 data, size_t offset, __global half *p);
3194@@ -12145,8 +12153,7 @@ void __ovld vstore_half3_rtn(double3 data, size_t offset, __private half *p);
3195 void __ovld vstore_half4_rtn(double4 data, size_t offset, __private half *p);
3196 void __ovld vstore_half8_rtn(double8 data, size_t offset, __private half *p);
3197 void __ovld vstore_half16_rtn(double16 data, size_t offset, __private half *p);
3198-#endif //cl_khr_fp64
3199-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
3200+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3201
3202 /**
3203 * For n = 1, 2, 4, 8 and 16 read sizeof (halfn)
3204@@ -12167,14 +12174,14 @@ float3 __ovld vloada_half3(size_t offset, const __constant half *p);
3205 float4 __ovld vloada_half4(size_t offset, const __constant half *p);
3206 float8 __ovld vloada_half8(size_t offset, const __constant half *p);
3207 float16 __ovld vloada_half16(size_t offset, const __constant half *p);
3208-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
3209+#ifdef __opencl_c_generic_address_space
3210 float __ovld vloada_half(size_t offset, const half *p);
3211 float2 __ovld vloada_half2(size_t offset, const half *p);
3212 float3 __ovld vloada_half3(size_t offset, const half *p);
3213 float4 __ovld vloada_half4(size_t offset, const half *p);
3214 float8 __ovld vloada_half8(size_t offset, const half *p);
3215 float16 __ovld vloada_half16(size_t offset, const half *p);
3216-#else
3217+#endif //__opencl_c_generic_address_space
3218 float __ovld vloada_half(size_t offset, const __global half *p);
3219 float2 __ovld vloada_half2(size_t offset, const __global half *p);
3220 float3 __ovld vloada_half3(size_t offset, const __global half *p);
3221@@ -12193,7 +12200,6 @@ float3 __ovld vloada_half3(size_t offset, const __private half *p);
3222 float4 __ovld vloada_half4(size_t offset, const __private half *p);
3223 float8 __ovld vloada_half8(size_t offset, const __private half *p);
3224 float16 __ovld vloada_half16(size_t offset, const __private half *p);
3225-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
3226
3227 /**
3228 * The floatn value given by data is converted to
3229@@ -12211,7 +12217,7 @@ float16 __ovld vloada_half16(size_t offset, const __private half *p);
3230 * mode. The default current rounding mode is
3231 * round to nearest even.
3232 */
3233-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
3234+#ifdef __opencl_c_generic_address_space
3235 void __ovld vstorea_half(float data, size_t offset, half *p);
3236 void __ovld vstorea_half2(float2 data, size_t offset, half *p);
3237 void __ovld vstorea_half3(float3 data, size_t offset, half *p);
3238@@ -12247,7 +12253,7 @@ void __ovld vstorea_half4_rtn(float4 data, size_t offset, half *p);
3239 void __ovld vstorea_half8_rtn(float8 data, size_t offset, half *p);
3240 void __ovld vstorea_half16_rtn(float16 data, size_t offset, half *p);
3241
3242-#ifdef cl_khr_fp64
3243+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3244 void __ovld vstorea_half(double data, size_t offset, half *p);
3245 void __ovld vstorea_half2(double2 data, size_t offset, half *p);
3246 void __ovld vstorea_half3(double3 data, size_t offset, half *p);
3247@@ -12282,9 +12288,9 @@ void __ovld vstorea_half3_rtn(double3 data, size_t offset, half *p);
3248 void __ovld vstorea_half4_rtn(double4 data, size_t offset, half *p);
3249 void __ovld vstorea_half8_rtn(double8 data, size_t offset, half *p);
3250 void __ovld vstorea_half16_rtn(double16 data, size_t offset, half *p);
3251-#endif //cl_khr_fp64
3252+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3253+#endif //__opencl_c_generic_address_space
3254
3255-#else
3256 void __ovld vstorea_half(float data, size_t offset, __global half *p);
3257 void __ovld vstorea_half2(float2 data, size_t offset, __global half *p);
3258 void __ovld vstorea_half3(float3 data, size_t offset, __global half *p);
3259@@ -12390,7 +12396,7 @@ void __ovld vstorea_half4_rtn(float4 data, size_t offset, __private half *p);
3260 void __ovld vstorea_half8_rtn(float8 data, size_t offset, __private half *p);
3261 void __ovld vstorea_half16_rtn(float16 data, size_t offset, __private half *p);
3262
3263-#ifdef cl_khr_fp64
3264+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3265 void __ovld vstorea_half(double data, size_t offset, __global half *p);
3266 void __ovld vstorea_half2(double2 data, size_t offset, __global half *p);
3267 void __ovld vstorea_half3(double3 data, size_t offset, __global half *p);
3268@@ -12495,8 +12501,7 @@ void __ovld vstorea_half3_rtn(double3 data,size_t offset, __private half *p);
3269 void __ovld vstorea_half4_rtn(double4 data,size_t offset, __private half *p);
3270 void __ovld vstorea_half8_rtn(double8 data,size_t offset, __private half *p);
3271 void __ovld vstorea_half16_rtn(double16 data,size_t offset, __private half *p);
3272-#endif //cl_khr_fp64
3273-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
3274+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3275
3276 // OpenCL v1.1 s6.11.8, v1.2 s6.12.8, v2.0 s6.13.8 - Synchronization Functions
3277
3278@@ -12580,7 +12585,7 @@ void __ovld write_mem_fence(cl_mem_fence_flags flags);
3279
3280 // OpenCL v2.0 s6.13.9 - Address Space Qualifier Functions
3281
3282-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
3283+#ifdef __opencl_c_generic_address_space
3284 cl_mem_fence_flags __ovld get_fence(const void *ptr);
3285 cl_mem_fence_flags __ovld get_fence(void *ptr);
3286
3287@@ -12591,7 +12596,7 @@ cl_mem_fence_flags __ovld get_fence(void *ptr);
3288 * where gentype is builtin type or user defined type.
3289 */
3290
3291-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
3292+#endif //__opencl_c_generic_address_space
3293
3294 // OpenCL v1.1 s6.11.10, v1.2 s6.12.10, v2.0 s6.13.10 - Async Copies from Global to Local Memory, Local to Global Memory, and Prefetch
3295
3296@@ -12730,7 +12735,7 @@ event_t __ovld async_work_group_copy(__global uint16 *dst, const __local uint16
3297 event_t __ovld async_work_group_copy(__global long16 *dst, const __local long16 *src, size_t num_elements, event_t event);
3298 event_t __ovld async_work_group_copy(__global ulong16 *dst, const __local ulong16 *src, size_t num_elements, event_t event);
3299 event_t __ovld async_work_group_copy(__global float16 *dst, const __local float16 *src, size_t num_elements, event_t event);
3300-#ifdef cl_khr_fp64
3301+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3302 event_t __ovld async_work_group_copy(__local double *dst, const __global double *src, size_t num_elements, event_t event);
3303 event_t __ovld async_work_group_copy(__local double2 *dst, const __global double2 *src, size_t num_elements, event_t event);
3304 event_t __ovld async_work_group_copy(__local double3 *dst, const __global double3 *src, size_t num_elements, event_t event);
3305@@ -12743,7 +12748,7 @@ event_t __ovld async_work_group_copy(__global double3 *dst, const __local double
3306 event_t __ovld async_work_group_copy(__global double4 *dst, const __local double4 *src, size_t num_elements, event_t event);
3307 event_t __ovld async_work_group_copy(__global double8 *dst, const __local double8 *src, size_t num_elements, event_t event);
3308 event_t __ovld async_work_group_copy(__global double16 *dst, const __local double16 *src, size_t num_elements, event_t event);
3309-#endif //cl_khr_fp64
3310+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3311 #ifdef cl_khr_fp16
3312 event_t __ovld async_work_group_copy(__local half *dst, const __global half *src, size_t num_elements, event_t event);
3313 event_t __ovld async_work_group_copy(__local half2 *dst, const __global half2 *src, size_t num_elements, event_t event);
3314@@ -12893,7 +12898,7 @@ event_t __ovld async_work_group_strided_copy(__global uint16 *dst, const __local
3315 event_t __ovld async_work_group_strided_copy(__global long16 *dst, const __local long16 *src, size_t num_elements, size_t dst_stride, event_t event);
3316 event_t __ovld async_work_group_strided_copy(__global ulong16 *dst, const __local ulong16 *src, size_t num_elements, size_t dst_stride, event_t event);
3317 event_t __ovld async_work_group_strided_copy(__global float16 *dst, const __local float16 *src, size_t num_elements, size_t dst_stride, event_t event);
3318-#ifdef cl_khr_fp64
3319+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3320 event_t __ovld async_work_group_strided_copy(__local double *dst, const __global double *src, size_t num_elements, size_t src_stride, event_t event);
3321 event_t __ovld async_work_group_strided_copy(__local double2 *dst, const __global double2 *src, size_t num_elements, size_t src_stride, event_t event);
3322 event_t __ovld async_work_group_strided_copy(__local double3 *dst, const __global double3 *src, size_t num_elements, size_t src_stride, event_t event);
3323@@ -12906,7 +12911,7 @@ event_t __ovld async_work_group_strided_copy(__global double3 *dst, const __loca
3324 event_t __ovld async_work_group_strided_copy(__global double4 *dst, const __local double4 *src, size_t num_elements, size_t dst_stride, event_t event);
3325 event_t __ovld async_work_group_strided_copy(__global double8 *dst, const __local double8 *src, size_t num_elements, size_t dst_stride, event_t event);
3326 event_t __ovld async_work_group_strided_copy(__global double16 *dst, const __local double16 *src, size_t num_elements, size_t dst_stride, event_t event);
3327-#endif //cl_khr_fp64
3328+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3329 #ifdef cl_khr_fp16
3330 event_t __ovld async_work_group_strided_copy(__local half *dst, const __global half *src, size_t num_elements, size_t src_stride, event_t event);
3331 event_t __ovld async_work_group_strided_copy(__local half2 *dst, const __global half2 *src, size_t num_elements, size_t src_stride, event_t event);
3332@@ -12996,14 +13001,14 @@ void __ovld prefetch(const __global uint16 *p, size_t num_elements);
3333 void __ovld prefetch(const __global long16 *p, size_t num_elements);
3334 void __ovld prefetch(const __global ulong16 *p, size_t num_elements);
3335 void __ovld prefetch(const __global float16 *p, size_t num_elements);
3336-#ifdef cl_khr_fp64
3337+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3338 void __ovld prefetch(const __global double *p, size_t num_elements);
3339 void __ovld prefetch(const __global double2 *p, size_t num_elements);
3340 void __ovld prefetch(const __global double3 *p, size_t num_elements);
3341 void __ovld prefetch(const __global double4 *p, size_t num_elements);
3342 void __ovld prefetch(const __global double8 *p, size_t num_elements);
3343 void __ovld prefetch(const __global double16 *p, size_t num_elements);
3344-#endif //cl_khr_fp64
3345+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3346 #ifdef cl_khr_fp16
3347 void __ovld prefetch(const __global half *p, size_t num_elements);
3348 void __ovld prefetch(const __global half2 *p, size_t num_elements);
3349@@ -13026,9 +13031,11 @@ void __ovld prefetch(const __global half16 *p, size_t num_elements);
3350 * pointed by p. The function returns old.
3351 */
3352 int __ovld atomic_add(volatile __global int *p, int val);
3353-unsigned int __ovld atomic_add(volatile __global unsigned int *p, unsigned int val);
3354+unsigned int __ovld atomic_add(volatile __global unsigned int *p,
3355+ unsigned int val);
3356 int __ovld atomic_add(volatile __local int *p, int val);
3357-unsigned int __ovld atomic_add(volatile __local unsigned int *p, unsigned int val);
3358+unsigned int __ovld atomic_add(volatile __local unsigned int *p,
3359+ unsigned int val);
3360 #ifdef __OPENCL_CPP_VERSION__
3361 int __ovld atomic_add(volatile int *p, int val);
3362 unsigned int __ovld atomic_add(volatile unsigned int *p, unsigned int val);
3363@@ -13056,9 +13063,11 @@ unsigned long __ovld atom_add(volatile __local unsigned long *p, unsigned long v
3364 * returns old.
3365 */
3366 int __ovld atomic_sub(volatile __global int *p, int val);
3367-unsigned int __ovld atomic_sub(volatile __global unsigned int *p, unsigned int val);
3368+unsigned int __ovld atomic_sub(volatile __global unsigned int *p,
3369+ unsigned int val);
3370 int __ovld atomic_sub(volatile __local int *p, int val);
3371-unsigned int __ovld atomic_sub(volatile __local unsigned int *p, unsigned int val);
3372+unsigned int __ovld atomic_sub(volatile __local unsigned int *p,
3373+ unsigned int val);
3374 #ifdef __OPENCL_CPP_VERSION__
3375 int __ovld atomic_sub(volatile int *p, int val);
3376 unsigned int __ovld atomic_sub(volatile unsigned int *p, unsigned int val);
3377@@ -13086,9 +13095,11 @@ unsigned long __ovld atom_sub(volatile __local unsigned long *p, unsigned long v
3378 * value.
3379 */
3380 int __ovld atomic_xchg(volatile __global int *p, int val);
3381-unsigned int __ovld atomic_xchg(volatile __global unsigned int *p, unsigned int val);
3382+unsigned int __ovld atomic_xchg(volatile __global unsigned int *p,
3383+ unsigned int val);
3384 int __ovld atomic_xchg(volatile __local int *p, int val);
3385-unsigned int __ovld atomic_xchg(volatile __local unsigned int *p, unsigned int val);
3386+unsigned int __ovld atomic_xchg(volatile __local unsigned int *p,
3387+ unsigned int val);
3388 float __ovld atomic_xchg(volatile __global float *p, float val);
3389 float __ovld atomic_xchg(volatile __local float *p, float val);
3390 #ifdef __OPENCL_CPP_VERSION__
3391@@ -13183,12 +13194,15 @@ unsigned long __ovld atom_dec(volatile __local unsigned long *p);
3392 * returns old.
3393 */
3394 int __ovld atomic_cmpxchg(volatile __global int *p, int cmp, int val);
3395-unsigned int __ovld atomic_cmpxchg(volatile __global unsigned int *p, unsigned int cmp, unsigned int val);
3396+unsigned int __ovld atomic_cmpxchg(volatile __global unsigned int *p,
3397+ unsigned int cmp, unsigned int val);
3398 int __ovld atomic_cmpxchg(volatile __local int *p, int cmp, int val);
3399-unsigned int __ovld atomic_cmpxchg(volatile __local unsigned int *p, unsigned int cmp, unsigned int val);
3400+unsigned int __ovld atomic_cmpxchg(volatile __local unsigned int *p,
3401+ unsigned int cmp, unsigned int val);
3402 #ifdef __OPENCL_CPP_VERSION__
3403 int __ovld atomic_cmpxchg(volatile int *p, int cmp, int val);
3404-unsigned int __ovld atomic_cmpxchg(volatile unsigned int *p, unsigned int cmp, unsigned int val);
3405+unsigned int __ovld atomic_cmpxchg(volatile unsigned int *p, unsigned int cmp,
3406+ unsigned int val);
3407 #endif
3408
3409 #if defined(cl_khr_global_int32_base_atomics)
3410@@ -13215,9 +13229,11 @@ unsigned long __ovld atom_cmpxchg(volatile __local unsigned long *p, unsigned lo
3411 * returns old.
3412 */
3413 int __ovld atomic_min(volatile __global int *p, int val);
3414-unsigned int __ovld atomic_min(volatile __global unsigned int *p, unsigned int val);
3415+unsigned int __ovld atomic_min(volatile __global unsigned int *p,
3416+ unsigned int val);
3417 int __ovld atomic_min(volatile __local int *p, int val);
3418-unsigned int __ovld atomic_min(volatile __local unsigned int *p, unsigned int val);
3419+unsigned int __ovld atomic_min(volatile __local unsigned int *p,
3420+ unsigned int val);
3421 #ifdef __OPENCL_CPP_VERSION__
3422 int __ovld atomic_min(volatile int *p, int val);
3423 unsigned int __ovld atomic_min(volatile unsigned int *p, unsigned int val);
3424@@ -13247,9 +13263,11 @@ unsigned long __ovld atom_min(volatile __local unsigned long *p, unsigned long v
3425 * returns old.
3426 */
3427 int __ovld atomic_max(volatile __global int *p, int val);
3428-unsigned int __ovld atomic_max(volatile __global unsigned int *p, unsigned int val);
3429+unsigned int __ovld atomic_max(volatile __global unsigned int *p,
3430+ unsigned int val);
3431 int __ovld atomic_max(volatile __local int *p, int val);
3432-unsigned int __ovld atomic_max(volatile __local unsigned int *p, unsigned int val);
3433+unsigned int __ovld atomic_max(volatile __local unsigned int *p,
3434+ unsigned int val);
3435 #ifdef __OPENCL_CPP_VERSION__
3436 int __ovld atomic_max(volatile int *p, int val);
3437 unsigned int __ovld atomic_max(volatile unsigned int *p, unsigned int val);
3438@@ -13278,9 +13296,11 @@ unsigned long __ovld atom_max(volatile __local unsigned long *p, unsigned long v
3439 * pointed by p. The function returns old.
3440 */
3441 int __ovld atomic_and(volatile __global int *p, int val);
3442-unsigned int __ovld atomic_and(volatile __global unsigned int *p, unsigned int val);
3443+unsigned int __ovld atomic_and(volatile __global unsigned int *p,
3444+ unsigned int val);
3445 int __ovld atomic_and(volatile __local int *p, int val);
3446-unsigned int __ovld atomic_and(volatile __local unsigned int *p, unsigned int val);
3447+unsigned int __ovld atomic_and(volatile __local unsigned int *p,
3448+ unsigned int val);
3449 #ifdef __OPENCL_CPP_VERSION__
3450 int __ovld atomic_and(volatile int *p, int val);
3451 unsigned int __ovld atomic_and(volatile unsigned int *p, unsigned int val);
3452@@ -13309,9 +13329,11 @@ unsigned long __ovld atom_and(volatile __local unsigned long *p, unsigned long v
3453 * pointed by p. The function returns old.
3454 */
3455 int __ovld atomic_or(volatile __global int *p, int val);
3456-unsigned int __ovld atomic_or(volatile __global unsigned int *p, unsigned int val);
3457+unsigned int __ovld atomic_or(volatile __global unsigned int *p,
3458+ unsigned int val);
3459 int __ovld atomic_or(volatile __local int *p, int val);
3460-unsigned int __ovld atomic_or(volatile __local unsigned int *p, unsigned int val);
3461+unsigned int __ovld atomic_or(volatile __local unsigned int *p,
3462+ unsigned int val);
3463 #ifdef __OPENCL_CPP_VERSION__
3464 int __ovld atomic_or(volatile int *p, int val);
3465 unsigned int __ovld atomic_or(volatile unsigned int *p, unsigned int val);
3466@@ -13340,9 +13362,11 @@ unsigned long __ovld atom_or(volatile __local unsigned long *p, unsigned long va
3467 * pointed by p. The function returns old.
3468 */
3469 int __ovld atomic_xor(volatile __global int *p, int val);
3470-unsigned int __ovld atomic_xor(volatile __global unsigned int *p, unsigned int val);
3471+unsigned int __ovld atomic_xor(volatile __global unsigned int *p,
3472+ unsigned int val);
3473 int __ovld atomic_xor(volatile __local int *p, int val);
3474-unsigned int __ovld atomic_xor(volatile __local unsigned int *p, unsigned int val);
3475+unsigned int __ovld atomic_xor(volatile __local unsigned int *p,
3476+ unsigned int val);
3477 #ifdef __OPENCL_CPP_VERSION__
3478 int __ovld atomic_xor(volatile int *p, int val);
3479 unsigned int __ovld atomic_xor(volatile unsigned int *p, unsigned int val);
3480@@ -13380,108 +13404,78 @@ unsigned long __ovld atom_xor(volatile __local unsigned long *p, unsigned long v
3481 #endif
3482
3483 // atomic_init()
3484+#ifdef __opencl_c_generic_address_space
3485 void __ovld atomic_init(volatile atomic_int *object, int value);
3486 void __ovld atomic_init(volatile atomic_uint *object, uint value);
3487 void __ovld atomic_init(volatile atomic_float *object, float value);
3488 #if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
3489 void __ovld atomic_init(volatile atomic_long *object, long value);
3490 void __ovld atomic_init(volatile atomic_ulong *object, ulong value);
3491-#ifdef cl_khr_fp64
3492+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3493 void __ovld atomic_init(volatile atomic_double *object, double value);
3494-#endif //cl_khr_fp64
3495-#endif
3496+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3497+#endif // defined(cl_khr_int64_base_atomics) &&
3498+ // defined(cl_khr_int64_extended_atomics)
3499+#endif // __opencl_c_generic_address_space
3500+
3501+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
3502+void __ovld atomic_init(volatile atomic_int __global *object, int value);
3503+void __ovld atomic_init(volatile atomic_int __local *object, int value);
3504+void __ovld atomic_init(volatile atomic_uint __global *object, uint value);
3505+void __ovld atomic_init(volatile atomic_uint __local *object, uint value);
3506+void __ovld atomic_init(volatile atomic_float __global *object, float value);
3507+void __ovld atomic_init(volatile atomic_float __local *object, float value);
3508+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
3509+void __ovld atomic_init(volatile atomic_long __global *object, long value);
3510+void __ovld atomic_init(volatile atomic_long __local *object, long value);
3511+void __ovld atomic_init(volatile atomic_ulong __global *object, ulong value);
3512+void __ovld atomic_init(volatile atomic_ulong __local *object, ulong value);
3513+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
3514+void __ovld atomic_init(volatile atomic_double __global *object, double value);
3515+void __ovld atomic_init(volatile atomic_double __local *object, double value);
3516+#endif // cl_khr_fp64
3517+#endif // defined(cl_khr_int64_base_atomics) &&
3518+ // defined(cl_khr_int64_extended_atomics)
3519+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
3520
3521 // atomic_work_item_fence()
3522-void __ovld atomic_work_item_fence(cl_mem_fence_flags flags, memory_order order, memory_scope scope);
3523+void __ovld atomic_work_item_fence(cl_mem_fence_flags flags, memory_order order,
3524+ memory_scope scope);
3525
3526 // atomic_fetch()
3527-
3528+#if defined(__opencl_c_atomic_scope_device) && \
3529+ defined(__opencl_c_atomic_order_seq_cst)
3530+#ifdef __opencl_c_generic_address_space
3531 int __ovld atomic_fetch_add(volatile atomic_int *object, int operand);
3532-int __ovld atomic_fetch_add_explicit(volatile atomic_int *object, int operand, memory_order order);
3533-int __ovld atomic_fetch_add_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope);
3534 uint __ovld atomic_fetch_add(volatile atomic_uint *object, uint operand);
3535-uint __ovld atomic_fetch_add_explicit(volatile atomic_uint *object, uint operand, memory_order order);
3536-uint __ovld atomic_fetch_add_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope);
3537 int __ovld atomic_fetch_sub(volatile atomic_int *object, int operand);
3538-int __ovld atomic_fetch_sub_explicit(volatile atomic_int *object, int operand, memory_order order);
3539-int __ovld atomic_fetch_sub_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope);
3540 uint __ovld atomic_fetch_sub(volatile atomic_uint *object, uint operand);
3541-uint __ovld atomic_fetch_sub_explicit(volatile atomic_uint *object, uint operand, memory_order order);
3542-uint __ovld atomic_fetch_sub_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope);
3543 int __ovld atomic_fetch_or(volatile atomic_int *object, int operand);
3544-int __ovld atomic_fetch_or_explicit(volatile atomic_int *object, int operand, memory_order order);
3545-int __ovld atomic_fetch_or_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope);
3546 uint __ovld atomic_fetch_or(volatile atomic_uint *object, uint operand);
3547-uint __ovld atomic_fetch_or_explicit(volatile atomic_uint *object, uint operand, memory_order order);
3548-uint __ovld atomic_fetch_or_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope);
3549 int __ovld atomic_fetch_xor(volatile atomic_int *object, int operand);
3550-int __ovld atomic_fetch_xor_explicit(volatile atomic_int *object, int operand, memory_order order);
3551-int __ovld atomic_fetch_xor_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope);
3552 uint __ovld atomic_fetch_xor(volatile atomic_uint *object, uint operand);
3553-uint __ovld atomic_fetch_xor_explicit(volatile atomic_uint *object, uint operand, memory_order order);
3554-uint __ovld atomic_fetch_xor_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope);
3555 int __ovld atomic_fetch_and(volatile atomic_int *object, int operand);
3556-int __ovld atomic_fetch_and_explicit(volatile atomic_int *object, int operand, memory_order order);
3557-int __ovld atomic_fetch_and_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope);
3558 uint __ovld atomic_fetch_and(volatile atomic_uint *object, uint operand);
3559-uint __ovld atomic_fetch_and_explicit(volatile atomic_uint *object, uint operand, memory_order order);
3560-uint __ovld atomic_fetch_and_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope);
3561 int __ovld atomic_fetch_min(volatile atomic_int *object, int operand);
3562-int __ovld atomic_fetch_min_explicit(volatile atomic_int *object, int operand, memory_order order);
3563-int __ovld atomic_fetch_min_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope);
3564 uint __ovld atomic_fetch_min(volatile atomic_uint *object, uint operand);
3565-uint __ovld atomic_fetch_min_explicit(volatile atomic_uint *object, uint operand, memory_order order);
3566-uint __ovld atomic_fetch_min_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope);
3567 int __ovld atomic_fetch_max(volatile atomic_int *object, int operand);
3568-int __ovld atomic_fetch_max_explicit(volatile atomic_int *object, int operand, memory_order order);
3569-int __ovld atomic_fetch_max_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope);
3570 uint __ovld atomic_fetch_max(volatile atomic_uint *object, uint operand);
3571-uint __ovld atomic_fetch_max_explicit(volatile atomic_uint *object, uint operand, memory_order order);
3572-uint __ovld atomic_fetch_max_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope);
3573
3574 #if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
3575 long __ovld atomic_fetch_add(volatile atomic_long *object, long operand);
3576-long __ovld atomic_fetch_add_explicit(volatile atomic_long *object, long operand, memory_order order);
3577-long __ovld atomic_fetch_add_explicit(volatile atomic_long *object, long operand, memory_order order, memory_scope scope);
3578 ulong __ovld atomic_fetch_add(volatile atomic_ulong *object, ulong operand);
3579-ulong __ovld atomic_fetch_add_explicit(volatile atomic_ulong *object, ulong operand, memory_order order);
3580-ulong __ovld atomic_fetch_add_explicit(volatile atomic_ulong *object, ulong operand, memory_order order, memory_scope scope);
3581 long __ovld atomic_fetch_sub(volatile atomic_long *object, long operand);
3582-long __ovld atomic_fetch_sub_explicit(volatile atomic_long *object, long operand, memory_order order);
3583-long __ovld atomic_fetch_sub_explicit(volatile atomic_long *object, long operand, memory_order order, memory_scope scope);
3584 ulong __ovld atomic_fetch_sub(volatile atomic_ulong *object, ulong operand);
3585-ulong __ovld atomic_fetch_sub_explicit(volatile atomic_ulong *object, ulong operand, memory_order order);
3586-ulong __ovld atomic_fetch_sub_explicit(volatile atomic_ulong *object, ulong operand, memory_order order, memory_scope scope);
3587 long __ovld atomic_fetch_or(volatile atomic_long *object, long operand);
3588-long __ovld atomic_fetch_or_explicit(volatile atomic_long *object, long operand, memory_order order);
3589-long __ovld atomic_fetch_or_explicit(volatile atomic_long *object, long operand, memory_order order, memory_scope scope);
3590 ulong __ovld atomic_fetch_or(volatile atomic_ulong *object, ulong operand);
3591-ulong __ovld atomic_fetch_or_explicit(volatile atomic_ulong *object, ulong operand, memory_order order);
3592-ulong __ovld atomic_fetch_or_explicit(volatile atomic_ulong *object, ulong operand, memory_order order, memory_scope scope);
3593 long __ovld atomic_fetch_xor(volatile atomic_long *object, long operand);
3594-long __ovld atomic_fetch_xor_explicit(volatile atomic_long *object, long operand, memory_order order);
3595-long __ovld atomic_fetch_xor_explicit(volatile atomic_long *object, long operand, memory_order order, memory_scope scope);
3596 ulong __ovld atomic_fetch_xor(volatile atomic_ulong *object, ulong operand);
3597-ulong __ovld atomic_fetch_xor_explicit(volatile atomic_ulong *object, ulong operand, memory_order order);
3598-ulong __ovld atomic_fetch_xor_explicit(volatile atomic_ulong *object, ulong operand, memory_order order, memory_scope scope);
3599 long __ovld atomic_fetch_and(volatile atomic_long *object, long operand);
3600-long __ovld atomic_fetch_and_explicit(volatile atomic_long *object, long operand, memory_order order);
3601-long __ovld atomic_fetch_and_explicit(volatile atomic_long *object, long operand, memory_order order, memory_scope scope);
3602 ulong __ovld atomic_fetch_and(volatile atomic_ulong *object, ulong operand);
3603-ulong __ovld atomic_fetch_and_explicit(volatile atomic_ulong *object, ulong operand, memory_order order);
3604-ulong __ovld atomic_fetch_and_explicit(volatile atomic_ulong *object, ulong operand, memory_order order, memory_scope scope);
3605 long __ovld atomic_fetch_min(volatile atomic_long *object, long operand);
3606-long __ovld atomic_fetch_min_explicit(volatile atomic_long *object, long operand, memory_order order);
3607-long __ovld atomic_fetch_min_explicit(volatile atomic_long *object, long operand, memory_order order, memory_scope scope);
3608 ulong __ovld atomic_fetch_min(volatile atomic_ulong *object, ulong operand);
3609-ulong __ovld atomic_fetch_min_explicit(volatile atomic_ulong *object, ulong operand, memory_order order);
3610-ulong __ovld atomic_fetch_min_explicit(volatile atomic_ulong *object, ulong operand, memory_order order, memory_scope scope);
3611 long __ovld atomic_fetch_max(volatile atomic_long *object, long operand);
3612-long __ovld atomic_fetch_max_explicit(volatile atomic_long *object, long operand, memory_order order);
3613-long __ovld atomic_fetch_max_explicit(volatile atomic_long *object, long operand, memory_order order, memory_scope scope);
3614 ulong __ovld atomic_fetch_max(volatile atomic_ulong *object, ulong operand);
3615-ulong __ovld atomic_fetch_max_explicit(volatile atomic_ulong *object, ulong operand, memory_order order);
3616-ulong __ovld atomic_fetch_max_explicit(volatile atomic_ulong *object, ulong operand, memory_order order, memory_scope scope);
3617 #endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
3618
3619 // OpenCL v2.0 s6.13.11.7.5:
3620@@ -13489,196 +13483,2239 @@ ulong __ovld atomic_fetch_max_explicit(volatile atomic_ulong *object, ulong oper
3621 // or/xor/and/min/max: atomic type argument can be intptr_t/uintptr_t, value type argument can be intptr_t/uintptr_t.
3622
3623 #if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
3624-uintptr_t __ovld atomic_fetch_add(volatile atomic_uintptr_t *object, ptrdiff_t operand);
3625-uintptr_t __ovld atomic_fetch_add_explicit(volatile atomic_uintptr_t *object, ptrdiff_t operand, memory_order order);
3626-uintptr_t __ovld atomic_fetch_add_explicit(volatile atomic_uintptr_t *object, ptrdiff_t operand, memory_order order, memory_scope scope);
3627-uintptr_t __ovld atomic_fetch_sub(volatile atomic_uintptr_t *object, ptrdiff_t operand);
3628-uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *object, ptrdiff_t operand, memory_order order);
3629-uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *object, ptrdiff_t operand, memory_order order, memory_scope scope);
3630-
3631-uintptr_t __ovld atomic_fetch_or(volatile atomic_uintptr_t *object, intptr_t operand);
3632-uintptr_t __ovld atomic_fetch_or_explicit(volatile atomic_uintptr_t *object, intptr_t operand, memory_order order);
3633-uintptr_t __ovld atomic_fetch_or_explicit(volatile atomic_uintptr_t *object, intptr_t operand, memory_order order, memory_scope scope);
3634-uintptr_t __ovld atomic_fetch_xor(volatile atomic_uintptr_t *object, intptr_t operand);
3635-uintptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_uintptr_t *object, intptr_t operand, memory_order order);
3636-uintptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_uintptr_t *object, intptr_t operand, memory_order order, memory_scope scope);
3637-uintptr_t __ovld atomic_fetch_and(volatile atomic_uintptr_t *object, intptr_t operand);
3638-uintptr_t __ovld atomic_fetch_and_explicit(volatile atomic_uintptr_t *object, intptr_t operand, memory_order order);
3639-uintptr_t __ovld atomic_fetch_and_explicit(volatile atomic_uintptr_t *object, intptr_t operand, memory_order order, memory_scope scope);
3640-uintptr_t __ovld atomic_fetch_min(volatile atomic_uintptr_t *object, intptr_t opermax);
3641-uintptr_t __ovld atomic_fetch_min_explicit(volatile atomic_uintptr_t *object, intptr_t opermax, memory_order minder);
3642-uintptr_t __ovld atomic_fetch_min_explicit(volatile atomic_uintptr_t *object, intptr_t opermax, memory_order minder, memory_scope scope);
3643-uintptr_t __ovld atomic_fetch_max(volatile atomic_uintptr_t *object, intptr_t opermax);
3644-uintptr_t __ovld atomic_fetch_max_explicit(volatile atomic_uintptr_t *object, intptr_t opermax, memory_order minder);
3645-uintptr_t __ovld atomic_fetch_max_explicit(volatile atomic_uintptr_t *object, intptr_t opermax, memory_order minder, memory_scope scope);
3646-
3647-intptr_t __ovld atomic_fetch_or(volatile atomic_intptr_t *object, uintptr_t operand);
3648-intptr_t __ovld atomic_fetch_or_explicit(volatile atomic_intptr_t *object, uintptr_t operand, memory_order order);
3649-intptr_t __ovld atomic_fetch_or_explicit(volatile atomic_intptr_t *object, uintptr_t operand, memory_order order, memory_scope scope);
3650-intptr_t __ovld atomic_fetch_xor(volatile atomic_intptr_t *object, uintptr_t operand);
3651-intptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_intptr_t *object, uintptr_t operand, memory_order order);
3652-intptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_intptr_t *object, uintptr_t operand, memory_order order, memory_scope scope);
3653-intptr_t __ovld atomic_fetch_and(volatile atomic_intptr_t *object, uintptr_t operand);
3654-intptr_t __ovld atomic_fetch_and_explicit(volatile atomic_intptr_t *object, uintptr_t operand, memory_order order);
3655-intptr_t __ovld atomic_fetch_and_explicit(volatile atomic_intptr_t *object, uintptr_t operand, memory_order order, memory_scope scope);
3656-intptr_t __ovld atomic_fetch_min(volatile atomic_intptr_t *object, uintptr_t opermax);
3657-intptr_t __ovld atomic_fetch_min_explicit(volatile atomic_intptr_t *object, uintptr_t opermax, memory_order minder);
3658-intptr_t __ovld atomic_fetch_min_explicit(volatile atomic_intptr_t *object, uintptr_t opermax, memory_order minder, memory_scope scope);
3659-intptr_t __ovld atomic_fetch_max(volatile atomic_intptr_t *object, uintptr_t opermax);
3660-intptr_t __ovld atomic_fetch_max_explicit(volatile atomic_intptr_t *object, uintptr_t opermax, memory_order minder);
3661-intptr_t __ovld atomic_fetch_max_explicit(volatile atomic_intptr_t *object, uintptr_t opermax, memory_order minder, memory_scope scope);
3662+uintptr_t __ovld atomic_fetch_add(volatile atomic_uintptr_t *object,
3663+ ptrdiff_t operand);
3664+uintptr_t __ovld atomic_fetch_sub(volatile atomic_uintptr_t *object,
3665+ ptrdiff_t operand);
3666+
3667+uintptr_t __ovld atomic_fetch_or(volatile atomic_uintptr_t *object,
3668+ intptr_t operand);
3669+uintptr_t __ovld atomic_fetch_xor(volatile atomic_uintptr_t *object,
3670+ intptr_t operand);
3671+uintptr_t __ovld atomic_fetch_and(volatile atomic_uintptr_t *object,
3672+ intptr_t operand);
3673+uintptr_t __ovld atomic_fetch_min(volatile atomic_uintptr_t *object,
3674+ intptr_t opermax);
3675+uintptr_t __ovld atomic_fetch_max(volatile atomic_uintptr_t *object,
3676+ intptr_t opermax);
3677+
3678+intptr_t __ovld atomic_fetch_or(volatile atomic_intptr_t *object,
3679+ uintptr_t operand);
3680+intptr_t __ovld atomic_fetch_xor(volatile atomic_intptr_t *object,
3681+ uintptr_t operand);
3682+intptr_t __ovld atomic_fetch_and(volatile atomic_intptr_t *object,
3683+ uintptr_t operand);
3684+intptr_t __ovld atomic_fetch_min(volatile atomic_intptr_t *object,
3685+ uintptr_t opermax);
3686+intptr_t __ovld atomic_fetch_max(volatile atomic_intptr_t *object,
3687+ uintptr_t opermax);
3688+#endif // defined(cl_khr_int64_base_atomics) &&
3689+ // defined(cl_khr_int64_extended_atomics)
3690+#endif // __opencl_c_generic_address_space
3691+
3692+#if(__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
3693+int __ovld atomic_fetch_add(volatile atomic_int __global *object, int operand);
3694+uint __ovld atomic_fetch_add(volatile atomic_uint __local *object,
3695+ uint operand);
3696+int __ovld atomic_fetch_sub(volatile atomic_int __global *object, int operand);
3697+int __ovld atomic_fetch_sub(volatile atomic_int __local *object, int operand);
3698+uint __ovld atomic_fetch_sub(volatile atomic_uint __local *object,
3699+ uint operand);
3700+uint __ovld atomic_fetch_sub(volatile atomic_uint __global *object,
3701+ uint operand);
3702+int __ovld atomic_fetch_or(volatile atomic_int __global *object, int operand);
3703+uint __ovld atomic_fetch_sub(volatile atomic_uint __local *object,
3704+ uint operand);
3705+uint __ovld atomic_fetch_or(volatile atomic_uint __global *object,
3706+ uint operand);
3707+uint __ovld atomic_fetch_or(volatile atomic_uint __local *object, uint operand);
3708+int __ovld atomic_fetch_xor(volatile atomic_int __global *object, int operand);
3709+int __ovld atomic_fetch_xor(volatile atomic_int __local *object, int operand);
3710+uint __ovld atomic_fetch_xor(volatile atomic_uint __global *object,
3711+ uint operand);
3712+uint __ovld atomic_fetch_xor(volatile atomic_uint __local *object,
3713+ uint operand);
3714+int __ovld atomic_fetch_and(volatile atomic_int __global *object, int operand);
3715+int __ovld atomic_fetch_and(volatile atomic_int __local *object, int operand);
3716+uint __ovld atomic_fetch_and(volatile atomic_uint __global *object,
3717+ uint operand);
3718+uint __ovld atomic_fetch_and(volatile atomic_uint __local *object,
3719+ uint operand);
3720+int __ovld atomic_fetch_min(volatile atomic_int __global *object, int operand);
3721+int __ovld atomic_fetch_min(volatile atomic_int __local *object, int operand);
3722+uint __ovld atomic_fetch_min(volatile atomic_uint __global *object,
3723+ uint operand);
3724+uint __ovld atomic_fetch_min(volatile atomic_uint __local *object,
3725+ uint operand);
3726+int __ovld atomic_fetch_max(volatile atomic_int __global *object, int operand);
3727+int __ovld atomic_fetch_max(volatile atomic_int __local *object, int operand);
3728+uint __ovld atomic_fetch_max(volatile atomic_uint __global *object,
3729+ uint operand);
3730+uint __ovld atomic_fetch_max(volatile atomic_uint __local *object,
3731+ uint operand);
3732+
3733+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
3734+long __ovld atomic_fetch_add(volatile atomic_long __global *object,
3735+ long operand);
3736+long __ovld atomic_fetch_add(volatile atomic_long __local *object,
3737+ long operand);
3738+ulong __ovld atomic_fetch_add(volatile atomic_ulong __global *object,
3739+ ulong operand);
3740+ulong __ovld atomic_fetch_add(volatile atomic_ulong __local *object,
3741+ ulong operand);
3742+long __ovld atomic_fetch_sub(volatile atomic_long __global *object,
3743+ long operand);
3744+long __ovld atomic_fetch_sub(volatile atomic_long __local *object,
3745+ long operand);
3746+ulong __ovld atomic_fetch_sub(volatile atomic_ulong __global *object,
3747+ ulong operand);
3748+ulong __ovld atomic_fetch_sub(volatile atomic_ulong __local *object,
3749+ ulong operand);
3750+long __ovld atomic_fetch_or(volatile atomic_long __global *object,
3751+ long operand);
3752+long __ovld atomic_fetch_or(volatile atomic_long __local *object, long operand);
3753+ulong __ovld atomic_fetch_or(volatile atomic_ulong __global *object,
3754+ ulong operand);
3755+ulong __ovld atomic_fetch_or(volatile atomic_ulong __local *object,
3756+ ulong operand);
3757+long __ovld atomic_fetch_xor(volatile atomic_long __global *object,
3758+ long operand);
3759+long __ovld atomic_fetch_xor(volatile atomic_long __local *object,
3760+ long operand);
3761+ulong __ovld atomic_fetch_xor(volatile atomic_ulong __global *object,
3762+ ulong operand);
3763+ulong __ovld atomic_fetch_xor(volatile atomic_ulong __local *object,
3764+ ulong operand);
3765+long __ovld atomic_fetch_and(volatile atomic_long __global *object,
3766+ long operand);
3767+long __ovld atomic_fetch_and(volatile atomic_long __local *object,
3768+ long operand);
3769+ulong __ovld atomic_fetch_and(volatile atomic_ulong __global *object,
3770+ ulong operand);
3771+ulong __ovld atomic_fetch_and(volatile atomic_ulong __local *object,
3772+ ulong operand);
3773+long __ovld atomic_fetch_min(volatile atomic_long __global *object,
3774+ long operand);
3775+long __ovld atomic_fetch_min(volatile atomic_long __local *object,
3776+ long operand);
3777+ulong __ovld atomic_fetch_min(volatile atomic_ulong __global *object,
3778+ ulong operand);
3779+ulong __ovld atomic_fetch_min(volatile atomic_ulong __local *object,
3780+ ulong operand);
3781+long __ovld atomic_fetch_max(volatile atomic_long __global *object,
3782+ long operand);
3783+long __ovld atomic_fetch_max(volatile atomic_long __local *object,
3784+ long operand);
3785+ulong __ovld atomic_fetch_max(volatile atomic_ulong __global *object,
3786+ ulong operand);
3787+ulong __ovld atomic_fetch_max(volatile atomic_ulong __local *object,
3788+ ulong operand);
3789+#endif // defined(cl_khr_int64_base_atomics) &&
3790+ // defined(cl_khr_int64_extended_atomics)
3791+
3792+// OpenCL v2.0 s6.13.11.7.5:
3793+// add/sub: atomic type argument can be uintptr_t/intptr_t, value type argument
3794+// can be ptrdiff_t. or/xor/and/min/max: atomic type argument can be
3795+// intptr_t/uintptr_t, value type argument can be intptr_t/uintptr_t.
3796+
3797+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
3798+uintptr_t __ovld atomic_fetch_add(volatile atomic_uintptr_t __global *object,
3799+ ptrdiff_t operand);
3800+uintptr_t __ovld atomic_fetch_add(volatile atomic_uintptr_t __local *object,
3801+ ptrdiff_t operand);
3802+uintptr_t __ovld atomic_fetch_sub(volatile atomic_uintptr_t __global *object,
3803+ ptrdiff_t operand);
3804+uintptr_t __ovld atomic_fetch_sub(volatile atomic_uintptr_t __local *object,
3805+ ptrdiff_t operand);
3806+
3807+uintptr_t __ovld atomic_fetch_or(volatile atomic_uintptr_t __global *object,
3808+ intptr_t operand);
3809+uintptr_t __ovld atomic_fetch_or(volatile atomic_uintptr_t __local *object,
3810+ intptr_t operand);
3811+uintptr_t __ovld atomic_fetch_xor(volatile atomic_uintptr_t __global *object,
3812+ intptr_t operand);
3813+uintptr_t __ovld atomic_fetch_xor(volatile atomic_uintptr_t __local *object,
3814+ intptr_t operand);
3815+uintptr_t __ovld atomic_fetch_and(volatile atomic_uintptr_t __global *object,
3816+ intptr_t operand);
3817+uintptr_t __ovld atomic_fetch_and(volatile atomic_uintptr_t __local *object,
3818+ intptr_t operand);
3819+uintptr_t __ovld atomic_fetch_min(volatile atomic_uintptr_t __global *object,
3820+ intptr_t opermax);
3821+uintptr_t __ovld atomic_fetch_min(volatile atomic_uintptr_t __local *object,
3822+ intptr_t opermax);
3823+uintptr_t __ovld atomic_fetch_max(volatile atomic_uintptr_t __global *object,
3824+ intptr_t opermax);
3825+uintptr_t __ovld atomic_fetch_max(volatile atomic_uintptr_t __local *object,
3826+ intptr_t opermax);
3827+
3828+intptr_t __ovld atomic_fetch_or(volatile atomic_intptr_t __global *object,
3829+ uintptr_t operand);
3830+intptr_t __ovld atomic_fetch_or(volatile atomic_intptr_t __local *object,
3831+ uintptr_t operand);
3832+intptr_t __ovld atomic_fetch_xor(volatile atomic_intptr_t __global *object,
3833+ uintptr_t operand);
3834+intptr_t __ovld atomic_fetch_xor(volatile atomic_intptr_t __local *object,
3835+ uintptr_t operand);
3836+intptr_t __ovld atomic_fetch_and(volatile atomic_intptr_t __global *object,
3837+ uintptr_t operand);
3838+intptr_t __ovld atomic_fetch_and(volatile atomic_intptr_t __local *object,
3839+ uintptr_t operand);
3840+intptr_t __ovld atomic_fetch_min(volatile atomic_intptr_t __global *object,
3841+ uintptr_t opermax);
3842+intptr_t __ovld atomic_fetch_min(volatile atomic_intptr_t __local *object,
3843+ uintptr_t opermax);
3844+intptr_t __ovld atomic_fetch_max(volatile atomic_intptr_t __global *object,
3845+ uintptr_t opermax);
3846+intptr_t __ovld atomic_fetch_max(volatile atomic_intptr_t __local *object,
3847+ uintptr_t opermax);
3848+#endif // defined(cl_khr_int64_base_atomics) &&
3849+ // defined(cl_khr_int64_extended_atomics)
3850+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
3851+
3852+#endif // defined(__opencl_c_atomic_scope_device) &&
3853+ // defined(__opencl_c_atomic_order_seq_cst)
3854+
3855+#ifdef __opencl_c_generic_address_space
3856+#ifdef __opencl_c_atomic_scope_device
3857+int __ovld atomic_fetch_add_explicit(volatile atomic_int *object, int operand,
3858+ memory_order order);
3859+uint __ovld atomic_fetch_add_explicit(volatile atomic_uint *object,
3860+ uint operand, memory_order order);
3861+int __ovld atomic_fetch_sub_explicit(volatile atomic_int *object, int operand,
3862+ memory_order order);
3863+uint __ovld atomic_fetch_sub_explicit(volatile atomic_uint *object,
3864+ uint operand, memory_order order);
3865+int __ovld atomic_fetch_or_explicit(volatile atomic_int *object, int operand,
3866+ memory_order order);
3867+uint __ovld atomic_fetch_or_explicit(volatile atomic_uint *object, uint operand,
3868+ memory_order order);
3869+int __ovld atomic_fetch_xor_explicit(volatile atomic_int *object, int operand,
3870+ memory_order order);
3871+uint __ovld atomic_fetch_xor_explicit(volatile atomic_uint *object,
3872+ uint operand, memory_order order);
3873+int __ovld atomic_fetch_and_explicit(volatile atomic_int *object, int operand,
3874+ memory_order order);
3875+uint __ovld atomic_fetch_and_explicit(volatile atomic_uint *object,
3876+ uint operand, memory_order order);
3877+int __ovld atomic_fetch_min_explicit(volatile atomic_int *object, int operand,
3878+ memory_order order);
3879+uint __ovld atomic_fetch_min_explicit(volatile atomic_uint *object,
3880+ uint operand, memory_order order);
3881+int __ovld atomic_fetch_max_explicit(volatile atomic_int *object, int operand,
3882+ memory_order order);
3883+uint __ovld atomic_fetch_max_explicit(volatile atomic_uint *object,
3884+ uint operand, memory_order order);
3885+#endif // __opencl_c_atomic_scope_device
3886+int __ovld atomic_fetch_add_explicit(volatile atomic_int *object, int operand,
3887+ memory_order order, memory_scope scope);
3888+uint __ovld atomic_fetch_add_explicit(volatile atomic_uint *object,
3889+ uint operand, memory_order order,
3890+ memory_scope scope);
3891+int __ovld atomic_fetch_sub_explicit(volatile atomic_int *object, int operand,
3892+ memory_order order, memory_scope scope);
3893+uint __ovld atomic_fetch_sub_explicit(volatile atomic_uint *object,
3894+ uint operand, memory_order order,
3895+ memory_scope scope);
3896+int __ovld atomic_fetch_or_explicit(volatile atomic_int *object, int operand,
3897+ memory_order order, memory_scope scope);
3898+uint __ovld atomic_fetch_or_explicit(volatile atomic_uint *object, uint operand,
3899+ memory_order order, memory_scope scope);
3900+int __ovld atomic_fetch_xor_explicit(volatile atomic_int *object, int operand,
3901+ memory_order order, memory_scope scope);
3902+uint __ovld atomic_fetch_xor_explicit(volatile atomic_uint *object,
3903+ uint operand, memory_order order,
3904+ memory_scope scope);
3905+int __ovld atomic_fetch_and_explicit(volatile atomic_int *object, int operand,
3906+ memory_order order, memory_scope scope);
3907+uint __ovld atomic_fetch_and_explicit(volatile atomic_uint *object,
3908+ uint operand, memory_order order,
3909+ memory_scope scope);
3910+int __ovld atomic_fetch_min_explicit(volatile atomic_int *object, int operand,
3911+ memory_order order, memory_scope scope);
3912+uint __ovld atomic_fetch_min_explicit(volatile atomic_uint *object,
3913+ uint operand, memory_order order,
3914+ memory_scope scope);
3915+int __ovld atomic_fetch_max_explicit(volatile atomic_int *object, int operand,
3916+ memory_order order, memory_scope scope);
3917+uint __ovld atomic_fetch_max_explicit(volatile atomic_uint *object,
3918+ uint operand, memory_order order,
3919+ memory_scope scope);
3920+
3921+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
3922+#ifdef __opencl_c_atomic_scope_device
3923+long __ovld atomic_fetch_add_explicit(volatile atomic_long *object,
3924+ long operand, memory_order order);
3925+ulong __ovld atomic_fetch_add_explicit(volatile atomic_ulong *object,
3926+ ulong operand, memory_order order);
3927+long __ovld atomic_fetch_sub_explicit(volatile atomic_long *object,
3928+ long operand, memory_order order);
3929+ulong __ovld atomic_fetch_sub_explicit(volatile atomic_ulong *object,
3930+ ulong operand, memory_order order);
3931+long __ovld atomic_fetch_or_explicit(volatile atomic_long *object, long operand,
3932+ memory_order order);
3933+ulong __ovld atomic_fetch_or_explicit(volatile atomic_ulong *object,
3934+ ulong operand, memory_order order);
3935+long __ovld atomic_fetch_xor_explicit(volatile atomic_long *object,
3936+ long operand, memory_order order);
3937+ulong __ovld atomic_fetch_xor_explicit(volatile atomic_ulong *object,
3938+ ulong operand, memory_order order);
3939+long __ovld atomic_fetch_and_explicit(volatile atomic_long *object,
3940+ long operand, memory_order order);
3941+ulong __ovld atomic_fetch_and_explicit(volatile atomic_ulong *object,
3942+ ulong operand, memory_order order);
3943+long __ovld atomic_fetch_min_explicit(volatile atomic_long *object,
3944+ long operand, memory_order order);
3945+ulong __ovld atomic_fetch_min_explicit(volatile atomic_ulong *object,
3946+ ulong operand, memory_order order);
3947+long __ovld atomic_fetch_max_explicit(volatile atomic_long *object,
3948+ long operand, memory_order order);
3949+ulong __ovld atomic_fetch_max_explicit(volatile atomic_ulong *object,
3950+ ulong operand, memory_order order);
3951+#endif // __opencl_c_atomic_scope_device
3952+long __ovld atomic_fetch_add_explicit(volatile atomic_long *object,
3953+ long operand, memory_order order,
3954+ memory_scope scope);
3955+ulong __ovld atomic_fetch_add_explicit(volatile atomic_ulong *object,
3956+ ulong operand, memory_order order,
3957+ memory_scope scope);
3958+long __ovld atomic_fetch_sub_explicit(volatile atomic_long *object,
3959+ long operand, memory_order order,
3960+ memory_scope scope);
3961+ulong __ovld atomic_fetch_sub_explicit(volatile atomic_ulong *object,
3962+ ulong operand, memory_order order,
3963+ memory_scope scope);
3964+long __ovld atomic_fetch_or_explicit(volatile atomic_long *object, long operand,
3965+ memory_order order, memory_scope scope);
3966+ulong __ovld atomic_fetch_or_explicit(volatile atomic_ulong *object,
3967+ ulong operand, memory_order order,
3968+ memory_scope scope);
3969+long __ovld atomic_fetch_xor_explicit(volatile atomic_long *object,
3970+ long operand, memory_order order,
3971+ memory_scope scope);
3972+ulong __ovld atomic_fetch_xor_explicit(volatile atomic_ulong *object,
3973+ ulong operand, memory_order order,
3974+ memory_scope scope);
3975+long __ovld atomic_fetch_and_explicit(volatile atomic_long *object,
3976+ long operand, memory_order order,
3977+ memory_scope scope);
3978+ulong __ovld atomic_fetch_and_explicit(volatile atomic_ulong *object,
3979+ ulong operand, memory_order order,
3980+ memory_scope scope);
3981+long __ovld atomic_fetch_min_explicit(volatile atomic_long *object,
3982+ long operand, memory_order order,
3983+ memory_scope scope);
3984+ulong __ovld atomic_fetch_min_explicit(volatile atomic_ulong *object,
3985+ ulong operand, memory_order order,
3986+ memory_scope scope);
3987+long __ovld atomic_fetch_max_explicit(volatile atomic_long *object,
3988+ long operand, memory_order order,
3989+ memory_scope scope);
3990+ulong __ovld atomic_fetch_max_explicit(volatile atomic_ulong *object,
3991+ ulong operand, memory_order order,
3992+ memory_scope scope);
3993+#endif // defined(cl_khr_int64_base_atomics) &&
3994+ // defined(cl_khr_int64_extended_atomics)
3995+
3996+// OpenCL v2.0 s6.13.11.7.5:
3997+// add/sub: atomic type argument can be uintptr_t/intptr_t, value type argument
3998+// can be ptrdiff_t. or/xor/and/min/max: atomic type argument can be
3999+// intptr_t/uintptr_t, value type argument can be intptr_t/uintptr_t.
4000+
4001+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
4002+#ifdef __opencl_c_atomic_scope_device
4003+uintptr_t __ovld atomic_fetch_add_explicit(volatile atomic_uintptr_t *object,
4004+ ptrdiff_t operand,
4005+ memory_order order);
4006+uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *object,
4007+ ptrdiff_t operand,
4008+ memory_order order);
4009+uintptr_t __ovld atomic_fetch_or_explicit(volatile atomic_uintptr_t *object,
4010+ intptr_t operand, memory_order order);
4011+uintptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_uintptr_t *object,
4012+ intptr_t operand,
4013+ memory_order order);
4014+uintptr_t __ovld atomic_fetch_and_explicit(volatile atomic_uintptr_t *object,
4015+ intptr_t operand,
4016+ memory_order order);
4017+uintptr_t __ovld atomic_fetch_min_explicit(volatile atomic_uintptr_t *object,
4018+ intptr_t opermax,
4019+ memory_order minder);
4020+uintptr_t __ovld atomic_fetch_max_explicit(volatile atomic_uintptr_t *object,
4021+ intptr_t opermax,
4022+ memory_order minder);
4023+intptr_t __ovld atomic_fetch_or_explicit(volatile atomic_intptr_t *object,
4024+ uintptr_t operand, memory_order order);
4025+intptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_intptr_t *object,
4026+ uintptr_t operand,
4027+ memory_order order);
4028+intptr_t __ovld atomic_fetch_and_explicit(volatile atomic_intptr_t *object,
4029+ uintptr_t operand,
4030+ memory_order order);
4031+intptr_t __ovld atomic_fetch_min_explicit(volatile atomic_intptr_t *object,
4032+ uintptr_t opermax,
4033+ memory_order minder);
4034+intptr_t __ovld atomic_fetch_max_explicit(volatile atomic_intptr_t *object,
4035+ uintptr_t opermax,
4036+ memory_order minder);
4037+#endif // __opencl_c_atomic_scope_device
4038+uintptr_t __ovld atomic_fetch_add_explicit(volatile atomic_uintptr_t *object,
4039+ ptrdiff_t operand,
4040+ memory_order order,
4041+ memory_scope scope);
4042+uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *object,
4043+ ptrdiff_t operand,
4044+ memory_order order,
4045+ memory_scope scope);
4046+
4047+uintptr_t __ovld atomic_fetch_or_explicit(volatile atomic_uintptr_t *object,
4048+ intptr_t operand, memory_order order,
4049+ memory_scope scope);
4050+uintptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_uintptr_t *object,
4051+ intptr_t operand, memory_order order,
4052+ memory_scope scope);
4053+uintptr_t __ovld atomic_fetch_and_explicit(volatile atomic_uintptr_t *object,
4054+ intptr_t operand, memory_order order,
4055+ memory_scope scope);
4056+uintptr_t __ovld atomic_fetch_min_explicit(volatile atomic_uintptr_t *object,
4057+ intptr_t opermax,
4058+ memory_order minder,
4059+ memory_scope scope);
4060+uintptr_t __ovld atomic_fetch_max_explicit(volatile atomic_uintptr_t *object,
4061+ intptr_t opermax,
4062+ memory_order minder,
4063+ memory_scope scope);
4064+
4065+intptr_t __ovld atomic_fetch_or_explicit(volatile atomic_intptr_t *object,
4066+ uintptr_t operand, memory_order order,
4067+ memory_scope scope);
4068+intptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_intptr_t *object,
4069+ uintptr_t operand, memory_order order,
4070+ memory_scope scope);
4071+intptr_t __ovld atomic_fetch_and_explicit(volatile atomic_intptr_t *object,
4072+ uintptr_t operand, memory_order order,
4073+ memory_scope scope);
4074+intptr_t __ovld atomic_fetch_min_explicit(volatile atomic_intptr_t *object,
4075+ uintptr_t opermax,
4076+ memory_order minder,
4077+ memory_scope scope);
4078+intptr_t __ovld atomic_fetch_max_explicit(volatile atomic_intptr_t *object,
4079+ uintptr_t opermax,
4080+ memory_order minder,
4081+ memory_scope scope);
4082 #endif
4083+#endif // __opencl_c_generic_address_space
4084+
4085+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
4086+#ifdef __opencl_c_atomic_scope_device
4087+int __ovld atomic_fetch_add_explicit(volatile atomic_int __global *object,
4088+ int operand, memory_order order);
4089+int __ovld atomic_fetch_add_explicit(volatile atomic_int __local *object,
4090+ int operand, memory_order order);
4091+uint __ovld atomic_fetch_add_explicit(volatile atomic_uint __global *object,
4092+ uint operand, memory_order order);
4093+uint __ovld atomic_fetch_add_explicit(volatile atomic_uint __local *object,
4094+ uint operand, memory_order order);
4095+int __ovld atomic_fetch_sub_explicit(volatile atomic_int __global *object,
4096+ int operand, memory_order order);
4097+int __ovld atomic_fetch_sub_explicit(volatile atomic_int __local *object,
4098+ int operand, memory_order order);
4099+uint __ovld atomic_fetch_sub_explicit(volatile atomic_uint __global *object,
4100+ uint operand, memory_order order);
4101+uint __ovld atomic_fetch_sub_explicit(volatile atomic_uint __local *object,
4102+ uint operand, memory_order order);
4103+int __ovld atomic_fetch_or_explicit(volatile atomic_int __global *object,
4104+ int operand, memory_order order);
4105+int __ovld atomic_fetch_or_explicit(volatile atomic_int __local *object,
4106+ int operand, memory_order order);
4107+uint __ovld atomic_fetch_or_explicit(volatile atomic_uint __global *object,
4108+ uint operand, memory_order order);
4109+uint __ovld atomic_fetch_or_explicit(volatile atomic_uint __local *object,
4110+ uint operand, memory_order order);
4111+int __ovld atomic_fetch_xor_explicit(volatile atomic_int __global *object,
4112+ int operand, memory_order order);
4113+int __ovld atomic_fetch_xor_explicit(volatile atomic_int __local *object,
4114+ int operand, memory_order order);
4115+uint __ovld atomic_fetch_xor_explicit(volatile atomic_uint __global *object,
4116+ uint operand, memory_order order);
4117+uint __ovld atomic_fetch_xor_explicit(volatile atomic_uint __local *object,
4118+ uint operand, memory_order order);
4119+int __ovld atomic_fetch_and_explicit(volatile atomic_int __global *object,
4120+ int operand, memory_order order);
4121+int __ovld atomic_fetch_and_explicit(volatile atomic_int __local *object,
4122+ int operand, memory_order order);
4123+uint __ovld atomic_fetch_and_explicit(volatile atomic_uint __global *object,
4124+ uint operand, memory_order order);
4125+uint __ovld atomic_fetch_and_explicit(volatile atomic_uint __local *object,
4126+ uint operand, memory_order order);
4127+int __ovld atomic_fetch_min_explicit(volatile atomic_int __global *object,
4128+ int operand, memory_order order);
4129+int __ovld atomic_fetch_min_explicit(volatile atomic_int __local *object,
4130+ int operand, memory_order order);
4131+uint __ovld atomic_fetch_min_explicit(volatile atomic_uint __global *object,
4132+ uint operand, memory_order order);
4133+uint __ovld atomic_fetch_min_explicit(volatile atomic_uint __local *object,
4134+ uint operand, memory_order order);
4135+int __ovld atomic_fetch_max_explicit(volatile atomic_int __global *object,
4136+ int operand, memory_order order);
4137+int __ovld atomic_fetch_max_explicit(volatile atomic_int __local *object,
4138+ int operand, memory_order order);
4139+uint __ovld atomic_fetch_max_explicit(volatile atomic_uint __global *object,
4140+ uint operand, memory_order order);
4141+uint __ovld atomic_fetch_max_explicit(volatile atomic_uint __local *object,
4142+ uint operand, memory_order order);
4143+#endif // __opencl_c_atomic_scope_device
4144+int __ovld atomic_fetch_add_explicit(volatile atomic_int __global *object,
4145+ int operand, memory_order order,
4146+ memory_scope scope);
4147+int __ovld atomic_fetch_add_explicit(volatile atomic_int __local *object,
4148+ int operand, memory_order order,
4149+ memory_scope scope);
4150+uint __ovld atomic_fetch_add_explicit(volatile atomic_uint __global *object,
4151+ uint operand, memory_order order,
4152+ memory_scope scope);
4153+uint __ovld atomic_fetch_add_explicit(volatile atomic_uint __local *object,
4154+ uint operand, memory_order order,
4155+ memory_scope scope);
4156+int __ovld atomic_fetch_sub_explicit(volatile atomic_int __global *object,
4157+ int operand, memory_order order,
4158+ memory_scope scope);
4159+int __ovld atomic_fetch_sub_explicit(volatile atomic_int __local *object,
4160+ int operand, memory_order order,
4161+ memory_scope scope);
4162+uint __ovld atomic_fetch_sub_explicit(volatile atomic_uint __global *object,
4163+ uint operand, memory_order order,
4164+ memory_scope scope);
4165+uint __ovld atomic_fetch_sub_explicit(volatile atomic_uint __local *object,
4166+ uint operand, memory_order order,
4167+ memory_scope scope);
4168+int __ovld atomic_fetch_or_explicit(volatile atomic_int __global *object,
4169+ int operand, memory_order order,
4170+ memory_scope scope);
4171+int __ovld atomic_fetch_or_explicit(volatile atomic_int __local *object,
4172+ int operand, memory_order order,
4173+ memory_scope scope);
4174+uint __ovld atomic_fetch_or_explicit(volatile atomic_uint __global *object,
4175+ uint operand, memory_order order,
4176+ memory_scope scope);
4177+uint __ovld atomic_fetch_or_explicit(volatile atomic_uint __local *object,
4178+ uint operand, memory_order order,
4179+ memory_scope scope);
4180+int __ovld atomic_fetch_xor_explicit(volatile atomic_int __global *object,
4181+ int operand, memory_order order,
4182+ memory_scope scope);
4183+int __ovld atomic_fetch_xor_explicit(volatile atomic_int __local *object,
4184+ int operand, memory_order order,
4185+ memory_scope scope);
4186+uint __ovld atomic_fetch_xor_explicit(volatile atomic_uint __global *object,
4187+ uint operand, memory_order order,
4188+ memory_scope scope);
4189+uint __ovld atomic_fetch_xor_explicit(volatile atomic_uint __local *object,
4190+ uint operand, memory_order order,
4191+ memory_scope scope);
4192+int __ovld atomic_fetch_and_explicit(volatile atomic_int __global *object,
4193+ int operand, memory_order order,
4194+ memory_scope scope);
4195+int __ovld atomic_fetch_and_explicit(volatile atomic_int __local *object,
4196+ int operand, memory_order order,
4197+ memory_scope scope);
4198+uint __ovld atomic_fetch_and_explicit(volatile atomic_uint __global *object,
4199+ uint operand, memory_order order,
4200+ memory_scope scope);
4201+uint __ovld atomic_fetch_and_explicit(volatile atomic_uint __local *object,
4202+ uint operand, memory_order order,
4203+ memory_scope scope);
4204+int __ovld atomic_fetch_min_explicit(volatile atomic_int __global *object,
4205+ int operand, memory_order order,
4206+ memory_scope scope);
4207+int __ovld atomic_fetch_min_explicit(volatile atomic_int __local *object,
4208+ int operand, memory_order order,
4209+ memory_scope scope);
4210+uint __ovld atomic_fetch_min_explicit(volatile atomic_uint __global *object,
4211+ uint operand, memory_order order,
4212+ memory_scope scope);
4213+uint __ovld atomic_fetch_min_explicit(volatile atomic_uint __local *object,
4214+ uint operand, memory_order order,
4215+ memory_scope scope);
4216+int __ovld atomic_fetch_max_explicit(volatile atomic_int __global *object,
4217+ int operand, memory_order order,
4218+ memory_scope scope);
4219+int __ovld atomic_fetch_max_explicit(volatile atomic_int __local *object,
4220+ int operand, memory_order order,
4221+ memory_scope scope);
4222+uint __ovld atomic_fetch_max_explicit(volatile atomic_uint __global *object,
4223+ uint operand, memory_order order,
4224+ memory_scope scope);
4225+uint __ovld atomic_fetch_max_explicit(volatile atomic_uint __local *object,
4226+ uint operand, memory_order order,
4227+ memory_scope scope);
4228+
4229+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
4230+#ifdef __opencl_c_atomic_scope_device
4231+long __ovld atomic_fetch_add_explicit(volatile atomic_long __global *object,
4232+ long operand, memory_order order);
4233+long __ovld atomic_fetch_add_explicit(volatile atomic_long __local *object,
4234+ long operand, memory_order order);
4235+ulong __ovld atomic_fetch_add_explicit(volatile atomic_ulong __global *object,
4236+ ulong operand, memory_order order);
4237+ulong __ovld atomic_fetch_add_explicit(volatile atomic_ulong __local *object,
4238+ ulong operand, memory_order order);
4239+long __ovld atomic_fetch_sub_explicit(volatile atomic_long __global *object,
4240+ long operand, memory_order order);
4241+long __ovld atomic_fetch_sub_explicit(volatile atomic_long __local *object,
4242+ long operand, memory_order order);
4243+ulong __ovld atomic_fetch_sub_explicit(volatile atomic_ulong __global *object,
4244+ ulong operand, memory_order order);
4245+ulong __ovld atomic_fetch_sub_explicit(volatile atomic_ulong __local *object,
4246+ ulong operand, memory_order order);
4247+long __ovld atomic_fetch_or_explicit(volatile atomic_long __global *object,
4248+ long operand, memory_order order);
4249+long __ovld atomic_fetch_or_explicit(volatile atomic_long __local *object,
4250+ long operand, memory_order order);
4251+ulong __ovld atomic_fetch_or_explicit(volatile atomic_ulong __global *object,
4252+ ulong operand, memory_order order);
4253+ulong __ovld atomic_fetch_or_explicit(volatile atomic_ulong __local *object,
4254+ ulong operand, memory_order order);
4255+long __ovld atomic_fetch_xor_explicit(volatile atomic_long __global *object,
4256+ long operand, memory_order order);
4257+long __ovld atomic_fetch_xor_explicit(volatile atomic_long __local *object,
4258+ long operand, memory_order order);
4259+ulong __ovld atomic_fetch_xor_explicit(volatile atomic_ulong __global *object,
4260+ ulong operand, memory_order order);
4261+ulong __ovld atomic_fetch_xor_explicit(volatile atomic_ulong __local *object,
4262+ ulong operand, memory_order order);
4263+long __ovld atomic_fetch_and_explicit(volatile atomic_long __global *object,
4264+ long operand, memory_order order);
4265+long __ovld atomic_fetch_and_explicit(volatile atomic_long __local *object,
4266+ long operand, memory_order order);
4267+ulong __ovld atomic_fetch_and_explicit(volatile atomic_ulong __global *object,
4268+ ulong operand, memory_order order);
4269+ulong __ovld atomic_fetch_and_explicit(volatile atomic_ulong __local *object,
4270+ ulong operand, memory_order order);
4271+long __ovld atomic_fetch_min_explicit(volatile atomic_long __global *object,
4272+ long operand, memory_order order);
4273+long __ovld atomic_fetch_min_explicit(volatile atomic_long __local *object,
4274+ long operand, memory_order order);
4275+ulong __ovld atomic_fetch_min_explicit(volatile atomic_ulong __global *object,
4276+ ulong operand, memory_order order);
4277+ulong __ovld atomic_fetch_min_explicit(volatile atomic_ulong __local *object,
4278+ ulong operand, memory_order order);
4279+long __ovld atomic_fetch_max_explicit(volatile atomic_long __global *object,
4280+ long operand, memory_order order);
4281+long __ovld atomic_fetch_max_explicit(volatile atomic_long __local *object,
4282+ long operand, memory_order order);
4283+ulong __ovld atomic_fetch_max_explicit(volatile atomic_ulong __global *object,
4284+ ulong operand, memory_order order);
4285+ulong __ovld atomic_fetch_max_explicit(volatile atomic_ulong __local *object,
4286+ ulong operand, memory_order order);
4287+#endif // __opencl_c_atomic_scope_device
4288+long __ovld atomic_fetch_add_explicit(volatile atomic_long __global *object,
4289+ long operand, memory_order order,
4290+ memory_scope scope);
4291+long __ovld atomic_fetch_add_explicit(volatile atomic_long __local *object,
4292+ long operand, memory_order order,
4293+ memory_scope scope);
4294+ulong __ovld atomic_fetch_add_explicit(volatile atomic_ulong __global *object,
4295+ ulong operand, memory_order order,
4296+ memory_scope scope);
4297+ulong __ovld atomic_fetch_add_explicit(volatile atomic_ulong __local *object,
4298+ ulong operand, memory_order order,
4299+ memory_scope scope);
4300+long __ovld atomic_fetch_sub_explicit(volatile atomic_long __global *object,
4301+ long operand, memory_order order,
4302+ memory_scope scope);
4303+long __ovld atomic_fetch_sub_explicit(volatile atomic_long __local *object,
4304+ long operand, memory_order order,
4305+ memory_scope scope);
4306+ulong __ovld atomic_fetch_sub_explicit(volatile atomic_ulong __global *object,
4307+ ulong operand, memory_order order,
4308+ memory_scope scope);
4309+ulong __ovld atomic_fetch_sub_explicit(volatile atomic_ulong __local *object,
4310+ ulong operand, memory_order order,
4311+ memory_scope scope);
4312+long __ovld atomic_fetch_or_explicit(volatile atomic_long __global *object,
4313+ long operand, memory_order order,
4314+ memory_scope scope);
4315+long __ovld atomic_fetch_or_explicit(volatile atomic_long __local *object,
4316+ long operand, memory_order order,
4317+ memory_scope scope);
4318+ulong __ovld atomic_fetch_or_explicit(volatile atomic_ulong __global *object,
4319+ ulong operand, memory_order order,
4320+ memory_scope scope);
4321+ulong __ovld atomic_fetch_or_explicit(volatile atomic_ulong __local *object,
4322+ ulong operand, memory_order order,
4323+ memory_scope scope);
4324+long __ovld atomic_fetch_xor_explicit(volatile atomic_long __global *object,
4325+ long operand, memory_order order,
4326+ memory_scope scope);
4327+long __ovld atomic_fetch_xor_explicit(volatile atomic_long __local *object,
4328+ long operand, memory_order order,
4329+ memory_scope scope);
4330+ulong __ovld atomic_fetch_xor_explicit(volatile atomic_ulong __global *object,
4331+ ulong operand, memory_order order,
4332+ memory_scope scope);
4333+ulong __ovld atomic_fetch_xor_explicit(volatile atomic_ulong __local *object,
4334+ ulong operand, memory_order order,
4335+ memory_scope scope);
4336+long __ovld atomic_fetch_and_explicit(volatile atomic_long __global *object,
4337+ long operand, memory_order order,
4338+ memory_scope scope);
4339+long __ovld atomic_fetch_and_explicit(volatile atomic_long __local *object,
4340+ long operand, memory_order order,
4341+ memory_scope scope);
4342+ulong __ovld atomic_fetch_and_explicit(volatile atomic_ulong __global *object,
4343+ ulong operand, memory_order order,
4344+ memory_scope scope);
4345+ulong __ovld atomic_fetch_and_explicit(volatile atomic_ulong __local *object,
4346+ ulong operand, memory_order order,
4347+ memory_scope scope);
4348+long __ovld atomic_fetch_min_explicit(volatile atomic_long __global *object,
4349+ long operand, memory_order order,
4350+ memory_scope scope);
4351+long __ovld atomic_fetch_min_explicit(volatile atomic_long __local *object,
4352+ long operand, memory_order order,
4353+ memory_scope scope);
4354+ulong __ovld atomic_fetch_min_explicit(volatile atomic_ulong __global *object,
4355+ ulong operand, memory_order order,
4356+ memory_scope scope);
4357+ulong __ovld atomic_fetch_min_explicit(volatile atomic_ulong __local *object,
4358+ ulong operand, memory_order order,
4359+ memory_scope scope);
4360+long __ovld atomic_fetch_max_explicit(volatile atomic_long __global *object,
4361+ long operand, memory_order order,
4362+ memory_scope scope);
4363+long __ovld atomic_fetch_max_explicit(volatile atomic_long __local *object,
4364+ long operand, memory_order order,
4365+ memory_scope scope);
4366+ulong __ovld atomic_fetch_max_explicit(volatile atomic_ulong __global *object,
4367+ ulong operand, memory_order order,
4368+ memory_scope scope);
4369+ulong __ovld atomic_fetch_max_explicit(volatile atomic_ulong __local *object,
4370+ ulong operand, memory_order order,
4371+ memory_scope scope);
4372+#endif // defined(cl_khr_int64_base_atomics) &&
4373+ // defined(cl_khr_int64_extended_atomics)
4374+
4375+// OpenCL v2.0 s6.13.11.7.5:
4376+// add/sub: atomic type argument can be uintptr_t/intptr_t, value type argument
4377+// can be ptrdiff_t. or/xor/and/min/max: atomic type argument can be
4378+// intptr_t/uintptr_t, value type argument can be intptr_t/uintptr_t.
4379+
4380+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
4381+#ifdef __opencl_c_atomic_scope_device
4382+uintptr_t __ovld
4383+atomic_fetch_add_explicit(volatile atomic_uintptr_t __global *object,
4384+ ptrdiff_t operand, memory_order order);
4385+uintptr_t __ovld
4386+atomic_fetch_add_explicit(volatile atomic_uintptr_t __local *object,
4387+ ptrdiff_t operand, memory_order order);
4388+uintptr_t __ovld
4389+atomic_fetch_sub_explicit(volatile atomic_uintptr_t __global *object,
4390+ ptrdiff_t operand, memory_order order);
4391+uintptr_t __ovld
4392+atomic_fetch_sub_explicit(volatile atomic_uintptr_t __local *object,
4393+ ptrdiff_t operand, memory_order order);
4394+uintptr_t __ovld
4395+atomic_fetch_or_explicit(volatile atomic_uintptr_t __global *object,
4396+ intptr_t operand, memory_order order);
4397+uintptr_t __ovld
4398+atomic_fetch_or_explicit(volatile atomic_uintptr_t __local *object,
4399+ intptr_t operand, memory_order order);
4400+uintptr_t __ovld
4401+atomic_fetch_xor_explicit(volatile atomic_uintptr_t __global *object,
4402+ intptr_t operand, memory_order order);
4403+uintptr_t __ovld
4404+atomic_fetch_xor_explicit(volatile atomic_uintptr_t __local *object,
4405+ intptr_t operand, memory_order order);
4406+uintptr_t __ovld
4407+atomic_fetch_and_explicit(volatile atomic_uintptr_t __global *object,
4408+ intptr_t operand, memory_order order);
4409+uintptr_t __ovld
4410+atomic_fetch_and_explicit(volatile atomic_uintptr_t __local *object,
4411+ intptr_t operand, memory_order order);
4412+uintptr_t __ovld
4413+atomic_fetch_min_explicit(volatile atomic_uintptr_t __global *object,
4414+ intptr_t opermax, memory_order minder);
4415+uintptr_t __ovld
4416+atomic_fetch_min_explicit(volatile atomic_uintptr_t __local *object,
4417+ intptr_t opermax, memory_order minder);
4418+uintptr_t __ovld
4419+atomic_fetch_max_explicit(volatile atomic_uintptr_t __global *object,
4420+ intptr_t opermax, memory_order minder);
4421+uintptr_t __ovld
4422+atomic_fetch_max_explicit(volatile atomic_uintptr_t __local *object,
4423+ intptr_t opermax, memory_order minder);
4424+intptr_t __ovld
4425+atomic_fetch_or_explicit(volatile atomic_intptr_t __global *object,
4426+ uintptr_t operand, memory_order order);
4427+intptr_t __ovld
4428+atomic_fetch_or_explicit(volatile atomic_intptr_t __local *object,
4429+ uintptr_t operand, memory_order order);
4430+intptr_t __ovld
4431+atomic_fetch_xor_explicit(volatile atomic_intptr_t __global *object,
4432+ uintptr_t operand, memory_order order);
4433+intptr_t __ovld
4434+atomic_fetch_xor_explicit(volatile atomic_intptr_t __local *object,
4435+ uintptr_t operand, memory_order order);
4436+intptr_t __ovld
4437+atomic_fetch_and_explicit(volatile atomic_intptr_t __global *object,
4438+ uintptr_t operand, memory_order order);
4439+intptr_t __ovld
4440+atomic_fetch_and_explicit(volatile atomic_intptr_t __local *object,
4441+ uintptr_t operand, memory_order order);
4442+intptr_t __ovld
4443+atomic_fetch_min_explicit(volatile atomic_intptr_t __global *object,
4444+ uintptr_t opermax, memory_order minder);
4445+intptr_t __ovld
4446+atomic_fetch_min_explicit(volatile atomic_intptr_t __local *object,
4447+ uintptr_t opermax, memory_order minder);
4448+intptr_t __ovld
4449+atomic_fetch_max_explicit(volatile atomic_intptr_t __global *object,
4450+ uintptr_t opermax, memory_order minder);
4451+intptr_t __ovld
4452+atomic_fetch_max_explicit(volatile atomic_intptr_t __local *object,
4453+ uintptr_t opermax, memory_order minder);
4454+#endif // __opencl_c_atomic_scope_device
4455+uintptr_t __ovld atomic_fetch_add_explicit(
4456+ volatile atomic_uintptr_t __global *object, ptrdiff_t operand,
4457+ memory_order order, memory_scope scope);
4458+uintptr_t __ovld atomic_fetch_add_explicit(
4459+ volatile atomic_uintptr_t __local *object, ptrdiff_t operand,
4460+ memory_order order, memory_scope scope);
4461+uintptr_t __ovld atomic_fetch_sub_explicit(
4462+ volatile atomic_uintptr_t __global *object, ptrdiff_t operand,
4463+ memory_order order, memory_scope scope);
4464+uintptr_t __ovld atomic_fetch_sub_explicit(
4465+ volatile atomic_uintptr_t __local *object, ptrdiff_t operand,
4466+ memory_order order, memory_scope scope);
4467+
4468+uintptr_t __ovld atomic_fetch_or_explicit(
4469+ volatile atomic_uintptr_t __global *object, intptr_t operand,
4470+ memory_order order, memory_scope scope);
4471+uintptr_t __ovld atomic_fetch_or_explicit(
4472+ volatile atomic_uintptr_t __local *object, intptr_t operand,
4473+ memory_order order, memory_scope scope);
4474+uintptr_t __ovld atomic_fetch_xor_explicit(
4475+ volatile atomic_uintptr_t __global *object, intptr_t operand,
4476+ memory_order order, memory_scope scope);
4477+uintptr_t __ovld atomic_fetch_xor_explicit(
4478+ volatile atomic_uintptr_t __local *object, intptr_t operand,
4479+ memory_order order, memory_scope scope);
4480+uintptr_t __ovld atomic_fetch_and_explicit(
4481+ volatile atomic_uintptr_t __global *object, intptr_t operand,
4482+ memory_order order, memory_scope scope);
4483+uintptr_t __ovld atomic_fetch_and_explicit(
4484+ volatile atomic_uintptr_t __local *object, intptr_t operand,
4485+ memory_order order, memory_scope scope);
4486+uintptr_t __ovld atomic_fetch_min_explicit(
4487+ volatile atomic_uintptr_t __global *object, intptr_t opermax,
4488+ memory_order minder, memory_scope scope);
4489+uintptr_t __ovld atomic_fetch_min_explicit(
4490+ volatile atomic_uintptr_t __local *object, intptr_t opermax,
4491+ memory_order minder, memory_scope scope);
4492+uintptr_t __ovld atomic_fetch_max_explicit(
4493+ volatile atomic_uintptr_t __global *object, intptr_t opermax,
4494+ memory_order minder, memory_scope scope);
4495+uintptr_t __ovld atomic_fetch_max_explicit(
4496+ volatile atomic_uintptr_t __local *object, intptr_t opermax,
4497+ memory_order minder, memory_scope scope);
4498+
4499+intptr_t __ovld atomic_fetch_or_explicit(
4500+ volatile atomic_intptr_t __global *object, uintptr_t operand,
4501+ memory_order order, memory_scope scope);
4502+intptr_t __ovld atomic_fetch_or_explicit(
4503+ volatile atomic_intptr_t __local *object, uintptr_t operand,
4504+ memory_order order, memory_scope scope);
4505+intptr_t __ovld atomic_fetch_xor_explicit(
4506+ volatile atomic_intptr_t __global *object, uintptr_t operand,
4507+ memory_order order, memory_scope scope);
4508+intptr_t __ovld atomic_fetch_xor_explicit(
4509+ volatile atomic_intptr_t __local *object, uintptr_t operand,
4510+ memory_order order, memory_scope scope);
4511+intptr_t __ovld atomic_fetch_and_explicit(
4512+ volatile atomic_intptr_t __global *object, uintptr_t operand,
4513+ memory_order order, memory_scope scope);
4514+intptr_t __ovld atomic_fetch_and_explicit(
4515+ volatile atomic_intptr_t __local *object, uintptr_t operand,
4516+ memory_order order, memory_scope scope);
4517+intptr_t __ovld atomic_fetch_min_explicit(
4518+ volatile atomic_intptr_t __global *object, uintptr_t opermax,
4519+ memory_order minder, memory_scope scope);
4520+intptr_t __ovld atomic_fetch_min_explicit(
4521+ volatile atomic_intptr_t __local *object, uintptr_t opermax,
4522+ memory_order minder, memory_scope scope);
4523+intptr_t __ovld atomic_fetch_max_explicit(
4524+ volatile atomic_intptr_t __global *object, uintptr_t opermax,
4525+ memory_order minder, memory_scope scope);
4526+intptr_t __ovld atomic_fetch_max_explicit(
4527+ volatile atomic_intptr_t __local *object, uintptr_t opermax,
4528+ memory_order minder, memory_scope scope);
4529+#endif // defined(cl_khr_int64_base_atomics) &&
4530+ // defined(cl_khr_int64_extended_atomics)
4531+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
4532
4533 // atomic_store()
4534
4535+#if defined(__opencl_c_atomic_scope_device) && \
4536+ defined(__opencl_c_atomic_order_seq_cst)
4537+
4538+#ifdef __opencl_c_generic_address_space
4539 void __ovld atomic_store(volatile atomic_int *object, int desired);
4540-void __ovld atomic_store_explicit(volatile atomic_int *object, int desired, memory_order order);
4541-void __ovld atomic_store_explicit(volatile atomic_int *object, int desired, memory_order order, memory_scope scope);
4542 void __ovld atomic_store(volatile atomic_uint *object, uint desired);
4543-void __ovld atomic_store_explicit(volatile atomic_uint *object, uint desired, memory_order order);
4544-void __ovld atomic_store_explicit(volatile atomic_uint *object, uint desired, memory_order order, memory_scope scope);
4545 void __ovld atomic_store(volatile atomic_float *object, float desired);
4546-void __ovld atomic_store_explicit(volatile atomic_float *object, float desired, memory_order order);
4547-void __ovld atomic_store_explicit(volatile atomic_float *object, float desired, memory_order order, memory_scope scope);
4548 #if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
4549-#ifdef cl_khr_fp64
4550+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
4551 void __ovld atomic_store(volatile atomic_double *object, double desired);
4552-void __ovld atomic_store_explicit(volatile atomic_double *object, double desired, memory_order order);
4553-void __ovld atomic_store_explicit(volatile atomic_double *object, double desired, memory_order order, memory_scope scope);
4554-#endif //cl_khr_fp64
4555+#endif
4556 void __ovld atomic_store(volatile atomic_long *object, long desired);
4557-void __ovld atomic_store_explicit(volatile atomic_long *object, long desired, memory_order order);
4558-void __ovld atomic_store_explicit(volatile atomic_long *object, long desired, memory_order order, memory_scope scope);
4559 void __ovld atomic_store(volatile atomic_ulong *object, ulong desired);
4560-void __ovld atomic_store_explicit(volatile atomic_ulong *object, ulong desired, memory_order order);
4561-void __ovld atomic_store_explicit(volatile atomic_ulong *object, ulong desired, memory_order order, memory_scope scope);
4562+#endif // defined(cl_khr_int64_base_atomics) &&
4563+ // defined(cl_khr_int64_extended_atomics)
4564+#endif // __opencl_c_generic_address_space
4565+
4566+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
4567+void __ovld atomic_store(volatile atomic_int __global *object, int desired);
4568+void __ovld atomic_store(volatile atomic_int __local *object, int desired);
4569+void __ovld atomic_store(volatile atomic_uint __global *object, uint desired);
4570+void __ovld atomic_store(volatile atomic_uint __local *object, uint desired);
4571+void __ovld atomic_store(volatile atomic_float __global *object, float desired);
4572+void __ovld atomic_store(volatile atomic_float __local *object, float desired);
4573+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
4574+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
4575+void __ovld atomic_store(volatile atomic_double __global *object,
4576+ double desired);
4577+void __ovld atomic_store(volatile atomic_double __local *object,
4578+ double desired);
4579 #endif
4580+void __ovld atomic_store(volatile atomic_long __global *object, long desired);
4581+void __ovld atomic_store(volatile atomic_long __local *object, long desired);
4582+void __ovld atomic_store(volatile atomic_ulong __global *object, ulong desired);
4583+void __ovld atomic_store(volatile atomic_ulong __local *object, ulong desired);
4584+#endif // defined(cl_khr_int64_base_atomics) &&
4585+ // defined(cl_khr_int64_extended_atomics)
4586+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
4587+
4588+#endif // defined(__opencl_c_atomic_scope_device) &&
4589+ // defined(__opencl_c_atomic_order_seq_cst)
4590+
4591+#ifdef __opencl_c_generic_address_space
4592+#ifdef __opencl_c_atomic_scope_device
4593+void __ovld atomic_store_explicit(volatile atomic_int *object, int desired,
4594+ memory_order order);
4595+void __ovld atomic_store_explicit(volatile atomic_uint *object, uint desired,
4596+ memory_order order);
4597+void __ovld atomic_store_explicit(volatile atomic_float *object, float desired,
4598+ memory_order order);
4599+#endif // __opencl_c_atomic_scope_device
4600+void __ovld atomic_store_explicit(volatile atomic_int *object, int desired,
4601+ memory_order order, memory_scope scope);
4602+void __ovld atomic_store_explicit(volatile atomic_uint *object, uint desired,
4603+ memory_order order, memory_scope scope);
4604+void __ovld atomic_store_explicit(volatile atomic_float *object, float desired,
4605+ memory_order order, memory_scope scope);
4606+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
4607+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
4608+#ifdef __opencl_c_atomic_scope_device
4609+void __ovld atomic_store_explicit(volatile atomic_double *object,
4610+ double desired, memory_order order);
4611+#endif //__opencl_c_atomic_scope_device
4612+void __ovld atomic_store_explicit(volatile atomic_double *object,
4613+ double desired, memory_order order,
4614+ memory_scope scope);
4615+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
4616+#ifdef __opencl_c_atomic_scope_device
4617+void __ovld atomic_store_explicit(volatile atomic_long *object, long desired,
4618+ memory_order order);
4619+void __ovld atomic_store_explicit(volatile atomic_ulong *object, ulong desired,
4620+ memory_order order);
4621+#endif //__opencl_c_atomic_scope_device
4622+void __ovld atomic_store_explicit(volatile atomic_long *object, long desired,
4623+ memory_order order, memory_scope scope);
4624+void __ovld atomic_store_explicit(volatile atomic_ulong *object, ulong desired,
4625+ memory_order order, memory_scope scope);
4626+#endif // defined(cl_khr_int64_base_atomics) &&
4627+ // defined(cl_khr_int64_extended_atomics)
4628+#endif // __opencl_c_generic_address_space
4629+
4630+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
4631+#ifdef __opencl_c_atomic_scope_device
4632+void __ovld atomic_store_explicit(volatile atomic_int __global *object,
4633+ int desired, memory_order order);
4634+void __ovld atomic_store_explicit(volatile atomic_int __local *object,
4635+ int desired, memory_order order);
4636+void __ovld atomic_store_explicit(volatile atomic_uint __global *object,
4637+ uint desired, memory_order order);
4638+void __ovld atomic_store_explicit(volatile atomic_uint __local *object,
4639+ uint desired, memory_order order);
4640+void __ovld atomic_store_explicit(volatile atomic_float __global *object,
4641+ float desired, memory_order order);
4642+void __ovld atomic_store_explicit(volatile atomic_float __local *object,
4643+ float desired, memory_order order);
4644+#endif // __opencl_c_atomic_scope_device
4645+void __ovld atomic_store_explicit(volatile atomic_int __global *object,
4646+ int desired, memory_order order,
4647+ memory_scope scope);
4648+void __ovld atomic_store_explicit(volatile atomic_int __local *object,
4649+ int desired, memory_order order,
4650+ memory_scope scope);
4651+void __ovld atomic_store_explicit(volatile atomic_uint __global *object,
4652+ uint desired, memory_order order,
4653+ memory_scope scope);
4654+void __ovld atomic_store_explicit(volatile atomic_uint __local *object,
4655+ uint desired, memory_order order,
4656+ memory_scope scope);
4657+void __ovld atomic_store_explicit(volatile atomic_float __global *object,
4658+ float desired, memory_order order,
4659+ memory_scope scope);
4660+void __ovld atomic_store_explicit(volatile atomic_float __local *object,
4661+ float desired, memory_order order,
4662+ memory_scope scope);
4663+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
4664+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
4665+#ifdef __opencl_c_atomic_scope_device
4666+void __ovld atomic_store_explicit(volatile atomic_double __global *object,
4667+ double desired, memory_order order);
4668+void __ovld atomic_store_explicit(volatile atomic_double __local *object,
4669+ double desired, memory_order order);
4670+#endif //__opencl_c_atomic_scope_device
4671+void __ovld atomic_store_explicit(volatile atomic_double __global *object,
4672+ double desired, memory_order order,
4673+ memory_scope scope);
4674+void __ovld atomic_store_explicit(volatile atomic_double __local *object,
4675+ double desired, memory_order order,
4676+ memory_scope scope);
4677+#endif // cl_khr_fp64
4678+#ifdef __opencl_c_atomic_scope_device
4679+void __ovld atomic_store_explicit(volatile atomic_long __global *object,
4680+ long desired, memory_order order);
4681+void __ovld atomic_store_explicit(volatile atomic_long __local *object,
4682+ long desired, memory_order order);
4683+void __ovld atomic_store_explicit(volatile atomic_ulong __global *object,
4684+ ulong desired, memory_order order);
4685+void __ovld atomic_store_explicit(volatile atomic_ulong __local *object,
4686+ ulong desired, memory_order order);
4687+#endif // __opencl_c_atomic_scope_device
4688+void __ovld atomic_store_explicit(volatile atomic_long __global *object,
4689+ long desired, memory_order order,
4690+ memory_scope scope);
4691+void __ovld atomic_store_explicit(volatile atomic_long __local *object,
4692+ long desired, memory_order order,
4693+ memory_scope scope);
4694+void __ovld atomic_store_explicit(volatile atomic_ulong __global *object,
4695+ ulong desired, memory_order order,
4696+ memory_scope scope);
4697+void __ovld atomic_store_explicit(volatile atomic_ulong __local *object,
4698+ ulong desired, memory_order order,
4699+ memory_scope scope);
4700+#endif // defined(cl_khr_int64_base_atomics) &&
4701+ // defined(cl_khr_int64_extended_atomics)
4702+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
4703
4704 // atomic_load()
4705-
4706+#ifdef __opencl_c_generic_address_space
4707+#if defined(__opencl_c_atomic_scope_device) && \
4708+ defined(__opencl_c_atomic_order_seq_cst)
4709 int __ovld atomic_load(volatile atomic_int *object);
4710-int __ovld atomic_load_explicit(volatile atomic_int *object, memory_order order);
4711-int __ovld atomic_load_explicit(volatile atomic_int *object, memory_order order, memory_scope scope);
4712 uint __ovld atomic_load(volatile atomic_uint *object);
4713-uint __ovld atomic_load_explicit(volatile atomic_uint *object, memory_order order);
4714-uint __ovld atomic_load_explicit(volatile atomic_uint *object, memory_order order, memory_scope scope);
4715 float __ovld atomic_load(volatile atomic_float *object);
4716-float __ovld atomic_load_explicit(volatile atomic_float *object, memory_order order);
4717-float __ovld atomic_load_explicit(volatile atomic_float *object, memory_order order, memory_scope scope);
4718 #if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
4719-#ifdef cl_khr_fp64
4720+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
4721 double __ovld atomic_load(volatile atomic_double *object);
4722-double __ovld atomic_load_explicit(volatile atomic_double *object, memory_order order);
4723-double __ovld atomic_load_explicit(volatile atomic_double *object, memory_order order, memory_scope scope);
4724-#endif //cl_khr_fp64
4725+#endif // cl_khr_fp64
4726 long __ovld atomic_load(volatile atomic_long *object);
4727-long __ovld atomic_load_explicit(volatile atomic_long *object, memory_order order);
4728-long __ovld atomic_load_explicit(volatile atomic_long *object, memory_order order, memory_scope scope);
4729 ulong __ovld atomic_load(volatile atomic_ulong *object);
4730-ulong __ovld atomic_load_explicit(volatile atomic_ulong *object, memory_order order);
4731-ulong __ovld atomic_load_explicit(volatile atomic_ulong *object, memory_order order, memory_scope scope);
4732-#endif
4733+#endif // defined(cl_khr_int64_base_atomics) &&
4734+ // defined(cl_khr_int64_extended_atomics)
4735+#endif // defined(__opencl_c_atomic_scope_device) &&
4736+ // defined(__opencl_c_atomic_order_seq_cst)
4737+#endif //__opencl_c_generic_address_space
4738+
4739+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
4740+#if defined(__opencl_c_atomic_scope_device) && \
4741+ defined(__opencl_c_atomic_order_seq_cst)
4742+int __ovld atomic_load(volatile atomic_int __global *object);
4743+int __ovld atomic_load(volatile atomic_int __local *object);
4744+uint __ovld atomic_load(volatile atomic_uint __global *object);
4745+uint __ovld atomic_load(volatile atomic_uint __local *object);
4746+float __ovld atomic_load(volatile atomic_float __global *object);
4747+float __ovld atomic_load(volatile atomic_float __local *object);
4748+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
4749+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
4750+double __ovld atomic_load(volatile atomic_double __global *object);
4751+double __ovld atomic_load(volatile atomic_double __local *object);
4752+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
4753+long __ovld atomic_load(volatile atomic_long __global *object);
4754+long __ovld atomic_load(volatile atomic_long __local *object);
4755+ulong __ovld atomic_load(volatile atomic_ulong __global *object);
4756+ulong __ovld atomic_load(volatile atomic_ulong __local *object);
4757+#endif // defined(cl_khr_int64_base_atomics) &&
4758+ // defined(cl_khr_int64_extended_atomics)
4759+#endif // defined(__opencl_c_atomic_scope_device) &&
4760+ // defined(__opencl_c_atomic_order_seq_cst)
4761+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
4762+
4763+#ifdef __opencl_c_generic_address_space
4764+#ifdef __opencl_c_atomic_scope_device
4765+int __ovld atomic_load_explicit(volatile atomic_int *object,
4766+ memory_order order);
4767+uint __ovld atomic_load_explicit(volatile atomic_uint *object,
4768+ memory_order order);
4769+float __ovld atomic_load_explicit(volatile atomic_float *object,
4770+ memory_order order);
4771+#endif // __opencl_c_atomic_scope_device
4772+int __ovld atomic_load_explicit(volatile atomic_int *object, memory_order order,
4773+ memory_scope scope);
4774+uint __ovld atomic_load_explicit(volatile atomic_uint *object,
4775+ memory_order order, memory_scope scope);
4776+float __ovld atomic_load_explicit(volatile atomic_float *object,
4777+ memory_order order, memory_scope scope);
4778+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
4779+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
4780+#ifdef __opencl_c_atomic_scope_device
4781+double __ovld atomic_load_explicit(volatile atomic_double *object,
4782+ memory_order order);
4783+#endif // __opencl_c_atomic_scope_device
4784+double __ovld atomic_load_explicit(volatile atomic_double *object,
4785+ memory_order order, memory_scope scope);
4786+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
4787+#ifdef __opencl_c_atomic_scope_device
4788+long __ovld atomic_load_explicit(volatile atomic_long *object,
4789+ memory_order order);
4790+ulong __ovld atomic_load_explicit(volatile atomic_ulong *object,
4791+ memory_order order);
4792+#endif //__opencl_c_atomic_scope_device
4793+long __ovld atomic_load_explicit(volatile atomic_long *object,
4794+ memory_order order, memory_scope scope);
4795+ulong __ovld atomic_load_explicit(volatile atomic_ulong *object,
4796+ memory_order order, memory_scope scope);
4797+#endif // defined(cl_khr_int64_base_atomics) &&
4798+ // defined(cl_khr_int64_extended_atomics)
4799+#endif // __opencl_c_generic_address_space
4800+
4801+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
4802+#ifdef __opencl_c_atomic_scope_device
4803+int __ovld atomic_load_explicit(volatile atomic_int __global *object,
4804+ memory_order order);
4805+int __ovld atomic_load_explicit(volatile atomic_int __local *object,
4806+ memory_order order);
4807+uint __ovld atomic_load_explicit(volatile atomic_uint __global *object,
4808+ memory_order order);
4809+uint __ovld atomic_load_explicit(volatile atomic_uint __local *object,
4810+ memory_order order);
4811+float __ovld atomic_load_explicit(volatile atomic_float __global *object,
4812+ memory_order order);
4813+float __ovld atomic_load_explicit(volatile atomic_float __local *object,
4814+ memory_order order);
4815+#endif // __opencl_c_atomic_scope_device
4816+int __ovld atomic_load_explicit(volatile atomic_int __global *object,
4817+ memory_order order, memory_scope scope);
4818+int __ovld atomic_load_explicit(volatile atomic_int __local *object,
4819+ memory_order order, memory_scope scope);
4820+uint __ovld atomic_load_explicit(volatile atomic_uint __global *object,
4821+ memory_order order, memory_scope scope);
4822+uint __ovld atomic_load_explicit(volatile atomic_uint __local *object,
4823+ memory_order order, memory_scope scope);
4824+float __ovld atomic_load_explicit(volatile atomic_float __global *object,
4825+ memory_order order, memory_scope scope);
4826+float __ovld atomic_load_explicit(volatile atomic_float __local *object,
4827+ memory_order order, memory_scope scope);
4828+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
4829+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
4830+#ifdef __opencl_c_atomic_scope_device
4831+double __ovld atomic_load_explicit(volatile atomic_double __global *object,
4832+ memory_order order);
4833+double __ovld atomic_load_explicit(volatile atomic_double __local *object,
4834+ memory_order order);
4835+#endif // __opencl_c_atomic_scope_device
4836+double __ovld atomic_load_explicit(volatile atomic_double __global *object,
4837+ memory_order order, memory_scope scope);
4838+double __ovld atomic_load_explicit(volatile atomic_double __local *object,
4839+ memory_order order, memory_scope scope);
4840+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
4841+#ifdef __opencl_c_atomic_scope_device
4842+long __ovld atomic_load_explicit(volatile atomic_long __global *object,
4843+ memory_order order);
4844+long __ovld atomic_load_explicit(volatile atomic_long __local *object,
4845+ memory_order order);
4846+ulong __ovld atomic_load_explicit(volatile atomic_ulong __global *object,
4847+ memory_order order);
4848+ulong __ovld atomic_load_explicit(volatile atomic_ulong __local *object,
4849+ memory_order order);
4850+#endif // __opencl_c_atomic_scope_device
4851+long __ovld atomic_load_explicit(volatile atomic_long __global *object,
4852+ memory_order order, memory_scope scope);
4853+long __ovld atomic_load_explicit(volatile atomic_long __local *object,
4854+ memory_order order, memory_scope scope);
4855+ulong __ovld atomic_load_explicit(volatile atomic_ulong __global *object,
4856+ memory_order order, memory_scope scope);
4857+ulong __ovld atomic_load_explicit(volatile atomic_ulong __local *object,
4858+ memory_order order, memory_scope scope);
4859+#endif // defined(cl_khr_int64_base_atomics) &&
4860+ // defined(cl_khr_int64_extended_atomics)
4861+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
4862
4863 // atomic_exchange()
4864-
4865+#ifdef __opencl_c_generic_address_space
4866+#if defined(__opencl_c_atomic_scope_device) && \
4867+ defined(__opencl_c_atomic_order_seq_cst)
4868 int __ovld atomic_exchange(volatile atomic_int *object, int desired);
4869-int __ovld atomic_exchange_explicit(volatile atomic_int *object, int desired, memory_order order);
4870-int __ovld atomic_exchange_explicit(volatile atomic_int *object, int desired, memory_order order, memory_scope scope);
4871 uint __ovld atomic_exchange(volatile atomic_uint *object, uint desired);
4872-uint __ovld atomic_exchange_explicit(volatile atomic_uint *object, uint desired, memory_order order);
4873-uint __ovld atomic_exchange_explicit(volatile atomic_uint *object, uint desired, memory_order order, memory_scope scope);
4874 float __ovld atomic_exchange(volatile atomic_float *object, float desired);
4875-float __ovld atomic_exchange_explicit(volatile atomic_float *object, float desired, memory_order order);
4876-float __ovld atomic_exchange_explicit(volatile atomic_float *object, float desired, memory_order order, memory_scope scope);
4877 #if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
4878-#ifdef cl_khr_fp64
4879+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
4880 double __ovld atomic_exchange(volatile atomic_double *object, double desired);
4881-double __ovld atomic_exchange_explicit(volatile atomic_double *object, double desired, memory_order order);
4882-double __ovld atomic_exchange_explicit(volatile atomic_double *object, double desired, memory_order order, memory_scope scope);
4883-#endif //cl_khr_fp64
4884+#endif
4885 long __ovld atomic_exchange(volatile atomic_long *object, long desired);
4886-long __ovld atomic_exchange_explicit(volatile atomic_long *object, long desired, memory_order order);
4887-long __ovld atomic_exchange_explicit(volatile atomic_long *object, long desired, memory_order order, memory_scope scope);
4888 ulong __ovld atomic_exchange(volatile atomic_ulong *object, ulong desired);
4889-ulong __ovld atomic_exchange_explicit(volatile atomic_ulong *object, ulong desired, memory_order order);
4890-ulong __ovld atomic_exchange_explicit(volatile atomic_ulong *object, ulong desired, memory_order order, memory_scope scope);
4891+#endif // defined(cl_khr_int64_base_atomics) &&
4892+ // defined(cl_khr_int64_extended_atomics)
4893+#endif // defined(__opencl_c_atomic_scope_device) &&
4894+ // defined(__opencl_c_atomic_order_seq_cst)
4895+#endif // __opencl_c_generic_address_space
4896+
4897+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
4898+#if defined(__opencl_c_atomic_scope_device) && \
4899+ defined(__opencl_c_atomic_order_seq_cst)
4900+int __ovld atomic_exchange(volatile atomic_int __global *object, int desired);
4901+int __ovld atomic_exchange(volatile atomic_int __local *object, int desired);
4902+uint __ovld atomic_exchange(volatile atomic_uint __global *object,
4903+ uint desired);
4904+uint __ovld atomic_exchange(volatile atomic_uint __local *object, uint desired);
4905+float __ovld atomic_exchange(volatile atomic_float __global *object,
4906+ float desired);
4907+float __ovld atomic_exchange(volatile atomic_float __local *object,
4908+ float desired);
4909+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
4910+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
4911+double __ovld atomic_exchange(volatile atomic_double __global *object,
4912+ double desired);
4913+double __ovld atomic_exchange(volatile atomic_double __local *object,
4914+ double desired);
4915 #endif
4916+long __ovld atomic_exchange(volatile atomic_long __global *object,
4917+ long desired);
4918+long __ovld atomic_exchange(volatile atomic_long __local *object, long desired);
4919+ulong __ovld atomic_exchange(volatile atomic_ulong __global *object,
4920+ ulong desired);
4921+ulong __ovld atomic_exchange(volatile atomic_ulong __local *object,
4922+ ulong desired);
4923+#endif // defined(cl_khr_int64_base_atomics) &&
4924+ // defined(cl_khr_int64_extended_atomics)
4925+#endif // defined(__opencl_c_atomic_scope_device) &&
4926+ // defined(__opencl_c_atomic_order_seq_cst)
4927+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
4928+
4929+#ifdef __opencl_c_generic_address_space
4930+#ifdef __opencl_c_atomic_scope_device
4931+int __ovld atomic_exchange_explicit(volatile atomic_int *object, int desired,
4932+ memory_order order);
4933+uint __ovld atomic_exchange_explicit(volatile atomic_uint *object, uint desired,
4934+ memory_order order);
4935+float __ovld atomic_exchange_explicit(volatile atomic_float *object,
4936+ float desired, memory_order order);
4937+#endif // __opencl_c_atomic_scope_device
4938+int __ovld atomic_exchange_explicit(volatile atomic_int *object, int desired,
4939+ memory_order order, memory_scope scope);
4940+uint __ovld atomic_exchange_explicit(volatile atomic_uint *object, uint desired,
4941+ memory_order order, memory_scope scope);
4942+float __ovld atomic_exchange_explicit(volatile atomic_float *object,
4943+ float desired, memory_order order,
4944+ memory_scope scope);
4945+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
4946+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
4947+#ifdef __opencl_c_atomic_scope_device
4948+double __ovld atomic_exchange_explicit(volatile atomic_double *object,
4949+ double desired, memory_order order);
4950+#endif // __opencl_c_atomic_scope_device
4951+double __ovld atomic_exchange_explicit(volatile atomic_double *object,
4952+ double desired, memory_order order,
4953+ memory_scope scope);
4954+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
4955+#ifdef __opencl_c_atomic_scope_device
4956+long __ovld atomic_exchange_explicit(volatile atomic_long *object, long desired,
4957+ memory_order order);
4958+ulong __ovld atomic_exchange_explicit(volatile atomic_ulong *object,
4959+ ulong desired, memory_order order);
4960+#endif // __opencl_c_atomic_scope_device
4961+long __ovld atomic_exchange_explicit(volatile atomic_long *object, long desired,
4962+ memory_order order, memory_scope scope);
4963+ulong __ovld atomic_exchange_explicit(volatile atomic_ulong *object,
4964+ ulong desired, memory_order order,
4965+ memory_scope scope);
4966+#endif // defined(cl_khr_int64_base_atomics) &&
4967+ // defined(cl_khr_int64_extended_atomics)
4968+#endif // __opencl_c_generic_address_space
4969+
4970+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
4971+#ifdef __opencl_c_atomic_scope_device
4972+int __ovld atomic_exchange_explicit(volatile atomic_int __global *object,
4973+ int desired, memory_order order);
4974+int __ovld atomic_exchange_explicit(volatile atomic_int __local *object,
4975+ int desired, memory_order order);
4976+uint __ovld atomic_exchange_explicit(volatile atomic_uint __global *object,
4977+ uint desired, memory_order order);
4978+uint __ovld atomic_exchange_explicit(volatile atomic_uint __local *object,
4979+ uint desired, memory_order order);
4980+float __ovld atomic_exchange_explicit(volatile atomic_float __global *object,
4981+ float desired, memory_order order);
4982+float __ovld atomic_exchange_explicit(volatile atomic_float __local *object,
4983+ float desired, memory_order order);
4984+#endif // __opencl_c_atomic_scope_device
4985+int __ovld atomic_exchange_explicit(volatile atomic_int __global *object,
4986+ int desired, memory_order order,
4987+ memory_scope scope);
4988+int __ovld atomic_exchange_explicit(volatile atomic_int __local *object,
4989+ int desired, memory_order order,
4990+ memory_scope scope);
4991+uint __ovld atomic_exchange_explicit(volatile atomic_uint __global *object,
4992+ uint desired, memory_order order,
4993+ memory_scope scope);
4994+uint __ovld atomic_exchange_explicit(volatile atomic_uint __local *object,
4995+ uint desired, memory_order order,
4996+ memory_scope scope);
4997+float __ovld atomic_exchange_explicit(volatile atomic_float __global *object,
4998+ float desired, memory_order order,
4999+ memory_scope scope);
5000+float __ovld atomic_exchange_explicit(volatile atomic_float __local *object,
5001+ float desired, memory_order order,
5002+ memory_scope scope);
5003+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
5004+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
5005+#ifdef __opencl_c_atomic_scope_device
5006+double __ovld atomic_exchange_explicit(volatile atomic_double __global *object,
5007+ double desired, memory_order order);
5008+double __ovld atomic_exchange_explicit(volatile atomic_double __local *object,
5009+ double desired, memory_order order);
5010+#endif // __opencl_c_atomic_scope_device
5011+double __ovld atomic_exchange_explicit(volatile atomic_double __global *object,
5012+ double desired, memory_order order,
5013+ memory_scope scope);
5014+double __ovld atomic_exchange_explicit(volatile atomic_double __local *object,
5015+ double desired, memory_order order,
5016+ memory_scope scope);
5017+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
5018+#ifdef __opencl_c_atomic_scope_device
5019+long __ovld atomic_exchange_explicit(volatile atomic_long __global *object,
5020+ long desired, memory_order order);
5021+long __ovld atomic_exchange_explicit(volatile atomic_long __local *object,
5022+ long desired, memory_order order);
5023+ulong __ovld atomic_exchange_explicit(volatile atomic_ulong __global *object,
5024+ ulong desired, memory_order order);
5025+ulong __ovld atomic_exchange_explicit(volatile atomic_ulong __local *object,
5026+ ulong desired, memory_order order);
5027+#endif // __opencl_c_atomic_scope_device
5028+long __ovld atomic_exchange_explicit(volatile atomic_long __global *object,
5029+ long desired, memory_order order,
5030+ memory_scope scope);
5031+long __ovld atomic_exchange_explicit(volatile atomic_long __local *object,
5032+ long desired, memory_order order,
5033+ memory_scope scope);
5034+ulong __ovld atomic_exchange_explicit(volatile atomic_ulong __global *object,
5035+ ulong desired, memory_order order,
5036+ memory_scope scope);
5037+ulong __ovld atomic_exchange_explicit(volatile atomic_ulong __local *object,
5038+ ulong desired, memory_order order,
5039+ memory_scope scope);
5040+#endif // defined(cl_khr_int64_base_atomics) &&
5041+ // defined(cl_khr_int64_extended_atomics)
5042+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
5043
5044 // atomic_compare_exchange_strong() and atomic_compare_exchange_weak()
5045-
5046-bool __ovld atomic_compare_exchange_strong(volatile atomic_int *object, int *expected, int desired);
5047-bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_int *object, int *expected,
5048- int desired, memory_order success, memory_order failure);
5049-bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_int *object, int *expected,
5050- int desired, memory_order success, memory_order failure, memory_scope scope);
5051-bool __ovld atomic_compare_exchange_strong(volatile atomic_uint *object, uint *expected, uint desired);
5052-bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_uint *object, uint *expected,
5053- uint desired, memory_order success, memory_order failure);
5054-bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_uint *object, uint *expected,
5055- uint desired, memory_order success, memory_order failure, memory_scope scope);
5056-bool __ovld atomic_compare_exchange_weak(volatile atomic_int *object, int *expected, int desired);
5057-bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_int *object, int *expected,
5058- int desired, memory_order success, memory_order failure);
5059-bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_int *object, int *expected,
5060- int desired, memory_order success, memory_order failure, memory_scope scope);
5061-bool __ovld atomic_compare_exchange_weak(volatile atomic_uint *object, uint *expected, uint desired);
5062-bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_uint *object, uint *expected,
5063- uint desired, memory_order success, memory_order failure);
5064-bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_uint *object, uint *expected,
5065- uint desired, memory_order success, memory_order failure, memory_scope scope);
5066-bool __ovld atomic_compare_exchange_strong(volatile atomic_float *object, float *expected, float desired);
5067-bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_float *object, float *expected,
5068- float desired, memory_order success, memory_order failure);
5069-bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_float *object, float *expected,
5070- float desired, memory_order success, memory_order failure, memory_scope scope);
5071-bool __ovld atomic_compare_exchange_weak(volatile atomic_float *object, float *expected, float desired);
5072-bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_float *object, float *expected,
5073- float desired, memory_order success, memory_order failure);
5074-bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_float *object, float *expected,
5075- float desired, memory_order success, memory_order failure, memory_scope scope);
5076+#ifdef __opencl_c_generic_address_space
5077+#if defined(__opencl_c_atomic_scope_device) && \
5078+ defined(__opencl_c_atomic_order_seq_cst)
5079+bool __ovld atomic_compare_exchange_strong(volatile atomic_int *object,
5080+ int *expected, int desired);
5081+bool __ovld atomic_compare_exchange_strong(volatile atomic_uint *object,
5082+ uint *expected, uint desired);
5083+bool __ovld atomic_compare_exchange_weak(volatile atomic_int *object,
5084+ int *expected, int desired);
5085+bool __ovld atomic_compare_exchange_weak(volatile atomic_uint *object,
5086+ uint *expected, uint desired);
5087+bool __ovld atomic_compare_exchange_strong(volatile atomic_float *object,
5088+ float *expected, float desired);
5089+bool __ovld atomic_compare_exchange_weak(volatile atomic_float *object,
5090+ float *expected, float desired);
5091+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
5092+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
5093+bool __ovld atomic_compare_exchange_strong(volatile atomic_double *object,
5094+ double *expected, double desired);
5095+bool __ovld atomic_compare_exchange_weak(volatile atomic_double *object,
5096+ double *expected, double desired);
5097+#endif
5098+bool __ovld atomic_compare_exchange_strong(volatile atomic_long *object,
5099+ long *expected, long desired);
5100+bool __ovld atomic_compare_exchange_weak(volatile atomic_long *object,
5101+ long *expected, long desired);
5102+bool __ovld atomic_compare_exchange_strong(volatile atomic_ulong *object,
5103+ ulong *expected, ulong desired);
5104+bool __ovld atomic_compare_exchange_weak(volatile atomic_ulong *object,
5105+ ulong *expected, ulong desired);
5106+#endif // defined(cl_khr_int64_base_atomics) &&
5107+ // defined(cl_khr_int64_extended_atomics)
5108+#endif // defined(__opencl_c_atomic_scope_device) &&
5109+ // defined(__opencl_c_atomic_order_seq_cst)
5110+#endif // __opencl_c_generic_address_space
5111+
5112+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
5113+#if defined(__opencl_c_atomic_scope_device) && \
5114+ defined(__opencl_c_atomic_order_seq_cst)
5115+bool __ovld atomic_compare_exchange_strong(volatile atomic_int __global *object,
5116+ int __global *expected, int desired);
5117+bool __ovld atomic_compare_exchange_strong(volatile atomic_int __local *object,
5118+ int __global *expected, int desired);
5119+bool __ovld atomic_compare_exchange_strong(volatile atomic_int __global *object,
5120+ int __local *expected, int desired);
5121+bool __ovld atomic_compare_exchange_strong(volatile atomic_int __local *object,
5122+ int __local *expected, int desired);
5123+bool __ovld atomic_compare_exchange_strong(volatile atomic_int __global *object,
5124+ int __private *expected,
5125+ int desired);
5126+bool __ovld atomic_compare_exchange_strong(volatile atomic_int __local *object,
5127+ int __private *expected,
5128+ int desired);
5129+bool __ovld
5130+atomic_compare_exchange_strong(volatile atomic_uint __global *object,
5131+ uint __global *expected, uint desired);
5132+bool __ovld atomic_compare_exchange_strong(volatile atomic_uint __local *object,
5133+ uint __global *expected,
5134+ uint desired);
5135+bool __ovld
5136+atomic_compare_exchange_strong(volatile atomic_uint __global *object,
5137+ uint __local *expected, uint desired);
5138+bool __ovld atomic_compare_exchange_strong(volatile atomic_uint __local *object,
5139+ uint __local *expected,
5140+ uint desired);
5141+bool __ovld
5142+atomic_compare_exchange_strong(volatile atomic_uint __global *object,
5143+ uint __private *expected, uint desired);
5144+bool __ovld atomic_compare_exchange_strong(volatile atomic_uint __local *object,
5145+ uint __private *expected,
5146+ uint desired);
5147+bool __ovld atomic_compare_exchange_weak(volatile atomic_int __global *object,
5148+ int __global *expected, int desired);
5149+bool __ovld atomic_compare_exchange_weak(volatile atomic_int __local *object,
5150+ int __global *expected, int desired);
5151+bool __ovld atomic_compare_exchange_weak(volatile atomic_int __global *object,
5152+ int __local *expected, int desired);
5153+bool __ovld atomic_compare_exchange_weak(volatile atomic_int __local *object,
5154+ int __local *expected, int desired);
5155+bool __ovld atomic_compare_exchange_weak(volatile atomic_int __global *object,
5156+ int __private *expected, int desired);
5157+bool __ovld atomic_compare_exchange_weak(volatile atomic_int __local *object,
5158+ int __private *expected, int desired);
5159+bool __ovld atomic_compare_exchange_weak(volatile atomic_uint __global *object,
5160+ uint __global *expected, uint desired);
5161+bool __ovld atomic_compare_exchange_weak(volatile atomic_uint __local *object,
5162+ uint __global *expected, uint desired);
5163+bool __ovld atomic_compare_exchange_weak(volatile atomic_uint __global *object,
5164+ uint __local *expected, uint desired);
5165+bool __ovld atomic_compare_exchange_weak(volatile atomic_uint __local *object,
5166+ uint __local *expected, uint desired);
5167+bool __ovld atomic_compare_exchange_weak(volatile atomic_uint __global *object,
5168+ uint __private *expected,
5169+ uint desired);
5170+bool __ovld atomic_compare_exchange_weak(volatile atomic_uint __local *object,
5171+ uint __private *expected,
5172+ uint desired);
5173+bool __ovld
5174+atomic_compare_exchange_strong(volatile atomic_float __global *object,
5175+ float __global *expected, float desired);
5176+bool __ovld
5177+atomic_compare_exchange_strong(volatile atomic_float __local *object,
5178+ float __global *expected, float desired);
5179+bool __ovld
5180+atomic_compare_exchange_strong(volatile atomic_float __global *object,
5181+ float __local *expected, float desired);
5182+bool __ovld
5183+atomic_compare_exchange_strong(volatile atomic_float __local *object,
5184+ float __local *expected, float desired);
5185+bool __ovld
5186+atomic_compare_exchange_strong(volatile atomic_float __global *object,
5187+ float __private *expected, float desired);
5188+bool __ovld
5189+atomic_compare_exchange_strong(volatile atomic_float __local *object,
5190+ float __private *expected, float desired);
5191+bool __ovld atomic_compare_exchange_weak(volatile atomic_float __global *object,
5192+ float __global *expected,
5193+ float desired);
5194+bool __ovld atomic_compare_exchange_weak(volatile atomic_float __local *object,
5195+ float __global *expected,
5196+ float desired);
5197+bool __ovld atomic_compare_exchange_weak(volatile atomic_float __global *object,
5198+ float __local *expected,
5199+ float desired);
5200+bool __ovld atomic_compare_exchange_weak(volatile atomic_float __local *object,
5201+ float __local *expected,
5202+ float desired);
5203+bool __ovld atomic_compare_exchange_weak(volatile atomic_float __global *object,
5204+ float __private *expected,
5205+ float desired);
5206+bool __ovld atomic_compare_exchange_weak(volatile atomic_float __local *object,
5207+ float __private *expected,
5208+ float desired);
5209 #if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
5210-#ifdef cl_khr_fp64
5211-bool __ovld atomic_compare_exchange_strong(volatile atomic_double *object, double *expected, double desired);
5212-bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_double *object, double *expected,
5213- double desired, memory_order success, memory_order failure);
5214-bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_double *object, double *expected,
5215- double desired, memory_order success, memory_order failure, memory_scope scope);
5216-bool __ovld atomic_compare_exchange_weak(volatile atomic_double *object, double *expected, double desired);
5217-bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_double *object, double *expected,
5218- double desired, memory_order success, memory_order failure);
5219-bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_double *object, double *expected,
5220- double desired, memory_order success, memory_order failure, memory_scope scope);
5221-#endif //cl_khr_fp64
5222-bool __ovld atomic_compare_exchange_strong(volatile atomic_long *object, long *expected, long desired);
5223-bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_long *object, long *expected,
5224- long desired, memory_order success, memory_order failure);
5225-bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_long *object, long *expected,
5226- long desired, memory_order success, memory_order failure, memory_scope scope);
5227-bool __ovld atomic_compare_exchange_weak(volatile atomic_long *object, long *expected, long desired);
5228-bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_long *object, long *expected,
5229- long desired, memory_order success, memory_order failure);
5230-bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_long *object, long *expected,
5231- long desired, memory_order success, memory_order failure, memory_scope scope);
5232-bool __ovld atomic_compare_exchange_strong(volatile atomic_ulong *object, ulong *expected, ulong desired);
5233-bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_ulong *object, ulong *expected,
5234- ulong desired, memory_order success, memory_order failure);
5235-bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_ulong *object, ulong *expected,
5236- ulong desired, memory_order success, memory_order failure, memory_scope scope);
5237-bool __ovld atomic_compare_exchange_weak(volatile atomic_ulong *object, ulong *expected, ulong desired);
5238-bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_ulong *object, ulong *expected,
5239- ulong desired, memory_order success, memory_order failure);
5240-bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_ulong *object, ulong *expected,
5241- ulong desired, memory_order success, memory_order failure, memory_scope scope);
5242+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
5243+bool __ovld
5244+atomic_compare_exchange_strong(volatile atomic_double __global *object,
5245+ double __global *expected, double desired);
5246+bool __ovld
5247+atomic_compare_exchange_strong(volatile atomic_double __local *object,
5248+ double __global *expected, double desired);
5249+bool __ovld
5250+atomic_compare_exchange_strong(volatile atomic_double __global *object,
5251+ double __local *expected, double desired);
5252+bool __ovld
5253+atomic_compare_exchange_strong(volatile atomic_double __local *object,
5254+ double __local *expected, double desired);
5255+bool __ovld
5256+atomic_compare_exchange_strong(volatile atomic_double __global *object,
5257+ double __private *expected, double desired);
5258+bool __ovld
5259+atomic_compare_exchange_strong(volatile atomic_double __local *object,
5260+ double __private *expected, double desired);
5261+bool __ovld
5262+atomic_compare_exchange_weak(volatile atomic_double __global *object,
5263+ double __global *expected, double desired);
5264+bool __ovld atomic_compare_exchange_weak(volatile atomic_double __local *object,
5265+ double __global *expected,
5266+ double desired);
5267+bool __ovld
5268+atomic_compare_exchange_weak(volatile atomic_double __global *object,
5269+ double __local *expected, double desired);
5270+bool __ovld atomic_compare_exchange_weak(volatile atomic_double __local *object,
5271+ double __local *expected,
5272+ double desired);
5273+bool __ovld
5274+atomic_compare_exchange_weak(volatile atomic_double __global *object,
5275+ double __private *expected, double desired);
5276+bool __ovld atomic_compare_exchange_weak(volatile atomic_double __local *object,
5277+ double __private *expected,
5278+ double desired);
5279 #endif
5280+bool __ovld
5281+atomic_compare_exchange_strong(volatile atomic_long __global *object,
5282+ long __global *expected, long desired);
5283+bool __ovld atomic_compare_exchange_strong(volatile atomic_long __local *object,
5284+ long __global *expected,
5285+ long desired);
5286+bool __ovld
5287+atomic_compare_exchange_strong(volatile atomic_long __global *object,
5288+ long __local *expected, long desired);
5289+bool __ovld atomic_compare_exchange_strong(volatile atomic_long __local *object,
5290+ long __local *expected,
5291+ long desired);
5292+bool __ovld
5293+atomic_compare_exchange_strong(volatile atomic_long __global *object,
5294+ long __private *expected, long desired);
5295+bool __ovld atomic_compare_exchange_strong(volatile atomic_long __local *object,
5296+ long __private *expected,
5297+ long desired);
5298+bool __ovld atomic_compare_exchange_weak(volatile atomic_long __global *object,
5299+ long __global *expected, long desired);
5300+bool __ovld atomic_compare_exchange_weak(volatile atomic_long __local *object,
5301+ long __global *expected, long desired);
5302+bool __ovld atomic_compare_exchange_weak(volatile atomic_long __global *object,
5303+ long __local *expected, long desired);
5304+bool __ovld atomic_compare_exchange_weak(volatile atomic_long __local *object,
5305+ long __local *expected, long desired);
5306+bool __ovld atomic_compare_exchange_weak(volatile atomic_long __global *object,
5307+ long __private *expected,
5308+ long desired);
5309+bool __ovld atomic_compare_exchange_weak(volatile atomic_long __local *object,
5310+ long __private *expected,
5311+ long desired);
5312+bool __ovld
5313+atomic_compare_exchange_strong(volatile atomic_ulong __global *object,
5314+ ulong __global *expected, ulong desired);
5315+bool __ovld
5316+atomic_compare_exchange_strong(volatile atomic_ulong __local *object,
5317+ ulong __global *expected, ulong desired);
5318+bool __ovld
5319+atomic_compare_exchange_strong(volatile atomic_ulong __global *object,
5320+ ulong __local *expected, ulong desired);
5321+bool __ovld
5322+atomic_compare_exchange_strong(volatile atomic_ulong __local *object,
5323+ ulong __local *expected, ulong desired);
5324+bool __ovld
5325+atomic_compare_exchange_strong(volatile atomic_ulong __global *object,
5326+ ulong __private *expected, ulong desired);
5327+bool __ovld
5328+atomic_compare_exchange_strong(volatile atomic_ulong __local *object,
5329+ ulong __private *expected, ulong desired);
5330+bool __ovld atomic_compare_exchange_weak(volatile atomic_ulong __global *object,
5331+ ulong __global *expected,
5332+ ulong desired);
5333+bool __ovld atomic_compare_exchange_weak(volatile atomic_ulong __local *object,
5334+ ulong __global *expected,
5335+ ulong desired);
5336+bool __ovld atomic_compare_exchange_weak(volatile atomic_ulong __global *object,
5337+ ulong __local *expected,
5338+ ulong desired);
5339+bool __ovld atomic_compare_exchange_weak(volatile atomic_ulong __local *object,
5340+ ulong __local *expected,
5341+ ulong desired);
5342+bool __ovld atomic_compare_exchange_weak(volatile atomic_ulong __global *object,
5343+ ulong __private *expected,
5344+ ulong desired);
5345+bool __ovld atomic_compare_exchange_weak(volatile atomic_ulong __local *object,
5346+ ulong __private *expected,
5347+ ulong desired);
5348+#endif // defined(cl_khr_int64_base_atomics) &&
5349+ // defined(cl_khr_int64_extended_atomics)
5350+#endif // defined(__opencl_c_atomic_scope_device) &&
5351+ // defined(__opencl_c_atomic_order_seq_cst)
5352+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
5353+
5354+#ifdef __opencl_c_generic_address_space
5355+#ifdef __opencl_c_atomic_scope_device
5356+bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_int *object,
5357+ int *expected, int desired,
5358+ memory_order success,
5359+ memory_order failure);
5360+bool __ovld atomic_compare_exchange_strong_explicit(
5361+ volatile atomic_uint *object, uint *expected, uint desired,
5362+ memory_order success, memory_order failure);
5363+bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_int *object,
5364+ int *expected, int desired,
5365+ memory_order success,
5366+ memory_order failure);
5367+bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_uint *object,
5368+ uint *expected, uint desired,
5369+ memory_order success,
5370+ memory_order failure);
5371+bool __ovld atomic_compare_exchange_strong_explicit(
5372+ volatile atomic_float *object, float *expected, float desired,
5373+ memory_order success, memory_order failure);
5374+bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_float *object,
5375+ float *expected,
5376+ float desired,
5377+ memory_order success,
5378+ memory_order failure);
5379+#endif // __opencl_c_atomic_scope_device
5380+bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_int *object,
5381+ int *expected, int desired,
5382+ memory_order success,
5383+ memory_order failure,
5384+ memory_scope scope);
5385+bool __ovld atomic_compare_exchange_strong_explicit(
5386+ volatile atomic_uint *object, uint *expected, uint desired,
5387+ memory_order success, memory_order failure, memory_scope scope);
5388+bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_int *object,
5389+ int *expected, int desired,
5390+ memory_order success,
5391+ memory_order failure,
5392+ memory_scope scope);
5393+bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_uint *object,
5394+ uint *expected, uint desired,
5395+ memory_order success,
5396+ memory_order failure,
5397+ memory_scope scope);
5398+bool __ovld atomic_compare_exchange_strong_explicit(
5399+ volatile atomic_float *object, float *expected, float desired,
5400+ memory_order success, memory_order failure, memory_scope scope);
5401+bool __ovld atomic_compare_exchange_weak_explicit(
5402+ volatile atomic_float *object, float *expected, float desired,
5403+ memory_order success, memory_order failure, memory_scope scope);
5404+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
5405+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
5406+#ifdef __opencl_c_atomic_scope_device
5407+bool __ovld atomic_compare_exchange_strong_explicit(
5408+ volatile atomic_double *object, double *expected, double desired,
5409+ memory_order success, memory_order failure);
5410+bool __ovld atomic_compare_exchange_weak_explicit(
5411+ volatile atomic_double *object, double *expected, double desired,
5412+ memory_order success, memory_order failure);
5413+#endif // __opencl_c_atomic_scope_device
5414+bool __ovld atomic_compare_exchange_strong_explicit(
5415+ volatile atomic_double *object, double *expected, double desired,
5416+ memory_order success, memory_order failure, memory_scope scope);
5417+bool __ovld atomic_compare_exchange_weak_explicit(
5418+ volatile atomic_double *object, double *expected, double desired,
5419+ memory_order success, memory_order failure, memory_scope scope);
5420+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
5421+#ifdef __opencl_c_atomic_scope_device
5422+bool __ovld atomic_compare_exchange_strong_explicit(
5423+ volatile atomic_long *object, long *expected, long desired,
5424+ memory_order success, memory_order failure);
5425+bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_long *object,
5426+ long *expected, long desired,
5427+ memory_order success,
5428+ memory_order failure);
5429+bool __ovld atomic_compare_exchange_strong_explicit(
5430+ volatile atomic_ulong *object, ulong *expected, ulong desired,
5431+ memory_order success, memory_order failure);
5432+bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_ulong *object,
5433+ ulong *expected,
5434+ ulong desired,
5435+ memory_order success,
5436+ memory_order failure);
5437+#endif // __opencl_c_atomic_scope_device
5438+bool __ovld atomic_compare_exchange_strong_explicit(
5439+ volatile atomic_long *object, long *expected, long desired,
5440+ memory_order success, memory_order failure, memory_scope scope);
5441+bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_long *object,
5442+ long *expected, long desired,
5443+ memory_order success,
5444+ memory_order failure,
5445+ memory_scope scope);
5446+bool __ovld atomic_compare_exchange_strong_explicit(
5447+ volatile atomic_ulong *object, ulong *expected, ulong desired,
5448+ memory_order success, memory_order failure, memory_scope scope);
5449+bool __ovld atomic_compare_exchange_weak_explicit(
5450+ volatile atomic_ulong *object, ulong *expected, ulong desired,
5451+ memory_order success, memory_order failure, memory_scope scope);
5452+#endif // defined(cl_khr_int64_base_atomics) &&
5453+ // defined(cl_khr_int64_extended_atomics)
5454+#endif // __opencl_c_generic_address_space
5455+
5456+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
5457+#ifdef __opencl_c_atomic_scope_device
5458+bool __ovld atomic_compare_exchange_strong_explicit(
5459+ volatile atomic_int __global *object, int __global *expected, int desired,
5460+ memory_order success, memory_order failure);
5461+bool __ovld atomic_compare_exchange_strong_explicit(
5462+ volatile atomic_int __local *object, int __global *expected, int desired,
5463+ memory_order success, memory_order failure);
5464+bool __ovld atomic_compare_exchange_strong_explicit(
5465+ volatile atomic_int __global *object, int __local *expected, int desired,
5466+ memory_order success, memory_order failure);
5467+bool __ovld atomic_compare_exchange_strong_explicit(
5468+ volatile atomic_int __local *object, int __local *expected, int desired,
5469+ memory_order success, memory_order failure);
5470+bool __ovld atomic_compare_exchange_strong_explicit(
5471+ volatile atomic_int __global *object, int __private *expected, int desired,
5472+ memory_order success, memory_order failure);
5473+bool __ovld atomic_compare_exchange_strong_explicit(
5474+ volatile atomic_int __local *object, int __private *expected, int desired,
5475+ memory_order success, memory_order failure);
5476+bool __ovld atomic_compare_exchange_strong_explicit(
5477+ volatile atomic_uint __global *object, uint __global *expected,
5478+ uint desired, memory_order success, memory_order failure);
5479+bool __ovld atomic_compare_exchange_strong_explicit(
5480+ volatile atomic_uint __local *object, uint __global *expected, uint desired,
5481+ memory_order success, memory_order failure);
5482+bool __ovld atomic_compare_exchange_strong_explicit(
5483+ volatile atomic_uint __global *object, uint __local *expected, uint desired,
5484+ memory_order success, memory_order failure);
5485+bool __ovld atomic_compare_exchange_strong_explicit(
5486+ volatile atomic_uint __local *object, uint __local *expected, uint desired,
5487+ memory_order success, memory_order failure);
5488+bool __ovld atomic_compare_exchange_strong_explicit(
5489+ volatile atomic_uint __global *object, uint __private *expected,
5490+ uint desired, memory_order success, memory_order failure);
5491+bool __ovld atomic_compare_exchange_strong_explicit(
5492+ volatile atomic_uint __local *object, uint __private *expected,
5493+ uint desired, memory_order success, memory_order failure);
5494+bool __ovld atomic_compare_exchange_weak_explicit(
5495+ volatile atomic_int __global *object, int __global *expected, int desired,
5496+ memory_order success, memory_order failure);
5497+bool __ovld atomic_compare_exchange_weak_explicit(
5498+ volatile atomic_int __local *object, int __global *expected, int desired,
5499+ memory_order success, memory_order failure);
5500+bool __ovld atomic_compare_exchange_weak_explicit(
5501+ volatile atomic_int __global *object, int __local *expected, int desired,
5502+ memory_order success, memory_order failure);
5503+bool __ovld atomic_compare_exchange_weak_explicit(
5504+ volatile atomic_int __local *object, int __local *expected, int desired,
5505+ memory_order success, memory_order failure);
5506+bool __ovld atomic_compare_exchange_weak_explicit(
5507+ volatile atomic_int __global *object, int __private *expected, int desired,
5508+ memory_order success, memory_order failure);
5509+bool __ovld atomic_compare_exchange_weak_explicit(
5510+ volatile atomic_int __local *object, int __private *expected, int desired,
5511+ memory_order success, memory_order failure);
5512+bool __ovld atomic_compare_exchange_weak_explicit(
5513+ volatile atomic_uint __global *object, uint __global *expected,
5514+ uint desired, memory_order success, memory_order failure);
5515+bool __ovld atomic_compare_exchange_weak_explicit(
5516+ volatile atomic_uint __local *object, uint __global *expected, uint desired,
5517+ memory_order success, memory_order failure);
5518+bool __ovld atomic_compare_exchange_weak_explicit(
5519+ volatile atomic_uint __global *object, uint __local *expected, uint desired,
5520+ memory_order success, memory_order failure);
5521+bool __ovld atomic_compare_exchange_weak_explicit(
5522+ volatile atomic_uint __local *object, uint __local *expected, uint desired,
5523+ memory_order success, memory_order failure);
5524+bool __ovld atomic_compare_exchange_weak_explicit(
5525+ volatile atomic_uint __global *object, uint __private *expected,
5526+ uint desired, memory_order success, memory_order failure);
5527+bool __ovld atomic_compare_exchange_weak_explicit(
5528+ volatile atomic_uint __local *object, uint __private *expected,
5529+ uint desired, memory_order success, memory_order failure);
5530+bool __ovld atomic_compare_exchange_strong_explicit(
5531+ volatile atomic_float __global *object, float __global *expected,
5532+ float desired, memory_order success, memory_order failure);
5533+bool __ovld atomic_compare_exchange_strong_explicit(
5534+ volatile atomic_float __local *object, float __global *expected,
5535+ float desired, memory_order success, memory_order failure);
5536+bool __ovld atomic_compare_exchange_strong_explicit(
5537+ volatile atomic_float __global *object, float __local *expected,
5538+ float desired, memory_order success, memory_order failure);
5539+bool __ovld atomic_compare_exchange_strong_explicit(
5540+ volatile atomic_float __local *object, float __local *expected,
5541+ float desired, memory_order success, memory_order failure);
5542+bool __ovld atomic_compare_exchange_strong_explicit(
5543+ volatile atomic_float __global *object, float __private *expected,
5544+ float desired, memory_order success, memory_order failure);
5545+bool __ovld atomic_compare_exchange_strong_explicit(
5546+ volatile atomic_float __local *object, float __private *expected,
5547+ float desired, memory_order success, memory_order failure);
5548+bool __ovld atomic_compare_exchange_weak_explicit(
5549+ volatile atomic_float __global *object, float __global *expected,
5550+ float desired, memory_order success, memory_order failure);
5551+bool __ovld atomic_compare_exchange_weak_explicit(
5552+ volatile atomic_float __local *object, float __global *expected,
5553+ float desired, memory_order success, memory_order failure);
5554+bool __ovld atomic_compare_exchange_weak_explicit(
5555+ volatile atomic_float __global *object, float __local *expected,
5556+ float desired, memory_order success, memory_order failure);
5557+bool __ovld atomic_compare_exchange_weak_explicit(
5558+ volatile atomic_float __local *object, float __local *expected,
5559+ float desired, memory_order success, memory_order failure);
5560+bool __ovld atomic_compare_exchange_weak_explicit(
5561+ volatile atomic_float __global *object, float __private *expected,
5562+ float desired, memory_order success, memory_order failure);
5563+bool __ovld atomic_compare_exchange_weak_explicit(
5564+ volatile atomic_float __local *object, float __private *expected,
5565+ float desired, memory_order success, memory_order failure);
5566+#endif // __opencl_c_atomic_scope_device
5567+bool __ovld atomic_compare_exchange_strong_explicit(
5568+ volatile atomic_int __global *object, int __global *expected, int desired,
5569+ memory_order success, memory_order failure, memory_scope scope);
5570+bool __ovld atomic_compare_exchange_strong_explicit(
5571+ volatile atomic_int __local *object, int __global *expected, int desired,
5572+ memory_order success, memory_order failure, memory_scope scope);
5573+bool __ovld atomic_compare_exchange_strong_explicit(
5574+ volatile atomic_int __global *object, int __local *expected, int desired,
5575+ memory_order success, memory_order failure, memory_scope scope);
5576+bool __ovld atomic_compare_exchange_strong_explicit(
5577+ volatile atomic_int __local *object, int __local *expected, int desired,
5578+ memory_order success, memory_order failure, memory_scope scope);
5579+bool __ovld atomic_compare_exchange_strong_explicit(
5580+ volatile atomic_int __global *object, int __private *expected, int desired,
5581+ memory_order success, memory_order failure, memory_scope scope);
5582+bool __ovld atomic_compare_exchange_strong_explicit(
5583+ volatile atomic_int __local *object, int __private *expected, int desired,
5584+ memory_order success, memory_order failure, memory_scope scope);
5585+bool __ovld atomic_compare_exchange_strong_explicit(
5586+ volatile atomic_uint __global *object, uint __global *expected,
5587+ uint desired, memory_order success, memory_order failure,
5588+ memory_scope scope);
5589+bool __ovld atomic_compare_exchange_strong_explicit(
5590+ volatile atomic_uint __local *object, uint __global *expected, uint desired,
5591+ memory_order success, memory_order failure, memory_scope scope);
5592+bool __ovld atomic_compare_exchange_strong_explicit(
5593+ volatile atomic_uint __global *object, uint __local *expected, uint desired,
5594+ memory_order success, memory_order failure, memory_scope scope);
5595+bool __ovld atomic_compare_exchange_strong_explicit(
5596+ volatile atomic_uint __local *object, uint __local *expected, uint desired,
5597+ memory_order success, memory_order failure, memory_scope scope);
5598+bool __ovld atomic_compare_exchange_strong_explicit(
5599+ volatile atomic_uint __global *object, uint __private *expected,
5600+ uint desired, memory_order success, memory_order failure,
5601+ memory_scope scope);
5602+bool __ovld atomic_compare_exchange_strong_explicit(
5603+ volatile atomic_uint __local *object, uint __private *expected,
5604+ uint desired, memory_order success, memory_order failure,
5605+ memory_scope scope);
5606+bool __ovld atomic_compare_exchange_weak_explicit(
5607+ volatile atomic_int __global *object, int __global *expected, int desired,
5608+ memory_order success, memory_order failure, memory_scope scope);
5609+bool __ovld atomic_compare_exchange_weak_explicit(
5610+ volatile atomic_int __local *object, int __global *expected, int desired,
5611+ memory_order success, memory_order failure, memory_scope scope);
5612+bool __ovld atomic_compare_exchange_weak_explicit(
5613+ volatile atomic_int __global *object, int __local *expected, int desired,
5614+ memory_order success, memory_order failure, memory_scope scope);
5615+bool __ovld atomic_compare_exchange_weak_explicit(
5616+ volatile atomic_int __local *object, int __local *expected, int desired,
5617+ memory_order success, memory_order failure, memory_scope scope);
5618+bool __ovld atomic_compare_exchange_weak_explicit(
5619+ volatile atomic_int __global *object, int __private *expected, int desired,
5620+ memory_order success, memory_order failure, memory_scope scope);
5621+bool __ovld atomic_compare_exchange_weak_explicit(
5622+ volatile atomic_int __local *object, int __private *expected, int desired,
5623+ memory_order success, memory_order failure, memory_scope scope);
5624+bool __ovld atomic_compare_exchange_weak_explicit(
5625+ volatile atomic_uint __global *object, uint __global *expected,
5626+ uint desired, memory_order success, memory_order failure,
5627+ memory_scope scope);
5628+bool __ovld atomic_compare_exchange_weak_explicit(
5629+ volatile atomic_uint __local *object, uint __global *expected, uint desired,
5630+ memory_order success, memory_order failure, memory_scope scope);
5631+bool __ovld atomic_compare_exchange_weak_explicit(
5632+ volatile atomic_uint __global *object, uint __local *expected, uint desired,
5633+ memory_order success, memory_order failure, memory_scope scope);
5634+bool __ovld atomic_compare_exchange_weak_explicit(
5635+ volatile atomic_uint __local *object, uint __local *expected, uint desired,
5636+ memory_order success, memory_order failure, memory_scope scope);
5637+bool __ovld atomic_compare_exchange_weak_explicit(
5638+ volatile atomic_uint __global *object, uint __private *expected,
5639+ uint desired, memory_order success, memory_order failure,
5640+ memory_scope scope);
5641+bool __ovld atomic_compare_exchange_weak_explicit(
5642+ volatile atomic_uint __local *object, uint __private *expected,
5643+ uint desired, memory_order success, memory_order failure,
5644+ memory_scope scope);
5645+bool __ovld atomic_compare_exchange_strong_explicit(
5646+ volatile atomic_float __global *object, float __global *expected,
5647+ float desired, memory_order success, memory_order failure,
5648+ memory_scope scope);
5649+bool __ovld atomic_compare_exchange_strong_explicit(
5650+ volatile atomic_float __local *object, float __global *expected,
5651+ float desired, memory_order success, memory_order failure,
5652+ memory_scope scope);
5653+bool __ovld atomic_compare_exchange_strong_explicit(
5654+ volatile atomic_float __global *object, float __local *expected,
5655+ float desired, memory_order success, memory_order failure,
5656+ memory_scope scope);
5657+bool __ovld atomic_compare_exchange_strong_explicit(
5658+ volatile atomic_float __local *object, float __local *expected,
5659+ float desired, memory_order success, memory_order failure,
5660+ memory_scope scope);
5661+bool __ovld atomic_compare_exchange_strong_explicit(
5662+ volatile atomic_float __global *object, float __private *expected,
5663+ float desired, memory_order success, memory_order failure,
5664+ memory_scope scope);
5665+bool __ovld atomic_compare_exchange_strong_explicit(
5666+ volatile atomic_float __local *object, float __private *expected,
5667+ float desired, memory_order success, memory_order failure,
5668+ memory_scope scope);
5669+bool __ovld atomic_compare_exchange_weak_explicit(
5670+ volatile atomic_float __global *object, float __global *expected,
5671+ float desired, memory_order success, memory_order failure,
5672+ memory_scope scope);
5673+bool __ovld atomic_compare_exchange_weak_explicit(
5674+ volatile atomic_float __local *object, float __global *expected,
5675+ float desired, memory_order success, memory_order failure,
5676+ memory_scope scope);
5677+bool __ovld atomic_compare_exchange_weak_explicit(
5678+ volatile atomic_float __global *object, float __local *expected,
5679+ float desired, memory_order success, memory_order failure,
5680+ memory_scope scope);
5681+bool __ovld atomic_compare_exchange_weak_explicit(
5682+ volatile atomic_float __local *object, float __local *expected,
5683+ float desired, memory_order success, memory_order failure,
5684+ memory_scope scope);
5685+bool __ovld atomic_compare_exchange_weak_explicit(
5686+ volatile atomic_float __global *object, float __private *expected,
5687+ float desired, memory_order success, memory_order failure,
5688+ memory_scope scope);
5689+bool __ovld atomic_compare_exchange_weak_explicit(
5690+ volatile atomic_float __local *object, float __private *expected,
5691+ float desired, memory_order success, memory_order failure,
5692+ memory_scope scope);
5693+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
5694+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
5695+#ifdef __opencl_c_atomic_scope_device
5696+bool __ovld atomic_compare_exchange_strong_explicit(
5697+ volatile atomic_double __global *object, double __global *expected,
5698+ double desired, memory_order success, memory_order failure);
5699+bool __ovld atomic_compare_exchange_strong_explicit(
5700+ volatile atomic_double __local *object, double __global *expected,
5701+ double desired, memory_order success, memory_order failure);
5702+bool __ovld atomic_compare_exchange_strong_explicit(
5703+ volatile atomic_double __global *object, double __local *expected,
5704+ double desired, memory_order success, memory_order failure);
5705+bool __ovld atomic_compare_exchange_strong_explicit(
5706+ volatile atomic_double __local *object, double __local *expected,
5707+ double desired, memory_order success, memory_order failure);
5708+bool __ovld atomic_compare_exchange_strong_explicit(
5709+ volatile atomic_double __global *object, double __private *expected,
5710+ double desired, memory_order success, memory_order failure);
5711+bool __ovld atomic_compare_exchange_strong_explicit(
5712+ volatile atomic_double __local *object, double __private *expected,
5713+ double desired, memory_order success, memory_order failure);
5714+bool __ovld atomic_compare_exchange_weak_explicit(
5715+ volatile atomic_double __global *object, double __global *expected,
5716+ double desired, memory_order success, memory_order failure);
5717+bool __ovld atomic_compare_exchange_weak_explicit(
5718+ volatile atomic_double __local *object, double __global *expected,
5719+ double desired, memory_order success, memory_order failure);
5720+bool __ovld atomic_compare_exchange_weak_explicit(
5721+ volatile atomic_double __global *object, double __local *expected,
5722+ double desired, memory_order success, memory_order failure);
5723+bool __ovld atomic_compare_exchange_weak_explicit(
5724+ volatile atomic_double __local *object, double __local *expected,
5725+ double desired, memory_order success, memory_order failure);
5726+bool __ovld atomic_compare_exchange_weak_explicit(
5727+ volatile atomic_double __global *object, double __private *expected,
5728+ double desired, memory_order success, memory_order failure);
5729+bool __ovld atomic_compare_exchange_weak_explicit(
5730+ volatile atomic_double __local *object, double __private *expected,
5731+ double desired, memory_order success, memory_order failure);
5732+#endif // __opencl_c_atomic_scope_device
5733+bool __ovld atomic_compare_exchange_strong_explicit(
5734+ volatile atomic_double __global *object, double __global *expected,
5735+ double desired, memory_order success, memory_order failure,
5736+ memory_scope scope);
5737+bool __ovld atomic_compare_exchange_strong_explicit(
5738+ volatile atomic_double __local *object, double __global *expected,
5739+ double desired, memory_order success, memory_order failure,
5740+ memory_scope scope);
5741+bool __ovld atomic_compare_exchange_strong_explicit(
5742+ volatile atomic_double __global *object, double __local *expected,
5743+ double desired, memory_order success, memory_order failure,
5744+ memory_scope scope);
5745+bool __ovld atomic_compare_exchange_strong_explicit(
5746+ volatile atomic_double __local *object, double __local *expected,
5747+ double desired, memory_order success, memory_order failure,
5748+ memory_scope scope);
5749+bool __ovld atomic_compare_exchange_strong_explicit(
5750+ volatile atomic_double __global *object, double __private *expected,
5751+ double desired, memory_order success, memory_order failure,
5752+ memory_scope scope);
5753+bool __ovld atomic_compare_exchange_strong_explicit(
5754+ volatile atomic_double __local *object, double __private *expected,
5755+ double desired, memory_order success, memory_order failure,
5756+ memory_scope scope);
5757+bool __ovld atomic_compare_exchange_weak_explicit(
5758+ volatile atomic_double __global *object, double __global *expected,
5759+ double desired, memory_order success, memory_order failure,
5760+ memory_scope scope);
5761+bool __ovld atomic_compare_exchange_weak_explicit(
5762+ volatile atomic_double __local *object, double __global *expected,
5763+ double desired, memory_order success, memory_order failure,
5764+ memory_scope scope);
5765+bool __ovld atomic_compare_exchange_weak_explicit(
5766+ volatile atomic_double __global *object, double __local *expected,
5767+ double desired, memory_order success, memory_order failure,
5768+ memory_scope scope);
5769+bool __ovld atomic_compare_exchange_weak_explicit(
5770+ volatile atomic_double __local *object, double __local *expected,
5771+ double desired, memory_order success, memory_order failure,
5772+ memory_scope scope);
5773+bool __ovld atomic_compare_exchange_weak_explicit(
5774+ volatile atomic_double __global *object, double __private *expected,
5775+ double desired, memory_order success, memory_order failure,
5776+ memory_scope scope);
5777+bool __ovld atomic_compare_exchange_weak_explicit(
5778+ volatile atomic_double __local *object, double __private *expected,
5779+ double desired, memory_order success, memory_order failure,
5780+ memory_scope scope);
5781+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
5782+#ifdef __opencl_c_atomic_scope_device
5783+bool __ovld atomic_compare_exchange_strong_explicit(
5784+ volatile atomic_long __global *object, long __global *expected,
5785+ long desired, memory_order success, memory_order failure);
5786+bool __ovld atomic_compare_exchange_strong_explicit(
5787+ volatile atomic_long __local *object, long __global *expected, long desired,
5788+ memory_order success, memory_order failure);
5789+bool __ovld atomic_compare_exchange_strong_explicit(
5790+ volatile atomic_long __global *object, long __local *expected, long desired,
5791+ memory_order success, memory_order failure);
5792+bool __ovld atomic_compare_exchange_strong_explicit(
5793+ volatile atomic_long __local *object, long __local *expected, long desired,
5794+ memory_order success, memory_order failure);
5795+bool __ovld atomic_compare_exchange_strong_explicit(
5796+ volatile atomic_long __global *object, long __private *expected,
5797+ long desired, memory_order success, memory_order failure);
5798+bool __ovld atomic_compare_exchange_strong_explicit(
5799+ volatile atomic_long __local *object, long __private *expected,
5800+ long desired, memory_order success, memory_order failure);
5801+bool __ovld atomic_compare_exchange_weak_explicit(
5802+ volatile atomic_long __global *object, long __global *expected,
5803+ long desired, memory_order success, memory_order failure);
5804+bool __ovld atomic_compare_exchange_weak_explicit(
5805+ volatile atomic_long __local *object, long __global *expected, long desired,
5806+ memory_order success, memory_order failure);
5807+bool __ovld atomic_compare_exchange_weak_explicit(
5808+ volatile atomic_long __global *object, long __local *expected, long desired,
5809+ memory_order success, memory_order failure);
5810+bool __ovld atomic_compare_exchange_weak_explicit(
5811+ volatile atomic_long __local *object, long __local *expected, long desired,
5812+ memory_order success, memory_order failure);
5813+bool __ovld atomic_compare_exchange_weak_explicit(
5814+ volatile atomic_long __global *object, long __private *expected,
5815+ long desired, memory_order success, memory_order failure);
5816+bool __ovld atomic_compare_exchange_weak_explicit(
5817+ volatile atomic_long __local *object, long __private *expected,
5818+ long desired, memory_order success, memory_order failure);
5819+bool __ovld atomic_compare_exchange_strong_explicit(
5820+ volatile atomic_ulong __global *object, ulong __global *expected,
5821+ ulong desired, memory_order success, memory_order failure);
5822+bool __ovld atomic_compare_exchange_strong_explicit(
5823+ volatile atomic_ulong __local *object, ulong __global *expected,
5824+ ulong desired, memory_order success, memory_order failure);
5825+bool __ovld atomic_compare_exchange_strong_explicit(
5826+ volatile atomic_ulong __global *object, ulong __local *expected,
5827+ ulong desired, memory_order success, memory_order failure);
5828+bool __ovld atomic_compare_exchange_strong_explicit(
5829+ volatile atomic_ulong __local *object, ulong __local *expected,
5830+ ulong desired, memory_order success, memory_order failure);
5831+bool __ovld atomic_compare_exchange_strong_explicit(
5832+ volatile atomic_ulong __global *object, ulong __private *expected,
5833+ ulong desired, memory_order success, memory_order failure);
5834+bool __ovld atomic_compare_exchange_strong_explicit(
5835+ volatile atomic_ulong __local *object, ulong __private *expected,
5836+ ulong desired, memory_order success, memory_order failure);
5837+bool __ovld atomic_compare_exchange_weak_explicit(
5838+ volatile atomic_ulong __global *object, ulong __global *expected,
5839+ ulong desired, memory_order success, memory_order failure);
5840+bool __ovld atomic_compare_exchange_weak_explicit(
5841+ volatile atomic_ulong __local *object, ulong __global *expected,
5842+ ulong desired, memory_order success, memory_order failure);
5843+bool __ovld atomic_compare_exchange_weak_explicit(
5844+ volatile atomic_ulong __global *object, ulong __local *expected,
5845+ ulong desired, memory_order success, memory_order failure);
5846+bool __ovld atomic_compare_exchange_weak_explicit(
5847+ volatile atomic_ulong __local *object, ulong __local *expected,
5848+ ulong desired, memory_order success, memory_order failure);
5849+bool __ovld atomic_compare_exchange_weak_explicit(
5850+ volatile atomic_ulong __global *object, ulong __private *expected,
5851+ ulong desired, memory_order success, memory_order failure);
5852+bool __ovld atomic_compare_exchange_weak_explicit(
5853+ volatile atomic_ulong __local *object, ulong __private *expected,
5854+ ulong desired, memory_order success, memory_order failure);
5855+#endif // __opencl_c_atomic_scope_device
5856+bool __ovld atomic_compare_exchange_strong_explicit(
5857+ volatile atomic_long __global *object, long __global *expected,
5858+ long desired, memory_order success, memory_order failure,
5859+ memory_scope scope);
5860+bool __ovld atomic_compare_exchange_strong_explicit(
5861+ volatile atomic_long __local *object, long __global *expected, long desired,
5862+ memory_order success, memory_order failure, memory_scope scope);
5863+bool __ovld atomic_compare_exchange_strong_explicit(
5864+ volatile atomic_long __global *object, long __local *expected, long desired,
5865+ memory_order success, memory_order failure, memory_scope scope);
5866+bool __ovld atomic_compare_exchange_strong_explicit(
5867+ volatile atomic_long __local *object, long __local *expected, long desired,
5868+ memory_order success, memory_order failure, memory_scope scope);
5869+bool __ovld atomic_compare_exchange_strong_explicit(
5870+ volatile atomic_long __global *object, long __private *expected,
5871+ long desired, memory_order success, memory_order failure,
5872+ memory_scope scope);
5873+bool __ovld atomic_compare_exchange_strong_explicit(
5874+ volatile atomic_long __local *object, long __private *expected,
5875+ long desired, memory_order success, memory_order failure,
5876+ memory_scope scope);
5877+bool __ovld atomic_compare_exchange_weak_explicit(
5878+ volatile atomic_long __global *object, long __global *expected,
5879+ long desired, memory_order success, memory_order failure,
5880+ memory_scope scope);
5881+bool __ovld atomic_compare_exchange_weak_explicit(
5882+ volatile atomic_long __local *object, long __global *expected, long desired,
5883+ memory_order success, memory_order failure, memory_scope scope);
5884+bool __ovld atomic_compare_exchange_weak_explicit(
5885+ volatile atomic_long __global *object, long __local *expected, long desired,
5886+ memory_order success, memory_order failure, memory_scope scope);
5887+bool __ovld atomic_compare_exchange_weak_explicit(
5888+ volatile atomic_long __local *object, long __local *expected, long desired,
5889+ memory_order success, memory_order failure, memory_scope scope);
5890+bool __ovld atomic_compare_exchange_weak_explicit(
5891+ volatile atomic_long __global *object, long __private *expected,
5892+ long desired, memory_order success, memory_order failure,
5893+ memory_scope scope);
5894+bool __ovld atomic_compare_exchange_weak_explicit(
5895+ volatile atomic_long __local *object, long __private *expected,
5896+ long desired, memory_order success, memory_order failure,
5897+ memory_scope scope);
5898+bool __ovld atomic_compare_exchange_strong_explicit(
5899+ volatile atomic_ulong __global *object, ulong __global *expected,
5900+ ulong desired, memory_order success, memory_order failure,
5901+ memory_scope scope);
5902+bool __ovld atomic_compare_exchange_strong_explicit(
5903+ volatile atomic_ulong __local *object, ulong __global *expected,
5904+ ulong desired, memory_order success, memory_order failure,
5905+ memory_scope scope);
5906+bool __ovld atomic_compare_exchange_strong_explicit(
5907+ volatile atomic_ulong __global *object, ulong __local *expected,
5908+ ulong desired, memory_order success, memory_order failure,
5909+ memory_scope scope);
5910+bool __ovld atomic_compare_exchange_strong_explicit(
5911+ volatile atomic_ulong __local *object, ulong __local *expected,
5912+ ulong desired, memory_order success, memory_order failure,
5913+ memory_scope scope);
5914+bool __ovld atomic_compare_exchange_strong_explicit(
5915+ volatile atomic_ulong __global *object, ulong __private *expected,
5916+ ulong desired, memory_order success, memory_order failure,
5917+ memory_scope scope);
5918+bool __ovld atomic_compare_exchange_strong_explicit(
5919+ volatile atomic_ulong __local *object, ulong __private *expected,
5920+ ulong desired, memory_order success, memory_order failure,
5921+ memory_scope scope);
5922+bool __ovld atomic_compare_exchange_weak_explicit(
5923+ volatile atomic_ulong __global *object, ulong __global *expected,
5924+ ulong desired, memory_order success, memory_order failure,
5925+ memory_scope scope);
5926+bool __ovld atomic_compare_exchange_weak_explicit(
5927+ volatile atomic_ulong __local *object, ulong __global *expected,
5928+ ulong desired, memory_order success, memory_order failure,
5929+ memory_scope scope);
5930+bool __ovld atomic_compare_exchange_weak_explicit(
5931+ volatile atomic_ulong __global *object, ulong __local *expected,
5932+ ulong desired, memory_order success, memory_order failure,
5933+ memory_scope scope);
5934+bool __ovld atomic_compare_exchange_weak_explicit(
5935+ volatile atomic_ulong __local *object, ulong __local *expected,
5936+ ulong desired, memory_order success, memory_order failure,
5937+ memory_scope scope);
5938+bool __ovld atomic_compare_exchange_weak_explicit(
5939+ volatile atomic_ulong __global *object, ulong __private *expected,
5940+ ulong desired, memory_order success, memory_order failure,
5941+ memory_scope scope);
5942+bool __ovld atomic_compare_exchange_weak_explicit(
5943+ volatile atomic_ulong __local *object, ulong __private *expected,
5944+ ulong desired, memory_order success, memory_order failure,
5945+ memory_scope scope);
5946+#endif // defined(cl_khr_int64_base_atomics) &&
5947+ // defined(cl_khr_int64_extended_atomics)
5948+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
5949
5950 // atomic_flag_test_and_set() and atomic_flag_clear()
5951-
5952+#if defined(__opencl_c_atomic_scope_device) && \
5953+ defined(__opencl_c_atomic_order_seq_cst)
5954+#ifdef __opencl_c_generic_address_space
5955 bool __ovld atomic_flag_test_and_set(volatile atomic_flag *object);
5956-bool __ovld atomic_flag_test_and_set_explicit(volatile atomic_flag *object, memory_order order);
5957-bool __ovld atomic_flag_test_and_set_explicit(volatile atomic_flag *object, memory_order order, memory_scope scope);
5958 void __ovld atomic_flag_clear(volatile atomic_flag *object);
5959-void __ovld atomic_flag_clear_explicit(volatile atomic_flag *object, memory_order order);
5960-void __ovld atomic_flag_clear_explicit(volatile atomic_flag *object, memory_order order, memory_scope scope);
5961+#endif // __opencl_c_generic_address_space
5962+
5963+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
5964+bool __ovld atomic_flag_test_and_set(volatile atomic_flag __global *object);
5965+bool __ovld atomic_flag_test_and_set(volatile atomic_flag __local *object);
5966+void __ovld atomic_flag_clear(volatile atomic_flag __global *object);
5967+void __ovld atomic_flag_clear(volatile atomic_flag __local *object);
5968+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
5969+#endif // defined(__opencl_c_atomic_scope_device) &&
5970+ // defined(__opencl_c_atomic_order_seq_cst)
5971+
5972+#ifdef __opencl_c_generic_address_space
5973+#ifdef __opencl_c_atomic_scope_device
5974+bool __ovld atomic_flag_test_and_set_explicit(volatile atomic_flag *object,
5975+ memory_order order);
5976+void __ovld atomic_flag_clear_explicit(volatile atomic_flag *object,
5977+ memory_order order);
5978+#endif // __opencl_c_atomic_scope_device
5979+bool __ovld atomic_flag_test_and_set_explicit(volatile atomic_flag *object,
5980+ memory_order order,
5981+ memory_scope scope);
5982+void __ovld atomic_flag_clear_explicit(volatile atomic_flag *object,
5983+ memory_order order, memory_scope scope);
5984+#endif // __opencl_c_generic_address_space
5985+
5986+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
5987+#ifdef __opencl_c_atomic_scope_device
5988+bool __ovld atomic_flag_test_and_set_explicit(
5989+ volatile atomic_flag __global *object, memory_order order);
5990+bool __ovld atomic_flag_test_and_set_explicit(
5991+ volatile atomic_flag __local *object, memory_order order);
5992+void __ovld atomic_flag_clear_explicit(volatile atomic_flag __global *object,
5993+ memory_order order);
5994+void __ovld atomic_flag_clear_explicit(volatile atomic_flag __local *object,
5995+ memory_order order);
5996+#endif // __opencl_c_atomic_scope_device
5997+bool __ovld
5998+atomic_flag_test_and_set_explicit(volatile atomic_flag __global *object,
5999+ memory_order order, memory_scope scope);
6000+bool __ovld
6001+atomic_flag_test_and_set_explicit(volatile atomic_flag __local *object,
6002+ memory_order order, memory_scope scope);
6003+void __ovld atomic_flag_clear_explicit(volatile atomic_flag __global *object,
6004+ memory_order order, memory_scope scope);
6005+void __ovld atomic_flag_clear_explicit(volatile atomic_flag __local *object,
6006+ memory_order order, memory_scope scope);
6007+#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
6008
6009 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6010
6011@@ -13906,7 +15943,7 @@ float16 __ovld __cnfn shuffle(float4 x, uint16 mask);
6012 float16 __ovld __cnfn shuffle(float8 x, uint16 mask);
6013 float16 __ovld __cnfn shuffle(float16 x, uint16 mask);
6014
6015-#ifdef cl_khr_fp64
6016+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
6017 double2 __ovld __cnfn shuffle(double2 x, ulong2 mask);
6018 double2 __ovld __cnfn shuffle(double4 x, ulong2 mask);
6019 double2 __ovld __cnfn shuffle(double8 x, ulong2 mask);
6020@@ -13926,7 +15963,7 @@ double16 __ovld __cnfn shuffle(double2 x, ulong16 mask);
6021 double16 __ovld __cnfn shuffle(double4 x, ulong16 mask);
6022 double16 __ovld __cnfn shuffle(double8 x, ulong16 mask);
6023 double16 __ovld __cnfn shuffle(double16 x, ulong16 mask);
6024-#endif //cl_khr_fp64
6025+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
6026
6027 #ifdef cl_khr_fp16
6028 half2 __ovld __cnfn shuffle(half2 x, ushort2 mask);
6029@@ -14130,7 +16167,7 @@ float16 __ovld __cnfn shuffle2(float4 x, float4 y, uint16 mask);
6030 float16 __ovld __cnfn shuffle2(float8 x, float8 y, uint16 mask);
6031 float16 __ovld __cnfn shuffle2(float16 x, float16 y, uint16 mask);
6032
6033-#ifdef cl_khr_fp64
6034+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
6035 double2 __ovld __cnfn shuffle2(double2 x, double2 y, ulong2 mask);
6036 double2 __ovld __cnfn shuffle2(double4 x, double4 y, ulong2 mask);
6037 double2 __ovld __cnfn shuffle2(double8 x, double8 y, ulong2 mask);
6038@@ -14150,7 +16187,7 @@ double16 __ovld __cnfn shuffle2(double2 x, double2 y, ulong16 mask);
6039 double16 __ovld __cnfn shuffle2(double4 x, double4 y, ulong16 mask);
6040 double16 __ovld __cnfn shuffle2(double8 x, double8 y, ulong16 mask);
6041 double16 __ovld __cnfn shuffle2(double16 x, double16 y, ulong16 mask);
6042-#endif //cl_khr_fp64
6043+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
6044
6045 #ifdef cl_khr_fp16
6046 half2 __ovld __cnfn shuffle2(half2 x, half2 y, ushort2 mask);
6047@@ -14186,6 +16223,7 @@ int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 2)))
6048 #pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing : enable
6049 #endif //cl_khr_gl_msaa_sharing
6050
6051+#ifdef __opencl_c_images
6052 /**
6053 * Use the coordinate (coord.xy) to do an element lookup in
6054 * the 2D image object specified by image.
6055@@ -14464,6 +16502,7 @@ half4 __purefn __ovld read_imageh(read_only image1d_buffer_t image, int coord);
6056
6057 // Image read functions for read_write images
6058 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6059+#ifdef __opencl_c_read_write_images
6060 float4 __purefn __ovld read_imagef(read_write image1d_t image, int coord);
6061 int4 __purefn __ovld read_imagei(read_write image1d_t image, int coord);
6062 uint4 __purefn __ovld read_imageui(read_write image1d_t image, int coord);
6063@@ -14507,6 +16546,7 @@ float __purefn __ovld read_imagef(read_write image2d_array_msaa_depth_t image, i
6064 #endif //cl_khr_gl_msaa_sharing
6065
6066 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6067+#ifdef __opencl_c_read_write_images
6068 #ifdef cl_khr_mipmap_image
6069 float4 __purefn __ovld read_imagef(read_write image1d_t image, sampler_t sampler, float coord, float lod);
6070 int4 __purefn __ovld read_imagei(read_write image1d_t image, sampler_t sampler, float coord, float lod);
6071@@ -14557,6 +16597,7 @@ int4 __purefn __ovld read_imagei(read_write image3d_t image, sampler_t sampler,
6072 uint4 __purefn __ovld read_imageui(read_write image3d_t image, sampler_t sampler, float4 coord, float4 gradientX, float4 gradientY);
6073
6074 #endif //cl_khr_mipmap_image
6075+#endif //__opencl_c_read_write_images
6076 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6077
6078 // Image read functions returning half4 type
6079@@ -14568,6 +16609,7 @@ half4 __purefn __ovld read_imageh(read_write image1d_array_t image, int2 coord);
6080 half4 __purefn __ovld read_imageh(read_write image2d_array_t image, int4 coord);
6081 half4 __purefn __ovld read_imageh(read_write image1d_buffer_t image, int coord);
6082 #endif //cl_khr_fp16
6083+#endif //__opencl_c_read_write_images
6084 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6085
6086 /**
6087@@ -14657,7 +16699,7 @@ void __ovld write_imagef(write_only image1d_array_t image_array, int2 coord, flo
6088 void __ovld write_imagei(write_only image1d_array_t image_array, int2 coord, int4 color);
6089 void __ovld write_imageui(write_only image1d_array_t image_array, int2 coord, uint4 color);
6090
6091-#ifdef cl_khr_3d_image_writes
6092+#if defined(cl_khr_3d_image_writes) || defined(__opencl_c_3d_image_writes)
6093 void __ovld write_imagef(write_only image3d_t image, int4 coord, float4 color);
6094 void __ovld write_imagei(write_only image3d_t image, int4 coord, int4 color);
6095 void __ovld write_imageui(write_only image3d_t image, int4 coord, uint4 color);
6096@@ -14690,7 +16732,7 @@ void __ovld write_imageui(write_only image2d_array_t image_array, int4 coord, in
6097 void __ovld write_imagef(write_only image2d_depth_t image, int2 coord, int lod, float depth);
6098 void __ovld write_imagef(write_only image2d_array_depth_t image, int4 coord, int lod, float depth);
6099
6100-#ifdef cl_khr_3d_image_writes
6101+#if defined(cl_khr_3d_image_writes) || defined(__opencl_c_3d_image_writes)
6102 void __ovld write_imagef(write_only image3d_t image, int4 coord, int lod, float4 color);
6103 void __ovld write_imagei(write_only image3d_t image, int4 coord, int lod, int4 color);
6104 void __ovld write_imageui(write_only image3d_t image, int4 coord, int lod, uint4 color);
6105@@ -14703,7 +16745,7 @@ void __ovld write_imageui(write_only image3d_t image, int4 coord, int lod, uint4
6106 #ifdef cl_khr_fp16
6107 void __ovld write_imageh(write_only image1d_t image, int coord, half4 color);
6108 void __ovld write_imageh(write_only image2d_t image, int2 coord, half4 color);
6109-#ifdef cl_khr_3d_image_writes
6110+#if defined(cl_khr_3d_image_writes) || defined(__opencl_c_3d_image_writes)
6111 void __ovld write_imageh(write_only image3d_t image, int4 coord, half4 color);
6112 #endif
6113 void __ovld write_imageh(write_only image1d_array_t image, int2 coord, half4 color);
6114@@ -14713,6 +16755,7 @@ void __ovld write_imageh(write_only image1d_buffer_t image, int coord, half4 col
6115
6116 // Image write functions for read_write images
6117 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6118+#ifdef __opencl_c_read_write_images
6119 void __ovld write_imagef(read_write image2d_t image, int2 coord, float4 color);
6120 void __ovld write_imagei(read_write image2d_t image, int2 coord, int4 color);
6121 void __ovld write_imageui(read_write image2d_t image, int2 coord, uint4 color);
6122@@ -14733,7 +16776,7 @@ void __ovld write_imagef(read_write image1d_array_t image_array, int2 coord, flo
6123 void __ovld write_imagei(read_write image1d_array_t image_array, int2 coord, int4 color);
6124 void __ovld write_imageui(read_write image1d_array_t image_array, int2 coord, uint4 color);
6125
6126-#ifdef cl_khr_3d_image_writes
6127+#if defined(cl_khr_3d_image_writes) || defined(__opencl_c_3d_image_writes)
6128 void __ovld write_imagef(read_write image3d_t image, int4 coord, float4 color);
6129 void __ovld write_imagei(read_write image3d_t image, int4 coord, int4 color);
6130 void __ovld write_imageui(read_write image3d_t image, int4 coord, uint4 color);
6131@@ -14765,7 +16808,7 @@ void __ovld write_imageui(read_write image2d_array_t image_array, int4 coord, in
6132 void __ovld write_imagef(read_write image2d_depth_t image, int2 coord, int lod, float color);
6133 void __ovld write_imagef(read_write image2d_array_depth_t image, int4 coord, int lod, float color);
6134
6135-#ifdef cl_khr_3d_image_writes
6136+#if defined(cl_khr_3d_image_writes) || defined(__opencl_c_3d_image_writes)
6137 void __ovld write_imagef(read_write image3d_t image, int4 coord, int lod, float4 color);
6138 void __ovld write_imagei(read_write image3d_t image, int4 coord, int lod, int4 color);
6139 void __ovld write_imageui(read_write image3d_t image, int4 coord, int lod, uint4 color);
6140@@ -14778,13 +16821,14 @@ void __ovld write_imageui(read_write image3d_t image, int4 coord, int lod, uint4
6141 #ifdef cl_khr_fp16
6142 void __ovld write_imageh(read_write image1d_t image, int coord, half4 color);
6143 void __ovld write_imageh(read_write image2d_t image, int2 coord, half4 color);
6144-#ifdef cl_khr_3d_image_writes
6145+#if defined(cl_khr_3d_image_writes) || defined(__opencl_c_3d_image_writes)
6146 void __ovld write_imageh(read_write image3d_t image, int4 coord, half4 color);
6147 #endif
6148 void __ovld write_imageh(read_write image1d_array_t image, int2 coord, half4 color);
6149 void __ovld write_imageh(read_write image2d_array_t image, int4 coord, half4 color);
6150 void __ovld write_imageh(read_write image1d_buffer_t image, int coord, half4 color);
6151 #endif //cl_khr_fp16
6152+#endif //__opencl_c_read_write_images
6153 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6154
6155 // Note: In OpenCL v1.0/1.1/1.2, image argument of image query builtin functions does not have
6156@@ -14798,7 +16842,7 @@ void __ovld write_imageh(read_write image1d_buffer_t image, int coord, half4 col
6157 int __ovld __cnfn get_image_width(read_only image1d_t image);
6158 int __ovld __cnfn get_image_width(read_only image1d_buffer_t image);
6159 int __ovld __cnfn get_image_width(read_only image2d_t image);
6160-#ifdef cl_khr_3d_image_writes
6161+#if defined(cl_khr_3d_image_writes) || defined(__opencl_c_3d_image_writes)
6162 int __ovld __cnfn get_image_width(read_only image3d_t image);
6163 #endif
6164 int __ovld __cnfn get_image_width(read_only image1d_array_t image);
6165@@ -14817,7 +16861,7 @@ int __ovld __cnfn get_image_width(read_only image2d_array_msaa_depth_t image);
6166 int __ovld __cnfn get_image_width(write_only image1d_t image);
6167 int __ovld __cnfn get_image_width(write_only image1d_buffer_t image);
6168 int __ovld __cnfn get_image_width(write_only image2d_t image);
6169-#ifdef cl_khr_3d_image_writes
6170+#if defined(cl_khr_3d_image_writes) || defined(__opencl_c_3d_image_writes)
6171 int __ovld __cnfn get_image_width(write_only image3d_t image);
6172 #endif
6173 int __ovld __cnfn get_image_width(write_only image1d_array_t image);
6174@@ -14834,6 +16878,7 @@ int __ovld __cnfn get_image_width(write_only image2d_array_msaa_depth_t image);
6175 #endif //cl_khr_gl_msaa_sharing
6176
6177 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6178+#ifdef __opencl_c_read_write_images
6179 int __ovld __cnfn get_image_width(read_write image1d_t image);
6180 int __ovld __cnfn get_image_width(read_write image1d_buffer_t image);
6181 int __ovld __cnfn get_image_width(read_write image2d_t image);
6182@@ -14850,6 +16895,7 @@ int __ovld __cnfn get_image_width(read_write image2d_msaa_depth_t image);
6183 int __ovld __cnfn get_image_width(read_write image2d_array_msaa_t image);
6184 int __ovld __cnfn get_image_width(read_write image2d_array_msaa_depth_t image);
6185 #endif //cl_khr_gl_msaa_sharing
6186+#endif //__opencl_c_read_write_images
6187 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6188
6189 /**
6190@@ -14870,7 +16916,7 @@ int __ovld __cnfn get_image_height(read_only image2d_array_msaa_depth_t image);
6191 #endif //cl_khr_gl_msaa_sharing
6192
6193 int __ovld __cnfn get_image_height(write_only image2d_t image);
6194-#ifdef cl_khr_3d_image_writes
6195+#if defined(cl_khr_3d_image_writes) || defined(__opencl_c_3d_image_writes)
6196 int __ovld __cnfn get_image_height(write_only image3d_t image);
6197 #endif
6198 int __ovld __cnfn get_image_height(write_only image2d_array_t image);
6199@@ -14886,6 +16932,7 @@ int __ovld __cnfn get_image_height(write_only image2d_array_msaa_depth_t image);
6200 #endif //cl_khr_gl_msaa_sharing
6201
6202 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6203+#ifdef __opencl_c_read_write_images
6204 int __ovld __cnfn get_image_height(read_write image2d_t image);
6205 int __ovld __cnfn get_image_height(read_write image3d_t image);
6206 int __ovld __cnfn get_image_height(read_write image2d_array_t image);
6207@@ -14899,6 +16946,7 @@ int __ovld __cnfn get_image_height(read_write image2d_msaa_depth_t image);
6208 int __ovld __cnfn get_image_height(read_write image2d_array_msaa_t image);
6209 int __ovld __cnfn get_image_height(read_write image2d_array_msaa_depth_t image);
6210 #endif //cl_khr_gl_msaa_sharing
6211+#endif //__opencl_c_read_write_images
6212 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6213
6214 /**
6215@@ -14906,12 +16954,14 @@ int __ovld __cnfn get_image_height(read_write image2d_array_msaa_depth_t image);
6216 */
6217 int __ovld __cnfn get_image_depth(read_only image3d_t image);
6218
6219-#ifdef cl_khr_3d_image_writes
6220+#if defined(cl_khr_3d_image_writes) || defined(__opencl_c_3d_image_writes)
6221 int __ovld __cnfn get_image_depth(write_only image3d_t image);
6222 #endif
6223
6224 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6225+#ifdef __opencl_c_read_write_images
6226 int __ovld __cnfn get_image_depth(read_write image3d_t image);
6227+#endif //__opencl_c_read_write_images
6228 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6229
6230 // OpenCL Extension v2.0 s9.18 - Mipmaps
6231@@ -14927,13 +16977,15 @@ int __ovld get_image_num_mip_levels(read_only image3d_t image);
6232
6233 int __ovld get_image_num_mip_levels(write_only image1d_t image);
6234 int __ovld get_image_num_mip_levels(write_only image2d_t image);
6235-#ifdef cl_khr_3d_image_writes
6236+#if defined(cl_khr_3d_image_writes) || defined(__opencl_c_3d_image_writes)
6237 int __ovld get_image_num_mip_levels(write_only image3d_t image);
6238 #endif
6239
6240+#ifdef __opencl_c_read_write_images
6241 int __ovld get_image_num_mip_levels(read_write image1d_t image);
6242 int __ovld get_image_num_mip_levels(read_write image2d_t image);
6243 int __ovld get_image_num_mip_levels(read_write image3d_t image);
6244+#endif //__opencl_c_read_write_images
6245
6246 int __ovld get_image_num_mip_levels(read_only image1d_array_t image);
6247 int __ovld get_image_num_mip_levels(read_only image2d_array_t image);
6248@@ -14945,10 +16997,12 @@ int __ovld get_image_num_mip_levels(write_only image2d_array_t image);
6249 int __ovld get_image_num_mip_levels(write_only image2d_array_depth_t image);
6250 int __ovld get_image_num_mip_levels(write_only image2d_depth_t image);
6251
6252+#ifdef __opencl_c_read_write_images
6253 int __ovld get_image_num_mip_levels(read_write image1d_array_t image);
6254 int __ovld get_image_num_mip_levels(read_write image2d_array_t image);
6255 int __ovld get_image_num_mip_levels(read_write image2d_array_depth_t image);
6256 int __ovld get_image_num_mip_levels(read_write image2d_depth_t image);
6257+#endif //__opencl_c_read_write_images
6258
6259 #endif //cl_khr_mipmap_image
6260 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6261@@ -14992,7 +17046,7 @@ int __ovld __cnfn get_image_channel_data_type(read_only image2d_array_msaa_depth
6262 int __ovld __cnfn get_image_channel_data_type(write_only image1d_t image);
6263 int __ovld __cnfn get_image_channel_data_type(write_only image1d_buffer_t image);
6264 int __ovld __cnfn get_image_channel_data_type(write_only image2d_t image);
6265-#ifdef cl_khr_3d_image_writes
6266+#if defined(cl_khr_3d_image_writes) || defined(__opencl_c_3d_image_writes)
6267 int __ovld __cnfn get_image_channel_data_type(write_only image3d_t image);
6268 #endif
6269 int __ovld __cnfn get_image_channel_data_type(write_only image1d_array_t image);
6270@@ -15009,6 +17063,7 @@ int __ovld __cnfn get_image_channel_data_type(write_only image2d_array_msaa_dept
6271 #endif //cl_khr_gl_msaa_sharing
6272
6273 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6274+#ifdef __opencl_c_read_write_images
6275 int __ovld __cnfn get_image_channel_data_type(read_write image1d_t image);
6276 int __ovld __cnfn get_image_channel_data_type(read_write image1d_buffer_t image);
6277 int __ovld __cnfn get_image_channel_data_type(read_write image2d_t image);
6278@@ -15025,6 +17080,7 @@ int __ovld __cnfn get_image_channel_data_type(read_write image2d_msaa_depth_t im
6279 int __ovld __cnfn get_image_channel_data_type(read_write image2d_array_msaa_t image);
6280 int __ovld __cnfn get_image_channel_data_type(read_write image2d_array_msaa_depth_t image);
6281 #endif //cl_khr_gl_msaa_sharing
6282+#endif //__opencl_c_read_write_images
6283 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6284
6285 /**
6286@@ -15064,7 +17120,7 @@ int __ovld __cnfn get_image_channel_order(read_only image2d_array_msaa_depth_t i
6287 int __ovld __cnfn get_image_channel_order(write_only image1d_t image);
6288 int __ovld __cnfn get_image_channel_order(write_only image1d_buffer_t image);
6289 int __ovld __cnfn get_image_channel_order(write_only image2d_t image);
6290-#ifdef cl_khr_3d_image_writes
6291+#if defined(cl_khr_3d_image_writes) || defined(__opencl_c_3d_image_writes)
6292 int __ovld __cnfn get_image_channel_order(write_only image3d_t image);
6293 #endif
6294 int __ovld __cnfn get_image_channel_order(write_only image1d_array_t image);
6295@@ -15081,6 +17137,7 @@ int __ovld __cnfn get_image_channel_order(write_only image2d_array_msaa_depth_t
6296 #endif //cl_khr_gl_msaa_sharing
6297
6298 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6299+#ifdef __opencl_c_read_write_images
6300 int __ovld __cnfn get_image_channel_order(read_write image1d_t image);
6301 int __ovld __cnfn get_image_channel_order(read_write image1d_buffer_t image);
6302 int __ovld __cnfn get_image_channel_order(read_write image2d_t image);
6303@@ -15097,6 +17154,7 @@ int __ovld __cnfn get_image_channel_order(read_write image2d_msaa_depth_t image)
6304 int __ovld __cnfn get_image_channel_order(read_write image2d_array_msaa_t image);
6305 int __ovld __cnfn get_image_channel_order(read_write image2d_array_msaa_depth_t image);
6306 #endif //cl_khr_gl_msaa_sharing
6307+#endif //__opencl_c_read_write_images
6308 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6309
6310 /**
6311@@ -15131,6 +17189,7 @@ int2 __ovld __cnfn get_image_dim(write_only image2d_array_msaa_depth_t image);
6312 #endif //cl_khr_gl_msaa_sharing
6313
6314 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6315+#ifdef __opencl_c_read_write_images
6316 int2 __ovld __cnfn get_image_dim(read_write image2d_t image);
6317 int2 __ovld __cnfn get_image_dim(read_write image2d_array_t image);
6318 #ifdef cl_khr_depth_images
6319@@ -15143,6 +17202,7 @@ int2 __ovld __cnfn get_image_dim(read_write image2d_msaa_depth_t image);
6320 int2 __ovld __cnfn get_image_dim(read_write image2d_array_msaa_t image);
6321 int2 __ovld __cnfn get_image_dim(read_write image2d_array_msaa_depth_t image);
6322 #endif //cl_khr_gl_msaa_sharing
6323+#endif //__opencl_c_read_write_images
6324 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6325
6326 /**
6327@@ -15152,11 +17212,13 @@ int2 __ovld __cnfn get_image_dim(read_write image2d_array_msaa_depth_t image);
6328 * component and the w component is 0.
6329 */
6330 int4 __ovld __cnfn get_image_dim(read_only image3d_t image);
6331-#ifdef cl_khr_3d_image_writes
6332+#if defined(cl_khr_3d_image_writes) || defined(__opencl_c_3d_image_writes)
6333 int4 __ovld __cnfn get_image_dim(write_only image3d_t image);
6334 #endif
6335 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6336+#ifdef __opencl_c_read_write_images
6337 int4 __ovld __cnfn get_image_dim(read_write image3d_t image);
6338+#endif //__opencl_c_read_write_images
6339 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6340
6341 /**
6342@@ -15184,6 +17246,7 @@ size_t __ovld __cnfn get_image_array_size(write_only image2d_array_msaa_depth_t
6343 #endif //cl_khr_gl_msaa_sharing
6344
6345 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6346+#ifdef __opencl_c_read_write_images
6347 size_t __ovld __cnfn get_image_array_size(read_write image1d_array_t image_array);
6348 size_t __ovld __cnfn get_image_array_size(read_write image2d_array_t image_array);
6349 #ifdef cl_khr_depth_images
6350@@ -15193,6 +17256,7 @@ size_t __ovld __cnfn get_image_array_size(read_write image2d_array_depth_t image
6351 size_t __ovld __cnfn get_image_array_size(read_write image2d_array_msaa_t image_array);
6352 size_t __ovld __cnfn get_image_array_size(read_write image2d_array_msaa_depth_t image_array);
6353 #endif //cl_khr_gl_msaa_sharing
6354+#endif //__opencl_c_read_write_images
6355 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6356
6357 /**
6358@@ -15210,16 +17274,21 @@ int __ovld get_image_num_samples(write_only image2d_array_msaa_t image);
6359 int __ovld get_image_num_samples(write_only image2d_array_msaa_depth_t image);
6360
6361 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6362+#ifdef __opencl_c_read_write_images
6363 int __ovld get_image_num_samples(read_write image2d_msaa_t image);
6364 int __ovld get_image_num_samples(read_write image2d_msaa_depth_t image);
6365 int __ovld get_image_num_samples(read_write image2d_array_msaa_t image);
6366 int __ovld get_image_num_samples(read_write image2d_array_msaa_depth_t image);
6367+#endif //__opencl_c_read_write_images
6368 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6369 #endif
6370
6371+#endif //__opencl_c_images
6372+
6373 // OpenCL v2.0 s6.13.15 - Work-group Functions
6374
6375 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6376+#ifdef __opencl_c_work_group_collective_functions
6377 int __ovld __conv work_group_all(int predicate);
6378 int __ovld __conv work_group_any(int predicate);
6379
6380@@ -15243,11 +17312,11 @@ ulong __ovld __conv work_group_broadcast(ulong a, size_t x, size_t y, size_t z);
6381 float __ovld __conv work_group_broadcast(float a, size_t local_id);
6382 float __ovld __conv work_group_broadcast(float a, size_t x, size_t y);
6383 float __ovld __conv work_group_broadcast(float a, size_t x, size_t y, size_t z);
6384-#ifdef cl_khr_fp64
6385+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
6386 double __ovld __conv work_group_broadcast(double a, size_t local_id);
6387 double __ovld __conv work_group_broadcast(double a, size_t x, size_t y);
6388 double __ovld __conv work_group_broadcast(double a, size_t x, size_t y, size_t z);
6389-#endif //cl_khr_fp64
6390+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
6391
6392 #ifdef cl_khr_fp16
6393 half __ovld __conv work_group_reduce_add(half x);
6394@@ -15305,7 +17374,7 @@ float __ovld __conv work_group_scan_exclusive_max(float x);
6395 float __ovld __conv work_group_scan_inclusive_add(float x);
6396 float __ovld __conv work_group_scan_inclusive_min(float x);
6397 float __ovld __conv work_group_scan_inclusive_max(float x);
6398-#ifdef cl_khr_fp64
6399+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
6400 double __ovld __conv work_group_reduce_add(double x);
6401 double __ovld __conv work_group_reduce_min(double x);
6402 double __ovld __conv work_group_reduce_max(double x);
6403@@ -15315,19 +17384,18 @@ double __ovld __conv work_group_scan_exclusive_max(double x);
6404 double __ovld __conv work_group_scan_inclusive_add(double x);
6405 double __ovld __conv work_group_scan_inclusive_min(double x);
6406 double __ovld __conv work_group_scan_inclusive_max(double x);
6407-#endif //cl_khr_fp64
6408-
6409+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
6410+#endif //__opencl_c_work_group_collective_functions
6411 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6412
6413 // OpenCL v2.0 s6.13.16 - Pipe Functions
6414-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6415+#ifdef __opencl_c_pipes
6416 bool __ovld is_valid_reserve_id(reserve_id_t reserve_id);
6417-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6418-
6419+#endif //__opencl_c_pipes
6420
6421 // OpenCL v2.0 s6.13.17 - Enqueue Kernels
6422 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6423-
6424+#ifdef __opencl_c_device_enqueue
6425 ndrange_t __ovld ndrange_1D(size_t);
6426 ndrange_t __ovld ndrange_1D(size_t, size_t);
6427 ndrange_t __ovld ndrange_1D(size_t, size_t, size_t);
6428@@ -15355,11 +17423,13 @@ bool __ovld is_valid_event (clk_event_t event);
6429 void __ovld capture_event_profiling_info(clk_event_t, clk_profiling_info, __global void* value);
6430
6431 queue_t __ovld get_default_queue(void);
6432+#endif //__opencl_c_device_enqueue
6433 #endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6434
6435 // OpenCL Extension v2.0 s9.17 - Sub-groups
6436
6437-#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
6438+#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups) || \
6439+ defined(__opencl_c_subgroups)
6440 // Shared Sub Group Functions
6441 uint __ovld get_sub_group_size(void);
6442 uint __ovld get_max_sub_group_size(void);
6443@@ -15445,7 +17515,7 @@ half __ovld __conv sub_group_scan_inclusive_min(half x);
6444 half __ovld __conv sub_group_scan_inclusive_max(half x);
6445 #endif //cl_khr_fp16
6446
6447-#ifdef cl_khr_fp64
6448+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
6449 double __ovld __conv sub_group_broadcast(double x, uint sub_group_local_id);
6450 double __ovld __conv sub_group_reduce_add(double x);
6451 double __ovld __conv sub_group_reduce_min(double x);
6452@@ -15456,7 +17526,7 @@ double __ovld __conv sub_group_scan_exclusive_max(double x);
6453 double __ovld __conv sub_group_scan_inclusive_add(double x);
6454 double __ovld __conv sub_group_scan_inclusive_min(double x);
6455 double __ovld __conv sub_group_scan_inclusive_max(double x);
6456-#endif //cl_khr_fp64
6457+#endif // defined(cl_khr_fp64) || defined(__opencl_c_fp64)
6458
6459 #endif //cl_khr_subgroups cl_intel_subgroups
6460
6461@@ -16226,16 +18296,22 @@ uint16 __ovld __conv intel_sub_group_shuffle_xor( uint16 x, uint c );
6462 long __ovld __conv intel_sub_group_shuffle_xor( long x, uint c );
6463 ulong __ovld __conv intel_sub_group_shuffle_xor( ulong x, uint c );
6464
6465+#ifdef __opencl_c_images
6466 uint __ovld __conv intel_sub_group_block_read( read_only image2d_t image, int2 coord );
6467 uint2 __ovld __conv intel_sub_group_block_read2( read_only image2d_t image, int2 coord );
6468 uint4 __ovld __conv intel_sub_group_block_read4( read_only image2d_t image, int2 coord );
6469 uint8 __ovld __conv intel_sub_group_block_read8( read_only image2d_t image, int2 coord );
6470+#endif //__opencl_c_images
6471
6472 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6473+#ifdef __opencl_c_images
6474+#ifdef __opencl_c_read_write_images
6475 uint __ovld __conv intel_sub_group_block_read(read_write image2d_t image, int2 coord);
6476 uint2 __ovld __conv intel_sub_group_block_read2(read_write image2d_t image, int2 coord);
6477 uint4 __ovld __conv intel_sub_group_block_read4(read_write image2d_t image, int2 coord);
6478 uint8 __ovld __conv intel_sub_group_block_read8(read_write image2d_t image, int2 coord);
6479+#endif //__opencl_c_read_write_images
6480+#endif //__opencl_c_images
6481 #endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6482
6483 uint __ovld __conv intel_sub_group_block_read( const __global uint* p );
6484@@ -16243,16 +18319,22 @@ uint2 __ovld __conv intel_sub_group_block_read2( const __global uint* p );
6485 uint4 __ovld __conv intel_sub_group_block_read4( const __global uint* p );
6486 uint8 __ovld __conv intel_sub_group_block_read8( const __global uint* p );
6487
6488+#ifdef __opencl_c_images
6489 void __ovld __conv intel_sub_group_block_write(write_only image2d_t image, int2 coord, uint data);
6490 void __ovld __conv intel_sub_group_block_write2(write_only image2d_t image, int2 coord, uint2 data);
6491 void __ovld __conv intel_sub_group_block_write4(write_only image2d_t image, int2 coord, uint4 data);
6492 void __ovld __conv intel_sub_group_block_write8(write_only image2d_t image, int2 coord, uint8 data);
6493+#endif //__opencl_c_images
6494
6495 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6496+#ifdef __opencl_c_images
6497+#ifdef __opencl_c_read_write_images
6498 void __ovld __conv intel_sub_group_block_write(read_write image2d_t image, int2 coord, uint data);
6499 void __ovld __conv intel_sub_group_block_write2(read_write image2d_t image, int2 coord, uint2 data);
6500 void __ovld __conv intel_sub_group_block_write4(read_write image2d_t image, int2 coord, uint4 data);
6501 void __ovld __conv intel_sub_group_block_write8(read_write image2d_t image, int2 coord, uint8 data);
6502+#endif // __opencl_c_read_write_images
6503+#endif // __opencl_c_images
6504 #endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6505
6506 void __ovld __conv intel_sub_group_block_write( __global uint* p, uint data );
6507@@ -16267,7 +18349,7 @@ half __ovld __conv intel_sub_group_shuffle_up( half prev, half cur, uint c );
6508 half __ovld __conv intel_sub_group_shuffle_xor( half x, uint c );
6509 #endif
6510
6511-#if defined(cl_khr_fp64)
6512+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
6513 double __ovld __conv intel_sub_group_shuffle( double x, uint c );
6514 double __ovld __conv intel_sub_group_shuffle_down( double prev, double cur, uint c );
6515 double __ovld __conv intel_sub_group_shuffle_up( double prev, double cur, uint c );
6516@@ -16366,16 +18448,22 @@ ushort __ovld __conv intel_sub_group_scan_inclusive_min( ushort x );
6517 short __ovld __conv intel_sub_group_scan_inclusive_max( short x );
6518 ushort __ovld __conv intel_sub_group_scan_inclusive_max( ushort x );
6519
6520+#ifdef __opencl_c_images
6521 uint __ovld __conv intel_sub_group_block_read_ui( read_only image2d_t image, int2 byte_coord );
6522 uint2 __ovld __conv intel_sub_group_block_read_ui2( read_only image2d_t image, int2 byte_coord );
6523 uint4 __ovld __conv intel_sub_group_block_read_ui4( read_only image2d_t image, int2 byte_coord );
6524 uint8 __ovld __conv intel_sub_group_block_read_ui8( read_only image2d_t image, int2 byte_coord );
6525+#endif //__opencl_c_images
6526
6527 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6528+#ifdef __opencl_c_images
6529+#ifdef __opencl_c_read_write_images
6530 uint __ovld __conv intel_sub_group_block_read_ui( read_write image2d_t image, int2 byte_coord );
6531 uint2 __ovld __conv intel_sub_group_block_read_ui2( read_write image2d_t image, int2 byte_coord );
6532 uint4 __ovld __conv intel_sub_group_block_read_ui4( read_write image2d_t image, int2 byte_coord );
6533 uint8 __ovld __conv intel_sub_group_block_read_ui8( read_write image2d_t image, int2 byte_coord );
6534+#endif //__opencl_c_read_write_images
6535+#endif //__opencl_c_images
6536 #endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6537
6538 uint __ovld __conv intel_sub_group_block_read_ui( const __global uint* p );
6539@@ -16383,16 +18471,22 @@ uint2 __ovld __conv intel_sub_group_block_read_ui2( const __global uint* p
6540 uint4 __ovld __conv intel_sub_group_block_read_ui4( const __global uint* p );
6541 uint8 __ovld __conv intel_sub_group_block_read_ui8( const __global uint* p );
6542
6543+#ifdef __opencl_c_images
6544 void __ovld __conv intel_sub_group_block_write_ui( read_only image2d_t image, int2 byte_coord, uint data );
6545 void __ovld __conv intel_sub_group_block_write_ui2( read_only image2d_t image, int2 byte_coord, uint2 data );
6546 void __ovld __conv intel_sub_group_block_write_ui4( read_only image2d_t image, int2 byte_coord, uint4 data );
6547 void __ovld __conv intel_sub_group_block_write_ui8( read_only image2d_t image, int2 byte_coord, uint8 data );
6548+#endif //__opencl_c_images
6549
6550 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6551+#ifdef __opencl_c_images
6552+#ifdef __opencl_c_read_write_images
6553 void __ovld __conv intel_sub_group_block_write_ui( read_write image2d_t image, int2 byte_coord, uint data );
6554 void __ovld __conv intel_sub_group_block_write_ui2( read_write image2d_t image, int2 byte_coord, uint2 data );
6555 void __ovld __conv intel_sub_group_block_write_ui4( read_write image2d_t image, int2 byte_coord, uint4 data );
6556 void __ovld __conv intel_sub_group_block_write_ui8( read_write image2d_t image, int2 byte_coord, uint8 data );
6557+#endif //__opencl_c_read_write_images
6558+#endif //__opencl_c_images
6559 #endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6560
6561 void __ovld __conv intel_sub_group_block_write_ui( __global uint* p, uint data );
6562@@ -16400,16 +18494,22 @@ void __ovld __conv intel_sub_group_block_write_ui2( __global uint* p, uint
6563 void __ovld __conv intel_sub_group_block_write_ui4( __global uint* p, uint4 data );
6564 void __ovld __conv intel_sub_group_block_write_ui8( __global uint* p, uint8 data );
6565
6566+#ifdef __opencl_c_images
6567 ushort __ovld __conv intel_sub_group_block_read_us( read_only image2d_t image, int2 coord );
6568 ushort2 __ovld __conv intel_sub_group_block_read_us2( read_only image2d_t image, int2 coord );
6569 ushort4 __ovld __conv intel_sub_group_block_read_us4( read_only image2d_t image, int2 coord );
6570 ushort8 __ovld __conv intel_sub_group_block_read_us8( read_only image2d_t image, int2 coord );
6571+#endif //__opencl_c_images
6572
6573 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6574+#ifdef __opencl_c_images
6575+#ifdef __opencl_c_read_write_images
6576 ushort __ovld __conv intel_sub_group_block_read_us(read_write image2d_t image, int2 coord);
6577 ushort2 __ovld __conv intel_sub_group_block_read_us2(read_write image2d_t image, int2 coord);
6578 ushort4 __ovld __conv intel_sub_group_block_read_us4(read_write image2d_t image, int2 coord);
6579 ushort8 __ovld __conv intel_sub_group_block_read_us8(read_write image2d_t image, int2 coord);
6580+#endif //__opencl_c_read_write_images
6581+#endif //__opencl_c_images
6582 #endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6583
6584 ushort __ovld __conv intel_sub_group_block_read_us( const __global ushort* p );
6585@@ -16417,16 +18517,22 @@ ushort2 __ovld __conv intel_sub_group_block_read_us2( const __global ushort*
6586 ushort4 __ovld __conv intel_sub_group_block_read_us4( const __global ushort* p );
6587 ushort8 __ovld __conv intel_sub_group_block_read_us8( const __global ushort* p );
6588
6589+#ifdef __opencl_c_images
6590 void __ovld __conv intel_sub_group_block_write_us(write_only image2d_t image, int2 coord, ushort data);
6591 void __ovld __conv intel_sub_group_block_write_us2(write_only image2d_t image, int2 coord, ushort2 data);
6592 void __ovld __conv intel_sub_group_block_write_us4(write_only image2d_t image, int2 coord, ushort4 data);
6593 void __ovld __conv intel_sub_group_block_write_us8(write_only image2d_t image, int2 coord, ushort8 data);
6594+#endif //__opencl_c_images
6595
6596 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6597+#ifdef __opencl_c_images
6598+#ifdef __opencl_c_read_write_images
6599 void __ovld __conv intel_sub_group_block_write_us(read_write image2d_t image, int2 coord, ushort data);
6600 void __ovld __conv intel_sub_group_block_write_us2(read_write image2d_t image, int2 coord, ushort2 data);
6601 void __ovld __conv intel_sub_group_block_write_us4(read_write image2d_t image, int2 coord, ushort4 data);
6602 void __ovld __conv intel_sub_group_block_write_us8(read_write image2d_t image, int2 coord, ushort8 data);
6603+#endif //__opencl_c_read_write_images
6604+#endif //__opencl_c_images
6605 #endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
6606
6607 void __ovld __conv intel_sub_group_block_write_us( __global ushort* p, ushort data );
6608@@ -16545,6 +18651,7 @@ short2 __ovld intel_sub_group_avc_ime_adjust_ref_offset(
6609 short2 ref_offset, ushort2 src_coord, ushort2 ref_window_size,
6610 ushort2 image_size);
6611
6612+#ifdef __opencl_c_images
6613 intel_sub_group_avc_ime_result_t __ovld
6614 intel_sub_group_avc_ime_evaluate_with_single_reference(
6615 read_only image2d_t src_image, read_only image2d_t ref_image,
6616@@ -16585,6 +18692,7 @@ intel_sub_group_avc_ime_evaluate_with_dual_reference_streaminout(
6617 read_only image2d_t bwd_ref_image, sampler_t vme_media_sampler,
6618 intel_sub_group_avc_ime_payload_t payload,
6619 intel_sub_group_avc_ime_dual_reference_streamin_t streamin_components);
6620+#endif //__opencl_c_images
6621
6622 intel_sub_group_avc_ime_single_reference_streamin_t __ovld
6623 intel_sub_group_avc_ime_get_single_reference_streamin(
6624@@ -16649,6 +18757,7 @@ intel_sub_group_avc_ref_payload_t __ovld
6625 intel_sub_group_avc_ref_set_bilinear_filter_enable(
6626 intel_sub_group_avc_ref_payload_t payload);
6627
6628+#ifdef __opencl_c_images
6629 intel_sub_group_avc_ref_result_t __ovld
6630 intel_sub_group_avc_ref_evaluate_with_single_reference(
6631 read_only image2d_t src_image, read_only image2d_t ref_image,
6632@@ -16667,6 +18776,7 @@ intel_sub_group_avc_ref_evaluate_with_multi_reference(
6633 read_only image2d_t src_image, uint packed_reference_ids,
6634 uchar packed_reference_field_polarities, sampler_t vme_media_sampler,
6635 intel_sub_group_avc_ref_payload_t payload);
6636+#endif //__opencl_c_images
6637
6638 // SIC built-in functions
6639 intel_sub_group_avc_sic_payload_t __ovld
6640@@ -16717,6 +18827,7 @@ intel_sub_group_avc_sic_set_block_based_raw_skip_sad(
6641 uchar block_based_skip_type,
6642 intel_sub_group_avc_sic_payload_t payload);
6643
6644+#ifdef __opencl_c_images
6645 intel_sub_group_avc_sic_result_t __ovld
6646 intel_sub_group_avc_sic_evaluate_ipe(
6647 read_only image2d_t src_image, sampler_t vme_media_sampler,
6648@@ -16739,6 +18850,7 @@ intel_sub_group_avc_sic_evaluate_with_multi_reference(
6649 read_only image2d_t src_image, uint packed_reference_ids,
6650 uchar packed_reference_field_polarities, sampler_t vme_media_sampler,
6651 intel_sub_group_avc_sic_payload_t payload);
6652+#endif //__opencl_c_images
6653
6654 uchar __ovld intel_sub_group_avc_sic_get_ipe_luma_shape(
6655 intel_sub_group_avc_sic_result_t result);
6656diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
6657index c87d240a8206..8c8f03bba0f3 100644
6658--- a/clang/lib/Parse/ParseDecl.cpp
6659+++ b/clang/lib/Parse/ParseDecl.cpp
6660@@ -3799,8 +3799,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
6661 isInvalid = DS.SetTypeAltiVecBool(true, Loc, PrevSpec, DiagID, Policy);
6662 break;
6663 case tok::kw_pipe:
6664- if (!getLangOpts().OpenCL || (getLangOpts().OpenCLVersion < 200 &&
6665- !getLangOpts().OpenCLCPlusPlus)) {
6666+ if (!getLangOpts().OpenCLPipeKeyword) {
6667 // OpenCL 2.0 defined this keyword. OpenCL 1.2 and earlier should
6668 // support the "pipe" word as identifier.
6669 Tok.getIdentifierInfo()->revertTokenIDToIdentifier();
6670@@ -3922,8 +3921,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
6671 case tok::kw___generic:
6672 // generic address space is introduced only in OpenCL v2.0
6673 // see OpenCL C Spec v2.0 s6.5.5
6674- if (Actions.getLangOpts().OpenCLVersion < 200 &&
6675- !Actions.getLangOpts().OpenCLCPlusPlus) {
6676+ if (!Actions.getLangOpts().OpenCLGenericKeyword) {
6677 DiagID = diag::err_opencl_unknown_type_specifier;
6678 PrevSpec = Tok.getIdentifierInfo()->getNameStart();
6679 isInvalid = true;
6680@@ -4973,8 +4971,7 @@ bool Parser::isDeclarationSpecifier(bool DisambiguatingWithExpression) {
6681 default: return false;
6682
6683 case tok::kw_pipe:
6684- return (getLangOpts().OpenCL && getLangOpts().OpenCLVersion >= 200) ||
6685- getLangOpts().OpenCLCPlusPlus;
6686+ return getLangOpts().OpenCLPipeKeyword;
6687
6688 case tok::identifier: // foo::bar
6689 // Unfortunate hack to support "Class.factoryMethod" notation.
6690@@ -5499,8 +5496,7 @@ static bool isPtrOperatorToken(tok::TokenKind Kind, const LangOptions &Lang,
6691 if (Kind == tok::star || Kind == tok::caret)
6692 return true;
6693
6694- if (Kind == tok::kw_pipe &&
6695- ((Lang.OpenCL && Lang.OpenCLVersion >= 200) || Lang.OpenCLCPlusPlus))
6696+ if (Kind == tok::kw_pipe && Lang.OpenCLPipeKeyword)
6697 return true;
6698
6699 if (!Lang.CPlusPlus)
6700diff --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp
6701index 6402b31d00b2..65f283ad556b 100644
6702--- a/clang/lib/Parse/ParsePragma.cpp
6703+++ b/clang/lib/Parse/ParsePragma.cpp
6704@@ -749,12 +749,14 @@ void Parser::HandlePragmaOpenCLExtension() {
6705 if (Name == "all") {
6706 if (State == Disable) {
6707 Opt.disableAll();
6708- Opt.enableSupportedCore(getLangOpts());
6709+ Opt.enableSupportedCore();
6710 } else {
6711 PP.Diag(NameLoc, diag::warn_pragma_expected_predicate) << 1;
6712 }
6713+ } else if (Opt.isFeature(Name)) {
6714+ PP.Diag(NameLoc, diag::warn_opencl_pragma_feature_ignore) << Ident;
6715 } else if (State == Begin) {
6716- if (!Opt.isKnown(Name) || !Opt.isSupported(Name, getLangOpts())) {
6717+ if (!Opt.isKnown(Name) || !Opt.isSupported(Name)) {
6718 Opt.support(Name);
6719 }
6720 Actions.setCurrentOpenCLExtension(Name);
6721@@ -764,9 +766,9 @@ void Parser::HandlePragmaOpenCLExtension() {
6722 Actions.setCurrentOpenCLExtension("");
6723 } else if (!Opt.isKnown(Name))
6724 PP.Diag(NameLoc, diag::warn_pragma_unknown_extension) << Ident;
6725- else if (Opt.isSupportedExtension(Name, getLangOpts()))
6726+ else if (Opt.isSupportedExtension(Name))
6727 Opt.enable(Name, State == Enable);
6728- else if (Opt.isSupportedCore(Name, getLangOpts()))
6729+ else if (Opt.isSupportedCore(Name))
6730 PP.Diag(NameLoc, diag::warn_pragma_extension_is_core) << Ident;
6731 else
6732 PP.Diag(NameLoc, diag::warn_pragma_unsupported_extension) << Ident;
6733diff --git a/clang/lib/Sema/OpenCLBuiltins.td b/clang/lib/Sema/OpenCLBuiltins.td
6734index 745363a6b43f..6a1fce567090 100644
6735--- a/clang/lib/Sema/OpenCLBuiltins.td
6736+++ b/clang/lib/Sema/OpenCLBuiltins.td
6737@@ -22,11 +22,13 @@
6738 class Version<int _Version> {
6739 int ID = _Version;
6740 }
6741+
6742 def CLAll : Version< 0>;
6743 def CL10 : Version<100>;
6744 def CL11 : Version<110>;
6745 def CL12 : Version<120>;
6746 def CL20 : Version<200>;
6747+def CL30 : Version<300>;
6748
6749 // Address spaces
6750 // Pointer types need to be assigned an address space.
6751@@ -72,6 +74,14 @@ def ArmIntegerDotProductAccumulateInt8 : FunctionExtension<"cl_arm_integ
6752 def ArmIntegerDotProductAccumulateInt16 : FunctionExtension<"cl_arm_integer_dot_product_accumulate_int16">;
6753 def ArmIntegerDotProductAccumulateSaturateInt8 : FunctionExtension<"cl_arm_integer_dot_product_accumulate_saturate_int8">;
6754
6755+// Features
6756+def FuncExtGenericAddressSpace : FunctionExtension<"__opencl_c_generic_address_space">;
6757+def FuncExtWorkGroupCollective : FunctionExtension<"__opencl_c_work_group_collective_functions">;
6758+def FuncExtPipes : FunctionExtension<"__opencl_c_pipes">;
6759+def FuncExtDeviceSidEenqueue : FunctionExtension<"__opencl_c_device_enqueue">;
6760+def FuncNonExplicitAtomicFeatures : FunctionExtension<"__opencl_c_atomic_order_seq_cst __opencl_c_atomic_scope_device">;
6761+def FuncNonExplicitAtomicFeaturesAndGenericAS : FunctionExtension<"__opencl_c_atomic_order_seq_cst __opencl_c_atomic_scope_device __opencl_c_generic_address_space">;
6762+
6763 // Qualified Type. These map to ASTContext::QualType.
6764 class QualType<string _Name, bit _IsAbstract=0> {
6765 // Name of the field or function in a clang::ASTContext
6766@@ -236,13 +246,9 @@ class Builtin<string _Name, list<Type> _Signature, list<bit> _Attributes = Attr.
6767 bit IsConv = _Attributes[2];
6768 // OpenCL extensions to which the function belongs.
6769 FunctionExtension Extension = FuncExtNone;
6770- // Version of OpenCL from which the function is available (e.g.: CL10).
6771- // MinVersion is inclusive.
6772- Version MinVersion = CL10;
6773- // Version of OpenCL from which the function is not supported anymore.
6774- // MaxVersion is exclusive.
6775+ // List of OpenCL version in which this function available.
6776 // CLAll makes the function available for all versions.
6777- Version MaxVersion = CLAll;
6778+ list<Version> Versions = [CLAll];
6779 }
6780
6781 //===----------------------------------------------------------------------===//
6782@@ -421,7 +427,7 @@ foreach name = ["get_global_size", "get_global_id", "get_local_size",
6783 def : Builtin<name, [Size, UInt], Attr.Const>;
6784 }
6785
6786-let MinVersion = CL20 in {
6787+let Versions = [CL20, CL30] in {
6788 def : Builtin<"get_enqueued_local_size", [Size, UInt]>;
6789 foreach name = ["get_global_linear_id", "get_local_linear_id"] in {
6790 def : Builtin<name, [Size]>;
6791@@ -494,7 +500,7 @@ foreach name = ["fma", "mad"] in {
6792 }
6793
6794 // --- Version dependent ---
6795-let MaxVersion = CL20 in {
6796+let Versions = [CL10, CL11, CL12, CL30] in {
6797 foreach AS = [GlobalAS, LocalAS, PrivateAS] in {
6798 foreach name = ["fract", "modf", "sincos"] in {
6799 def : Builtin<name, [FGenTypeN, FGenTypeN, PointerType<FGenTypeN, AS>]>;
6800@@ -511,7 +517,9 @@ let MaxVersion = CL20 in {
6801 }
6802 }
6803 }
6804-let MinVersion = CL20 in {
6805+
6806+let Versions = [CL20, CL30] in {
6807+ let Extension = FuncExtGenericAddressSpace in {
6808 foreach name = ["fract", "modf", "sincos"] in {
6809 def : Builtin<name, [FGenTypeN, FGenTypeN, PointerType<FGenTypeN, GenericAS>]>;
6810 }
6811@@ -524,6 +532,7 @@ let MinVersion = CL20 in {
6812 def : Builtin<name, [Type, Type, Type, PointerType<GenTypeIntVecAndScalar, GenericAS>]>;
6813 }
6814 }
6815+ }
6816 }
6817
6818 // --- Table 9 ---
6819@@ -554,7 +563,7 @@ foreach name = ["abs"] in {
6820 foreach name = ["clz", "popcount"] in {
6821 def : Builtin<name, [AIGenTypeN, AIGenTypeN], Attr.Const>;
6822 }
6823-let MinVersion = CL20 in {
6824+let Versions = [CL20, CL30] in {
6825 foreach name = ["ctz"] in {
6826 def : Builtin<name, [AIGenTypeN, AIGenTypeN]>;
6827 }
6828@@ -728,7 +737,7 @@ foreach name = ["select"] in {
6829 // --- Table 15 ---
6830 // Variants for OpenCL versions below 2.0, using pointers to the global, local
6831 // and private address spaces.
6832-let MaxVersion = CL20 in {
6833+let Versions = [CL10, CL11, CL12, CL30] in {
6834 foreach AS = [GlobalAS, LocalAS, PrivateAS] in {
6835 foreach VSize = [2, 3, 4, 8, 16] in {
6836 foreach name = ["vload" # VSize] in {
6837@@ -771,7 +780,8 @@ let MaxVersion = CL20 in {
6838 }
6839 // Variants for OpenCL versions above 2.0, using pointers to the generic
6840 // address space.
6841-let MinVersion = CL20 in {
6842+let Versions = [CL20, CL30] in {
6843+ let Extension = FuncExtGenericAddressSpace in {
6844 foreach VSize = [2, 3, 4, 8, 16] in {
6845 foreach name = ["vload" # VSize] in {
6846 def : Builtin<name, [VectorType<Char, VSize>, Size, PointerType<ConstType<Char>, GenericAS>]>;
6847@@ -809,6 +819,7 @@ let MinVersion = CL20 in {
6848 }
6849 }
6850 }
6851+ }
6852 }
6853 // Variants using pointers to the constant address space.
6854 foreach VSize = [2, 3, 4, 8, 16] in {
6855@@ -829,7 +840,7 @@ foreach VSize = [2, 3, 4, 8, 16] in {
6856 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, ConstantAS>]>;
6857 }
6858 }
6859-let MaxVersion = CL20 in {
6860+let Versions = [CL10, CL11, CL12, CL30] in {
6861 foreach AS = [GlobalAS, LocalAS, PrivateAS] in {
6862 def : Builtin<"vload_half", [Float, Size, PointerType<ConstType<Half>, AS>]>;
6863 def : Builtin<"vloada_half", [Float, Size, PointerType<ConstType<Half>, AS>]>;
6864@@ -852,7 +863,8 @@ let MaxVersion = CL20 in {
6865 }
6866 }
6867 }
6868-let MinVersion = CL20 in {
6869+let Versions = [CL20, CL30] in {
6870+ let Extension = FuncExtGenericAddressSpace in {
6871 foreach AS = [GenericAS] in {
6872 def : Builtin<"vload_half", [Float, Size, PointerType<ConstType<Half>, AS>]>;
6873 def : Builtin<"vloada_half", [Float, Size, PointerType<ConstType<Half>, AS>]>;
6874@@ -874,6 +886,7 @@ let MinVersion = CL20 in {
6875 }
6876 }
6877 }
6878+ }
6879 }
6880
6881 foreach AS = [ConstantAS] in {
6882@@ -899,7 +912,9 @@ foreach name = ["async_work_group_strided_copy"] in {
6883 def : Builtin<name, [Event, PointerType<AGenTypeN, GlobalAS>, PointerType<ConstType<AGenTypeN>, LocalAS>, Size, Size, Event]>;
6884 }
6885 foreach name = ["wait_group_events"] in {
6886+ let Extension = FuncExtGenericAddressSpace in {
6887 def : Builtin<name, [Void, Int, PointerType<Event, GenericAS>]>;
6888+ }
6889 }
6890 foreach name = ["prefetch"] in {
6891 def : Builtin<name, [Void, PointerType<ConstType<AGenTypeN>, GlobalAS>, Size]>;
6892@@ -1000,13 +1015,25 @@ foreach AS = [GlobalAS, LocalAS] in {
6893 }
6894 }
6895 }
6896+
6897 // OpenCL v2.0 s6.13.11 - Atomic Functions.
6898-let MinVersion = CL20 in {
6899+
6900+let Versions = [CL20, CL30] in {
6901+ let Extension = FuncExtGenericAddressSpace in {
6902+ foreach TypePair = [[AtomicInt, Int], [AtomicUInt, UInt],
6903+ [AtomicLong, Long], [AtomicULong, ULong],
6904+ [AtomicFloat, Float], [AtomicDouble, Double]] in {
6905+ def : Builtin<"atomic_init",
6906+ [Void, PointerType<VolatileType<TypePair[0]>, GenericAS>, TypePair[1]]>;
6907+ }
6908+ }
6909+}
6910+
6911+let Versions = [CL20, CL30] in {
6912+ let Extension = FuncNonExplicitAtomicFeaturesAndGenericAS in {
6913 foreach TypePair = [[AtomicInt, Int], [AtomicUInt, UInt],
6914 [AtomicLong, Long], [AtomicULong, ULong],
6915 [AtomicFloat, Float], [AtomicDouble, Double]] in {
6916- def : Builtin<"atomic_init",
6917- [Void, PointerType<VolatileType<TypePair[0]>, GenericAS>, TypePair[1]]>;
6918 def : Builtin<"atomic_store",
6919 [Void, PointerType<VolatileType<TypePair[0]>, GenericAS>, TypePair[1]]>;
6920 def : Builtin<"atomic_load",
6921@@ -1038,6 +1065,59 @@ let MinVersion = CL20 in {
6922 [TypePair[1], PointerType<VolatileType<TypePair[0]>, GenericAS>, TypePair[2]]>;
6923 }
6924 }
6925+ }
6926+}
6927+
6928+let Versions = [CL30] in {
6929+ foreach AS = [GlobalAS, LocalAS] in {
6930+ foreach TypePair = [[AtomicInt, Int], [AtomicUInt, UInt],
6931+ [AtomicLong, Long], [AtomicULong, ULong],
6932+ [AtomicFloat, Float], [AtomicDouble, Double]] in {
6933+ def : Builtin<"atomic_init",
6934+ [Void, PointerType<VolatileType<TypePair[0]>, AS>, TypePair[1]]>;
6935+ }
6936+ }
6937+}
6938+
6939+let Versions = [CL30] in {
6940+ let Extension = FuncNonExplicitAtomicFeatures in {
6941+ foreach AS = [GlobalAS, LocalAS] in {
6942+ foreach TypePair = [[AtomicInt, Int], [AtomicUInt, UInt],
6943+ [AtomicLong, Long], [AtomicULong, ULong],
6944+ [AtomicFloat, Float], [AtomicDouble, Double]] in {
6945+ def : Builtin<"atomic_store",
6946+ [Void, PointerType<VolatileType<TypePair[0]>, AS>, TypePair[1]]>;
6947+ def : Builtin<"atomic_load",
6948+ [TypePair[1], PointerType<VolatileType<TypePair[0]>, AS>]>;
6949+ def : Builtin<"atomic_exchange",
6950+ [TypePair[1], PointerType<VolatileType<TypePair[0]>, AS>, TypePair[1]]>;
6951+ foreach Variant = ["weak", "strong"] in {
6952+ def : Builtin<"atomic_compare_exchange_" # Variant,
6953+ [Bool, PointerType<VolatileType<TypePair[0]>, AS>,
6954+ PointerType<TypePair[1], AS>, TypePair[1]]>;
6955+ }
6956+ }
6957+
6958+ foreach TypePair = [[AtomicInt, Int, Int], [AtomicUInt, UInt, UInt],
6959+ [AtomicLong, Long, Long], [AtomicULong, ULong, ULong],
6960+ [AtomicIntPtr, IntPtr, PtrDiff],
6961+ [AtomicUIntPtr, UIntPtr, PtrDiff]] in {
6962+ foreach ModOp = ["add", "sub"] in {
6963+ def : Builtin<"atomic_fetch_" # ModOp,
6964+ [TypePair[1], PointerType<VolatileType<TypePair[0]>, AS>, TypePair[2]]>;
6965+ }
6966+ }
6967+ foreach TypePair = [[AtomicInt, Int, Int], [AtomicUInt, UInt, UInt],
6968+ [AtomicLong, Long, Long], [AtomicULong, ULong, ULong],
6969+ [AtomicIntPtr, IntPtr, IntPtr],
6970+ [AtomicUIntPtr, UIntPtr, UIntPtr]] in {
6971+ foreach ModOp = ["or", "xor", "and", "min", "max"] in {
6972+ def : Builtin<"atomic_fetch_" # ModOp,
6973+ [TypePair[1], PointerType<VolatileType<TypePair[0]>, AS>, TypePair[2]]>;
6974+ }
6975+ }
6976+ }
6977+ }
6978 }
6979
6980 //--------------------------------------------------------------------
6981@@ -1217,7 +1297,8 @@ foreach aQual = ["WO", "RW"] in {
6982 //--------------------------------------------------------------------
6983 // OpenCL v2.0 s6.13.15 - Work-group Functions
6984 // --- Table 26 ---
6985-let MinVersion = CL20 in {
6986+let Versions = [CL20, CL30] in {
6987+ let Extension = FuncExtWorkGroupCollective in {
6988 foreach name = ["work_group_all", "work_group_any"] in {
6989 def : Builtin<name, [Int, Int], Attr.Convergent>;
6990 }
6991@@ -1232,6 +1313,7 @@ let MinVersion = CL20 in {
6992 def : Builtin<name # op, [IntLongFloatGenType1, IntLongFloatGenType1], Attr.Convergent>;
6993 }
6994 }
6995+ }
6996 }
6997
6998
6999@@ -1241,8 +1323,10 @@ let MinVersion = CL20 in {
7000 // Defined in Builtins.def
7001
7002 // --- Table 28 ---
7003-// Builtins taking pipe arguments are defined in Builtins.def
7004-def : Builtin<"is_valid_reserve_id", [Bool, ReserveId]>;
7005+let Extension = FuncExtPipes in {
7006+ // Builtins taking pipe arguments are defined in Builtins.def
7007+ def : Builtin<"is_valid_reserve_id", [Bool, ReserveId]>;
7008+}
7009
7010 // --- Table 29 ---
7011 // Defined in Builtins.def
7012@@ -1257,21 +1341,22 @@ def : Builtin<"is_valid_reserve_id", [Bool, ReserveId]>;
7013 // Defined in Builtins.def
7014
7015 // --- Table 33 ---
7016-def : Builtin<"enqueue_marker",
7017- [Int, Queue, UInt, PointerType<ConstType<ClkEvent>, GenericAS>, PointerType<ClkEvent, GenericAS>]>;
7018+let Extension = FuncExtDeviceSidEenqueue in {
7019+ def : Builtin<"enqueue_marker",
7020+ [Int, Queue, UInt, PointerType<ConstType<ClkEvent>, GenericAS>, PointerType<ClkEvent, GenericAS>]>;
7021
7022-// --- Table 34 ---
7023-def : Builtin<"retain_event", [Void, ClkEvent]>;
7024-def : Builtin<"release_event", [Void, ClkEvent]>;
7025-def : Builtin<"create_user_event", [ClkEvent]>;
7026-def : Builtin<"is_valid_event", [Bool, ClkEvent]>;
7027-def : Builtin<"set_user_event_status", [Void, ClkEvent, Int]>;
7028-// TODO: capture_event_profiling_info
7029-
7030-// --- Table 35 ---
7031-def : Builtin<"get_default_queue", [Queue]>;
7032-// TODO: ndrange functions
7033+ // --- Table 34 ---
7034+ def : Builtin<"retain_event", [Void, ClkEvent]>;
7035+ def : Builtin<"release_event", [Void, ClkEvent]>;
7036+ def : Builtin<"create_user_event", [ClkEvent]>;
7037+ def : Builtin<"is_valid_event", [Bool, ClkEvent]>;
7038+ def : Builtin<"set_user_event_status", [Void, ClkEvent, Int]>;
7039+ // TODO: capture_event_profiling_info
7040
7041+ // --- Table 35 ---
7042+ def : Builtin<"get_default_queue", [Queue]>;
7043+ // TODO: ndrange functions
7044+}
7045
7046 //--------------------------------------------------------------------
7047 // End of the builtin functions defined in the OpenCL C specification.
7048@@ -1456,7 +1541,7 @@ let Extension = FuncExtKhrSubgroups in {
7049 "get_sub_group_local_id"] in {
7050 def : Builtin<name, [UInt]>;
7051 }
7052- let MinVersion = CL20 in {
7053+ let Versions = [CL20] in {
7054 foreach name = ["get_enqueued_num_sub_groups"] in {
7055 def : Builtin<name, [UInt]>;
7056 }
7057diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
7058index 2f2b52106f3d..5092a4691b9b 100644
7059--- a/clang/lib/Sema/Sema.cpp
7060+++ b/clang/lib/Sema/Sema.cpp
7061@@ -291,9 +291,10 @@ void Sema::Initialize() {
7062 // Initialize predefined OpenCL types and supported extensions and (optional)
7063 // core features.
7064 if (getLangOpts().OpenCL) {
7065+ getOpenCLOptions().setOpenCLVersion(getLangOpts());
7066 getOpenCLOptions().addSupport(
7067 Context.getTargetInfo().getSupportedOpenCLOpts());
7068- getOpenCLOptions().enableSupportedCore(getLangOpts());
7069+ getOpenCLOptions().enableSupportedCore();
7070 addImplicitTypedef("sampler_t", Context.OCLSamplerTy);
7071 addImplicitTypedef("event_t", Context.OCLEventTy);
7072 if (getLangOpts().OpenCLCPlusPlus || getLangOpts().OpenCLVersion >= 200) {
7073@@ -349,12 +350,18 @@ void Sema::Initialize() {
7074 "cl_khr_int64_base_atomics cl_khr_int64_extended_atomics");
7075
7076 setOpenCLExtensionForType(AtomicDoubleT, "cl_khr_fp64");
7077+ setOpenCLExtensionForType(Context.OCLReserveIDTy, "__opencl_c_pipes");
7078+ setOpenCLExtensionForType(Context.OCLClkEventTy,
7079+ "__opencl_c_device_enqueue");
7080+ setOpenCLExtensionForType(Context.OCLQueueTy,
7081+ "__opencl_c_device_enqueue");
7082 }
7083
7084 setOpenCLExtensionForType(Context.DoubleTy, "cl_khr_fp64");
7085
7086-#define GENERIC_IMAGE_TYPE_EXT(Type, Id, Ext) \
7087- setOpenCLExtensionForType(Context.Id, Ext);
7088+#define GENERIC_IMAGE_TYPE_EXT(Type, Id, Ext) \
7089+ setOpenCLExtensionForType(Context.Id, Ext); \
7090+ setOpenCLExtensionForType(Context.Id, "__opencl_c_images");
7091 #include "clang/Basic/OpenCLImageTypes.def"
7092 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
7093 addImplicitTypedef(#ExtType, Context.Id##Ty); \
7094@@ -2423,6 +2430,27 @@ bool Sema::isOpenCLDisabledDecl(Decl *FD) {
7095 return false;
7096 }
7097
7098+template <typename DiagLocT, typename DiagInfoT>
7099+void Sema::DiagnoseOpenCLRequiresOption(llvm::StringRef OpenCLOptName,
7100+ DiagLocT DiagLoc, DiagInfoT DiagInfo,
7101+ unsigned Selector,
7102+ SourceRange SrcRange) {
7103+ const auto &LO = getLangOpts();
7104+ auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
7105+ // For versions higher that 3.0 diagnosing feature
7106+ if (CLVer >= 300) {
7107+ OpenCLOptName =
7108+ llvm::StringSwitch<llvm::StringRef>(OpenCLOptName)
7109+ .Case("cl_khr_3d_image_writes", "__opencl_c_3d_image_writes")
7110+ .Case("cl_khr_subgroups", "__opencl_c_subgroups")
7111+ .Case("cl_khr_fp64", "__opencl_c_fp64")
7112+ .Default(OpenCLOptName);
7113+ }
7114+
7115+ Diag(DiagLoc, diag::err_opencl_requires_extension)
7116+ << Selector << DiagInfo << OpenCLOptName << SrcRange;
7117+}
7118+
7119 template <typename T, typename DiagLocT, typename DiagInfoT, typename MapT>
7120 bool Sema::checkOpenCLDisabledTypeOrDecl(T D, DiagLocT DiagLoc,
7121 DiagInfoT DiagInfo, MapT &Map,
7122@@ -2434,8 +2462,7 @@ bool Sema::checkOpenCLDisabledTypeOrDecl(T D, DiagLocT DiagLoc,
7123 bool Disabled = false;
7124 for (auto &I : Loc->second) {
7125 if (I != CurrOpenCLExtension && !getOpenCLOptions().isEnabled(I)) {
7126- Diag(DiagLoc, diag::err_opencl_requires_extension) << Selector << DiagInfo
7127- << I << SrcRange;
7128+ DiagnoseOpenCLRequiresOption(I, DiagLoc, DiagInfo, Selector, SrcRange);
7129 Disabled = true;
7130 }
7131 }
7132@@ -2471,3 +2498,13 @@ bool Sema::checkOpenCLDisabledDecl(const NamedDecl &D, const Expr &E) {
7133 return checkOpenCLDisabledTypeOrDecl(&D, E.getBeginLoc(), FnName,
7134 OpenCLDeclExtMap, 1, D.getSourceRange());
7135 }
7136+
7137+bool Sema::checkOpenCLSubgroupExtForCallExpr(CallExpr *Call) {
7138+ if (!getOpenCLOptions().isEnabled("cl_khr_subgroups")) {
7139+ DiagnoseOpenCLRequiresOption("cl_khr_subgroups", Call->getBeginLoc(),
7140+ Call->getDirectCallee(), 1,
7141+ Call->getSourceRange());
7142+ return true;
7143+ }
7144+ return false;
7145+}
7146diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
7147index 1bf04d9cb4f2..9dd63db0f420 100644
7148--- a/clang/lib/Sema/SemaChecking.cpp
7149+++ b/clang/lib/Sema/SemaChecking.cpp
7150@@ -835,20 +835,11 @@ static bool checkOpenCLBlockArgs(Sema &S, Expr *BlockArg) {
7151 return IllegalParams;
7152 }
7153
7154-static bool checkOpenCLSubgroupExt(Sema &S, CallExpr *Call) {
7155- if (!S.getOpenCLOptions().isEnabled("cl_khr_subgroups")) {
7156- S.Diag(Call->getBeginLoc(), diag::err_opencl_requires_extension)
7157- << 1 << Call->getDirectCallee() << "cl_khr_subgroups";
7158- return true;
7159- }
7160- return false;
7161-}
7162-
7163 static bool SemaOpenCLBuiltinNDRangeAndBlock(Sema &S, CallExpr *TheCall) {
7164 if (checkArgCount(S, TheCall, 2))
7165 return true;
7166
7167- if (checkOpenCLSubgroupExt(S, TheCall))
7168+ if (S.checkOpenCLSubgroupExtForCallExpr(TheCall))
7169 return true;
7170
7171 // First argument is an ndrange_t type.
7172@@ -1883,7 +1874,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
7173 break;
7174 case Builtin::BIsub_group_reserve_read_pipe:
7175 case Builtin::BIsub_group_reserve_write_pipe:
7176- if (checkOpenCLSubgroupExt(*this, TheCall) ||
7177+ if (checkOpenCLSubgroupExtForCallExpr(TheCall) ||
7178 SemaBuiltinReserveRWPipe(*this, TheCall))
7179 return ExprError();
7180 break;
7181@@ -1896,7 +1887,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
7182 break;
7183 case Builtin::BIsub_group_commit_read_pipe:
7184 case Builtin::BIsub_group_commit_write_pipe:
7185- if (checkOpenCLSubgroupExt(*this, TheCall) ||
7186+ if (checkOpenCLSubgroupExtForCallExpr(TheCall) ||
7187 SemaBuiltinCommitRWPipe(*this, TheCall))
7188 return ExprError();
7189 break;
7190@@ -4149,6 +4140,20 @@ DiagnoseCStringFormatDirectiveInCFAPI(Sema &S,
7191 }
7192 }
7193
7194+bool Sema::isSupportedOpenCLOMemoryOrdering(int64_t Ordering) const {
7195+ assert(llvm::isValidAtomicOrderingCABI(Ordering));
7196+ auto OrderingCABI = (llvm::AtomicOrderingCABI)Ordering;
7197+ switch (OrderingCABI) {
7198+ case llvm::AtomicOrderingCABI::acquire:
7199+ case llvm::AtomicOrderingCABI::release:
7200+ case llvm::AtomicOrderingCABI::acq_rel:
7201+ return OpenCLFeatures.isEnabled("__opencl_c_atomic_order_acq_rel");
7202+
7203+ default:
7204+ return true;
7205+ }
7206+}
7207+
7208 /// Determine whether the given type has a non-null nullability annotation.
7209 static bool isNonNullType(ASTContext &ctx, QualType type) {
7210 if (auto nullability = type->getNullability(ctx))
7211@@ -4920,10 +4925,17 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
7212 if (SubExprs.size() >= 2 && Form != Init) {
7213 llvm::APSInt Result(32);
7214 if (SubExprs[1]->isIntegerConstantExpr(Result, Context) &&
7215- !isValidOrderingForOp(Result.getSExtValue(), Op))
7216+ !isValidOrderingForOp(Result.getSExtValue(), Op)) {
7217 Diag(SubExprs[1]->getBeginLoc(),
7218 diag::warn_atomic_op_has_invalid_memory_order)
7219 << SubExprs[1]->getSourceRange();
7220+ } else if (IsOpenCL &&
7221+ !isSupportedOpenCLOMemoryOrdering(Result.getSExtValue())) {
7222+ Diag(SubExprs[1]->getBeginLoc(),
7223+ diag::err_opencl_memory_ordering_require_feat)
7224+ << SubExprs[1]->getSourceRange();
7225+ return ExprError();
7226+ }
7227 }
7228
7229 if (auto ScopeModel = AtomicExpr::getScopeModel(Op)) {
7230diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
7231index 5b0417fa8859..2dee60763d57 100644
7232--- a/clang/lib/Sema/SemaDecl.cpp
7233+++ b/clang/lib/Sema/SemaDecl.cpp
7234@@ -6290,7 +6290,9 @@ void Sema::deduceOpenCLAddressSpace(ValueDecl *Decl) {
7235 if (Type->isSamplerT() || Type->isVoidType())
7236 return;
7237 LangAS ImplAS = LangAS::opencl_private;
7238- if ((getLangOpts().OpenCLCPlusPlus || getLangOpts().OpenCLVersion >= 200) &&
7239+ if ((getLangOpts().OpenCLCPlusPlus ||
7240+ getOpenCLOptions().isEnabled(
7241+ "__opencl_c_program_scope_global_variables")) &&
7242 Var->hasGlobalStorage())
7243 ImplAS = LangAS::opencl_global;
7244 // If the original type from a decayed type is an array type and that array
7245@@ -7849,18 +7851,22 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) {
7246 // OpenCL C v2.0 s6.5.1 - Variables defined at program scope and static
7247 // variables inside a function can also be declared in the global
7248 // address space.
7249+ // OpenCL C v3.0 s5.5 - For OpenCL C 2.0, or with the
7250+ // __opencl_c_program_scope_global_variables feature macro, the
7251+ // address space for a variable at program scope or a static variable
7252+ // also be __global
7253 // C++ for OpenCL inherits rule from OpenCL C v2.0.
7254 // FIXME: Adding local AS in C++ for OpenCL might make sense.
7255 if (NewVD->isFileVarDecl() || NewVD->isStaticLocal() ||
7256 NewVD->hasExternalStorage()) {
7257- if (!T->isSamplerT() &&
7258- !T->isDependentType() &&
7259+ if (!T->isSamplerT() && !T->isDependentType() &&
7260 !(T.getAddressSpace() == LangAS::opencl_constant ||
7261 (T.getAddressSpace() == LangAS::opencl_global &&
7262- (getLangOpts().OpenCLVersion == 200 ||
7263- getLangOpts().OpenCLCPlusPlus)))) {
7264+ (OpenCLFeatures.isEnabled(
7265+ "__opencl_c_program_scope_global_variables"))))) {
7266 int Scope = NewVD->isStaticLocal() | NewVD->hasExternalStorage() << 1;
7267- if (getLangOpts().OpenCLVersion == 200 || getLangOpts().OpenCLCPlusPlus)
7268+ if (OpenCLFeatures.isEnabled(
7269+ "__opencl_c_program_scope_global_variables"))
7270 Diag(NewVD->getLocation(), diag::err_opencl_global_invalid_addr_space)
7271 << Scope << "global or constant";
7272 else
7273diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
7274index a9a2a19b4797..73b35eae176a 100644
7275--- a/clang/lib/Sema/SemaDeclAttr.cpp
7276+++ b/clang/lib/Sema/SemaDeclAttr.cpp
7277@@ -6488,7 +6488,7 @@ static void handleInternalLinkageAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
7278 }
7279
7280 static void handleOpenCLNoSVMAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
7281- if (S.LangOpts.OpenCLVersion != 200)
7282+ if (S.LangOpts.OpenCLVersion < 200)
7283 S.Diag(AL.getLoc(), diag::err_attribute_requires_opencl_version)
7284 << AL << "2.0" << 0;
7285 else
7286@@ -6572,6 +6572,13 @@ static void handleOpenCLAccessAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
7287 << AL << PDecl->getType() << DeclTy->isImageType();
7288 D->setInvalidDecl(true);
7289 return;
7290+ } else if ((!S.getLangOpts().OpenCLCPlusPlus &&
7291+ S.getLangOpts().OpenCLVersion >= 200) &&
7292+ !S.getOpenCLOptions().isEnabled(
7293+ "__opencl_c_read_write_images")) {
7294+ S.Diag(AL.getLoc(), diag::err_opencl_requires_extension)
7295+ << 0 << PDecl->getType() << "__opencl_c_read_write_images";
7296+ return;
7297 }
7298 }
7299 }
7300diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
7301index 22bf35dbd0cb..b2081bb6b407 100644
7302--- a/clang/lib/Sema/SemaDeclCXX.cpp
7303+++ b/clang/lib/Sema/SemaDeclCXX.cpp
7304@@ -38,9 +38,9 @@
7305 #include "clang/Sema/ScopeInfo.h"
7306 #include "clang/Sema/SemaInternal.h"
7307 #include "clang/Sema/Template.h"
7308+#include "llvm/ADT/STLExtras.h"
7309 #include "llvm/ADT/ScopeExit.h"
7310 #include "llvm/ADT/SmallString.h"
7311-#include "llvm/ADT/STLExtras.h"
7312 #include "llvm/ADT/StringExtras.h"
7313 #include <map>
7314 #include <set>
7315@@ -15228,6 +15228,11 @@ CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl,
7316 if (auto *PtrTy = ResultType->getAs<PointerType>()) {
7317 ResultType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy);
7318 }
7319+ if (CanQual<PointerType> ExpectedPtrTy =
7320+ ExpectedResultType->getAs<PointerType>()) {
7321+ ExpectedResultType = SemaRef.Context.getCanonicalType(
7322+ RemoveAddressSpaceFromPtr(SemaRef, ExpectedPtrTy->getTypePtr()));
7323+ }
7324 }
7325
7326 // Check that the result type is what we expect.
7327@@ -15261,6 +15266,11 @@ CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl,
7328 FnDecl->getParamDecl(0)->getType()->getAs<PointerType>()) {
7329 FirstParamType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy);
7330 }
7331+ if (CanQual<PointerType> ExpectedPtrTy =
7332+ ExpectedFirstParamType->getAs<PointerType>()) {
7333+ ExpectedFirstParamType = SemaRef.Context.getCanonicalType(
7334+ RemoveAddressSpaceFromPtr(SemaRef, ExpectedPtrTy->getTypePtr()));
7335+ }
7336 }
7337
7338 // Check that the first parameter type is what we expect.
7339diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
7340index bcbecd545398..40eaebbc9495 100644
7341--- a/clang/lib/Sema/SemaLookup.cpp
7342+++ b/clang/lib/Sema/SemaLookup.cpp
7343@@ -775,19 +775,20 @@ static void InsertOCLBuiltinDeclarationsFromTable(Sema &S, LookupResult &LR,
7344 // as argument. Only meaningful for generic types, otherwise equals 1.
7345 unsigned GenTypeMaxCnt;
7346
7347+ ASTContext &Context = S.Context;
7348+
7349+ // Ignore this BIF if its version does not match the language options.
7350+ unsigned OpenCLVersion = Context.getLangOpts().OpenCLVersion;
7351+ if (Context.getLangOpts().OpenCLCPlusPlus)
7352+ OpenCLVersion = 200;
7353+
7354+ unsigned short VersionCode = OpenCLOptions::EncodeVersion(OpenCLVersion);
7355+
7356 for (unsigned SignatureIndex = 0; SignatureIndex < Len; SignatureIndex++) {
7357 const OpenCLBuiltinStruct &OpenCLBuiltin =
7358 BuiltinTable[FctIndex + SignatureIndex];
7359- ASTContext &Context = S.Context;
7360
7361- // Ignore this BIF if its version does not match the language options.
7362- unsigned OpenCLVersion = Context.getLangOpts().OpenCLVersion;
7363- if (Context.getLangOpts().OpenCLCPlusPlus)
7364- OpenCLVersion = 200;
7365- if (OpenCLVersion < OpenCLBuiltin.MinVersion)
7366- continue;
7367- if ((OpenCLBuiltin.MaxVersion != 0) &&
7368- (OpenCLVersion >= OpenCLBuiltin.MaxVersion))
7369+ if (!(OpenCLBuiltin.AllVersions & VersionCode))
7370 continue;
7371
7372 SmallVector<QualType, 1> RetTypes;
7373diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
7374index cc151a048b98..f380a5656a57 100644
7375--- a/clang/lib/Sema/SemaType.cpp
7376+++ b/clang/lib/Sema/SemaType.cpp
7377@@ -2042,7 +2042,7 @@ static QualType deduceOpenCLPointeeAddrSpace(Sema &S, QualType PointeeType) {
7378 !PointeeType.hasAddressSpace())
7379 PointeeType = S.getASTContext().getAddrSpaceQualType(
7380 PointeeType,
7381- S.getLangOpts().OpenCLCPlusPlus || S.getLangOpts().OpenCLVersion == 200
7382+ S.getOpenCLOptions().isEnabled("__opencl_c_generic_address_space")
7383 ? LangAS::opencl_generic
7384 : LangAS::opencl_private);
7385 return PointeeType;
7386@@ -5316,9 +5316,15 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
7387 }
7388
7389 case DeclaratorChunk::Pipe: {
7390- T = S.BuildReadPipeType(T, DeclType.Loc);
7391- processTypeAttrs(state, T, TAL_DeclSpec,
7392- D.getMutableDeclSpec().getAttributes());
7393+ if (S.getOpenCLOptions().isEnabled("__opencl_c_pipes")) {
7394+ T = S.BuildReadPipeType(T, DeclType.Loc);
7395+ processTypeAttrs(state, T, TAL_DeclSpec,
7396+ D.getMutableDeclSpec().getAttributes());
7397+ } else {
7398+ D.setInvalidType(true);
7399+ T = Context.IntTy;
7400+ S.Diag(D.getIdentifierLoc(), diag::err_opencl_pipes_require_feat);
7401+ }
7402 break;
7403 }
7404 }
7405diff --git a/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl b/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
7406index e1f3f6fe1419..b43d9df5935c 100644
7407--- a/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
7408+++ b/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
7409@@ -2,7 +2,8 @@
7410 // RUN: %clang_cc1 %s -emit-llvm -o - -O0 -triple amdgcn | FileCheck -enable-var-scope -check-prefixes=ALL,AMDGCN %s
7411 // RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -triple amdgcn | FileCheck -enable-var-scope -check-prefixes=ALL,AMDGCN,AMDGCN20 %s
7412 // RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL1.2 -O0 -triple spir-unknown-unknown-unknown | FileCheck -enable-var-scope -check-prefixes=SPIR %s
7413-
7414+// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL3.0 -O0 -triple spir-unknown-unknown-unknown | FileCheck -enable-var-scope -check-prefixes=SPIR %s
7415+// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL3.0 -cl-ext=__opencl_c_program_scope_global_variables -O0 -triple spir-unknown-unknown-unknown | FileCheck -enable-var-scope -check-prefixes=SPIR %s
7416 typedef int int2 __attribute__((ext_vector_type(2)));
7417
7418 typedef struct {
7419@@ -39,7 +40,7 @@ struct LargeStructTwoMember {
7420 int2 y[20];
7421 };
7422
7423-#if __OPENCL_C_VERSION__ >= 200
7424+#ifdef __opencl_c_program_scope_global_variables
7425 struct LargeStructOneMember g_s;
7426 #endif
7427
7428@@ -98,7 +99,7 @@ void FuncOneLargeMember(struct LargeStructOneMember u) {
7429 // AMDGCN20: %[[r0:.*]] = bitcast %struct.LargeStructOneMember addrspace(5)* %[[byval_temp]] to i8 addrspace(5)*
7430 // AMDGCN20: call void @llvm.memcpy.p5i8.p1i8.i64(i8 addrspace(5)* align 8 %[[r0]], i8 addrspace(1)* align 8 bitcast (%struct.LargeStructOneMember addrspace(1)* @g_s to i8 addrspace(1)*), i64 800, i1 false)
7431 // AMDGCN20: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval(%struct.LargeStructOneMember) align 8 %[[byval_temp]])
7432-#if __OPENCL_C_VERSION__ >= 200
7433+#ifdef __opencl_c_program_scope_global_variables
7434 void test_indirect_arg_globl(void) {
7435 FuncOneLargeMember(g_s);
7436 }
7437diff --git a/clang/test/CodeGenOpenCL/address-spaces-conversions.cl b/clang/test/CodeGenOpenCL/address-spaces-conversions.cl
7438index 52feccc540bb..9ecffcca5ee9 100644
7439--- a/clang/test/CodeGenOpenCL/address-spaces-conversions.cl
7440+++ b/clang/test/CodeGenOpenCL/address-spaces-conversions.cl
7441@@ -1,5 +1,7 @@
7442 // RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -O0 -ffake-address-space-map -cl-std=CL2.0 -emit-llvm -o - | FileCheck %s
7443+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -O0 -ffake-address-space-map -cl-std=CL3.0 -cl-ext=__opencl_c_generic_address_space -emit-llvm -o - | FileCheck %s
7444 // RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -O0 -cl-std=CL2.0 -emit-llvm -o - | FileCheck --check-prefix=CHECK-NOFAKE %s
7445+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -O0 -cl-std=CL3.0 -cl-ext=__opencl_c_generic_address_space -emit-llvm -o - | FileCheck --check-prefix=CHECK-NOFAKE %s
7446 // When -ffake-address-space-map is not used, all addr space mapped to 0 for x86_64.
7447
7448 // test that we generate address space casts everywhere we need conversions of
7449diff --git a/clang/test/CodeGenOpenCL/address-spaces-mangling.cl b/clang/test/CodeGenOpenCL/address-spaces-mangling.cl
7450index 50622f099143..e19ec8451d0d 100644
7451--- a/clang/test/CodeGenOpenCL/address-spaces-mangling.cl
7452+++ b/clang/test/CodeGenOpenCL/address-spaces-mangling.cl
7453@@ -6,6 +6,7 @@
7454 // We check that the address spaces are mangled the same in both version of OpenCL
7455 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL2.0 -emit-llvm -o - | FileCheck -check-prefix=OCL-20 %s
7456 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL1.2 -emit-llvm -o - | FileCheck -check-prefix=OCL-12 %s
7457+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL3.0 -emit-llvm -o - | FileCheck -check-prefix=OCL-12 %s
7458
7459 // We can't name this f as private is equivalent to default
7460 // no specifier given address space so we get multiple definition
7461@@ -47,7 +48,7 @@ void f(constant int *arg) { }
7462 // OCL-20-DAG: @_Z1fPU3AS2i
7463 // OCL-12-DAG: @_Z1fPU3AS2i
7464
7465-#if __OPENCL_C_VERSION__ >= 200
7466+#if __OPENCL_C_VERSION__ == 200
7467 __attribute__((overloadable))
7468 void f(generic int *arg) { }
7469 // ASMANG20: @_Z1fPU3AS4i
7470diff --git a/clang/test/CodeGenOpenCL/address-spaces.cl b/clang/test/CodeGenOpenCL/address-spaces.cl
7471index 144466a690b3..b150e1080b53 100644
7472--- a/clang/test/CodeGenOpenCL/address-spaces.cl
7473+++ b/clang/test/CodeGenOpenCL/address-spaces.cl
7474@@ -1,9 +1,13 @@
7475 // RUN: %clang_cc1 %s -O0 -ffake-address-space-map -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,SPIR
7476+// RUN: %clang_cc1 %s -O0 -cl-std=CL3.0 -ffake-address-space-map -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,SPIR
7477 // RUN: %clang_cc1 %s -O0 -DCL20 -cl-std=CL2.0 -ffake-address-space-map -emit-llvm -o - | FileCheck %s --check-prefixes=CL20,CL20SPIR
7478 // RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
7479+// RUN: %clang_cc1 %s -O0 -cl-std=CL3.0 -triple amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
7480 // RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -DCL20 -cl-std=CL2.0 -emit-llvm -o - | FileCheck %s --check-prefixes=CL20,CL20AMDGCN
7481 // RUN: %clang_cc1 %s -O0 -triple amdgcn-mesa-mesa3d -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
7482+// RUN: %clang_cc1 %s -O0 -cl-std=CL3.0 -triple amdgcn-mesa-mesa3d -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
7483 // RUN: %clang_cc1 %s -O0 -triple r600-- -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
7484+// RUN: %clang_cc1 %s -O0 -cl-std=CL3.0 -triple r600-- -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
7485
7486 // SPIR: %struct.S = type { i32, i32, i32* }
7487 // CL20SPIR: %struct.S = type { i32, i32, i32 addrspace(4)* }
7488diff --git a/clang/test/CodeGenOpenCL/amdgcn-automatic-variable.cl b/clang/test/CodeGenOpenCL/amdgcn-automatic-variable.cl
7489index 7216cb517495..8d3b30fe8074 100644
7490--- a/clang/test/CodeGenOpenCL/amdgcn-automatic-variable.cl
7491+++ b/clang/test/CodeGenOpenCL/amdgcn-automatic-variable.cl
7492@@ -1,4 +1,5 @@
7493 // RUN: %clang_cc1 -O0 -cl-std=CL1.2 -triple amdgcn---amdgizcl -emit-llvm %s -o - | FileCheck -check-prefixes=CHECK,CL12 %s
7494+// RUN: %clang_cc1 -O0 -cl-std=CL3.0 -triple amdgcn---amdgizcl -emit-llvm %s -o - | FileCheck -check-prefixes=CHECK,CL12 %s
7495 // RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn---amdgizcl -emit-llvm %s -o - | FileCheck -check-prefixes=CHECK,CL20 %s
7496
7497 // CL12-LABEL: define void @func1(i32 addrspace(5)* %x)
7498diff --git a/clang/test/CodeGenOpenCL/amdgpu-sizeof-alignof.cl b/clang/test/CodeGenOpenCL/amdgpu-sizeof-alignof.cl
7499index a5d438933fa4..8073c7756eb6 100644
7500--- a/clang/test/CodeGenOpenCL/amdgpu-sizeof-alignof.cl
7501+++ b/clang/test/CodeGenOpenCL/amdgpu-sizeof-alignof.cl
7502@@ -4,6 +4,17 @@
7503 // RUN: %clang_cc1 -triple amdgcn---opencl -cl-std=CL2.0 %s -emit-llvm -o - | FileCheck %s
7504 // RUN: %clang_cc1 -triple amdgcn---amdgizcl -cl-std=CL1.2 %s -emit-llvm -o - | FileCheck %s
7505 // RUN: %clang_cc1 -triple amdgcn---amdgizcl -cl-std=CL2.0 %s -emit-llvm -o - | FileCheck %s
7506+// RUN: %clang_cc1 -triple r600 -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s
7507+// RUN: %clang_cc1 -triple amdgcn-mesa-mesa3d -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s
7508+// RUN: %clang_cc1 -triple amdgcn---opencl -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s
7509+// RUN: %clang_cc1 -triple amdgcn---amdgizcl -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s
7510+// RUN: %clang_cc1 -triple amdgcn-mesa-mesa3d -cl-ext=__opencl_c_generic_address_space -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s
7511+// RUN: %clang_cc1 -triple amdgcn---opencl -cl-ext=__opencl_c_generic_address_space -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s
7512+// RUN: %clang_cc1 -triple amdgcn---amdgizcl -cl-ext=__opencl_c_generic_address_space -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s
7513+// RUN: %clang_cc1 -triple r600 -cl-ext=__opencl_c_fp64 -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s
7514+// RUN: %clang_cc1 -triple amdgcn-mesa-mesa3d -cl-ext=__opencl_c_fp64 -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s
7515+// RUN: %clang_cc1 -triple amdgcn---opencl -cl-ext=__opencl_c_fp64 -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s
7516+// RUN: %clang_cc1 -triple amdgcn---amdgizcl -cl-ext=__opencl_c_fp64 -cl-std=CL3.0 %s -emit-llvm -o - | FileCheck %s
7517
7518 #ifdef __AMDGCN__
7519 #define PTSIZE 8
7520@@ -11,7 +22,7 @@
7521 #define PTSIZE 4
7522 #endif
7523
7524-#ifdef cl_khr_fp64
7525+#if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
7526 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
7527 #endif
7528 #ifdef cl_khr_fp16
7529@@ -59,8 +70,12 @@ void test() {
7530 check(__alignof__(double) == 8);
7531 #endif
7532
7533- check(sizeof(void*) == (__OPENCL_C_VERSION__ >= 200 ? 8 : 4));
7534- check(__alignof__(void*) == (__OPENCL_C_VERSION__ >= 200 ? 8 : 4));
7535+ check(sizeof(private void*) == 4);
7536+ check(__alignof__(private void*) == 4);
7537+#ifdef __opencl_c_generic_address_space
7538+ check(sizeof(generic void*) == 8);
7539+ check(__alignof__(generic void*) == 8);
7540+#endif
7541 check(sizeof(global_ptr_t) == PTSIZE);
7542 check(__alignof__(global_ptr_t) == PTSIZE);
7543 check(sizeof(constant_ptr_t) == PTSIZE);
7544diff --git a/clang/test/CodeGenOpenCL/arm-integer-dot-product.cl b/clang/test/CodeGenOpenCL/arm-integer-dot-product.cl
7545index d1ab6aceac5c..70c5bace023b 100644
7546--- a/clang/test/CodeGenOpenCL/arm-integer-dot-product.cl
7547+++ b/clang/test/CodeGenOpenCL/arm-integer-dot-product.cl
7548@@ -1,4 +1,5 @@
7549 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -finclude-default-header -cl-std=CL1.2 -emit-llvm -o - -O0 | FileCheck %s
7550+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -finclude-default-header -cl-std=CL3.0 -emit-llvm -o - -O0 | FileCheck %s
7551
7552 #pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : enable
7553 void test_int8(uchar4 ua, uchar4 ub, char4 sa, char4 sb) {
7554diff --git a/clang/test/CodeGenOpenCL/cl-uniform-wg-size.cl b/clang/test/CodeGenOpenCL/cl-uniform-wg-size.cl
7555index 76ace5dca21e..5dc43e222f75 100644
7556--- a/clang/test/CodeGenOpenCL/cl-uniform-wg-size.cl
7557+++ b/clang/test/CodeGenOpenCL/cl-uniform-wg-size.cl
7558@@ -1,6 +1,8 @@
7559 // RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL1.2 -o - %s 2>&1 | FileCheck %s -check-prefixes CHECK,CHECK-UNIFORM
7560 // RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s 2>&1 | FileCheck %s -check-prefixes CHECK,CHECK-NONUNIFORM
7561 // RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -cl-uniform-work-group-size -o - %s 2>&1 | FileCheck %s -check-prefixes CHECK,CHECK-UNIFORM
7562+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL3.0 -o - %s 2>&1 | FileCheck %s -check-prefixes CHECK,CHECK-NONUNIFORM
7563+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL3.0 -cl-uniform-work-group-size -o - %s 2>&1 | FileCheck %s -check-prefixes CHECK,CHECK-UNIFORM
7564
7565 kernel void ker() {};
7566 // CHECK: define{{.*}}@ker() #0
7567diff --git a/clang/test/CodeGenOpenCL/fpmath.cl b/clang/test/CodeGenOpenCL/fpmath.cl
7568index 0108d909c94e..b28392739c71 100644
7569--- a/clang/test/CodeGenOpenCL/fpmath.cl
7570+++ b/clang/test/CodeGenOpenCL/fpmath.cl
7571@@ -2,6 +2,8 @@
7572 // RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown -cl-fp32-correctly-rounded-divide-sqrt | FileCheck --check-prefix=CHECK --check-prefix=DIVOPT %s
7573 // RUN: %clang_cc1 %s -emit-llvm -o - -DNOFP64 -cl-std=CL1.2 -triple r600-unknown-unknown -target-cpu r600 -pedantic | FileCheck --check-prefix=CHECK-FLT %s
7574 // RUN: %clang_cc1 %s -emit-llvm -o - -DFP64 -cl-std=CL1.2 -triple spir-unknown-unknown -pedantic | FileCheck --check-prefix=CHECK-DBL %s
7575+// RUN: %clang_cc1 %s -emit-llvm -o - -DNOFP64 -cl-std=CL3.0 -triple r600-unknown-unknown -target-cpu r600 -pedantic | FileCheck --check-prefix=CHECK-FLT %s
7576+// RUN: %clang_cc1 %s -emit-llvm -o - -DFP64 -cl-std=CL3.0 -cl-ext=__opencl_c_fp64 -triple spir-unknown-unknown -pedantic | FileCheck --check-prefix=CHECK-DBL %s
7577
7578 typedef __attribute__(( ext_vector_type(4) )) float float4;
7579
7580diff --git a/clang/test/CodeGenOpenCL/generic-address-space-feature.cl b/clang/test/CodeGenOpenCL/generic-address-space-feature.cl
7581new file mode 100644
7582index 000000000000..890860abe4d9
7583--- /dev/null
7584+++ b/clang/test/CodeGenOpenCL/generic-address-space-feature.cl
7585@@ -0,0 +1,28 @@
7586+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -O0 -cl-std=CL1.2 -cl-ext=-cl_khr_fp64 -finclude-default-header -emit-llvm -o - | FileCheck %s --check-prefixes=CL12
7587+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -O0 -cl-std=CL1.2 -cl-ext=-cl_khr_fp64 -fdeclare-opencl-builtins -emit-llvm -o - | FileCheck %s --check-prefixes=CL12
7588+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -O0 -cl-std=CL2.0 -cl-ext=-cl_khr_fp64 -finclude-default-header -emit-llvm -o - | FileCheck %s --check-prefixes=CL20
7589+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -O0 -cl-std=CL2.0 -cl-ext=-cl_khr_fp64 -fdeclare-opencl-builtins -emit-llvm -o - | FileCheck %s --check-prefixes=CL20
7590+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -O0 -cl-std=CL3.0 -cl-ext=-cl_khr_fp64 -finclude-default-header -emit-llvm -o - | FileCheck %s --check-prefixes=CL30
7591+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -O0 -cl-std=CL3.0 -cl-ext=-cl_khr_fp64,__opencl_c_generic_address_space -finclude-default-header -emit-llvm -o - | FileCheck %s --check-prefixes=CL30-GENERIC
7592+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -O0 -cl-std=CL3.0 -cl-ext=-cl_khr_fp64 -fdeclare-opencl-builtins -emit-llvm -o - | FileCheck %s --check-prefixes=CL30
7593+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -O0 -cl-std=CL3.0 -cl-ext=-cl_khr_fp64,__opencl_c_generic_address_space -fdeclare-opencl-builtins -emit-llvm -o - | FileCheck %s --check-prefixes=CL30-GENERIC
7594+
7595+void test(global float* src1, local float *src2, private float *src3, float *src4, float tmp) {
7596+ // CL20: %{{.+}} = addrspacecast float addrspace(1)* %{{.+}} to float addrspace(4)*
7597+ // CL12-NOT: addrspacecast
7598+ // CL30-NOT: addrspacecast
7599+ // CL30-GENERIC-NOT: addrspacecast
7600+ tmp = sincos(tmp, src1);
7601+ // CL20: %{{.+}} = addrspacecast float addrspace(3)* %{{.+}} to float addrspace(4)*
7602+ // CL12-NOT: addrspacecast
7603+ // CL30-NOT: addrspacecast
7604+ // CL30-GENERIC-NOT: addrspacecast
7605+ tmp = sincos(tmp, src2);
7606+
7607+ // CL12: %{{.+}} = call {{(spir_func )?}}float [[FUNCNAME:@.*sincos.*]](float %{{.+}}, float* {{.+}})
7608+ // CL20: %{{.+}} = call {{(spir_func )?}}float [[FUNCNAME:@.*sincos.*]](float %{{.+}}, float addrspace(4)* {{.+}})
7609+ // CL30: %{{.+}} = call {{(spir_func )?}}float [[FUNCNAME:@.*sincos.*]](float %{{.+}}, float* {{.+}})
7610+ // CL30-GENERIC: %{{.+}} = call {{(spir_func )?}}float [[FUNCNAME:@.*sincos.*]](float %{{.+}}, float addrspace(4)* {{.+}})
7611+ // CHECK: addrspacecast
7612+ tmp = sincos(tmp, src4);
7613+}
7614diff --git a/clang/test/CodeGenOpenCL/intel-subgroups-avc-ext-types.cl b/clang/test/CodeGenOpenCL/intel-subgroups-avc-ext-types.cl
7615index 515f13f6e768..5aa31ac6f345 100644
7616--- a/clang/test/CodeGenOpenCL/intel-subgroups-avc-ext-types.cl
7617+++ b/clang/test/CodeGenOpenCL/intel-subgroups-avc-ext-types.cl
7618@@ -1,4 +1,5 @@
7619 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL1.2 -cl-ext=+cl_intel_device_side_avc_motion_estimation -emit-llvm -o - -O0 | FileCheck %s
7620+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL3.0 -cl-ext=+cl_intel_device_side_avc_motion_estimation -emit-llvm -o - -O0 | FileCheck %s
7621
7622 // CHECK: %opencl.intel_sub_group_avc_mce_payload_t = type opaque
7623 // CHECK: %opencl.intel_sub_group_avc_ime_payload_t = type opaque
7624diff --git a/clang/test/CodeGenOpenCL/kernels-have-spir-cc-by-default.cl b/clang/test/CodeGenOpenCL/kernels-have-spir-cc-by-default.cl
7625index e89237623478..3d6708ac361f 100644
7626--- a/clang/test/CodeGenOpenCL/kernels-have-spir-cc-by-default.cl
7627+++ b/clang/test/CodeGenOpenCL/kernels-have-spir-cc-by-default.cl
7628@@ -1,5 +1,8 @@
7629 // RUN: %clang_cc1 %s -cl-std=CL1.2 -emit-llvm -triple x86_64-unknown-unknown -o - | FileCheck %s
7630 // RUN: %clang_cc1 %s -cl-std=CL1.2 -emit-llvm -triple amdgcn-unknown-unknown -o - | FileCheck -check-prefixes=AMDGCN %s
7631+// RUN: %clang_cc1 %s -cl-std=CL3.0 -cl-ext=__opencl_c_fp64 -emit-llvm -triple x86_64-unknown-unknown -o - | FileCheck %s
7632+// RUN: %clang_cc1 %s -cl-std=CL3.0 -cl-ext=__opencl_c_fp64 -emit-llvm -triple amdgcn-unknown-unknown -o - | FileCheck -check-prefixes=AMDGCN %s
7633+
7634 // Test that the kernels always use the SPIR calling convention
7635 // to have unambiguous mapping of arguments to feasibly implement
7636 // clSetKernelArg().
7637diff --git a/clang/test/CodeGenOpenCL/logical-ops.cl b/clang/test/CodeGenOpenCL/logical-ops.cl
7638index f083a8580ee7..499eab65039b 100644
7639--- a/clang/test/CodeGenOpenCL/logical-ops.cl
7640+++ b/clang/test/CodeGenOpenCL/logical-ops.cl
7641@@ -1,4 +1,5 @@
7642 // RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL1.2 -O1 -triple x86_64-unknown-linux-gnu | FileCheck %s
7643+// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL3.0 -cl-ext=__opencl_c_fp64 -O1 -triple x86_64-unknown-linux-gnu | FileCheck %s
7644 // RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=clc++ -O1 -triple x86_64-unknown-linux-gnu | FileCheck %s
7645
7646 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
7647diff --git a/clang/test/CodeGenOpenCL/no-half.cl b/clang/test/CodeGenOpenCL/no-half.cl
7648index aee8f678f01a..46da7fa339e8 100644
7649--- a/clang/test/CodeGenOpenCL/no-half.cl
7650+++ b/clang/test/CodeGenOpenCL/no-half.cl
7651@@ -1,6 +1,7 @@
7652 // RUN: %clang_cc1 %s -cl-std=cl2.0 -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s
7653 // RUN: %clang_cc1 %s -cl-std=cl1.2 -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s
7654 // RUN: %clang_cc1 %s -cl-std=cl1.1 -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s
7655+// RUN: %clang_cc1 %s -cl-std=cl3.0 -cl-ext=__opencl_c_fp64 -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s
7656
7657 #pragma OPENCL EXTENSION cl_khr_fp64:enable
7658
7659diff --git a/clang/test/CodeGenOpenCL/pipe_builtin.cl b/clang/test/CodeGenOpenCL/pipe_builtin.cl
7660index 02b9669b7ab1..0bf35c336199 100644
7661--- a/clang/test/CodeGenOpenCL/pipe_builtin.cl
7662+++ b/clang/test/CodeGenOpenCL/pipe_builtin.cl
7663@@ -1,4 +1,7 @@
7664 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -cl-ext=+cl_khr_subgroups -O0 -cl-std=clc++ -o - %s | FileCheck %s
7665+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -cl-ext=+cl_khr_subgroups -O0 -cl-std=cl2.0 -o - %s | FileCheck %s
7666+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -cl-ext=+cl_khr_subgroups -O0 -cl-std=cl3.0 -cl-ext=__opencl_c_pipes,__opencl_c_subgroups -o - %s | FileCheck %s
7667+
7668 // FIXME: Add MS ABI manglings of OpenCL things and remove %itanium_abi_triple
7669 // above to support OpenCL in the MS C++ ABI.
7670
7671diff --git a/clang/test/CodeGenOpenCL/pipe_types.cl b/clang/test/CodeGenOpenCL/pipe_types.cl
7672index ba064c6d7557..b7a523d4f084 100644
7673--- a/clang/test/CodeGenOpenCL/pipe_types.cl
7674+++ b/clang/test/CodeGenOpenCL/pipe_types.cl
7675@@ -1,4 +1,5 @@
7676 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
7677+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -cl-std=CL3.0 -cl-ext=__opencl_c_pipes -o - %s | FileCheck %s
7678
7679 // CHECK: %opencl.pipe_ro_t = type opaque
7680 // CHECK: %opencl.pipe_wo_t = type opaque
7681diff --git a/clang/test/CodeGenOpenCL/printf.cl b/clang/test/CodeGenOpenCL/printf.cl
7682index fc139d776db6..0133c5595d81 100644
7683--- a/clang/test/CodeGenOpenCL/printf.cl
7684+++ b/clang/test/CodeGenOpenCL/printf.cl
7685@@ -1,5 +1,7 @@
7686 // RUN: %clang_cc1 -cl-std=CL1.2 -cl-ext=-+cl_khr_fp64 -triple spir-unknown-unknown -disable-llvm-passes -emit-llvm -o - %s | FileCheck -check-prefixes=FP64,ALL %s
7687 // RUN: %clang_cc1 -cl-std=CL1.2 -cl-ext=-cl_khr_fp64 -triple spir-unknown-unknown -disable-llvm-passes -emit-llvm -o - %s | FileCheck -check-prefixes=NOFP64,ALL %s
7688+// RUN: %clang_cc1 -cl-std=CL3.0 -cl-ext=+__opencl_c_fp64 -triple spir-unknown-unknown -disable-llvm-passes -emit-llvm -o - %s | FileCheck -check-prefixes=FP64,ALL %s
7689+// RUN: %clang_cc1 -cl-std=CL3.0 -triple spir-unknown-unknown -disable-llvm-passes -emit-llvm -o - %s | FileCheck -check-prefixes=NOFP64,ALL %s
7690
7691 typedef __attribute__((ext_vector_type(2))) float float2;
7692 typedef __attribute__((ext_vector_type(2))) half half2;
7693diff --git a/clang/test/CodeGenOpenCL/unroll-hint.cl b/clang/test/CodeGenOpenCL/unroll-hint.cl
7694index 0f84450a1ae6..9347c935869b 100644
7695--- a/clang/test/CodeGenOpenCL/unroll-hint.cl
7696+++ b/clang/test/CodeGenOpenCL/unroll-hint.cl
7697@@ -1,5 +1,6 @@
7698 // RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
7699 // RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL1.2 -o - %s | FileCheck %s
7700+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL3.0 -o - %s | FileCheck %s
7701
7702 /*** for ***/
7703 void for_count()
7704diff --git a/clang/test/Driver/autocomplete.c b/clang/test/Driver/autocomplete.c
7705index 18b31320ea80..a6e7be887c8c 100644
7706--- a/clang/test/Driver/autocomplete.c
7707+++ b/clang/test/Driver/autocomplete.c
7708@@ -43,6 +43,8 @@
7709 // CLSTDALL-NEXT: CL1.2
7710 // CLSTDALL-NEXT: cl2.0
7711 // CLSTDALL-NEXT: CL2.0
7712+// CLSTDALL-NEXT: cl3.0
7713+// CLSTDALL-NEXT: CL3.0
7714 // CLSTDALL-NEXT: clc++
7715 // CLSTDALL-NEXT: CLC++
7716 // RUN: %clang --autocomplete=-fno-sanitize-coverage=,f | FileCheck %s -check-prefix=FNOSANICOVER
7717diff --git a/clang/test/Driver/opencl.cl b/clang/test/Driver/opencl.cl
7718index 05588f2c8b81..cc0a9143ab37 100644
7719--- a/clang/test/Driver/opencl.cl
7720+++ b/clang/test/Driver/opencl.cl
7721@@ -2,6 +2,7 @@
7722 // RUN: %clang -S -### -cl-std=CL1.1 %s 2>&1 | FileCheck --check-prefix=CHECK-CL11 %s
7723 // RUN: %clang -S -### -cl-std=CL1.2 %s 2>&1 | FileCheck --check-prefix=CHECK-CL12 %s
7724 // RUN: %clang -S -### -cl-std=CL2.0 %s 2>&1 | FileCheck --check-prefix=CHECK-CL20 %s
7725+// RUN: %clang -S -### -cl-std=CL3.0 %s 2>&1 | FileCheck --check-prefix=CHECK-CL30 %s
7726 // RUN: %clang -S -### -cl-std=clc++ %s 2>&1 | FileCheck --check-prefix=CHECK-CLCPP %s
7727 // RUN: %clang -S -### -cl-opt-disable %s 2>&1 | FileCheck --check-prefix=CHECK-OPT-DISABLE %s
7728 // RUN: %clang -S -### -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-STRICT-ALIASING %s
7729@@ -22,6 +23,7 @@
7730 // CHECK-CL11: "-cc1" {{.*}} "-cl-std=CL1.1"
7731 // CHECK-CL12: "-cc1" {{.*}} "-cl-std=CL1.2"
7732 // CHECK-CL20: "-cc1" {{.*}} "-cl-std=CL2.0"
7733+// CHECK-CL30: "-cc1" {{.*}} "-cl-std=CL3.0"
7734 // CHECK-CLCPP: "-cc1" {{.*}} "-cl-std=clc++"
7735 // CHECK-OPT-DISABLE: "-cc1" {{.*}} "-cl-opt-disable"
7736 // CHECK-STRICT-ALIASING: "-cc1" {{.*}} "-cl-strict-aliasing"
7737diff --git a/clang/test/Driver/unknown-std.cl b/clang/test/Driver/unknown-std.cl
7738index 6f371bac13ac..00209fb62556 100644
7739--- a/clang/test/Driver/unknown-std.cl
7740+++ b/clang/test/Driver/unknown-std.cl
7741@@ -10,6 +10,7 @@
7742 // CHECK-NEXT: note: use 'cl1.1' for 'OpenCL 1.1' standard
7743 // CHECK-NEXT: note: use 'cl1.2' for 'OpenCL 1.2' standard
7744 // CHECK-NEXT: note: use 'cl2.0' for 'OpenCL 2.0' standard
7745+// CHECK-NEXT: note: use 'cl3.0' for 'OpenCL 3.0' standard
7746 // CHECK-NEXT: note: use 'clc++' for 'C++ for OpenCL' standard
7747
7748 // Make sure that no other output is present.
7749diff --git a/clang/test/Frontend/stdlang.c b/clang/test/Frontend/stdlang.c
7750index 51484999e37a..eac4632fbdd6 100644
7751--- a/clang/test/Frontend/stdlang.c
7752+++ b/clang/test/Frontend/stdlang.c
7753@@ -9,6 +9,7 @@
7754 // RUN: %clang_cc1 -x cl -cl-std=CL1.1 -DOPENCL %s
7755 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 -DOPENCL %s
7756 // RUN: %clang_cc1 -x cl -cl-std=CL2.0 -DOPENCL %s
7757+// RUN: %clang_cc1 -x cl -cl-std=CL3.0 -DOPENCL %s
7758 // RUN: %clang_cc1 -x cl -cl-std=CLC++ -DOPENCL %s
7759 // RUN: not %clang_cc1 -x cl -std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
7760 // RUN: not %clang_cc1 -x cl -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
7761diff --git a/clang/test/Headers/opencl-c-header.cl b/clang/test/Headers/opencl-c-header.cl
7762index 1b151ffdd16a..2716076acdcf 100644
7763--- a/clang/test/Headers/opencl-c-header.cl
7764+++ b/clang/test/Headers/opencl-c-header.cl
7765@@ -1,6 +1,7 @@
7766 // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify | FileCheck %s
7767 // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.1 | FileCheck %s
7768 // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.2 | FileCheck %s
7769+// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL3.0 | FileCheck %s
7770 // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=clc++ | FileCheck %s --check-prefix=CHECK20
7771
7772 // Test including the default header as a module.
7773@@ -39,9 +40,11 @@
7774 // RUN: rm -rf %t
7775 // RUN: mkdir -p %t
7776 // RUN: %clang_cc1 -triple spir64-unknown-unknown -emit-llvm -o - -cl-std=CL1.2 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MOD %s
7777+// RUN: %clang_cc1 -triple spir64-unknown-unknown -emit-llvm -o - -cl-std=CL3.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MOD %s
7778 // RUN: %clang_cc1 -triple amdgcn--amdhsa -O0 -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s
7779 // RUN: chmod u-w %t
7780 // RUN: %clang_cc1 -triple spir64-unknown-unknown -emit-llvm -o - -cl-std=CL1.2 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MOD %s
7781+// RUN: %clang_cc1 -triple spir64-unknown-unknown -emit-llvm -o - -cl-std=CL3.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MOD %s
7782 // RUN: %clang_cc1 -triple amdgcn--amdhsa -O0 -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s
7783 // RUN: chmod u+w %t
7784
7785@@ -67,7 +70,7 @@ char f(char x) {
7786 // from OpenCL 2.0 onwards.
7787
7788 // CHECK20: _Z12write_imagef14ocl_image3d_wo
7789-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
7790+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
7791 void test_image3dwo(write_only image3d_t img) {
7792 write_imagef(img, (0), (0.0f));
7793 }
7794@@ -81,7 +84,7 @@ void test_atomics(__generic volatile unsigned int* a) {
7795 #endif
7796
7797 // Verify that ATOMIC_VAR_INIT is defined.
7798-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
7799+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
7800 global atomic_int z = ATOMIC_VAR_INIT(99);
7801 #endif //__OPENCL_C_VERSION__
7802
7803diff --git a/clang/test/Index/pipe-size.cl b/clang/test/Index/pipe-size.cl
7804index 94a1255f0a48..59b76051eda1 100644
7805--- a/clang/test/Index/pipe-size.cl
7806+++ b/clang/test/Index/pipe-size.cl
7807@@ -2,6 +2,13 @@
7808 // RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple spir-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR
7809 // RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple spir64-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR64
7810 // RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple amdgcn-amd-amdhsa %s -o - | FileCheck %s --check-prefix=AMDGCN
7811+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL3.0 -cl-ext=__opencl_c_pipes -emit-llvm -triple x86_64-unknown-linux-gnu %s -o - | FileCheck %s --check-prefix=X86
7812+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL3.0 -cl-ext=__opencl_c_pipes -emit-llvm -triple spir-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR
7813+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL3.0 -cl-ext=__opencl_c_pipes -emit-llvm -triple spir64-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR64
7814+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL3.0 -cl-ext=__opencl_c_pipes -emit-llvm -triple amdgcn-amd-amdhsa %s -o - | FileCheck %s --check-prefix=AMDGCN
7815+
7816+
7817+
7818 __kernel void testPipe( pipe int test )
7819 {
7820 int s = sizeof(test);
7821diff --git a/clang/test/Preprocessor/init-aarch64.c b/clang/test/Preprocessor/init-aarch64.c
7822index df2a6128989b..cbb0995b48b0 100644
7823--- a/clang/test/Preprocessor/init-aarch64.c
7824+++ b/clang/test/Preprocessor/init-aarch64.c
7825@@ -109,12 +109,12 @@
7826 // AARCH64-NEXT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
7827 // AARCH64_CXX-NEXT: #define __GLIBCXX_BITSIZE_INT_N_0 128
7828 // AARCH64_CXX-NEXT: #define __GLIBCXX_TYPE_INT_N_0 __int128
7829-// AARCH64-NEXT: #define __INT16_C_SUFFIX__
7830+// AARCH64-NEXT: #define __INT16_C_SUFFIX__
7831 // AARCH64-NEXT: #define __INT16_FMTd__ "hd"
7832 // AARCH64-NEXT: #define __INT16_FMTi__ "hi"
7833 // AARCH64-NEXT: #define __INT16_MAX__ 32767
7834 // AARCH64-NEXT: #define __INT16_TYPE__ short
7835-// AARCH64-NEXT: #define __INT32_C_SUFFIX__
7836+// AARCH64-NEXT: #define __INT32_C_SUFFIX__
7837 // AARCH64-NEXT: #define __INT32_FMTd__ "d"
7838 // AARCH64-NEXT: #define __INT32_FMTi__ "i"
7839 // AARCH64-NEXT: #define __INT32_MAX__ 2147483647
7840@@ -124,7 +124,7 @@
7841 // AARCH64-NEXT: #define __INT64_FMTi__ "li"
7842 // AARCH64-NEXT: #define __INT64_MAX__ 9223372036854775807L
7843 // AARCH64-NEXT: #define __INT64_TYPE__ long int
7844-// AARCH64-NEXT: #define __INT8_C_SUFFIX__
7845+// AARCH64-NEXT: #define __INT8_C_SUFFIX__
7846 // AARCH64-NEXT: #define __INT8_FMTd__ "hhd"
7847 // AARCH64-NEXT: #define __INT8_FMTi__ "hhi"
7848 // AARCH64-NEXT: #define __INT8_MAX__ 127
7849@@ -238,7 +238,7 @@
7850 // AARCH64-NEXT: #define __STDC_UTF_32__ 1
7851 // AARCH64_C: #define __STDC_VERSION__ 201710L
7852 // AARCH64-NEXT: #define __STDC__ 1
7853-// AARCH64-NEXT: #define __UINT16_C_SUFFIX__
7854+// AARCH64-NEXT: #define __UINT16_C_SUFFIX__
7855 // AARCH64-NEXT: #define __UINT16_FMTX__ "hX"
7856 // AARCH64-NEXT: #define __UINT16_FMTo__ "ho"
7857 // AARCH64-NEXT: #define __UINT16_FMTu__ "hu"
7858@@ -259,7 +259,7 @@
7859 // AARCH64-NEXT: #define __UINT64_FMTx__ "lx"
7860 // AARCH64-NEXT: #define __UINT64_MAX__ 18446744073709551615UL
7861 // AARCH64-NEXT: #define __UINT64_TYPE__ long unsigned int
7862-// AARCH64-NEXT: #define __UINT8_C_SUFFIX__
7863+// AARCH64-NEXT: #define __UINT8_C_SUFFIX__
7864 // AARCH64-NEXT: #define __UINT8_FMTX__ "hhX"
7865 // AARCH64-NEXT: #define __UINT8_FMTo__ "hho"
7866 // AARCH64-NEXT: #define __UINT8_FMTu__ "hhu"
7867@@ -329,7 +329,7 @@
7868 // AARCH64-NEXT: #define __UINT_LEAST8_FMTx__ "hhx"
7869 // AARCH64-NEXT: #define __UINT_LEAST8_MAX__ 255
7870 // AARCH64-NEXT: #define __UINT_LEAST8_TYPE__ unsigned char
7871-// AARCH64-NEXT: #define __USER_LABEL_PREFIX__
7872+// AARCH64-NEXT: #define __USER_LABEL_PREFIX__
7873 // AARCH64-NEXT: #define __VERSION__ "{{.*}}"
7874 // AARCH64-NEXT: #define __WCHAR_MAX__ 4294967295U
7875 // AARCH64-NEXT: #define __WCHAR_TYPE__ unsigned int
7876diff --git a/clang/test/Preprocessor/predefined-macros.c b/clang/test/Preprocessor/predefined-macros.c
7877index 083f0e539d88..6c80517ec4d4 100644
7878--- a/clang/test/Preprocessor/predefined-macros.c
7879+++ b/clang/test/Preprocessor/predefined-macros.c
7880@@ -129,6 +129,8 @@
7881 // RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-CL12
7882 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL2.0 \
7883 // RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-CL20
7884+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL3.0 \
7885+// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-CL30
7886 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-fast-relaxed-math \
7887 // RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
7888 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++ \
7889@@ -137,26 +139,37 @@
7890 // CHECK-CL10: #define CL_VERSION_1_1 110
7891 // CHECK-CL10: #define CL_VERSION_1_2 120
7892 // CHECK-CL10: #define CL_VERSION_2_0 200
7893+// CHECK-CL10: #define CL_VERSION_3_0 300
7894 // CHECK-CL10: #define __OPENCL_C_VERSION__ 100
7895 // CHECK-CL10-NOT: #define __FAST_RELAXED_MATH__ 1
7896 // CHECK-CL11: #define CL_VERSION_1_0 100
7897 // CHECK-CL11: #define CL_VERSION_1_1 110
7898 // CHECK-CL11: #define CL_VERSION_1_2 120
7899 // CHECK-CL11: #define CL_VERSION_2_0 200
7900+// CHECK-CL11: #define CL_VERSION_3_0 300
7901 // CHECK-CL11: #define __OPENCL_C_VERSION__ 110
7902 // CHECK-CL11-NOT: #define __FAST_RELAXED_MATH__ 1
7903 // CHECK-CL12: #define CL_VERSION_1_0 100
7904 // CHECK-CL12: #define CL_VERSION_1_1 110
7905 // CHECK-CL12: #define CL_VERSION_1_2 120
7906 // CHECK-CL12: #define CL_VERSION_2_0 200
7907+// CHECK-CL12: #define CL_VERSION_3_0 300
7908 // CHECK-CL12: #define __OPENCL_C_VERSION__ 120
7909 // CHECK-CL12-NOT: #define __FAST_RELAXED_MATH__ 1
7910 // CHECK-CL20: #define CL_VERSION_1_0 100
7911 // CHECK-CL20: #define CL_VERSION_1_1 110
7912 // CHECK-CL20: #define CL_VERSION_1_2 120
7913 // CHECK-CL20: #define CL_VERSION_2_0 200
7914+// CHECK-CL20: #define CL_VERSION_3_0 300
7915 // CHECK-CL20: #define __OPENCL_C_VERSION__ 200
7916 // CHECK-CL20-NOT: #define __FAST_RELAXED_MATH__ 1
7917+// CHECK-CL30: #define CL_VERSION_1_0 100
7918+// CHECK-CL30: #define CL_VERSION_1_1 110
7919+// CHECK-CL30: #define CL_VERSION_1_2 120
7920+// CHECK-CL30: #define CL_VERSION_2_0 200
7921+// CHECK-CL30: #define CL_VERSION_3_0 300
7922+// CHECK-CL30: #define __OPENCL_C_VERSION__ 300
7923+// CHECK-CL30-NOT: #define __FAST_RELAXED_MATH__ 1
7924 // CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
7925 // CHECK-CLCPP10: #define __CL_CPP_VERSION_1_0__ 100
7926 // CHECK-CLCPP10: #define __OPENCL_CPP_VERSION__ 100
7927diff --git a/clang/test/Sema/feature-extensions-simult-support.cl b/clang/test/Sema/feature-extensions-simult-support.cl
7928new file mode 100644
7929index 000000000000..0789105002b2
7930--- /dev/null
7931+++ b/clang/test/Sema/feature-extensions-simult-support.cl
7932@@ -0,0 +1,75 @@
7933+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2 -cl-ext=-cl_khr_fp64
7934+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2 -cl-ext=+cl_khr_fp64
7935+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2 -cl-ext=-cl_khr_3d_image_writes
7936+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2 -cl-ext=+cl_khr_3d_image_writes
7937+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2 -cl-ext=-cl_khr_subgroups
7938+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2 -cl-ext=+cl_khr_subgroups
7939+
7940+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 -cl-ext=-cl_khr_fp64
7941+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 -cl-ext=+cl_khr_fp64
7942+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 -cl-ext=-cl_khr_3d_image_writes
7943+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 -cl-ext=+cl_khr_3d_image_writes
7944+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 -cl-ext=-cl_khr_subgroups
7945+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 -cl-ext=+cl_khr_subgroups
7946+
7947+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_fp64
7948+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_3d_image_writes
7949+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_subgroups
7950+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_pipes
7951+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_device_enqueue
7952+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_read_write_images
7953+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_fp64,-cl_khr_fp64
7954+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_3d_image_writes,-cl_khr_3d_image_writes
7955+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_subgroups,-cl_khr_subgroups
7956+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+cl_khr_fp64
7957+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+cl_khr_3d_image_writes
7958+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+cl_khr_subgroups
7959+
7960+// expected-no-diagnostics
7961+
7962+#ifdef cl_khr_fp64
7963+ #ifndef __opencl_c_fp64
7964+ #error macros were not properly set up
7965+ #endif
7966+#endif
7967+#ifdef __opencl_c_fp64
7968+ #ifndef cl_khr_fp64
7969+ #error macros were not properly set up
7970+ #endif
7971+#endif
7972+
7973+#ifdef cl_khr_3d_image_writes
7974+ #ifndef __opencl_c_3d_image_writes
7975+ #error macros were not properly set up
7976+ #endif
7977+#endif
7978+#ifdef __opencl_c_3d_image_writes
7979+ #ifndef cl_khr_3d_image_writes
7980+ #error macros were not properly set up
7981+ #endif
7982+#endif
7983+
7984+#ifdef cl_khr_subgroups
7985+ #ifndef __opencl_c_subgroups
7986+ #error macros were not properly set up
7987+ #endif
7988+#endif
7989+#ifdef __opencl_c_subgroups
7990+ #ifndef cl_khr_subgroups
7991+ #error macros were not properly set up
7992+ #endif
7993+#endif
7994+
7995+#if defined(__opencl_c_pipes) || defined(__opencl_c_device_enqueue)
7996+ #ifndef __opencl_c_generic_address_space
7997+ #error macros were not properly set up
7998+ #endif
7999+#endif
8000+
8001+#if defined(__opencl_c_3d_image_writes) || defined(__opencl_c_read_write_images)
8002+ #ifndef __opencl_c_images
8003+ #error macros were not properly set up
8004+ #endif
8005+#endif
8006+
8007+kernel void test(){}
8008diff --git a/clang/test/Sema/features-ignore-pragma.cl b/clang/test/Sema/features-ignore-pragma.cl
8009new file mode 100644
8010index 000000000000..046ce5390754
8011--- /dev/null
8012+++ b/clang/test/Sema/features-ignore-pragma.cl
8013@@ -0,0 +1,24 @@
8014+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
8015+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=__opencl_c_fp64
8016+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=__opencl_c_subgroups
8017+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=__opencl_c_3d_image_writes
8018+
8019+#pragma OPENCL EXTENSION __opencl_c_fp64 : enable
8020+// expected-warning@-1 {{OpenCL feature support can't be controlled via pragma, ignoring}}
8021+
8022+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
8023+#ifndef __opencl_c_fp64
8024+// expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}}
8025+#endif
8026+
8027+#pragma OPENCL EXTENSION cl_khr_subgroups : enable
8028+#ifndef __opencl_c_subgroups
8029+// expected-warning@-2{{unsupported OpenCL extension 'cl_khr_subgroups' - ignoring}}
8030+#endif
8031+
8032+#pragma OPENCL EXTENSION cl_khr_3d_image_writes : enable
8033+#ifndef __opencl_c_3d_image_writes
8034+// expected-warning@-2{{unsupported OpenCL extension 'cl_khr_3d_image_writes' - ignoring}}
8035+#endif
8036+
8037+kernel void foo() {}
8038diff --git a/clang/test/Sema/opencl-features-pipes.cl b/clang/test/Sema/opencl-features-pipes.cl
8039new file mode 100644
8040index 000000000000..c0ac778f24a6
8041--- /dev/null
8042+++ b/clang/test/Sema/opencl-features-pipes.cl
8043@@ -0,0 +1,18 @@
8044+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1
8045+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
8046+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 -DHAS
8047+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
8048+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=__opencl_c_pipes -DHAS
8049+// expected-no-diagnostics
8050+
8051+#ifdef HAS
8052+ #ifndef __opencl_c_pipes
8053+ #error Feature should be defined
8054+ #endif
8055+#else
8056+ #ifdef __opencl_c_pipes
8057+ #error Feature should not be defined
8058+ #endif
8059+#endif
8060+
8061+kernel void foo() {}
8062diff --git a/clang/test/Sema/opencl-features.cl b/clang/test/Sema/opencl-features.cl
8063new file mode 100644
8064index 000000000000..aa432f6b60bf
8065--- /dev/null
8066+++ b/clang/test/Sema/opencl-features.cl
8067@@ -0,0 +1,128 @@
8068+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
8069+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 -cl-ext=-__opencl_c_device_enqueue,-__opencl_c_pipes,-__opencl_c_read_write_images
8070+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CLC++
8071+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
8072+// expected-no-diagnostics
8073+
8074+#ifndef __opencl_c_int64
8075+ #error Feature __opencl_c_int64 shouldn't be defined
8076+#endif
8077+
8078+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
8079+ #ifndef __opencl_c_3d_image_writes
8080+ #error Feature __opencl_c_3d_image_writes should be defined
8081+ #endif
8082+
8083+ #ifndef __opencl_c_atomic_order_acq_rel
8084+ #error Feature __opencl_c_atomic_order_acq_rel should be defined
8085+ #endif
8086+
8087+ #ifndef __opencl_c_atomic_order_seq_cst
8088+ #error Feature __opencl_c_atomic_order_seq_cst should be defined
8089+ #endif
8090+
8091+ #ifndef __opencl_c_atomic_scope_device
8092+ #error Feature __opencl_c_atomic_scope_device should be defined
8093+ #endif
8094+
8095+ #ifndef __opencl_c_atomic_scope_all_devices
8096+ #error Feature __opencl_c_atomic_scope_all_devices should be defined
8097+ #endif
8098+
8099+ #ifndef __opencl_c_device_enqueue
8100+ #error Feature __opencl_c_device_enqueue should be defined
8101+ #endif
8102+
8103+ #ifndef __opencl_c_generic_address_space
8104+ #error Feature __opencl_c_generic_address_space should be defined
8105+ #endif
8106+
8107+ #ifndef __opencl_c_pipes
8108+ #error Feature __opencl_c_pipes should be defined
8109+ #endif
8110+
8111+ #ifndef __opencl_c_program_scope_global_variables
8112+ #error Feature __opencl_c_program_scope_global_variables should be defined
8113+ #endif
8114+
8115+ #ifndef __opencl_c_read_write_images
8116+ #error Feature __opencl_c_read_write_images should be defined
8117+ #endif
8118+
8119+ #ifndef __opencl_c_subgroups
8120+ #error Feature __opencl_c_subgroups should be defined
8121+ #endif
8122+
8123+ #ifndef __opencl_c_work_group_collective_functions
8124+ #error Feature __opencl_c_work_group_collective_functions should be defined
8125+ #endif
8126+
8127+ #ifndef __opencl_c_fp64
8128+ #error Feature __opencl_c_fp64 should be defined
8129+ #endif
8130+
8131+ #ifndef __opencl_c_images
8132+ #error Feature __opencl_c_images should be defined
8133+ #endif
8134+#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
8135+
8136+
8137+#if __OPENCL_C_VERSION__ == CL_VERSION_3_0
8138+ #ifdef __opencl_c_3d_image_writes
8139+ #error Feature __opencl_c_3d_image_writes shouldn't be defined
8140+ #endif
8141+
8142+ #ifdef __opencl_c_atomic_order_acq_rel
8143+ #error Feature __opencl_c_atomic_order_acq_rel shouldn't be defined
8144+ #endif
8145+
8146+ #ifdef __opencl_c_atomic_order_seq_cst
8147+ #error Feature __opencl_c_atomic_order_seq_cst shouldn't be defined
8148+ #endif
8149+
8150+ #ifdef __opencl_c_atomic_scope_device
8151+ #error Feature __opencl_c_atomic_scope_device shouldn't be defined
8152+ #endif
8153+
8154+ #ifdef __opencl_c_atomic_scope_all_devices
8155+ #error Feature __opencl_c_atomic_scope_all_devices shouldn't be defined
8156+ #endif
8157+
8158+ #ifdef __opencl_c_device_enqueue
8159+ #error Feature __opencl_c_device_enqueue shouldn't be defined
8160+ #endif
8161+
8162+ #ifdef __opencl_c_generic_address_space
8163+ #error Feature __opencl_c_generic_address_space shouldn't be defined
8164+ #endif
8165+
8166+ #ifdef __opencl_c_pipes
8167+ #error Feature __opencl_c_pipes shouldn't be defined
8168+ #endif
8169+
8170+ #ifdef __opencl_c_program_scope_global_variables
8171+ #error Feature __opencl_c_program_scope_global_variables shouldn't be defined
8172+ #endif
8173+
8174+ #ifdef __opencl_c_read_write_images
8175+ #error Feature __opencl_c_read_write_images shouldn't be defined
8176+ #endif
8177+
8178+ #ifdef __opencl_c_subgroups
8179+ #error Feature __opencl_c_subgroups shouldn't be defined
8180+ #endif
8181+
8182+ #ifdef __opencl_c_work_group_collective_functions
8183+ #error Feature __opencl_c_work_group_collective_functions shouldn't be defined
8184+ #endif
8185+
8186+ #ifdef __opencl_c_fp64
8187+ #error Feature __opencl_c_fp64 shouldn't be defined
8188+ #endif
8189+
8190+ #ifdef __opencl_c_images
8191+ #error Feature __opencl_c_images shouldn't be defined
8192+ #endif
8193+#endif // __OPENCL_C_VERSION__ == CL_VERSION_3_0
8194+
8195+kernel void foo() {}
8196diff --git a/clang/test/Sema/pipe_builtins_feature.cl b/clang/test/Sema/pipe_builtins_feature.cl
8197new file mode 100644
8198index 000000000000..56fa94fc7705
8199--- /dev/null
8200+++ b/clang/test/Sema/pipe_builtins_feature.cl
8201@@ -0,0 +1,21 @@
8202+// RUN: %clang_cc1 -cl-std=CL2.0 -fsyntax-only -verify %s
8203+// RUN: %clang_cc1 -cl-std=CL3.0 -fsyntax-only -verify %s
8204+// RUN: %clang_cc1 -cl-std=CL3.0 -cl-ext=__opencl_c_pipes -fsyntax-only -verify %s
8205+
8206+#ifdef __opencl_c_pipes
8207+ #ifndef __opencl_c_generic_address_space
8208+ #error Generic address space feature must also be defined
8209+ #endif
8210+// CHECK: expected-no-diagnostics
8211+// check that pragma disable all doesn't touch feature support
8212+ #pragma OPENCL EXTENSION all : disable
8213+#endif
8214+
8215+void test(read_only pipe int p, global int *ptr) {
8216+ reserve_id_t rid;
8217+}
8218+
8219+#ifndef __opencl_c_pipes
8220+// expected-error@-5 {{expected parameter declarator}} expected-error@-5 {{expected ')'}} expected-note@-5 {{to match this '('}}
8221+// expected-error@-5 {{use of type 'reserve_id_t' requires __opencl_c_pipes extension to be enabled}}
8222+#endif
8223diff --git a/clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl b/clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
8224index a5a838241347..dbdc5cffd073 100644
8225--- a/clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
8226+++ b/clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
8227@@ -1,6 +1,9 @@
8228 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=CL2.0
8229 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=CL2.0
8230 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGENERIC -cl-std=CL2.0
8231+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=CL3.0 -cl-ext=__opencl_c_generic_address_space
8232+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=CL3.0 -cl-ext=__opencl_c_generic_address_space
8233+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGENERIC -cl-std=CL3.0 -cl-ext=__opencl_c_generic_address_space
8234 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=clc++
8235 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=clc++
8236 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGENERIC -cl-std=clc++
8237diff --git a/clang/test/SemaOpenCL/address-spaces.cl b/clang/test/SemaOpenCL/address-spaces.cl
8238index e9825fd1682a..563f1e649a82 100644
8239--- a/clang/test/SemaOpenCL/address-spaces.cl
8240+++ b/clang/test/SemaOpenCL/address-spaces.cl
8241@@ -1,5 +1,6 @@
8242 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
8243 // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
8244+// RUN: %clang_cc1 %s -cl-std=CL3.0 -cl-ext=__opencl_c_generic_address_space -verify -pedantic -fsyntax-only
8245 // RUN: %clang_cc1 %s -cl-std=clc++ -verify -pedantic -fsyntax-only
8246
8247 __constant int ci = 1;
8248diff --git a/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl b/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
8249index f63e2913c749..727141190a0b 100644
8250--- a/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
8251+++ b/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
8252@@ -2,6 +2,12 @@
8253 // RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 -DQUALS="const volatile"
8254 // RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir64-unknown-unknown" -verify -pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS=
8255 // RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir64-unknown-unknown" -verify -pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS="const volatile"
8256+// RUN: %clang_cc1 %s -cl-std=CL3.0 -triple "spir-unknown-unknown" -cl-ext=__opencl_c_device_enqueue,__opencl_c_subgroups -verify -pedantic -fsyntax-only -DB32 -DQUALS=
8257+// RUN: %clang_cc1 %s -cl-std=CL3.0 -triple "spir-unknown-unknown" -cl-ext=__opencl_c_device_enqueue,__opencl_c_subgroups -verify -pedantic -fsyntax-only -DB32 -DQUALS="const volatile"
8258+// RUN: %clang_cc1 %s -cl-std=CL3.0 -triple "spir64-unknown-unknown" -cl-ext=__opencl_c_device_enqueue,__opencl_c_subgroups -verify -pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS=
8259+// RUN: %clang_cc1 %s -cl-std=CL3.0 -triple "spir64-unknown-unknown" -cl-ext=__opencl_c_device_enqueue,__opencl_c_subgroups -verify -pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS="const volatile"
8260+
8261+
8262
8263 typedef struct {int a;} ndrange_t;
8264 // Diagnostic tests for different overloads of enqueue_kernel from Table 6.13.17.1 of OpenCL 2.0 Spec.
8265@@ -235,11 +241,17 @@ kernel void bar(global unsigned int *buf)
8266 kernel void foo1(global unsigned int *buf)
8267 {
8268 ndrange_t n;
8269- buf[0] = get_kernel_max_sub_group_size_for_ndrange(n, ^(){}); // expected-error {{use of declaration 'get_kernel_max_sub_group_size_for_ndrange' requires cl_khr_subgroups extension to be enabled}}
8270+ buf[0] = get_kernel_max_sub_group_size_for_ndrange(n, ^(){});
8271+#if __OPENCL_C_VERSION__ < 300
8272+// expected-error@-2 {{use of declaration 'get_kernel_max_sub_group_size_for_ndrange' requires cl_khr_subgroups extension to be enabled}}
8273+#endif
8274 }
8275
8276 kernel void bar1(global unsigned int *buf)
8277 {
8278 ndrange_t n;
8279- buf[0] = get_kernel_sub_group_count_for_ndrange(n, ^(){}); // expected-error {{use of declaration 'get_kernel_sub_group_count_for_ndrange' requires cl_khr_subgroups extension to be enabled}}
8280+ buf[0] = get_kernel_sub_group_count_for_ndrange(n, ^(){});
8281+#if __OPENCL_C_VERSION__ < 300
8282+// expected-error@-2 {{use of declaration 'get_kernel_sub_group_count_for_ndrange' requires cl_khr_subgroups extension to be enabled}}
8283+#endif
8284 }
8285diff --git a/clang/test/SemaOpenCL/forget-unsupported-builtins.cl b/clang/test/SemaOpenCL/forget-unsupported-builtins.cl
8286new file mode 100644
8287index 000000000000..14dd03e2c7db
8288--- /dev/null
8289+++ b/clang/test/SemaOpenCL/forget-unsupported-builtins.cl
8290@@ -0,0 +1,22 @@
8291+// RUN: %clang_cc1 -cl-std=cl3.0 -fsyntax-only -verify %s -triple spir-unknown-unknown
8292+// RUN: %clang_cc1 -cl-std=cl3.0 -fsyntax-only -cl-ext=__opencl_c_pipes,__opencl_c_generic_address_space,__opencl_c_device_enqueue -verify %s -triple spir-unknown-unknown -DFEATURES
8293+
8294+#ifndef FEATURES
8295+ // expected-no-diagnostics
8296+#else
8297+ // expected-error@+10 {{cannot redeclare builtin function 'get_pipe_max_packets'}}
8298+ // expected-note@+9 {{'get_pipe_max_packets' is a builtin with type 'unsigned int ()'}}
8299+ // expected-error@+9 {{cannot redeclare builtin function 'to_local'}}
8300+ // expected-note@+8 {{'to_local' is a builtin with type 'void *(void *)'}}
8301+ // expected-error@+8 {{cannot redeclare builtin function 'to_global'}}
8302+ // expected-note@+7 {{'to_global' is a builtin with type 'void *(void *)'}}
8303+ // expected-error@+7 {{cannot redeclare builtin function 'get_kernel_work_group_size'}}
8304+ // expected-note@+6 {{'get_kernel_work_group_size' is a builtin with type 'unsigned int ()'}}
8305+#endif
8306+
8307+int get_pipe_max_packets(int);
8308+int to_local(int);
8309+int to_global(int);
8310+int get_kernel_work_group_size(int);
8311+
8312+kernel void test(global int *dst) {}
8313diff --git a/clang/test/SemaOpenCL/image-features.cl b/clang/test/SemaOpenCL/image-features.cl
8314new file mode 100644
8315index 000000000000..ace6913bb31e
8316--- /dev/null
8317+++ b/clang/test/SemaOpenCL/image-features.cl
8318@@ -0,0 +1,20 @@
8319+// RUN: %clang_cc1 -cl-std=cl2.0 -fsyntax-only -verify %s -triple spir-unknown-unknown
8320+// RUN: %clang_cc1 -cl-std=cl3.0 -cl-ext=__opencl_c_images -fsyntax-only -verify %s -triple spir-unknown-unknown
8321+// RUN: %clang_cc1 -cl-std=cl3.0 -cl-ext=__opencl_c_3d_image_writes -fsyntax-only -verify %s -triple spir-unknown-unknown
8322+// RUN: %clang_cc1 -cl-std=cl3.0 -cl-ext=__opencl_c_read_write_images -fsyntax-only -verify %s -triple spir-unknown-unknown
8323+
8324+#if defined(__opencl_c_read_write_images) && defined(__opencl_c_3d_image_writes)
8325+ // expected-no-diagnostics
8326+#endif
8327+
8328+__kernel void write_3d_image(__write_only image3d_t i) {}
8329+
8330+#ifndef __opencl_c_3d_image_writes
8331+ // expected-error@-3 {{use of type '__write_only image3d_t' requires __opencl_c_3d_image_writes extension to be enabled}}
8332+#endif
8333+
8334+__kernel void read_write_3d_image(__read_write image3d_t i) { }
8335+
8336+#ifndef __opencl_c_read_write_images
8337+ // expected-error@-3 {{use of type '__read_write image3d_t' requires __opencl_c_read_write_images extension to be enabled}}
8338+#endif
8339diff --git a/clang/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl b/clang/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
8340index 36e76621d24a..38b0a04726e3 100644
8341--- a/clang/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
8342+++ b/clang/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
8343@@ -1,4 +1,5 @@
8344 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 -cl-ext=+cl_khr_subgroups
8345+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=__opencl_c_subgroups,__opencl_c_pipes
8346
8347 #pragma OPENCL EXTENSION cl_khr_subgroups : enable
8348
8349diff --git a/clang/test/SemaOpenCL/storageclass-cl20.cl b/clang/test/SemaOpenCL/storageclass-cl20.cl
8350index 581701d2a6a5..469c526ebc30 100644
8351--- a/clang/test/SemaOpenCL/storageclass-cl20.cl
8352+++ b/clang/test/SemaOpenCL/storageclass-cl20.cl
8353@@ -1,4 +1,5 @@
8354 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
8355+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=__opencl_c_program_scope_global_variables,__opencl_c_generic_address_space
8356
8357 int G2 = 0;
8358 global int G3 = 0;
8359diff --git a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
8360index 7c63cf51ecfa..785ff93aaf85 100644
8361--- a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
8362+++ b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
8363@@ -56,6 +56,7 @@
8364 //===----------------------------------------------------------------------===//
8365
8366 #include "TableGenBackends.h"
8367+#include "clang/Basic/OpenCLOptions.h"
8368 #include "llvm/ADT/MapVector.h"
8369 #include "llvm/ADT/STLExtras.h"
8370 #include "llvm/ADT/SmallString.h"
8371@@ -69,6 +70,7 @@
8372 #include "llvm/TableGen/Record.h"
8373 #include "llvm/TableGen/StringMatcher.h"
8374 #include "llvm/TableGen/TableGenBackend.h"
8375+#include <numeric>
8376 #include <set>
8377
8378 using namespace llvm;
8379@@ -228,6 +230,10 @@ private:
8380 // The function "tan", having the same signatures, would be mapped to the
8381 // same entry (<I1, I2, I3>).
8382 MapVector<BuiltinIndexListTy *, BuiltinTableEntries> SignatureListMap;
8383+
8384+ // Encode all versions
8385+ unsigned short
8386+ EncodeBuiltinVersions(std::vector<Record *> BuiltinVersionsRecords) const;
8387 };
8388 } // namespace
8389
8390@@ -338,12 +344,10 @@ struct OpenCLBuiltinStruct {
8391 const bool IsConst : 1;
8392 // Function attribute __attribute__((convergent))
8393 const bool IsConv : 1;
8394+ // All opencl versions encoded
8395+ const unsigned char AllVersions : 5;
8396 // OpenCL extension(s) required for this overload.
8397 const unsigned short Extension;
8398- // First OpenCL version in which this overload was introduced (e.g. CL20).
8399- const unsigned short MinVersion;
8400- // First OpenCL version in which this overload was removed (e.g. CL20).
8401- const unsigned short MaxVersion;
8402 };
8403
8404 )";
8405@@ -510,11 +514,9 @@ void BuiltinNameEmitter::EmitBuiltinTable() {
8406 << (Overload.first->getValueAsBit("IsPure")) << ", "
8407 << (Overload.first->getValueAsBit("IsConst")) << ", "
8408 << (Overload.first->getValueAsBit("IsConv")) << ", "
8409- << FunctionExtensionIndex[ExtName] << ", "
8410- << Overload.first->getValueAsDef("MinVersion")->getValueAsInt("ID")
8411- << ", "
8412- << Overload.first->getValueAsDef("MaxVersion")->getValueAsInt("ID")
8413- << " },\n";
8414+ << EncodeBuiltinVersions(
8415+ Overload.first->getValueAsListOfDefs("Versions"))
8416+ << ", " << FunctionExtensionIndex[ExtName] << " },\n";
8417 Index++;
8418 }
8419 }
8420@@ -535,10 +537,8 @@ bool BuiltinNameEmitter::CanReuseSignature(
8421 if (Rec->getValueAsBit("IsPure") == Rec2->getValueAsBit("IsPure") &&
8422 Rec->getValueAsBit("IsConst") == Rec2->getValueAsBit("IsConst") &&
8423 Rec->getValueAsBit("IsConv") == Rec2->getValueAsBit("IsConv") &&
8424- Rec->getValueAsDef("MinVersion")->getValueAsInt("ID") ==
8425- Rec2->getValueAsDef("MinVersion")->getValueAsInt("ID") &&
8426- Rec->getValueAsDef("MaxVersion")->getValueAsInt("ID") ==
8427- Rec2->getValueAsDef("MaxVersion")->getValueAsInt("ID") &&
8428+ EncodeBuiltinVersions(Rec->getValueAsListOfDefs("Versions")) ==
8429+ EncodeBuiltinVersions(Rec2->getValueAsListOfDefs("Versions")) &&
8430 Rec->getValueAsDef("Extension")->getName() ==
8431 Rec2->getValueAsDef("Extension")->getName()) {
8432 return true;
8433@@ -814,6 +814,15 @@ static void OCL2Qual(ASTContext &Context, const OpenCLTypeStruct &Ty,
8434 OS << "\n} // OCL2Qual\n";
8435 }
8436
8437+unsigned short BuiltinNameEmitter::EncodeBuiltinVersions(
8438+ std::vector<Record *> BuiltinVersionsRecords) const {
8439+ return std::accumulate(
8440+ BuiltinVersionsRecords.begin(), BuiltinVersionsRecords.end(),
8441+ (unsigned short)0, [](unsigned short C, Record *R) {
8442+ return C |= clang::OpenCLOptions::EncodeVersion(R->getValueAsInt("ID"));
8443+ });
8444+}
8445+
8446 void clang::EmitClangOpenCLBuiltins(RecordKeeper &Records, raw_ostream &OS) {
8447 BuiltinNameEmitter NameChecker(Records, OS);
8448 NameChecker.Emit();
8449--
84502.17.1
8451
diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0001-llvm-spirv-skip-building-tests.patch b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0001-llvm-spirv-skip-building-tests.patch
deleted file mode 100644
index 237dec51..00000000
--- a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0001-llvm-spirv-skip-building-tests.patch
+++ /dev/null
@@ -1,51 +0,0 @@
1From 6690d77f9007ce82984dc1b6ae12585cb3e04785 Mon Sep 17 00:00:00 2001
2From: Naveen Saini <naveen.kumar.saini@intel.com>
3Date: Wed, 21 Aug 2019 14:35:31 +0800
4Subject: [PATCH 1/2] llvm-spirv: skip building tests
5
6Some of these need clang to be built and since we're building this in-tree,
7that leads to problems when compiling libcxx, compiler-rt which aren't built
8in-tree.
9
10Instead of using SPIRV_SKIP_CLANG_BUILD to skip clang build and adding this to
11all components, disable the building of tests altogether.
12
13Upstream-Status: Inappropriate
14
15Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
16Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
17---
18 CMakeLists.txt | 10 ----------
19 1 file changed, 10 deletions(-)
20
21diff --git a/CMakeLists.txt b/CMakeLists.txt
22index ec61fb95..d723c0a5 100644
23--- a/CMakeLists.txt
24+++ b/CMakeLists.txt
25@@ -26,13 +26,6 @@ if(LLVM_SPIRV_BUILD_EXTERNAL)
26 set(CMAKE_CXX_STANDARD 14)
27 set(CMAKE_CXX_STANDARD_REQUIRED ON)
28
29- if(LLVM_SPIRV_INCLUDE_TESTS)
30- set(LLVM_TEST_COMPONENTS
31- llvm-as
32- llvm-dis
33- )
34- endif(LLVM_SPIRV_INCLUDE_TESTS)
35-
36 find_package(LLVM ${BASE_LLVM_VERSION} REQUIRED
37 COMPONENTS
38 Analysis
39@@ -65,9 +58,6 @@ set(LLVM_SPIRV_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include)
40
41 add_subdirectory(lib/SPIRV)
42 add_subdirectory(tools/llvm-spirv)
43-if(LLVM_SPIRV_INCLUDE_TESTS)
44- add_subdirectory(test)
45-endif(LLVM_SPIRV_INCLUDE_TESTS)
46
47 install(
48 FILES
49--
502.17.1
51
diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0002-Add-support-for-cl_ext_float_atomics-in-SPIRVWriter.patch b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0002-Add-support-for-cl_ext_float_atomics-in-SPIRVWriter.patch
deleted file mode 100644
index 14e370f7..00000000
--- a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0002-Add-support-for-cl_ext_float_atomics-in-SPIRVWriter.patch
+++ /dev/null
@@ -1,433 +0,0 @@
1From 8e12d8fb3cdbdafca73fe8ed4f0cde773b1788b4 Mon Sep 17 00:00:00 2001
2From: haonanya <haonan.yang@intel.com>
3Date: Wed, 28 Jul 2021 11:43:20 +0800
4Subject: [PATCH 2/2] Add support for cl_ext_float_atomics in SPIRVWriter
5
6Upstream-Status: Backport [Taken from opencl-clang patches, https://github.com/intel/opencl-clang/blob/ocl-open-110/patches/spirv/0001-Add-support-for-cl_ext_float_atomics-in-SPIRVWriter.patch]
7
8Signed-off-by: haonanya <haonan.yang@intel.com>
9Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
10---
11 lib/SPIRV/OCLToSPIRV.cpp | 80 +++++++++++++++++++++++--
12 lib/SPIRV/OCLUtil.cpp | 26 --------
13 lib/SPIRV/OCLUtil.h | 4 --
14 test/negative/InvalidAtomicBuiltins.cl | 12 +---
15 test/transcoding/AtomicFAddEXTForOCL.ll | 64 ++++++++++++++++++++
16 test/transcoding/AtomicFMaxEXTForOCL.ll | 64 ++++++++++++++++++++
17 test/transcoding/AtomicFMinEXTForOCL.ll | 64 ++++++++++++++++++++
18 7 files changed, 269 insertions(+), 45 deletions(-)
19 create mode 100644 test/transcoding/AtomicFAddEXTForOCL.ll
20 create mode 100644 test/transcoding/AtomicFMaxEXTForOCL.ll
21 create mode 100644 test/transcoding/AtomicFMinEXTForOCL.ll
22
23diff --git a/lib/SPIRV/OCLToSPIRV.cpp b/lib/SPIRV/OCLToSPIRV.cpp
24index 04d51586..f00f5f7b 100644
25--- a/lib/SPIRV/OCLToSPIRV.cpp
26+++ b/lib/SPIRV/OCLToSPIRV.cpp
27@@ -421,10 +421,63 @@ void OCLToSPIRVBase::visitCallInst(CallInst &CI) {
28 if (DemangledName.find(kOCLBuiltinName::AtomicPrefix) == 0 ||
29 DemangledName.find(kOCLBuiltinName::AtomPrefix) == 0) {
30
31- // Compute atomic builtins do not support floating types.
32- if (CI.getType()->isFloatingPointTy() &&
33- isComputeAtomicOCLBuiltin(DemangledName))
34- return;
35+ // Compute "atom" prefixed builtins do not support floating types.
36+ if (CI.getType()->isFloatingPointTy()) {
37+ if (DemangledName.find(kOCLBuiltinName::AtomPrefix) == 0)
38+ return;
39+ // handle functions which are "atomic_" prefixed.
40+ StringRef Stem = DemangledName;
41+ Stem = Stem.drop_front(strlen("atomic_"));
42+ // FP-typed atomic_{add, sub, inc, dec, exchange, min, max, or, and, xor,
43+ // fetch_or, fetch_xor, fetch_and, fetch_or_explicit, fetch_xor_explicit,
44+ // fetch_and_explicit} should be identified as function call
45+ bool IsFunctionCall = llvm::StringSwitch<bool>(Stem)
46+ .Case("add", true)
47+ .Case("sub", true)
48+ .Case("inc", true)
49+ .Case("dec", true)
50+ .Case("cmpxchg", true)
51+ .Case("min", true)
52+ .Case("max", true)
53+ .Case("or", true)
54+ .Case("xor", true)
55+ .Case("and", true)
56+ .Case("fetch_or", true)
57+ .Case("fetch_and", true)
58+ .Case("fetch_xor", true)
59+ .Case("fetch_or_explicit", true)
60+ .Case("fetch_xor_explicit", true)
61+ .Case("fetch_and_explicit", true)
62+ .Default(false);
63+ if (IsFunctionCall)
64+ return;
65+ if (F->arg_size() != 2) {
66+ IsFunctionCall = llvm::StringSwitch<bool>(Stem)
67+ .Case("exchange", true)
68+ .Case("fetch_add", true)
69+ .Case("fetch_sub", true)
70+ .Case("fetch_min", true)
71+ .Case("fetch_max", true)
72+ .Case("load", true)
73+ .Case("store", true)
74+ .Default(false);
75+ if (IsFunctionCall)
76+ return;
77+ }
78+ if (F->arg_size() != 3 && F->arg_size() != 4) {
79+ IsFunctionCall = llvm::StringSwitch<bool>(Stem)
80+ .Case("exchange_explicit", true)
81+ .Case("fetch_add_explicit", true)
82+ .Case("fetch_sub_explicit", true)
83+ .Case("fetch_min_explicit", true)
84+ .Case("fetch_max_explicit", true)
85+ .Case("load_explicit", true)
86+ .Case("store_explicit", true)
87+ .Default(false);
88+ if (IsFunctionCall)
89+ return;
90+ }
91+ }
92
93 auto PCI = &CI;
94 if (DemangledName == kOCLBuiltinName::AtomicInit) {
95@@ -839,7 +892,7 @@ void OCLToSPIRVBase::transAtomicBuiltin(CallInst *CI,
96 AttributeList Attrs = CI->getCalledFunction()->getAttributes();
97 mutateCallInstSPIRV(
98 M, CI,
99- [=](CallInst *CI, std::vector<Value *> &Args) {
100+ [=](CallInst *CI, std::vector<Value *> &Args) -> std::string {
101 Info.PostProc(Args);
102 // Order of args in OCL20:
103 // object, 0-2 other args, 1-2 order, scope
104@@ -868,7 +921,22 @@ void OCLToSPIRVBase::transAtomicBuiltin(CallInst *CI,
105 std::rotate(Args.begin() + 2, Args.begin() + OrderIdx,
106 Args.end() - Offset);
107 }
108- return getSPIRVFuncName(OCLSPIRVBuiltinMap::map(Info.UniqName));
109+
110+ llvm::Type* AtomicBuiltinsReturnType =
111+ CI->getCalledFunction()->getReturnType();
112+ auto IsFPType = [](llvm::Type *ReturnType) {
113+ return ReturnType->isHalfTy() || ReturnType->isFloatTy() ||
114+ ReturnType->isDoubleTy();
115+ };
116+ auto SPIRVFunctionName =
117+ getSPIRVFuncName(OCLSPIRVBuiltinMap::map(Info.UniqName));
118+ if (!IsFPType(AtomicBuiltinsReturnType))
119+ return SPIRVFunctionName;
120+ // Translate FP-typed atomic builtins.
121+ return llvm::StringSwitch<std::string>(SPIRVFunctionName)
122+ .Case("__spirv_AtomicIAdd", "__spirv_AtomicFAddEXT")
123+ .Case("__spirv_AtomicSMax", "__spirv_AtomicFMaxEXT")
124+ .Case("__spirv_AtomicSMin", "__spirv_AtomicFMinEXT");
125 },
126 &Attrs);
127 }
128diff --git a/lib/SPIRV/OCLUtil.cpp b/lib/SPIRV/OCLUtil.cpp
129index 2de3f152..85155e39 100644
130--- a/lib/SPIRV/OCLUtil.cpp
131+++ b/lib/SPIRV/OCLUtil.cpp
132@@ -662,32 +662,6 @@ size_t getSPIRVAtomicBuiltinNumMemoryOrderArgs(Op OC) {
133 return 1;
134 }
135
136-bool isComputeAtomicOCLBuiltin(StringRef DemangledName) {
137- if (!DemangledName.startswith(kOCLBuiltinName::AtomicPrefix) &&
138- !DemangledName.startswith(kOCLBuiltinName::AtomPrefix))
139- return false;
140-
141- return llvm::StringSwitch<bool>(DemangledName)
142- .EndsWith("add", true)
143- .EndsWith("sub", true)
144- .EndsWith("inc", true)
145- .EndsWith("dec", true)
146- .EndsWith("cmpxchg", true)
147- .EndsWith("min", true)
148- .EndsWith("max", true)
149- .EndsWith("and", true)
150- .EndsWith("or", true)
151- .EndsWith("xor", true)
152- .EndsWith("add_explicit", true)
153- .EndsWith("sub_explicit", true)
154- .EndsWith("or_explicit", true)
155- .EndsWith("xor_explicit", true)
156- .EndsWith("and_explicit", true)
157- .EndsWith("min_explicit", true)
158- .EndsWith("max_explicit", true)
159- .Default(false);
160-}
161-
162 BarrierLiterals getBarrierLiterals(CallInst *CI) {
163 auto N = CI->getNumArgOperands();
164 assert(N == 1 || N == 2);
165diff --git a/lib/SPIRV/OCLUtil.h b/lib/SPIRV/OCLUtil.h
166index 4c05c672..c8577e9b 100644
167--- a/lib/SPIRV/OCLUtil.h
168+++ b/lib/SPIRV/OCLUtil.h
169@@ -394,10 +394,6 @@ size_t getAtomicBuiltinNumMemoryOrderArgs(StringRef Name);
170 /// Get number of memory order arguments for spirv atomic builtin function.
171 size_t getSPIRVAtomicBuiltinNumMemoryOrderArgs(Op OC);
172
173-/// Return true for OpenCL builtins which do compute operations
174-/// (like add, sub, min, max, inc, dec, ...) atomically
175-bool isComputeAtomicOCLBuiltin(StringRef DemangledName);
176-
177 /// Get OCL version from metadata opencl.ocl.version.
178 /// \param AllowMulti Allows multiple operands if true.
179 /// \return OCL version encoded as Major*10^5+Minor*10^3+Rev,
180diff --git a/test/negative/InvalidAtomicBuiltins.cl b/test/negative/InvalidAtomicBuiltins.cl
181index b8ec5b89..23dcc4e3 100644
182--- a/test/negative/InvalidAtomicBuiltins.cl
183+++ b/test/negative/InvalidAtomicBuiltins.cl
184@@ -1,7 +1,9 @@
185 // Check that translator doesn't generate atomic instructions for atomic builtins
186 // which are not defined in the spec.
187
188-// RUN: %clang_cc1 -triple spir -O1 -cl-std=cl2.0 -fdeclare-opencl-builtins -finclude-default-header %s -emit-llvm-bc -o %t.bc
189+// To drop `fdeclare-opencl-builtins` option, since FP-typed atomic function
190+// TableGen definitions have not been introduced.
191+// RUN: %clang_cc1 -triple spir -O1 -cl-std=cl2.0 -finclude-default-header %s -emit-llvm-bc -o %t.bc
192 // RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s
193 // RUN: llvm-spirv %t.bc -o %t.spv
194 // RUN: spirv-val %t.spv
195@@ -41,13 +43,9 @@ float __attribute__((overloadable)) atomic_fetch_xor(volatile generic atomic_flo
196 double __attribute__((overloadable)) atomic_fetch_and(volatile generic atomic_double *object, double operand, memory_order order);
197 double __attribute__((overloadable)) atomic_fetch_max(volatile generic atomic_double *object, double operand, memory_order order);
198 double __attribute__((overloadable)) atomic_fetch_min(volatile generic atomic_double *object, double operand, memory_order order);
199-float __attribute__((overloadable)) atomic_fetch_add_explicit(volatile generic atomic_float *object, float operand, memory_order order);
200-float __attribute__((overloadable)) atomic_fetch_sub_explicit(volatile generic atomic_float *object, float operand, memory_order order);
201 float __attribute__((overloadable)) atomic_fetch_or_explicit(volatile generic atomic_float *object, float operand, memory_order order);
202 float __attribute__((overloadable)) atomic_fetch_xor_explicit(volatile generic atomic_float *object, float operand, memory_order order);
203 double __attribute__((overloadable)) atomic_fetch_and_explicit(volatile generic atomic_double *object, double operand, memory_order order);
204-double __attribute__((overloadable)) atomic_fetch_max_explicit(volatile generic atomic_double *object, double operand, memory_order order);
205-double __attribute__((overloadable)) atomic_fetch_min_explicit(volatile generic atomic_double *object, double operand, memory_order order);
206
207 __kernel void test_atomic_fn(volatile __global float *p,
208 volatile __global double *pp,
209@@ -86,11 +84,7 @@ __kernel void test_atomic_fn(volatile __global float *p,
210 d = atomic_fetch_and(pp, val, order);
211 d = atomic_fetch_min(pp, val, order);
212 d = atomic_fetch_max(pp, val, order);
213- f = atomic_fetch_add_explicit(p, val, order);
214- f = atomic_fetch_sub_explicit(p, val, order);
215 f = atomic_fetch_or_explicit(p, val, order);
216 f = atomic_fetch_xor_explicit(p, val, order);
217 d = atomic_fetch_and_explicit(pp, val, order);
218- d = atomic_fetch_min_explicit(pp, val, order);
219- d = atomic_fetch_max_explicit(pp, val, order);
220 }
221diff --git a/test/transcoding/AtomicFAddEXTForOCL.ll b/test/transcoding/AtomicFAddEXTForOCL.ll
222new file mode 100644
223index 00000000..fb146fb9
224--- /dev/null
225+++ b/test/transcoding/AtomicFAddEXTForOCL.ll
226@@ -0,0 +1,64 @@
227+; RUN: llvm-as %s -o %t.bc
228+; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_EXT_shader_atomic_float_add -o %t.spv
229+; RUN: spirv-val %t.spv
230+; RUN: llvm-spirv -to-text %t.spv -o %t.spt
231+; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
232+
233+; RUN: llvm-spirv --spirv-target-env=CL2.0 -r %t.spv -o %t.rev.bc
234+; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefixes=CHECK-LLVM-CL,CHECK-LLVM-CL20
235+
236+; RUN: llvm-spirv --spirv-target-env=SPV-IR -r %t.spv -o %t.rev.bc
237+; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefixes=CHECK-LLVM-SPV
238+
239+target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
240+target triple = "spir-unknown-unknown"
241+
242+; CHECK-SPIRV: Capability AtomicFloat32AddEXT
243+; CHECK-SPIRV: Capability AtomicFloat64AddEXT
244+; CHECK-SPIRV: Extension "SPV_EXT_shader_atomic_float_add"
245+; CHECK-SPIRV: TypeFloat [[TYPE_FLOAT_32:[0-9]+]] 32
246+; CHECK-SPIRV: TypeFloat [[TYPE_FLOAT_64:[0-9]+]] 64
247+
248+
249+; Function Attrs: convergent norecurse nounwind
250+define dso_local spir_func void @test_atomic_float(float addrspace(1)* %a) local_unnamed_addr #0 {
251+entry:
252+ ; CHECK-SPIRV: 7 AtomicFAddEXT [[TYPE_FLOAT_32]]
253+ ; CHECK-LLVM-CL20: call spir_func float @[[FLOAT_FUNC_NAME:_Z25atomic_fetch_add_explicit[[:alnum:]]+_Atomicff[a-zA-Z0-9_]+]]({{.*}})
254+ ; CHECK-LLVM-SPV: call spir_func float @[[FLOAT_FUNC_NAME:_Z21__spirv_AtomicFAddEXT[[:alnum:]]+fiif]]({{.*}})
255+ %call = tail call spir_func float @_Z25atomic_fetch_add_explicitPU3AS1VU7_Atomicff12memory_order(float addrspace(1)* %a, float 0.000000e+00, i32 0) #2
256+ ret void
257+}
258+
259+; Function Attrs: convergent
260+declare spir_func float @_Z25atomic_fetch_add_explicitPU3AS1VU7_Atomicff12memory_order(float addrspace(1)*, float, i32) local_unnamed_addr #1
261+; CHECK-LLVM-SPV: declare {{.*}}spir_func float @[[FLOAT_FUNC_NAME]](float
262+
263+; Function Attrs: convergent norecurse nounwind
264+define dso_local spir_func void @test_atomic_double(double addrspace(1)* %a) local_unnamed_addr #0 {
265+entry:
266+ ; CHECK-SPIRV: 7 AtomicFAddEXT [[TYPE_FLOAT_64]]
267+ ; CHECK-LLVM-CL20: call spir_func double @[[DOUBLE_FUNC_NAME:_Z25atomic_fetch_add_explicit[[:alnum:]]+_Atomicdd[a-zA-Z0-9_]+]]({{.*}})
268+ ; CHECK-LLVM-SPV: call spir_func double @[[DOUBLE_FUNC_NAME:_Z21__spirv_AtomicFAddEXT[[:alnum:]]+diid]]({{.*}})
269+ %call = tail call spir_func double @_Z25atomic_fetch_add_explicitPU3AS1VU7_Atomicdd12memory_order(double addrspace(1)* %a, double 0.000000e+00, i32 0) #2
270+ ret void
271+}
272+; Function Attrs: convergent
273+declare spir_func double @_Z25atomic_fetch_add_explicitPU3AS1VU7_Atomicdd12memory_order(double addrspace(1)*, double, i32) local_unnamed_addr #1
274+; CHECK-LLVM-SPV: declare {{.*}}spir_func double @[[DOUBLE_FUNC_NAME]](double
275+
276+; CHECK-LLVM-CL: declare {{.*}}spir_func float @[[FLOAT_FUNC_NAME]](float
277+; CHECK-LLVM-CL: declare {{.*}}spir_func double @[[DOUBLE_FUNC_NAME]](double
278+
279+attributes #0 = { convergent norecurse nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
280+attributes #1 = { convergent "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
281+attributes #2 = { convergent nounwind }
282+
283+!llvm.module.flags = !{!0}
284+!opencl.ocl.version = !{!1}
285+!opencl.spir.version = !{!1}
286+!llvm.ident = !{!2}
287+
288+!0 = !{i32 1, !"wchar_size", i32 4}
289+!1 = !{i32 2, i32 0}
290+!2 = !{!"clang version 13.0.0 (https://github.com/llvm/llvm-project.git 94aa388f0ce0723bb15503cf41c2c15b288375b9)"}
291diff --git a/test/transcoding/AtomicFMaxEXTForOCL.ll b/test/transcoding/AtomicFMaxEXTForOCL.ll
292new file mode 100644
293index 00000000..1f2530d9
294--- /dev/null
295+++ b/test/transcoding/AtomicFMaxEXTForOCL.ll
296@@ -0,0 +1,64 @@
297+; RUN: llvm-as %s -o %t.bc
298+; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_EXT_shader_atomic_float_min_max -o %t.spv
299+; RUN: spirv-val %t.spv
300+; RUN: llvm-spirv -to-text %t.spv -o %t.spt
301+; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
302+
303+; RUN: llvm-spirv --spirv-target-env=CL2.0 -r %t.spv -o %t.rev.bc
304+; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefixes=CHECK-LLVM-CL,CHECK-LLVM-CL20
305+
306+; RUN: llvm-spirv --spirv-target-env=SPV-IR -r %t.spv -o %t.rev.bc
307+; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefixes=CHECK-LLVM-SPV
308+
309+target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
310+target triple = "spir-unknown-unknown"
311+
312+; CHECK-SPIRV: Capability AtomicFloat32MinMaxEXT
313+; CHECK-SPIRV: Capability AtomicFloat64MinMaxEXT
314+; CHECK-SPIRV: Extension "SPV_EXT_shader_atomic_float_min_max"
315+; CHECK-SPIRV: TypeFloat [[TYPE_FLOAT_32:[0-9]+]] 32
316+; CHECK-SPIRV: TypeFloat [[TYPE_FLOAT_64:[0-9]+]] 64
317+
318+; Function Attrs: convergent norecurse nounwind
319+define dso_local spir_func void @test_float(float addrspace(1)* %a) local_unnamed_addr #0 {
320+entry:
321+ ; CHECK-SPIRV: 7 AtomicFMaxEXT [[TYPE_FLOAT_32]]
322+ ; CHECK-LLVM-CL20: call spir_func float @[[FLOAT_FUNC_NAME:_Z25atomic_fetch_max_explicit[[:alnum:]]+_Atomicff[a-zA-Z0-9_]+]]({{.*}})
323+ ; CHECK-LLVM-SPV: call spir_func float @[[FLOAT_FUNC_NAME:_Z21__spirv_AtomicFMaxEXT[[:alnum:]]+fiif]]({{.*}})
324+ %call = tail call spir_func float @_Z25atomic_fetch_max_explicitPU3AS1VU7_Atomicff12memory_order(float addrspace(1)* %a, float 0.000000e+00, i32 0) #2
325+ ret void
326+}
327+
328+; Function Attrs: convergent
329+declare spir_func float @_Z25atomic_fetch_max_explicitPU3AS1VU7_Atomicff12memory_order(float addrspace(1)*, float, i32) local_unnamed_addr #1
330+; CHECK-LLVM-SPV: declare {{.*}}spir_func float @[[FLOAT_FUNC_NAME]](float
331+
332+; Function Attrs: convergent norecurse nounwind
333+define dso_local spir_func void @test_double(double addrspace(1)* %a) local_unnamed_addr #0 {
334+entry:
335+ ; CHECK-SPIRV: 7 AtomicFMaxEXT [[TYPE_FLOAT_64]]
336+ ; CHECK-LLVM-CL20: call spir_func double @[[DOUBLE_FUNC_NAME:_Z25atomic_fetch_max_explicit[[:alnum:]]+_Atomicdd[a-zA-Z0-9_]+]]({{.*}})
337+ ; CHECK-LLVM-SPV: call spir_func double @[[DOUBLE_FUNC_NAME:_Z21__spirv_AtomicFMaxEXT[[:alnum:]]+diid]]({{.*}})
338+ %call = tail call spir_func double @_Z25atomic_fetch_max_explicitPU3AS1VU7_Atomicdd12memory_order(double addrspace(1)* %a, double 0.000000e+00, i32 0) #2
339+ ret void
340+}
341+
342+; Function Attrs: convergent
343+declare spir_func double @_Z25atomic_fetch_max_explicitPU3AS1VU7_Atomicdd12memory_order(double addrspace(1)*, double, i32) local_unnamed_addr #1
344+; CHECK-LLVM-SPV: declare {{.*}}spir_func double @[[DOUBLE_FUNC_NAME]](double
345+
346+; CHECK-LLVM-CL: declare {{.*}}spir_func float @[[FLOAT_FUNC_NAME]](float
347+; CHECK-LLVM-CL: declare {{.*}}spir_func double @[[DOUBLE_FUNC_NAME]](double
348+
349+attributes #0 = { convergent norecurse nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
350+attributes #1 = { convergent "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
351+attributes #2 = { convergent nounwind }
352+
353+!llvm.module.flags = !{!0}
354+!opencl.ocl.version = !{!1}
355+!opencl.spir.version = !{!1}
356+!llvm.ident = !{!2}
357+
358+!0 = !{i32 1, !"wchar_size", i32 4}
359+!1 = !{i32 2, i32 0}
360+!2 = !{!"clang version 13.0.0 (https://github.com/llvm/llvm-project.git 94aa388f0ce0723bb15503cf41c2c15b288375b9)"}
361diff --git a/test/transcoding/AtomicFMinEXTForOCL.ll b/test/transcoding/AtomicFMinEXTForOCL.ll
362new file mode 100644
363index 00000000..6196b0f8
364--- /dev/null
365+++ b/test/transcoding/AtomicFMinEXTForOCL.ll
366@@ -0,0 +1,64 @@
367+; RUN: llvm-as %s -o %t.bc
368+; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_EXT_shader_atomic_float_min_max -o %t.spv
369+; RUN: spirv-val %t.spv
370+; RUN: llvm-spirv -to-text %t.spv -o %t.spt
371+; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
372+
373+; RUN: llvm-spirv --spirv-target-env=CL2.0 -r %t.spv -o %t.rev.bc
374+; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefixes=CHECK-LLVM-CL,CHECK-LLVM-CL20
375+
376+; RUN: llvm-spirv --spirv-target-env=SPV-IR -r %t.spv -o %t.rev.bc
377+; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefixes=CHECK-LLVM-SPV
378+
379+target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
380+target triple = "spir-unknown-unknown"
381+
382+; CHECK-SPIRV: Capability AtomicFloat32MinMaxEXT
383+; CHECK-SPIRV: Capability AtomicFloat64MinMaxEXT
384+; CHECK-SPIRV: Extension "SPV_EXT_shader_atomic_float_min_max"
385+; CHECK-SPIRV: TypeFloat [[TYPE_FLOAT_32:[0-9]+]] 32
386+; CHECK-SPIRV: TypeFloat [[TYPE_FLOAT_64:[0-9]+]] 64
387+
388+; Function Attrs: convergent norecurse nounwind
389+define dso_local spir_func void @test_float(float addrspace(1)* %a) local_unnamed_addr #0 {
390+entry:
391+ ; CHECK-SPIRV: 7 AtomicFMinEXT [[TYPE_FLOAT_32]]
392+ ; CHECK-LLVM-CL20: call spir_func float @[[FLOAT_FUNC_NAME:_Z25atomic_fetch_min_explicit[[:alnum:]]+_Atomicff[a-zA-Z0-9_]+]]({{.*}})
393+ ; CHECK-LLVM-SPV: call spir_func float @[[FLOAT_FUNC_NAME:_Z21__spirv_AtomicFMinEXT[[:alnum:]]+fiif]]({{.*}})
394+ %call = tail call spir_func float @_Z25atomic_fetch_min_explicitPU3AS1VU7_Atomicff12memory_order(float addrspace(1)* %a, float 0.000000e+00, i32 0) #2
395+ ret void
396+}
397+
398+; Function Attrs: convergent
399+declare spir_func float @_Z25atomic_fetch_min_explicitPU3AS1VU7_Atomicff12memory_order(float addrspace(1)*, float, i32) local_unnamed_addr #1
400+; CHECK-LLVM-SPV: declare {{.*}}spir_func float @[[FLOAT_FUNC_NAME]](float
401+
402+; Function Attrs: convergent norecurse nounwind
403+define dso_local spir_func void @test_double(double addrspace(1)* %a) local_unnamed_addr #0 {
404+entry:
405+ ; CHECK-SPIRV: 7 AtomicFMinEXT [[TYPE_FLOAT_64]]
406+ ; CHECK-LLVM-CL20: call spir_func double @[[DOUBLE_FUNC_NAME:_Z25atomic_fetch_min_explicit[[:alnum:]]+_Atomicdd[a-zA-Z0-9_]+]]({{.*}})
407+ ; CHECK-LLVM-SPV: call spir_func double @[[DOUBLE_FUNC_NAME:_Z21__spirv_AtomicFMinEXT[[:alnum:]]+diid]]({{.*}})
408+ %call = tail call spir_func double @_Z25atomic_fetch_min_explicitPU3AS1VU7_Atomicdd12memory_order(double addrspace(1)* %a, double 0.000000e+00, i32 0) #2
409+ ret void
410+}
411+
412+; Function Attrs: convergent
413+declare spir_func double @_Z25atomic_fetch_min_explicitPU3AS1VU7_Atomicdd12memory_order(double addrspace(1)*, double, i32) local_unnamed_addr #1
414+; CHECK-LLVM-SPV: declare {{.*}}spir_func double @[[DOUBLE_FUNC_NAME]](double
415+
416+; CHECK-LLVM-CL: declare {{.*}}spir_func float @[[FLOAT_FUNC_NAME]](float
417+; CHECK-LLVM-CL: declare {{.*}}spir_func double @[[DOUBLE_FUNC_NAME]](double
418+
419+attributes #0 = { convergent norecurse nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
420+attributes #1 = { convergent "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
421+attributes #2 = { convergent nounwind }
422+
423+!llvm.module.flags = !{!0}
424+!opencl.ocl.version = !{!1}
425+!opencl.spir.version = !{!1}
426+!llvm.ident = !{!2}
427+
428+!0 = !{i32 1, !"wchar_size", i32 4}
429+!1 = !{i32 2, i32 0}
430+!2 = !{!"clang version 13.0.0 (https://github.com/llvm/llvm-project.git 94aa388f0ce0723bb15503cf41c2c15b288375b9)"}
431--
4322.17.1
433
diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0002-Memory-leak-fix-for-Managed-Static-Mutex.patch b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0002-Memory-leak-fix-for-Managed-Static-Mutex.patch
deleted file mode 100644
index 5b1f207e..00000000
--- a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0002-Memory-leak-fix-for-Managed-Static-Mutex.patch
+++ /dev/null
@@ -1,35 +0,0 @@
1From ef27f1f99ad661c9604b7ff10efb1122466c508b Mon Sep 17 00:00:00 2001
2From: juanrod2 <>
3Date: Tue, 22 Dec 2020 08:33:08 +0800
4Subject: [PATCH 2/6] Memory leak fix for Managed Static Mutex
5
6Upstream-Status: Backport [Taken from opencl-clang patches; https://github.com/intel/opencl-clang/blob/ocl-open-100/patches/llvm/0001-Memory-leak-fix-for-Managed-Static-Mutex.patch]
7
8Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
9
10Cleaning a mutex inside ManagedStatic llvm class.
11---
12 llvm/lib/Support/ManagedStatic.cpp | 6 +++++-
13 1 file changed, 5 insertions(+), 1 deletion(-)
14
15diff --git a/llvm/lib/Support/ManagedStatic.cpp b/llvm/lib/Support/ManagedStatic.cpp
16index 053493f72fb5..6571580ccecf 100644
17--- a/llvm/lib/Support/ManagedStatic.cpp
18+++ b/llvm/lib/Support/ManagedStatic.cpp
19@@ -76,8 +76,12 @@ void ManagedStaticBase::destroy() const {
20
21 /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables.
22 void llvm::llvm_shutdown() {
23- std::lock_guard<std::recursive_mutex> Lock(*getManagedStaticMutex());
24+ getManagedStaticMutex()->lock();
25
26 while (StaticList)
27 StaticList->destroy();
28+
29+ getManagedStaticMutex()->unlock();
30+ delete ManagedStaticMutex;
31+ ManagedStaticMutex = nullptr;
32 }
33--
342.17.1
35
diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0003-Remove-repo-name-in-LLVM-IR.patch b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0003-Remove-repo-name-in-LLVM-IR.patch
deleted file mode 100644
index 15c4f9e2..00000000
--- a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0003-Remove-repo-name-in-LLVM-IR.patch
+++ /dev/null
@@ -1,49 +0,0 @@
1From a71ab6fb04b918b856f1dd802cfdb4a7ccd53290 Mon Sep 17 00:00:00 2001
2From: Feng Zou <feng.zou@intel.com>
3Date: Tue, 20 Oct 2020 11:29:04 +0800
4Subject: [PATCH 3/6] Remove repo name in LLVM IR
5
6Upstream-Status: Backport [Taken from opencl-clang patches, https://github.com/intel/opencl-clang/blob/ocl-open-110/patches/llvm/0002-Remove-repo-name-in-LLVM-IR.patch]
7Signed-off-by: Feng Zou <feng.zou@intel.com>
8Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
9---
10 llvm/cmake/modules/VersionFromVCS.cmake | 23 ++++++++++++-----------
11 1 file changed, 12 insertions(+), 11 deletions(-)
12
13diff --git a/llvm/cmake/modules/VersionFromVCS.cmake b/llvm/cmake/modules/VersionFromVCS.cmake
14index 18edbeabe3e4..2d9652634787 100644
15--- a/llvm/cmake/modules/VersionFromVCS.cmake
16+++ b/llvm/cmake/modules/VersionFromVCS.cmake
17@@ -33,17 +33,18 @@ function(get_source_info path revision repository)
18 else()
19 set(remote "origin")
20 endif()
21- execute_process(COMMAND ${GIT_EXECUTABLE} remote get-url ${remote}
22- WORKING_DIRECTORY ${path}
23- RESULT_VARIABLE git_result
24- OUTPUT_VARIABLE git_output
25- ERROR_QUIET)
26- if(git_result EQUAL 0)
27- string(STRIP "${git_output}" git_output)
28- set(${repository} ${git_output} PARENT_SCOPE)
29- else()
30- set(${repository} ${path} PARENT_SCOPE)
31- endif()
32+ # Do not show repo name in IR
33+ # execute_process(COMMAND ${GIT_EXECUTABLE} remote get-url ${remote}
34+ # WORKING_DIRECTORY ${path}
35+ # RESULT_VARIABLE git_result
36+ # OUTPUT_VARIABLE git_output
37+ # ERROR_QUIET)
38+ # if(git_result EQUAL 0)
39+ # string(STRIP "${git_output}" git_output)
40+ # set(${repository} ${git_output} PARENT_SCOPE)
41+ # else()
42+ # set(${repository} ${path} PARENT_SCOPE)
43+ # endif()
44 endif()
45 else()
46 message(WARNING "Git not found. Version cannot be determined.")
47--
482.17.1
49
diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0004-Remove-__IMAGE_SUPPORT__-macro-for-SPIR-since-SPIR-d.patch b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0004-Remove-__IMAGE_SUPPORT__-macro-for-SPIR-since-SPIR-d.patch
deleted file mode 100644
index 25d88367..00000000
--- a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0004-Remove-__IMAGE_SUPPORT__-macro-for-SPIR-since-SPIR-d.patch
+++ /dev/null
@@ -1,51 +0,0 @@
1From 546d9089fe5e21cccc671a0a89555cd4d5f8c817 Mon Sep 17 00:00:00 2001
2From: Naveen Saini <naveen.kumar.saini@intel.com>
3Date: Thu, 19 Aug 2021 15:52:24 +0800
4Subject: [PATCH 4/6] Remove __IMAGE_SUPPORT__ macro for SPIR since SPIR
5 doesn't require image support
6
7Upstream-Status: Backport [Taken from opencl-clang patches; https://github.com/intel/opencl-clang/blob/ocl-open-110/patches/clang/0002-Remove-__IMAGE_SUPPORT__-macro-for-SPIR.patch]
8
9Signed-off-by: haonanya <haonan.yang@intel.com>
10Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
11---
12 clang/lib/Frontend/InitPreprocessor.cpp | 3 ---
13 clang/test/Preprocessor/predefined-macros.c | 2 --
14 2 files changed, 5 deletions(-)
15
16diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
17index 5bb489c11909..cf3b48cb65d2 100644
18--- a/clang/lib/Frontend/InitPreprocessor.cpp
19+++ b/clang/lib/Frontend/InitPreprocessor.cpp
20@@ -1115,9 +1115,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
21 if (TI.getSupportedOpenCLOpts().isSupported(#Ext)) \
22 Builder.defineMacro(#Ext);
23 #include "clang/Basic/OpenCLExtensions.def"
24-
25- if (TI.getTriple().isSPIR())
26- Builder.defineMacro("__IMAGE_SUPPORT__");
27 }
28
29 if (TI.hasInt128Type() && LangOpts.CPlusPlus && LangOpts.GNUMode) {
30diff --git a/clang/test/Preprocessor/predefined-macros.c b/clang/test/Preprocessor/predefined-macros.c
31index 6c80517ec4d4..b5e5d7e2d546 100644
32--- a/clang/test/Preprocessor/predefined-macros.c
33+++ b/clang/test/Preprocessor/predefined-macros.c
34@@ -186,14 +186,12 @@
35
36 // RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spir-unknown-unknown \
37 // RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIR
38-// CHECK-SPIR-DAG: #define __IMAGE_SUPPORT__ 1
39 // CHECK-SPIR-DAG: #define __SPIR__ 1
40 // CHECK-SPIR-DAG: #define __SPIR32__ 1
41 // CHECK-SPIR-NOT: #define __SPIR64__ 1
42
43 // RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spir64-unknown-unknown \
44 // RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIR64
45-// CHECK-SPIR64-DAG: #define __IMAGE_SUPPORT__ 1
46 // CHECK-SPIR64-DAG: #define __SPIR__ 1
47 // CHECK-SPIR64-DAG: #define __SPIR64__ 1
48 // CHECK-SPIR64-NOT: #define __SPIR32__ 1
49--
502.17.1
51
diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0005-Avoid-calling-ParseCommandLineOptions-in-BackendUtil.patch b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0005-Avoid-calling-ParseCommandLineOptions-in-BackendUtil.patch
deleted file mode 100644
index 2b86532c..00000000
--- a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0005-Avoid-calling-ParseCommandLineOptions-in-BackendUtil.patch
+++ /dev/null
@@ -1,52 +0,0 @@
1From 747e48959e18ac8b586078a82472a0799d12925c Mon Sep 17 00:00:00 2001
2From: Raphael Isemann <teemperor@gmail.com>
3Date: Thu, 1 Apr 2021 18:41:44 +0200
4Subject: [PATCH 5/6] Avoid calling ParseCommandLineOptions in BackendUtil if
5 possible
6
7Calling `ParseCommandLineOptions` should only be called from `main` as the
8CommandLine setup code isn't thread-safe. As BackendUtil is part of the
9generic Clang FrontendAction logic, a process which has several threads executing
10Clang FrontendActions will randomly crash in the unsafe setup code.
11
12This patch avoids calling the function unless either the debug-pass option or
13limit-float-precision option is set. Without these two options set the
14`ParseCommandLineOptions` call doesn't do anything beside parsing
15the command line `clang` which doesn't set any options.
16
17See also D99652 where LLDB received a workaround for this crash.
18
19Reviewed By: JDevlieghere
20
21Differential Revision: https://reviews.llvm.org/D99740
22
23Upstream-Status: Backport [Taken from opencl-clang patches; https://github.com/intel/opencl-clang/blob/ocl-open-110/patches/clang/0003-Avoid-calling-ParseCommandLineOptions-in-BackendUtil.patch]
24
25Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
26---
27 clang/lib/CodeGen/BackendUtil.cpp | 8 ++++++++
28 1 file changed, 8 insertions(+)
29
30diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
31index dce0940670a2..ab478090ed1c 100644
32--- a/clang/lib/CodeGen/BackendUtil.cpp
33+++ b/clang/lib/CodeGen/BackendUtil.cpp
34@@ -797,7 +797,15 @@ static void setCommandLineOpts(const CodeGenOptions &CodeGenOpts) {
35 BackendArgs.push_back("-limit-float-precision");
36 BackendArgs.push_back(CodeGenOpts.LimitFloatPrecision.c_str());
37 }
38+ // Check for the default "clang" invocation that won't set any cl::opt values.
39+ // Skip trying to parse the command line invocation to avoid the issues
40+ // described below.
41+ if (BackendArgs.size() == 1)
42+ return;
43 BackendArgs.push_back(nullptr);
44+ // FIXME: The command line parser below is not thread-safe and shares a global
45+ // state, so this call might crash or overwrite the options of another Clang
46+ // instance in the same process.
47 llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1,
48 BackendArgs.data());
49 }
50--
512.17.1
52
diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0006-OpenCL-support-cl_ext_float_atomics.patch b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0006-OpenCL-support-cl_ext_float_atomics.patch
deleted file mode 100644
index 0178fd43..00000000
--- a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0006-OpenCL-support-cl_ext_float_atomics.patch
+++ /dev/null
@@ -1,353 +0,0 @@
1From a1b924d76cdacfa3f9dbb79a9e3edddcd75f61ca Mon Sep 17 00:00:00 2001
2From: Naveen Saini <naveen.kumar.saini@intel.com>
3Date: Thu, 19 Aug 2021 16:06:33 +0800
4Subject: [PATCH 6/6] [OpenCL] support cl_ext_float_atomics
5
6Upstream-Status: Backport [Taken from opencl-clang patches; https://github.com/intel/opencl-clang/blob/ocl-open-110/patches/clang/0004-OpenCL-support-cl_ext_float_atomics.patch]
7
8Signed-off-by: haonanya <haonan.yang@intel.com>
9Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
10---
11 clang/lib/Headers/opencl-c-base.h | 25 ++++
12 clang/lib/Headers/opencl-c.h | 195 ++++++++++++++++++++++++++
13 clang/test/Headers/opencl-c-header.cl | 85 +++++++++++
14 3 files changed, 305 insertions(+)
15
16diff --git a/clang/lib/Headers/opencl-c-base.h b/clang/lib/Headers/opencl-c-base.h
17index afa900ab24d9..9a3ee8529acf 100644
18--- a/clang/lib/Headers/opencl-c-base.h
19+++ b/clang/lib/Headers/opencl-c-base.h
20@@ -62,6 +62,31 @@
21 #endif
22 #endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
23
24+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
25+// For SPIR all extensions are supported.
26+#if defined(__SPIR__)
27+#define cl_ext_float_atomics
28+#ifdef cl_khr_fp16
29+#define __opencl_c_ext_fp16_global_atomic_load_store 1
30+#define __opencl_c_ext_fp16_local_atomic_load_store 1
31+#define __opencl_c_ext_fp16_global_atomic_add 1
32+#define __opencl_c_ext_fp16_local_atomic_add 1
33+#define __opencl_c_ext_fp16_global_atomic_min_max 1
34+#define __opencl_c_ext_fp16_local_atomic_min_max 1
35+#endif
36+#ifdef __opencl_c_fp64
37+#define __opencl_c_ext_fp64_global_atomic_add 1
38+#define __opencl_c_ext_fp64_local_atomic_add 1
39+#define __opencl_c_ext_fp64_global_atomic_min_max 1
40+#define __opencl_c_ext_fp64_local_atomic_min_max 1
41+#endif
42+#define __opencl_c_ext_fp32_global_atomic_add 1
43+#define __opencl_c_ext_fp32_local_atomic_add 1
44+#define __opencl_c_ext_fp32_global_atomic_min_max 1
45+#define __opencl_c_ext_fp32_local_atomic_min_max 1
46+#endif // defined(__SPIR__)
47+#endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
48+
49 // built-in scalar data types:
50
51 /**
52diff --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
53index 67d900eb1c3d..bda0f5c6df80 100644
54--- a/clang/lib/Headers/opencl-c.h
55+++ b/clang/lib/Headers/opencl-c.h
56@@ -14354,6 +14354,201 @@ intptr_t __ovld atomic_fetch_max_explicit(
57 // defined(cl_khr_int64_extended_atomics)
58 #endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0)
59
60+#if defined(cl_ext_float_atomics)
61+
62+#if defined(__opencl_c_ext_fp32_global_atomic_min_max)
63+float __ovld atomic_fetch_min(volatile __global atomic_float *object,
64+ float operand);
65+float __ovld atomic_fetch_max(volatile __global atomic_float *object,
66+ float operand);
67+float __ovld atomic_fetch_min_explicit(volatile __global atomic_float *object,
68+ float operand, memory_order order);
69+float __ovld atomic_fetch_max_explicit(volatile __global atomic_float *object,
70+ float operand, memory_order order);
71+float __ovld atomic_fetch_min_explicit(volatile __global atomic_float *object,
72+ float operand, memory_order order,
73+ memory_scope scope);
74+float __ovld atomic_fetch_max_explicit(volatile __global atomic_float *object,
75+ float operand, memory_order order,
76+ memory_scope scope);
77+#endif
78+#if defined(__opencl_c_ext_fp32_local_atomic_min_max)
79+float __ovld atomic_fetch_min(volatile __local atomic_float *object,
80+ float operand);
81+float __ovld atomic_fetch_max(volatile __local atomic_float *object,
82+ float operand);
83+float __ovld atomic_fetch_min_explicit(volatile __local atomic_float *object,
84+ float operand, memory_order order);
85+float __ovld atomic_fetch_max_explicit(volatile __local atomic_float *object,
86+ float operand, memory_order order);
87+float __ovld atomic_fetch_min_explicit(volatile __local atomic_float *object,
88+ float operand, memory_order order,
89+ memory_scope scope);
90+float __ovld atomic_fetch_max_explicit(volatile __local atomic_float *object,
91+ float operand, memory_order order,
92+ memory_scope scope);
93+#endif
94+#if defined(__opencl_c_ext_fp32_global_atomic_min_max) || \
95+ defined(__opencl_c_ext_fp32_local_atomic_min_max)
96+float __ovld atomic_fetch_min(volatile atomic_float *object, float operand);
97+float __ovld atomic_fetch_max(volatile atomic_float *object, float operand);
98+float __ovld atomic_fetch_min_explicit(volatile atomic_float *object,
99+ float operand, memory_order order);
100+float __ovld atomic_fetch_max_explicit(volatile atomic_float *object,
101+ float operand, memory_order order);
102+float __ovld atomic_fetch_min_explicit(volatile atomic_float *object,
103+ float operand, memory_order order,
104+ memory_scope scope);
105+float __ovld atomic_fetch_max_explicit(volatile atomic_float *object,
106+ float operand, memory_order order,
107+ memory_scope scope);
108+#endif
109+#if defined(__opencl_c_ext_fp64_global_atomic_min_max)
110+double __ovld atomic_fetch_min(volatile __global atomic_double *object,
111+ double operand);
112+double __ovld atomic_fetch_max(volatile __global atomic_double *object,
113+ double operand);
114+double __ovld atomic_fetch_min_explicit(volatile __global atomic_double *object,
115+ double operand, memory_order order);
116+double __ovld atomic_fetch_max_explicit(volatile __global atomic_double *object,
117+ double operand, memory_order order);
118+double __ovld atomic_fetch_min_explicit(volatile __global atomic_double *object,
119+ double operand, memory_order order,
120+ memory_scope scope);
121+double __ovld atomic_fetch_max_explicit(volatile __global atomic_double *object,
122+ double operand, memory_order order,
123+ memory_scope scope);
124+#endif
125+#if defined(__opencl_c_ext_fp64_local_atomic_min_max)
126+double __ovld atomic_fetch_min(volatile __local atomic_double *object,
127+ double operand);
128+double __ovld atomic_fetch_max(volatile __local atomic_double *object,
129+ double operand);
130+double __ovld atomic_fetch_min_explicit(volatile __local atomic_double *object,
131+ double operand, memory_order order);
132+double __ovld atomic_fetch_max_explicit(volatile __local atomic_double *object,
133+ double operand, memory_order order);
134+double __ovld atomic_fetch_min_explicit(volatile __local atomic_double *object,
135+ double operand, memory_order order,
136+ memory_scope scope);
137+double __ovld atomic_fetch_max_explicit(volatile __local atomic_double *object,
138+ double operand, memory_order order,
139+ memory_scope scope);
140+#endif
141+#if defined(__opencl_c_ext_fp64_global_atomic_min_max) || \
142+ defined(__opencl_c_ext_fp64_local_atomic_min_max)
143+double __ovld atomic_fetch_min(volatile atomic_double *object, double operand);
144+double __ovld atomic_fetch_max(volatile atomic_double *object, double operand);
145+double __ovld atomic_fetch_min_explicit(volatile atomic_double *object,
146+ double operand, memory_order order);
147+double __ovld atomic_fetch_max_explicit(volatile atomic_double *object,
148+ double operand, memory_order order);
149+double __ovld atomic_fetch_min_explicit(volatile atomic_double *object,
150+ double operand, memory_order order,
151+ memory_scope scope);
152+double __ovld atomic_fetch_max_explicit(volatile atomic_double *object,
153+ double operand, memory_order order,
154+ memory_scope scope);
155+#endif
156+
157+#if defined(__opencl_c_ext_fp32_global_atomic_add)
158+float __ovld atomic_fetch_add(volatile __global atomic_float *object,
159+ float operand);
160+float __ovld atomic_fetch_sub(volatile __global atomic_float *object,
161+ float operand);
162+float __ovld atomic_fetch_add_explicit(volatile __global atomic_float *object,
163+ float operand, memory_order order);
164+float __ovld atomic_fetch_sub_explicit(volatile __global atomic_float *object,
165+ float operand, memory_order order);
166+float __ovld atomic_fetch_add_explicit(volatile __global atomic_float *object,
167+ float operand, memory_order order,
168+ memory_scope scope);
169+float __ovld atomic_fetch_sub_explicit(volatile __global atomic_float *object,
170+ float operand, memory_order order,
171+ memory_scope scope);
172+#endif
173+#if defined(__opencl_c_ext_fp32_local_atomic_add)
174+float __ovld atomic_fetch_add(volatile __local atomic_float *object,
175+ float operand);
176+float __ovld atomic_fetch_sub(volatile __local atomic_float *object,
177+ float operand);
178+float __ovld atomic_fetch_add_explicit(volatile __local atomic_float *object,
179+ float operand, memory_order order);
180+float __ovld atomic_fetch_sub_explicit(volatile __local atomic_float *object,
181+ float operand, memory_order order);
182+float __ovld atomic_fetch_add_explicit(volatile __local atomic_float *object,
183+ float operand, memory_order order,
184+ memory_scope scope);
185+float __ovld atomic_fetch_sub_explicit(volatile __local atomic_float *object,
186+ float operand, memory_order order,
187+ memory_scope scope);
188+#endif
189+#if defined(__opencl_c_ext_fp32_global_atomic_add) || \
190+ defined(__opencl_c_ext_fp32_local_atomic_add)
191+float __ovld atomic_fetch_add(volatile atomic_float *object, float operand);
192+float __ovld atomic_fetch_sub(volatile atomic_float *object, float operand);
193+float __ovld atomic_fetch_add_explicit(volatile atomic_float *object,
194+ float operand, memory_order order);
195+float __ovld atomic_fetch_sub_explicit(volatile atomic_float *object,
196+ float operand, memory_order order);
197+float __ovld atomic_fetch_add_explicit(volatile atomic_float *object,
198+ float operand, memory_order order,
199+ memory_scope scope);
200+float __ovld atomic_fetch_sub_explicit(volatile atomic_float *object,
201+ float operand, memory_order order,
202+ memory_scope scope);
203+#endif
204+
205+#if defined(__opencl_c_ext_fp64_global_atomic_add)
206+double __ovld atomic_fetch_add(volatile __global atomic_double *object,
207+ double operand);
208+double __ovld atomic_fetch_sub(volatile __global atomic_double *object,
209+ double operand);
210+double __ovld atomic_fetch_add_explicit(volatile __global atomic_double *object,
211+ double operand, memory_order order);
212+double __ovld atomic_fetch_sub_explicit(volatile __global atomic_double *object,
213+ double operand, memory_order order);
214+double __ovld atomic_fetch_add_explicit(volatile __global atomic_double *object,
215+ double operand, memory_order order,
216+ memory_scope scope);
217+double __ovld atomic_fetch_sub_explicit(volatile __global atomic_double *object,
218+ double operand, memory_order order,
219+ memory_scope scope);
220+#endif
221+#if defined(__opencl_c_ext_fp64_local_atomic_add)
222+double __ovld atomic_fetch_add(volatile __local atomic_double *object,
223+ double operand);
224+double __ovld atomic_fetch_sub(volatile __local atomic_double *object,
225+ double operand);
226+double __ovld atomic_fetch_add_explicit(volatile __local atomic_double *object,
227+ double operand, memory_order order);
228+double __ovld atomic_fetch_sub_explicit(volatile __local atomic_double *object,
229+ double operand, memory_order order);
230+double __ovld atomic_fetch_add_explicit(volatile __local atomic_double *object,
231+ double operand, memory_order order,
232+ memory_scope scope);
233+double __ovld atomic_fetch_sub_explicit(volatile __local atomic_double *object,
234+ double operand, memory_order order,
235+ memory_scope scope);
236+#endif
237+#if defined(__opencl_c_ext_fp64_global_atomic_add) || \
238+ defined(__opencl_c_ext_fp64_local_atomic_add)
239+double __ovld atomic_fetch_add(volatile atomic_double *object, double operand);
240+double __ovld atomic_fetch_sub(volatile atomic_double *object, double operand);
241+double __ovld atomic_fetch_add_explicit(volatile atomic_double *object,
242+ double operand, memory_order order);
243+double __ovld atomic_fetch_sub_explicit(volatile atomic_double *object,
244+ double operand, memory_order order);
245+double __ovld atomic_fetch_add_explicit(volatile atomic_double *object,
246+ double operand, memory_order order,
247+ memory_scope scope);
248+double __ovld atomic_fetch_sub_explicit(volatile atomic_double *object,
249+ double operand, memory_order order,
250+ memory_scope scope);
251+#endif
252+
253+#endif // cl_ext_float_atomics
254+
255 // atomic_store()
256
257 #if defined(__opencl_c_atomic_scope_device) && \
258diff --git a/clang/test/Headers/opencl-c-header.cl b/clang/test/Headers/opencl-c-header.cl
259index 2716076acdcf..6b3eca84e8b9 100644
260--- a/clang/test/Headers/opencl-c-header.cl
261+++ b/clang/test/Headers/opencl-c-header.cl
262@@ -98,3 +98,88 @@ global atomic_int z = ATOMIC_VAR_INIT(99);
263 #pragma OPENCL EXTENSION cl_intel_planar_yuv : enable
264
265 // CHECK-MOD: Reading modules
266+
267+// For SPIR all extensions are supported.
268+#if defined(__SPIR__)
269+
270+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
271+
272+#if __opencl_c_ext_fp16_global_atomic_load_store != 1
273+#error "Incorrectly defined __opencl_c_ext_fp16_global_atomic_load_store"
274+#endif
275+#if __opencl_c_ext_fp16_local_atomic_load_store != 1
276+#error "Incorrectly defined __opencl_c_ext_fp16_local_atomic_load_store"
277+#endif
278+#if __opencl_c_ext_fp16_global_atomic_add != 1
279+#error "Incorrectly defined __opencl_c_ext_fp16_global_atomic_add"
280+#endif
281+#if __opencl_c_ext_fp32_global_atomic_add != 1
282+#error "Incorrectly defined __opencl_c_ext_fp32_global_atomic_add"
283+#endif
284+#if __opencl_c_ext_fp16_local_atomic_add != 1
285+#error "Incorrectly defined __opencl_c_ext_fp16_local_atomic_add"
286+#endif
287+#if __opencl_c_ext_fp32_local_atomic_add != 1
288+#error "Incorrectly defined __opencl_c_ext_fp32_local_atomic_add"
289+#endif
290+#if __opencl_c_ext_fp16_global_atomic_min_max != 1
291+#error "Incorrectly defined __opencl_c_ext_fp16_global_atomic_min_max"
292+#endif
293+#if __opencl_c_ext_fp32_global_atomic_min_max != 1
294+#error "Incorrectly defined __opencl_c_ext_fp32_global_atomic_min_max"
295+#endif
296+#if __opencl_c_ext_fp16_local_atomic_min_max != 1
297+#error "Incorrectly defined __opencl_c_ext_fp16_local_atomic_min_max"
298+#endif
299+#if __opencl_c_ext_fp32_local_atomic_min_max != 1
300+#error "Incorrectly defined __opencl_c_ext_fp32_local_atomic_min_max"
301+#endif
302+
303+#else
304+#ifdef __opencl_c_ext_fp16_global_atomic_load_store
305+#error "Incorrectly __opencl_c_ext_fp16_global_atomic_load_store defined"
306+#endif
307+#ifdef __opencl_c_ext_fp16_local_atomic_load_store
308+#error "Incorrectly __opencl_c_ext_fp16_local_atomic_load_store defined"
309+#endif
310+#ifdef __opencl_c_ext_fp16_global_atomic_add
311+#error "Incorrectly __opencl_c_ext_fp16_global_atomic_add defined"
312+#endif
313+#ifdef __opencl_c_ext_fp32_global_atomic_add
314+#error "Incorrectly __opencl_c_ext_fp32_global_atomic_add defined"
315+#endif
316+#ifdef __opencl_c_ext_fp64_global_atomic_add
317+#error "Incorrectly __opencl_c_ext_fp64_global_atomic_add defined"
318+#endif
319+#ifdef __opencl_c_ext_fp16_local_atomic_add
320+#error "Incorrectly __opencl_c_ext_fp16_local_atomic_add defined"
321+#endif
322+#ifdef __opencl_c_ext_fp32_local_atomic_add
323+#error "Incorrectly __opencl_c_ext_fp32_local_atomic_add defined"
324+#endif
325+#ifdef __opencl_c_ext_fp64_local_atomic_add
326+#error "Incorrectly __opencl_c_ext_fp64_local_atomic_add defined"
327+#endif
328+#ifdef __opencl_c_ext_fp16_global_atomic_min_max
329+#error "Incorrectly __opencl_c_ext_fp16_global_atomic_min_max defined"
330+#endif
331+#ifdef __opencl_c_ext_fp32_global_atomic_min_max
332+#error "Incorrectly __opencl_c_ext_fp32_global_atomic_min_max defined"
333+#endif
334+#ifdef __opencl_c_ext_fp64_global_atomic_min_max
335+#error "Incorrectly __opencl_c_ext_fp64_global_atomic_min_max defined"
336+#endif
337+#ifdef __opencl_c_ext_fp16_local_atomic_min_max
338+#error "Incorrectly __opencl_c_ext_fp16_local_atomic_min_max defined"
339+#endif
340+#ifdef __opencl_c_ext_fp32_local_atomic_min_max
341+#error "Incorrectly __opencl_c_ext_fp32_local_atomic_min_max defined"
342+#endif
343+#ifdef __opencl_c_ext_fp64_local_atomic_min_max
344+#error "Incorrectly __opencl_c_ext_fp64_local_atomic_min_max defined"
345+#endif
346+
347+#endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
348+
349+#endif // defined(__SPIR__)
350+
351--
3522.17.1
353
diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0007-ispc-11_0_11_1_disable-A-B-A-B-in-InstCombine.patch b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0007-ispc-11_0_11_1_disable-A-B-A-B-in-InstCombine.patch
deleted file mode 100644
index dcf26bc9..00000000
--- a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0007-ispc-11_0_11_1_disable-A-B-A-B-in-InstCombine.patch
+++ /dev/null
@@ -1,47 +0,0 @@
1From ef2b930a8e33078449737a93e7d522b2280ec58c Mon Sep 17 00:00:00 2001
2From: Naveen Saini <naveen.kumar.saini@intel.com>
3Date: Fri, 27 Aug 2021 11:39:16 +0800
4Subject: [PATCH 1/2] This patch is needed for ISPC for Gen only
5
6Transformation of add to or is not safe for VC backend.
7
8Upstream-Status: Backport [Taken from ispc,https://github.com/ispc/ispc/blob/v1.16.1/llvm_patches/11_0_11_1_disable-A-B-A-B-in-InstCombine.patch]
9
10Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
11---
12 .../lib/Transforms/InstCombine/InstCombineAddSub.cpp | 12 ++++++++----
13 1 file changed, 8 insertions(+), 4 deletions(-)
14
15diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
16index a7f5e0a7774d..bf02b0f70827 100644
17--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
18+++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
19@@ -15,6 +15,7 @@
20 #include "llvm/ADT/APInt.h"
21 #include "llvm/ADT/STLExtras.h"
22 #include "llvm/ADT/SmallVector.h"
23+#include "llvm/ADT/Triple.h"
24 #include "llvm/Analysis/InstructionSimplify.h"
25 #include "llvm/Analysis/ValueTracking.h"
26 #include "llvm/IR/Constant.h"
27@@ -1324,10 +1325,13 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
28 return BinaryOperator::CreateSRem(RHS, NewRHS);
29 }
30 }
31-
32- // A+B --> A|B iff A and B have no bits set in common.
33- if (haveNoCommonBitsSet(LHS, RHS, DL, &AC, &I, &DT))
34- return BinaryOperator::CreateOr(LHS, RHS);
35+
36+ // Disable this transformation for ISPC SPIR-V
37+ if (!Triple(I.getModule()->getTargetTriple()).isSPIR()) {
38+ // A+B --> A|B iff A and B have no bits set in common.
39+ if (haveNoCommonBitsSet(LHS, RHS, DL, &AC, &I, &DT))
40+ return BinaryOperator::CreateOr(LHS, RHS);
41+ }
42
43 // FIXME: We already did a check for ConstantInt RHS above this.
44 // FIXME: Is this pattern covered by another fold? No regression tests fail on
45--
462.17.1
47
diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0008-ispc-11_0_11_1_packed_load_store_avx512.patch b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0008-ispc-11_0_11_1_packed_load_store_avx512.patch
deleted file mode 100644
index 9ceed0a9..00000000
--- a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm11-0008-ispc-11_0_11_1_packed_load_store_avx512.patch
+++ /dev/null
@@ -1,95 +0,0 @@
1From c20838176e8bea9e5a176c59c78bbce9051ec987 Mon Sep 17 00:00:00 2001
2From: Naveen Saini <naveen.kumar.saini@intel.com>
3Date: Fri, 27 Aug 2021 11:41:47 +0800
4Subject: [PATCH 2/2] [X86] When storing v1i1/v2i1/v4i1 to memory, make sure we
5 store zeros in the rest of the byte
6
7We can't store garbage in the unused bits. It possible that something like zextload from i1/i2/i4 is created to read the memory. Those zextloads would be legalized assuming the extra bits are 0.
8
9I'm not sure that the code in lowerStore is executed for the v1i1/v2i1/v4i1 case. It looks like the DAG combine in combineStore may have converted them to v8i1 first. And I think we're missing some cases to avoid going to the stack in the first place. But I don't have time to investigate those things at the moment so I wanted to focus on the correctness issue.
10
11Should fix PR48147.
12
13Reviewed By: RKSimon
14
15Differential Revision: https://reviews.llvm.org/D91294
16
17Upstream-Status: Backport [https://github.com/llvm/llvm-project/commit/a4124e455e641db1e18d4221d2dacb31953fd13b]
18
19Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
20---
21 llvm/lib/Target/X86/X86ISelLowering.cpp | 19 ++++++++++++++-----
22 llvm/lib/Target/X86/X86InstrAVX512.td | 3 ---
23 2 files changed, 14 insertions(+), 8 deletions(-)
24
25diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
26index 56690c3c555b..7e673a3163b7 100644
27--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
28+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
29@@ -23549,17 +23549,22 @@ static SDValue LowerStore(SDValue Op, const X86Subtarget &Subtarget,
30 // Without AVX512DQ, we need to use a scalar type for v2i1/v4i1/v8i1 stores.
31 if (StoredVal.getValueType().isVector() &&
32 StoredVal.getValueType().getVectorElementType() == MVT::i1) {
33- assert(StoredVal.getValueType().getVectorNumElements() <= 8 &&
34- "Unexpected VT");
35+ unsigned NumElts = StoredVal.getValueType().getVectorNumElements();
36+ assert(NumElts <= 8 && "Unexpected VT");
37 assert(!St->isTruncatingStore() && "Expected non-truncating store");
38 assert(Subtarget.hasAVX512() && !Subtarget.hasDQI() &&
39 "Expected AVX512F without AVX512DQI");
40
41+ // We must pad with zeros to ensure we store zeroes to any unused bits.
42 StoredVal = DAG.getNode(ISD::INSERT_SUBVECTOR, dl, MVT::v16i1,
43 DAG.getUNDEF(MVT::v16i1), StoredVal,
44 DAG.getIntPtrConstant(0, dl));
45 StoredVal = DAG.getBitcast(MVT::i16, StoredVal);
46 StoredVal = DAG.getNode(ISD::TRUNCATE, dl, MVT::i8, StoredVal);
47+ // Make sure we store zeros in the extra bits.
48+ if (NumElts < 8)
49+ StoredVal = DAG.getZeroExtendInReg(StoredVal, dl,
50+ MVT::getIntegerVT(NumElts));
51
52 return DAG.getStore(St->getChain(), dl, StoredVal, St->getBasePtr(),
53 St->getPointerInfo(), St->getOriginalAlign(),
54@@ -44133,17 +44138,21 @@ static SDValue combineStore(SDNode *N, SelectionDAG &DAG,
55 if (VT == MVT::v1i1 && VT == StVT && Subtarget.hasAVX512() &&
56 StoredVal.getOpcode() == ISD::SCALAR_TO_VECTOR &&
57 StoredVal.getOperand(0).getValueType() == MVT::i8) {
58- return DAG.getStore(St->getChain(), dl, StoredVal.getOperand(0),
59+ SDValue Val = StoredVal.getOperand(0);
60+ // We must store zeros to the unused bits.
61+ Val = DAG.getZeroExtendInReg(Val, dl, MVT::i1);
62+ return DAG.getStore(St->getChain(), dl, Val,
63 St->getBasePtr(), St->getPointerInfo(),
64 St->getOriginalAlign(),
65 St->getMemOperand()->getFlags());
66 }
67
68 // Widen v2i1/v4i1 stores to v8i1.
69- if ((VT == MVT::v2i1 || VT == MVT::v4i1) && VT == StVT &&
70+ if ((VT == MVT::v1i1 || VT == MVT::v2i1 || VT == MVT::v4i1) && VT == StVT &&
71 Subtarget.hasAVX512()) {
72 unsigned NumConcats = 8 / VT.getVectorNumElements();
73- SmallVector<SDValue, 4> Ops(NumConcats, DAG.getUNDEF(VT));
74+ // We must store zeros to the unused bits.
75+ SmallVector<SDValue, 4> Ops(NumConcats, DAG.getConstant(0, dl, VT));
76 Ops[0] = StoredVal;
77 StoredVal = DAG.getNode(ISD::CONCAT_VECTORS, dl, MVT::v8i1, Ops);
78 return DAG.getStore(St->getChain(), dl, StoredVal, St->getBasePtr(),
79diff --git a/llvm/lib/Target/X86/X86InstrAVX512.td b/llvm/lib/Target/X86/X86InstrAVX512.td
80index a3ad0b1c8dd6..aa1ccec02f2a 100644
81--- a/llvm/lib/Target/X86/X86InstrAVX512.td
82+++ b/llvm/lib/Target/X86/X86InstrAVX512.td
83@@ -2871,9 +2871,6 @@ def : Pat<(i64 (bitconvert (v64i1 VK64:$src))),
84
85 // Load/store kreg
86 let Predicates = [HasDQI] in {
87- def : Pat<(store VK1:$src, addr:$dst),
88- (KMOVBmk addr:$dst, (COPY_TO_REGCLASS VK1:$src, VK8))>;
89-
90 def : Pat<(v1i1 (load addr:$src)),
91 (COPY_TO_REGCLASS (KMOVBkm addr:$src), VK1)>;
92 def : Pat<(v2i1 (load addr:$src)),
93--
942.17.1
95
diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/llvm-project-source.bbappend b/dynamic-layers/clang-layer/recipes-devtools/clang/llvm-project-source.bbappend
index 3f304215..96011f1d 100644
--- a/dynamic-layers/clang-layer/recipes-devtools/clang/llvm-project-source.bbappend
+++ b/dynamic-layers/clang-layer/recipes-devtools/clang/llvm-project-source.bbappend
@@ -1,9 +1,6 @@
1FILESEXTRAPATHS:prepend:intel-x86-common := "${THISDIR}/files:" 1FILESEXTRAPATHS:prepend:intel-x86-common := "${THISDIR}/files:"
2 2
3SPIRV10_SRCREV = "fe4d6b767363a1995ccbfca27f79efb10dcfe110" 3SPIRV_SRCREV = "fe4d6b767363a1995ccbfca27f79efb10dcfe110"
4SPIRV11_SRCREV = "ca3a50e6e3193e399d26446d4f74a90e2a531f3a"
5
6SPIRV_SRCREV = "${@bb.utils.contains('LLVMVERSION', '10.0.1', '${SPIRV10_SRCREV}', '${SPIRV11_SRCREV}', d)}"
7 4
8SRC_URI_LLVM10_PATCHES = " \ 5SRC_URI_LLVM10_PATCHES = " \
9 file://llvm10-0001-llvm-spirv-skip-building-tests.patch;patchdir=llvm/projects/llvm-spirv \ 6 file://llvm10-0001-llvm-spirv-skip-building-tests.patch;patchdir=llvm/projects/llvm-spirv \
@@ -28,18 +25,6 @@ SRC_URI_LLVM10_PATCHES = " \
28 file://llvm10-0015-ispc-10_0_vXi1calling_avx512_i8_i16.patch \ 25 file://llvm10-0015-ispc-10_0_vXi1calling_avx512_i8_i16.patch \
29 " 26 "
30 27
31SRC_URI_LLVM11_PATCHES = " \
32 file://llvm11-0001-llvm-spirv-skip-building-tests.patch;patchdir=llvm/projects/llvm-spirv \
33 file://llvm11-0002-Add-support-for-cl_ext_float_atomics-in-SPIRVWriter.patch;patchdir=llvm/projects/llvm-spirv \
34 file://llvm11-0001-OpenCL-3.0-support.patch \
35 file://llvm11-0002-Memory-leak-fix-for-Managed-Static-Mutex.patch \
36 file://llvm11-0003-Remove-repo-name-in-LLVM-IR.patch \
37 file://llvm11-0004-Remove-__IMAGE_SUPPORT__-macro-for-SPIR-since-SPIR-d.patch \
38 file://llvm11-0005-Avoid-calling-ParseCommandLineOptions-in-BackendUtil.patch \
39 file://llvm11-0006-OpenCL-support-cl_ext_float_atomics.patch \
40 file://llvm11-0007-ispc-11_0_11_1_disable-A-B-A-B-in-InstCombine.patch \
41 file://llvm11-0008-ispc-11_0_11_1_packed_load_store_avx512.patch \
42 "
43SRC_URI_LLVM12_PATCHES = " \ 28SRC_URI_LLVM12_PATCHES = " \
44 file://llvm12-0001-Remove-__IMAGE_SUPPORT__-macro-for-SPIR-since-SPIR-d.patch \ 29 file://llvm12-0001-Remove-__IMAGE_SUPPORT__-macro-for-SPIR-since-SPIR-d.patch \
45 file://llvm12-0002-Avoid-calling-ParseCommandLineOptions-in-BackendUtil.patch \ 30 file://llvm12-0002-Avoid-calling-ParseCommandLineOptions-in-BackendUtil.patch \
@@ -51,12 +36,7 @@ SRC_URI_LLVM12_PATCHES = " \
51 36
52SPIRV_LLVM10_SRC_URI = "git://github.com/KhronosGroup/SPIRV-LLVM-Translator.git;protocol=https;branch=llvm_release_100;destsuffix=git/llvm/projects/llvm-spirv;name=spirv" 37SPIRV_LLVM10_SRC_URI = "git://github.com/KhronosGroup/SPIRV-LLVM-Translator.git;protocol=https;branch=llvm_release_100;destsuffix=git/llvm/projects/llvm-spirv;name=spirv"
53 38
54SPIRV_LLVM11_SRC_URI = "git://github.com/KhronosGroup/SPIRV-LLVM-Translator.git;protocol=https;branch=llvm_release_110;destsuffix=git/llvm/projects/llvm-spirv;name=spirv"
55
56
57
58SRC_URI:append:intel-x86-common = "${@bb.utils.contains('LLVMVERSION', '10.0.1', ' ${SPIRV_LLVM10_SRC_URI} ${SRC_URI_LLVM10_PATCHES} ', '', d)}" 39SRC_URI:append:intel-x86-common = "${@bb.utils.contains('LLVMVERSION', '10.0.1', ' ${SPIRV_LLVM10_SRC_URI} ${SRC_URI_LLVM10_PATCHES} ', '', d)}"
59SRC_URI:append:intel-x86-common = "${@bb.utils.contains('LLVMVERSION', '11.1.0', ' ${SPIRV_LLVM11_SRC_URI} ${SRC_URI_LLVM11_PATCHES} ', '', d)}"
60SRC_URI:append:intel-x86-common = "${@bb.utils.contains('LLVMVERSION', '12.0.0', ' ${SRC_URI_LLVM12_PATCHES} ', '', d)}" 40SRC_URI:append:intel-x86-common = "${@bb.utils.contains('LLVMVERSION', '12.0.0', ' ${SRC_URI_LLVM12_PATCHES} ', '', d)}"
61 41
62SRCREV_spirv = "${@bb.utils.contains_any('LLVMVERSION', [ '13.0.0', '12.0.0' ], '', '${SPIRV_SRCREV}', d)}" 42SRCREV_spirv = "${@bb.utils.contains_any('LLVMVERSION', [ '13.0.0', '12.0.0' ], '', '${SPIRV_SRCREV}', d)}"
diff --git a/dynamic-layers/clang-layer/recipes-opencl/opencl-clang/opencl-clang_11.0.0.bb b/dynamic-layers/clang-layer/recipes-opencl/opencl-clang/opencl-clang_11.0.0.bb
deleted file mode 100644
index 60d5f0cc..00000000
--- a/dynamic-layers/clang-layer/recipes-opencl/opencl-clang/opencl-clang_11.0.0.bb
+++ /dev/null
@@ -1,15 +0,0 @@
1require opencl-clang.inc
2
3SRC_URI:append = " file://0001-don-t-redefine-LLVM_TABLEGEN_EXE.patch \
4 "
5SRC_URI:append:class-native = " file://0002-make-sure-only-static-libraries-linked-for-native-bu.patch"
6
7SRCREV = "c67648d41df00ea8ee9d701d17299b86f86f0321"
8
9BRANCH = "ocl-open-110"
10
11EXTRA_OECMAKE += "\
12 -DLLVM_TABLEGEN_EXE=${STAGING_BINDIR_NATIVE}/llvm-tblgen \
13 -DCMAKE_SKIP_RPATH=TRUE \
14 -DPREFERRED_LLVM_VERSION="11.1.0" \
15 "