cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCL

ifrah
Adept II

Support of Templates in OpenCL (Linux)

Jump to solution

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?

0 Kudos
Reply
1 Solution

Accepted Solutions
nou
Exemplar

Re: Support of Templates in OpenCL (Linux)

Jump 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.

View solution in original post

7 Replies
nou
Exemplar

Re: Support of Templates in OpenCL (Linux)

Jump 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.

View solution in original post

ddemidov
Adept II

Re: Support of Templates in OpenCL (Linux)

Jump to solution

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).

ifrah
Adept II

Re: Support of Templates in OpenCL (Linux)

Jump to solution

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?

0 Kudos
Reply
nou
Exemplar

Re: Support of Templates in OpenCL (Linux)

Jump to solution

I just pasted template example from that PDF that you linked into KernelAnalyzer.

0 Kudos
Reply
ifrah
Adept II

Re: Support of Templates in OpenCL (Linux)

Jump to solution

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!

0 Kudos
Reply
himanshu_gautam
Grandmaster

Re: Support of Templates in OpenCL (Linux)

Jump to solution

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.

gc9
Adept III

Re: Support of Templates in OpenCL (Linux)

Jump to solution

Since Nov 2013, Bolt 1.1 and later versions are available for Linux. 

0 Kudos
Reply