Community
cancel
Showing results for 
Search instead for 
Did you mean: 
shetty__sujay
Beginner
219 Views

Does Intel OpenCL 2.1 support kernel C++?

Hi, 

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
3 Replies
Michael_C_Intel1
Moderator
219 Views

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.

 

-MichaelC

Michael_C_Intel1
Moderator
219 Views

SujayS,

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.

-MichaelC

Ben_A_Intel
Employee
219 Views

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):  https://godbolt.org/z/mZ22WE
  • Here is the open source SPIR-V LLVM translator that can convert the LLVM IR bitcode emitted by Clang to SPIR-V: https://github.com/khronosgroup/spirv-llvm-translator
  • Here is an example demonstrating how to create a kernel from a file containing SPIR-V (works on Windows and Linux): https://github.com/bashbaug/SimpleOpenCLSamples/tree/master/samples/05_spirvkernelfromfile

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: https://software.intel.com/en-us/oneapi/dpc-compiler

Thanks!