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;
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.