我试图在 CUDA C++ 中将模板内核作为协作内核启动失败,我做错了什么
错误
Error cannot determine which instance of function template "boolPrepareKernel" is intended
我尝试像下面那样调用内核
ForBoolKernelArgs<int> fbArgs = ...;
int device = 0;
cudaDeviceProp deviceProp;
cudaGetDeviceProperties(&deviceProp, device);
cudaLaunchCooperativeKernel((void*)boolPrepareKernel, deviceProp.multiProcessorCount, fFArgs.threads, fbArgs) ;
内核定义为
template <typename TYO>
__global__ void boolPrepareKernel(ForBoolKernelArgs<TYO> fbArgs) {
...
}
我尝试了参数化启动(在本例中为 int),例如
cudaLaunchCooperativeKernel((void*)(<int>boolPrepareKernel), deviceProp.multiProcessorCount, fFArgs.threads, fbArgs) ;
但我得到错误
no instance of overloaded function matches the argument list argument types are: (<error-type>, int, dim3, ForBoolKernelArgs<int>)
对于建议的案例
cudaLaunchCooperativeKernel((void*)(boolPrepareKernel<int>), deviceProp.multiProcessorCount, fFArgs.threads, fbArgs)
我的错误是
no instance of overloaded function matches the argument list argument types are: (void *, int, dim3, ForBoolKernelArgs<int>)
这可能很简单,但我被卡住了 - 感谢您的帮助!
供参考内核启动,如
boolPrepareKernel << <fFArgs.blocks, fFArgs.threads >> > (fbArgs);
工作,但当然网格同步不可用。