Closed Quuxplusone closed 3 years ago
Bugzilla Link | PR41008 |
Status | RESOLVED WONTFIX |
Importance | P enhancement |
Reported by | Kévin Petit (kevin.petit@arm.com) |
Reported on | 2019-03-08 03:42:39 -0800 |
Last modified on | 2021-01-14 07:11:09 -0800 |
Version | trunk |
Hardware | PC Linux |
CC | anastasia.stulova@arm.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
restrict is not a keyword in C++, and the word "restrict" does not appear in the OpenCL/C++ 2.2 specification (https://www.khronos.org/registry/OpenCL/specs/2.2/html/OpenCL_Cxx.html). So I think this is working correctly.
Clang permits use of __restrict to get restrict semantics in C++.
I guess the code just needs to be changed to use __restrict?
My understanding is that the goal of -cl-std=c++ is to maximise compatibility with OpenCL C whilst enabling C++ features to be used in conjunction with OpenCL.
restrict is rather common in OpenCL C programs. The first example that comes to mind is the SHOC benchmarks [1] but I've seen that in many other programs. I can see value in making this "just work" (easier to reuse and port code) if it doesn't create problems otherwise.
[1] https://github.com/vetter/shoc/blob/master/src/opencl/level1/spmv/spmv.cl
Yes, this is right! The idea is to accept as much OpenCL C code under -cl-std=c++ as possible without changes. But of course the other goal is also to minimize the divergence with C++ to avoid complicating compiler code base.
I will try to investigate why C++ didn't adopt this spelling in the first place to see if there are any wider implications of allowing it under C++ for OpenCL. Or perhaps Richards has some insights.
Thanks!
Makes sense, thank you!
Restrict is not supported by C++ for OpenCL v1.0, see section 2.2.1.3 (https://github.com/KhronosGroup/OpenCL-Docs/releases/tag/cxxforopencl-v1.0-r1)
It is possible that some other versions of the language will relax it however it doesn't seem easy at the moment with the C++ position on this. It is very easy to work around the issue by mapping to __restrict for use cases that guarantee to work correctly.