A problem with template and kernel call Compilation fails in this case

Hi,

I’ve got a problem with my program .

I want to templatized a function which calls a template kernel.

Here is my code:

main.cu

[codebox]:

#include “OpOnMatGPUH.cuh”

int main(){

int *a1, *a2;

matSquareMulGPU(a1, a2);

}[/codebox]

OpOnMatGPUH.cuh

[codebox]template

void

matSquareMulGPU(T* a, T* b);

#include “OpOnMatGPU.cu”[/codebox]

OpOnMatGPU.cu

[codebox]#include “matMul.cuh”

template

void matSquareMulGPU(T* a, T* b){

...

    matMulKernel<<< numBlocks , threadsPerBlock >>>(a,b);

    ...

}[/codebox]

matMul.cuh

[codebox]template

global void

matMulKernel(

				   T* mat1,

				   T* matRes,

				   int dimMat,

				   int method){

}[/codebox]

When i compile, under Visual Studio 2005, with Cuda 3.0, compiler sends me:

[codebox]c:\documents and settings\pgaulard\my documents\visual studio 2005\projects\testcuda\testcuda\OpOnMatGPU.cu(134) : error C2059: syntax error : ‘<’

1> c:/…/MainTest.cu(51) : see reference to function template instantiation ‘void matSquareMulGPU(int,T *,T *,int,float *,Args,CudaProps)’ being compiled

1> with

1> [

1> T=int

1> ][/codebox]

where 134 is the kernel call line in OpOnMatGPU.cu and 51 template function call line.

I don’t understand, because i can compile project simpleTemplate provided by Cuda SDK, where we can see how integrate templates.

Thanks for your help

pietro

From a quick glance:

Shouldn’t this:

template <class T>

void matSquareMulGPU(T* a, T* b){	

...		

matMulKernel<<< numBlocks , threadsPerBlock >>>(a,b);		

...

}

Changed to:

template <class T>

void matSquareMulGPU(T* a, T* b){	

...		

matMulKernel< T ><<< numBlocks , threadsPerBlock >>>(a,b);		

...

}

I’ve tried that and it doesn’t work. Compilation sends me the same result