Hi,
According to the following link, templates seem to be supported by OpenCL http://developer.amd.com/wordpress/media/2012/10/CPP_kernel_language.pdf
I am working on linux platform and I tried to use templated functions but i am constantly getting error -11. I am using simple C functions in my code apart from templates and using g++ to compile my code. Do we have to do something special or set something to use C++ stuff or templates?
Bolt use heavy templates (its for windows though) so it kind of proves that openCL does support templates or am i missing something?
Solved! Go to Solution.
just did quick test with template example from your link and it did compile successfully. do you pass -x clc++ as build option to clBuildProgram()? also you should retrieve build log clGetProgramBuildInfo() as it contain important informations and error messages.
just did quick test with template example from your link and it did compile successfully. do you pass -x clc++ as build option to clBuildProgram()? also you should retrieve build log clGetProgramBuildInfo() as it contain important informations and error messages.
Hey nou, can you send me or paste here the sample code (both cpp and cl files) that you used to run that sample template example?
I just pasted template example from that PDF that you linked into KernelAnalyzer.
Hey nou, the example is just kernel code (the one we put in .cl file. I hope you didn't add anything else to it). I can't figure out how to do 'The names “testAddFloat4” and “testAddInt8” are the external names for the two kernel template instants that must be used as parameters when calling to clCreateKernel API.' thats why i asked for .cpp file because that would make my life lot easier. Thanks!
Checkout AMD APP SDK Sample IntrostaticCPPKernel. The sample demonstrates, how to use templates in OpenCL kernels using AMD's static CPP Kernel extension.
And static cpp kernel extension is supported in linux too, as this sample is present in linux distribution of APP SDK.
Also, supporting bolt in linux is under consideration, and may happen soon.
There is standard OpenCL and there are AMD extensions. Bolt is based on C++ extensions by AMD and currently is not supported on anything but Windows platform/AMD hardware. So Bolt's biggest disadvantage is the same as CUDA's: it is not portable.
It is possible to use templated code with OpenCL in a standard-compliant and portable way: take a look at such projects as Boost.Compute (https://github.com/kylelutz/compute) or VexCL (https://github.com/ddemidov/vexcl).
Since Nov 2013, Bolt 1.1 and later versions are available for Linux.