tags:

views:

44

answers:

1
struct d_struct {
// stuff
};

__device__ __constant__ d_struct structs[SIZE];

When I call cudaMemcpyToSymbol("structs", &h_struct, sizeof(d_struct), index * sizeof(d_struct), cudaMemcpyHostToDevice) on a d_struct "h_struct" in host memory, I get an "invalid device symbol" cuda error.

A: 

If you can provide more details it will help, for example what platform are you running on and which host compiler version? Which CUDA toolkit version? What device?

In the meantime, some suggestions:

  • Make sure you are using the latest CUDA toolkit. At this time 3.1 is current and 3.2 is a Release Candidate
  • If you are running in Windows using the CUDA Wizard, try switching to the standard rules files provided by NVIDIA
  • Are you building for the correct Compute Capability? Just check that you aren't compiling for sm_13 and running on sm_12 for example
  • Are you calling cudaMemcpyToSymbol() from the same file where the constant is declared? If not, then it should still work since the lookup is done by name rather than symbol but check that you haven't declared it as extern "C" and that you are calling from C++
  • Given that you've left out a lot of code it's best to check - d_struct is not templated is it?
Tom