The -x option is available only in the latest versions of AMD OpenCL, which support OpenCL 1.2 and the static C ++ language extension. You will not find a word about this in the official Khronos documents, because this is all AMD's initiative and, ultimately, a supplier extension.
I assume that you have the correct runtime, so your kernel should be built with these parameters:
-x clc++
If you can create kernels with classes using this, you should be able to use templates.
If this does not work, it means that either your runtime setting is corrupt, for example. you are somehow using the wrong compiler, or that means you don't have the right runtime. If yes, provide your platform information.
I came across a static C ++ extension for some time, and I can testify that -x clc++ works.
You should also remember that using this extension will make your code not portable and not connected to devices compatible with AMD, as it is unlikely that other manufacturers will introduce the same extension (if ever).
Also, a note on Khronos docs - those returned by google are usually OpenCL 1.0 versions that can be annoying. I recommend downloading the standard 1.1 or 1.2, as well as getting a local copy of the relevant HTML documentation for quick access if you use OpenCL a lot. It helps.
source share