可以用函数模板定义和调用核函数吗

由于参数类型调用之前是未知的,
请问可以这样定义和调用核函数吗

global template
void CudaBuf2floatT( T *pBufIn, long nPixels, float *pBufOut)

CudaBuf2floatT<<<BLOCK_NUM,THREAD_NUM>>>( (ors_uint8 *)rawBuf, nPixels, pBufOut);

LZ您好:

我不懂C++,无法给你进一步的建议,不过您可以参阅一下CUDA C Programming Guide Appendix.D——C/C++ Language Support,看看有无您需要的内容。

祝您好运~

调用前指明类型,如CudaBuf2floatT<<<,>>>>( pBufIn, nPixels, pBufOut)

非常感谢两位的指点和支持, 晚上回去测试下

出现了连接错误是怎么回事啊

无法解析的外部符号 “void __cdecl test(unsigned char *)” (??$test@E@@YAXPAE@Z),该符号在函数 “void __cdecl GaussianSmooth(unsigned char *,int,int,double,unsigned char *)” (??$GaussianSmooth@E@@YAXPAEHHN0@Z) 中被引用。

函数是这样写的:

template
global void cu_test( T *t){

}
template
void test(T* t){
cu_test<<<1,1>>>(t);
}

test(T* t) 是在一个模板函数里调用的。