Hello to All,
I have 3 kernels (in 3 separate files).
These kernels have to use several constant variables.
These constant variables are declared, defined and allocated on the device in another file.
The problem is that some kernel does not get the right value of constant variables.
I also tried to use cudaGetSymbolAddress in the host function calling the kernel, but I get
“cannot take the address of constant data”
How have I to declare the variables in the files containing kernels?
Here it is how I allocate constant device memory:
[codebox]
CUDA_SAFE_CALL(cudaMemcpyToSymbol(“xdim”, &(ps->xdim), sizeof(int), 0, cudaMemcpyHostToDevice));
CUDA_SAFE_CALL(cudaMemcpyToSymbol(“ydim”, &(ps->ydim), sizeof(int), 0, cudaMemcpyHostToDevice));
CUDA_SAFE_CALL(cudaMemcpyToSymbol(“kStretch”, &(ps->kStretch), sizeof(REAL), 0, cudaMemcpyHostToDevice));
CUDA_SAFE_CALL(cudaMemcpyToSymbol(“kShear”, &(ps->kShear), sizeof(REAL), 0, cudaMemcpyHostToDevice));
CUDA_SAFE_CALL(cudaMemcpyToSymbol(“kBend”, &(ps->kBend),sizeof(REAL), 0, cudaMemcpyHostToDevice));
CUDA_SAFE_CALL(cudaMemcpyToSymbol(“pitch_position_d”, &ppos, sizeof(size_t), 0, cudaMemcpyHostToDevice));
CUDA_SAFE_CALL(cudaMemcpyToSymbol(“pitch_velocity_d”, &pvel, sizeof(size_t), 0, cudaMemcpyHostToDevice));
CUDA_SAFE_CALL(cudaMemcpyToSymbol(“pitch_force_d”, &pforce, sizeof(size_t), 0, cudaMemcpyHostToDevice));
CUDA_SAFE_CALL(cudaMemcpyToSymbol(“pitch_mass_d”, &pmass, sizeof(size_t), 0, cudaMemcpyHostToDevice));
[/codebox]
Here it is how I declare variables in each one of the files containing kernels
[codebox]
constant int xdim;
constant int ydim;
constant size_t pitch_position_d;
constant size_t pitch_velocity_d;
constant size_t pitch_force_d;
constant size_t pitch_mass_d;
constant size_t pitch_previousPosition_d;
[/codebox]
Why I can’t take the value of these variables?
I also tried using the device qualifier, but without success.
What’s wrong?
Thanks in advance
Francesco