I'm trying to modify my C++ program using CUDA 6.0 on Win7 to accept parameters from the command line and then copy them to constant memory. I get a invalid device symbol error and I don't understand why.
EDIT : I did see the solution at Invalid device symbol when copying to CUDA constant memory, but the difference is that my device constants are variables, not arrays. I tried duplicating the solution in there, but I get an error in intellisense (or whatever it is) stating that "argument of type int is incompatible with parameter of type const void*".
__device__ __constant__ int nc;
int main(int argc, char** argv)
{
int hnc =2; //Default value if no args passed in.
if (argc > 1)
hnc = strtod(argv[1], NULL);
cudaMemcpyToSymbol(&nc, &hnc, sizeof(int));
return 0;
}
Originally, I wanted to use a struct so that I can easily change the default model run parameters, but I got the same error.
struct modelParameters //Contains other parameters, but reduced for readability.
{
modelParameters() : nc(2) {}
int nc; //Nucleus Size
} knowles;
__device__ __constant__ int nc;
int main(int argc, char** argv)
{
int hnc = knowles.nc; //Default value if no args passed in.
if (argc > 1)
hnc = strtod(argv[1], NULL);
cudaMemcpyToSymbol(&nc, &hnc, sizeof(int));
return 0;
}