CUDA writing to constant memory wrong value

后端 未结 1 1335
生来不讨喜
生来不讨喜 2020-12-04 04:23

I have the following code to copy from a host variable to a __constant__ variable in CUDA

int main(int argc, char **argv){

    int exit_code;

         


        
相关标签:
1条回答
  • 2020-12-04 04:43

    Constant memory has implicit local scope linkage - answer to this on stack overflow. This means that the cudaMemcpyToSymbol have to be in the same generated .obj file of the kernel where you want to use it. You do your memcopy in Main.cu, but the kernel where you use your canstant memory is in Imageproc.cu. So for the constant values are unknown for the kernel chunche.

    A option to solve you're problem can be, to implement a wrapper. Just add a function in Imagepro.cu where you do the cudaMemcpyToSymbol and call the wrapper in Main.cu and pass your desired values for the constant memory in there.

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