Skip to content

Commit 17adb65

Browse files
frasercrmckgithub-actions[bot]
authored andcommitted
Automerge: [NVPTX] Support the OpenCL generic addrspace feature by default (#137940)
As best as I can see, all NVPTX architectures support the generic address space. I note there's a FIXME in the target's address space map about 'generic' still having to be added to the target but we haven't observed any issues with it downstream. The generic address space is mapped to the same target address space as default/private (0), but this isn't necessarily a problem for users.
2 parents 5381e45 + 6553dc3 commit 17adb65

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

clang/lib/Basic/Targets/NVPTX.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ class LLVM_LIBRARY_VISIBILITY NVPTXTargetInfo : public TargetInfo {
170170
Opts["cl_khr_global_int32_extended_atomics"] = true;
171171
Opts["cl_khr_local_int32_base_atomics"] = true;
172172
Opts["cl_khr_local_int32_extended_atomics"] = true;
173+
174+
Opts["__opencl_c_generic_address_space"] = true;
173175
}
174176

175177
const llvm::omp::GV &getGridValue() const override {

clang/test/Misc/nvptx.languageOptsOpenCL.cl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,11 @@
132132
#pragma OPENCL EXTENSION cl_khr_subgroups: enable
133133
// expected-warning@-1{{unsupported OpenCL extension 'cl_khr_subgroups' - ignoring}}
134134

135+
#if (__OPENCL_C_VERSION__ >= 300)
136+
#ifndef __opencl_c_generic_address_space
137+
#error "Missing __opencl_c_generic_address_space define"
138+
#else
139+
#error "Incorrect __opencl_c_generic_address_space define"
140+
#endif
141+
#pragma OPENCL EXTENSION __opencl_c_generic_address_space: enable
142+
#endif

0 commit comments

Comments
 (0)