'inline' for __global__ functions to avoid multiple definition error

前端 未结 1 439
闹比i
闹比i 2021-02-15 17:02

I have a CUDA template library, in which one function is actually not a template, but is defined within a .cuh header. (vector_add_kernel

相关标签:
1条回答
  • 2021-02-15 17:37

    If you want to keep your current code organisation, you have a very simple solution which is to declare your kernel static (in place of your inline keyword). This will prevent the linker from complaining, but will however generate as many different versions of the kernel as there will be of compilation units (object files) where the kernel.cuh will have been included.

    Another solution would be to templatise your kernel. I know you already dismissed this possibility, but you should reconsider it, since your kernel is a natural template for the float type of the input parameters...

    0 讨论(0)
提交回复
热议问题