template cuda kernel function cannot be called in another template function on vs2013

Hi, all
I recently found when trying to call a template cuda kernel function in a template host function the same errors happen.
Codes as follow:

template
global void addKernel()
{
}

template
void hostfun(Dtype *in, Dtype *out)
{
addKernel <<<1, 512>>>();
}

int main(int argc, char ** argv)
{
float *a, *b;
hostfun(a, b);
}

Could anyone help?
ps: my system is win7; vs 2013; cuda 7.0

I fixed missing pointer initializations to get rid of warnings. After that your code compiled without warnings or errors for me (CUDA 7.5, MSVS 2010, Win7 64). What is your exact nvcc command line, and what errors messages are emitted by the compiler?

template<typename Dtype>
 __global__ void addKernel()
 {
 }

 template<typename Dtype>
 void hostfun(Dtype *in, Dtype *out)
 {
     addKernel<Dtype> <<<1, 512>>>();
 }

 int main(int argc, char ** argv)
 {
     float *a = 0, *b = 0;
     hostfun(a, b);
 }

Hi,njuffa
points initialization don’t resolve my problem. The error messages are:
syntax error:missing ‘;’ before ‘constant’
syntax error:’>’
both on line 9(the same line as code “addKernel<<<1,512>>>()”).

If I initialtize addKernel directly in main function, it is ok.If I compile the above codes on vs2012, it is ok.

The nvcc command lines are as follows:
error MSB3721: The command ““C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\bin\nvcc.exe” -gencode=arch=compute_20,code=“sm_20,compute_20” --use-local-env --cl-version 2013 -ccbin “C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64” -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\include” -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\include" --keep-dir x64\Release -maxrregcount=0 --machine 64 --compile -cudart static -DWIN32 -DWIN64 -DNDEBUG -D_CONSOLE -D_MBCS -Xcompiler “/EHsc /W3 /nologo /O2 /Zi /MD " -o x64\Release\kernel.cu.obj “C:\Users\dmsuvorov\Documents\Visual Studio 2013\Projects\cuda_test\cuda_test\kernel.cu”” exited with code 2.

Your original post stated that you are using CUDA 7.0, but the compilation log above shows that the compiler from CUDA 6.5 is being used.

Is it possible your compiler configuration is corrupted? Mixing files from different CUDA releases can definitely cause weird compiler problems as I know from personal experience.

I tried both cuda 6.5 and 7.0 without success.

As I stated, I performed my experiment with CUDA 7.5, so you might want to try that. (I migrated straight from CUDA 6.5 to CUDA 7.5, as CUDA 7.0 seemed to have too many bugs).

I will give it a try, but I am afraid it is still not the root reason!
Anyway, thank you, njuffa.

On my environment (Win10 64bit, Visual Studio 2013), successfully compiled with both CUDA 7.0 & 7.5