OpenCL* for CPU
Ask questions and share information on Intel® SDK for OpenCL™ Applications and OpenCL™ implementations for Intel® CPU
This forum covers OpenCL* for CPU only. OpenCL* for GPU questions can be asked in the GPU Compute Software forum. Intel® FPGA SDK for OpenCL™ questions can be ask in the FPGA Intel® High Level Design forum.
1663 Discussions

Does Intel OpenCL 2.1 support kernel C++?



I'm working on a project where I'm using OpenCL 2.1 NEO and I want to know if I can use C++ inside the kernel code. I see AMD has that feature and also OpenCL 2.1 it has C++ specs. But I'm not able to use the C++ code inside the kernel.

0 Kudos
4 Replies

Hi SujayS,

Thanks for the interest and the question. I think your question can help a lot of users, so I'm linking some useful resources for users who want to develop with OpenCL-C++ and Intel Graphics Compute Runtime for OpenCL Driver (NEO).

At this time, NEO can ingest SPIR-V. Exploring compilation of OpenCL-C++ to SPIR-V may help you. Here are some overview references and examples:


Some spellings for toggles may have been updated between clang version so picking a toolchain to fit your needs may not be so trivial. The Khronos SPIR repo looks like a good place to start to keep it simple.

Hopefully, browsing the above guidance can help you get there. Please let us know how your exploration goes.





Also noteworthy,  the ioc64 tool, can compile SPIR-V to both Intel CPU and Intel Graphics Technology (NEO enabled) targets. You may wish to use it to check offline compilation for targets of interest. The ioc64 tool comes with Intel® SDK for OpenCL™ Applications and the Intel® oneAPI beta Data Parallel C++ Base Toolkit.

ioc64 maintainers monitor these forums so if you have SPIR-V usage feedback for Intel platforms this would be a good thread to speak to your experience.



I'd like to add a few additional links to Michael's excellent list above:

  • Here is an updated link demonstrating an OpenCL C++ kernel and command line that compiles through standard Clang (at least, as of this writing):
  • Here is the open source SPIR-V LLVM translator that can convert the LLVM IR bitcode emitted by Clang to SPIR-V:
  • Here is an example demonstrating how to create a kernel from a file containing SPIR-V (works on Windows and Linux):

Finally, if you are interested in a more complete end-to-end C++ experience, I'd encourage you to take a look at SYCL and Intel oneAPI Data Parallel C++.  More information about Data Parallel C++ can be found here:


New Contributor I

Is there any way to do compilation of C++ code (for use within an OpenCL kernel) at runtime with Intel OpenCL?
All avenues suggest that code must be compiled to SPIRV first (at application build/compile time), without allowing arbitrary C++ source to be created, compiled and executed all at runtime.

Examples of existing toolsets that allow for runtime compilation:
- NVRTC  (nvidias runtime compiler)
- OpenCL (using standard C)
- OpenCL  on AMD  (via their "opencl static c++ kernel language" extension)
- etc...

the use-case is executing shader graphs.
So imagine the user at runtime can construct an arbitrary node-graph representing a large computation.
I would like to translate that node-graph into C++ sourcecode at runtime, and then execute on the device.
If such a system were possible with Intel OpenCL,  what would need to be installed on the users machine to make this work?

thanks very much
Brian Sharpe