Use of Template kernel in opencl

Hello all

Actually program is written in cuda ,i am trying to port in openCL.template use in kernel funtion

CUDA FUNCTION:
Tamplate<type T, bool real> global void add( __global cl_int *a, __global cl_int *b, _global cl_int *c )
{ --}
how to use in opencL

i have changed this funtion into below .

OpenCL funtion:

Tamplate<type T, bool real> __kernel void add( __global cl_int *a, __global cl_int *b, _global cl_int *c )
{---------------}

can template kernel create in openCL? .if yes then how to use( how to build and launch in our function).

if No then how to port this funtion in opencL. please any body know help me to overcome this problem

I believe this question was answered here: [url]OpenCL template kernel - CUDA Programming and Performance - NVIDIA Developer Forums.

I’d contend, however, that modifying the source code to a kernel and compiling it on the fly is actually more valuable than templates, because you can change a kernel based on runtime variables.

Templates are, in my opinion, a very small subset of metaprogramming. As far as I know, that’s all the metaprogramming one can achieve with CUDA (aside from wrapping nvcc yourself). OpenCL supports a superset of templates by allowing you to compile kernels at runtime.

Thanks,

Ryan

Quick advertisement: PyCUDA makes it very easy to do runtime generation of CUDA kernels in Python. :)

(PyCUDA calls nvcc for you and load the resulting module automatically.)