A proposal for adding OpenCL C++ support (Spec v2.2)

Hello,

A number of developers from the member companies within the Khronos Group are interested to contribute the prototype implementation of OpenCL C++ that is currently located on github and based on version 3.6:

https://github.com/KhronosGroup/SPIR/commit/0cfb6f7533d42ae3398a8574efd8abbdac88ac44

This implementation is compliant to OpenCL v2.2 standard:

https://www.khronos.org/registry/OpenCL/specs/opencl-2.2-cplusplus.pdf

Similarly to OpenCL C being based on C99, OpenCL C++ support is entirely based on C++14 with a number of extensions (some of which will be shared with OpenCL C) and a few minor restrictions.

The plan would be to take small patches from the github repository and perform any necessary rework and clean up before putting up for review. From the OpenCL side, I don’t see any issue with this plan as it doesn’t interfere with any current development I am aware of, and also it would be great to progress to the next OpenCL standard. I just want to check if there are any objections from anyone or things we should be aware of before the start. I’m particularly looking for feedback from C++ implementers as there might be some overlap.

Additionally, there are two more related threads, which I plan to discuss separately. There is:

(i) standard library support libclcxx: https://github.com/KhronosGroup/libclcxx.

(ii) and IR generation to SPIRV: http://lists.llvm.org/pipermail/llvm-dev/2018-February/121317.html

that we would like to provide as well, in order to allow Clang to produce an end binary targeting a wider range of architectures directly (not just AMD GPU). We expect that the complete open source solution for OpenCL C++ will increase significantly Clang users and unify our development forces i.e. refactoring, bug hunting, etc. The plan would be to do similar for OpenCL C too at a later point of time.

Please, contact me if you have any thoughts or comments.

Cheers,

Anastasia

There were no objections to this so far. I assume it means nobody is opposing this new feature.

Just to give a bit more info and a chance for the last feedback. We don’t plan to contribute the whole patch but only around 3K lines + tests. The overall changes will be smaller than OpenCL 2.0. And they will mainly affect C++ code paths in Sema and CodeGen, but some parsing bits too.

The time frame to start this work will hopefully be the beginning of April.

Cheers,

Anastasia

There were no objections to this so far. I assume it means nobody is opposing this new feature.

I have no objections.

Just to give a bit more info and a chance for the last feedback. We don’t plan to contribute the whole patch but only around 3K lines + tests. The overall changes will be smaller than OpenCL 2.0. And they will mainly affect C++ code paths in Sema and CodeGen, but some parsing bits too.

The time frame to start this work will hopefully be the beginning of April.

Okay. Can you explain what it means that you won’t be contributing the whole patch?

John.

Hi John,

The OpenCL C++ patch contains integration with the SPIR-V translation tool. We have restared the discussion about that tool on llvm dev recently:

http://lists.llvm.org/pipermail/llvm-dev/2018-March/121794.html

If you look for example in the README file it explain such things as new option -emit-spirv.

https://github.com/KhronosGroup/SPIR/commit/0cfb6f7533d42ae3398a8574efd8abbdac88ac44

Also there is support for the SPIR-V friendly format:

https://github.com/KhronosGroup/SPIRV-LLVM/blob/khronos/spirv-3.6.1/docs/SPIRVRepresentationInLLVM.rst

This is mainly located in lib/CodeGen/OclCxxRewrite directory.

Because, we have a separate activity to redesign the integration with SPIRV, we won’t be contributing those bits currently. But the plan is to restart the discussion around this at some point hopefully soon.

Supporting SPIR-V is essential to us because it gives to many tool vendor a path to use Clang directly from upstream. So we will be working on its integration as well. But for now we would like to start with the generic OpenCL C++ support - Parsing, Sema, basic CodeGen, etc.

I hope it clarifies your question.

Thanks!

Anastasia

Hi John,

The OpenCL C++ patch contains integration with the SPIR-V translation tool. We have restared the discussion about that tool on llvm dev recently:
http://lists.llvm.org/pipermail/llvm-dev/2018-March/121794.html

If you look for example in the README file it explain such things as new option -emit-spirv.
https://github.com/KhronosGroup/SPIR/commit/0cfb6f7533d42ae3398a8574efd8abbdac88ac44

Also there is support for the SPIR-V friendly format:
https://github.com/KhronosGroup/SPIRV-LLVM/blob/khronos/spirv-3.6.1/docs/SPIRVRepresentationInLLVM.rst

This is mainly located in lib/CodeGen/OclCxxRewrite directory.

Because, we have a separate activity to redesign the integration with SPIRV, we won’t be contributing those bits currently. But the plan is to restart the discussion around this at some point hopefully soon.

Supporting SPIR-V is essential to us because it gives to many tool vendor a path to use Clang directly from upstream. So we will be working on its integration as well. But for now we would like to start with the generic OpenCL C++ support - Parsing, Sema, basic CodeGen, etc.

I see. So this is support for the full language, just not SPIR output. That seems totally reasonable to me.

John.