Copying data to constant memory failed at sm_20

Several posts in this forum or stackoverflow described a similar but not the same problem that I have come across. I am programming on a Tesla C2050, and the problem arises when I try to copy data to constant memory space using cudaMemcpyToSymbol. The syntax comes from CUDA API REFERENCE MANUAL. Here’s my code:

In Main.cu:

int main()

{

   ...

   double thickness=1.5;

   HandleDeviceError(cudaMemcpyToSymbol("thickness_device", &thickness, sizeof(double), 0, cudaMemcpyHostToDevice));

   ...

   return 0;

}

In Kernel.cu:

__constant__ double thickness_device;

When the program is executed with compute_10, sm_10, no error occurs, but the data thickness is somehow NOT copied to thickness_device at all. When it is executed with compute_20, sm_20, an error messange is thrown: invalid device symbol.

Could anyone help me with this problem? I appreciate any help!

Does it work if you move the cudaMemcpyToSymbol() call to Kernel.cu, i.e. to the same file where the symbol is declared?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.