I have several files for an app in image processing. As the number of rows and colums for an image does not change while doing some image processing algorithm I was trying to put those values in constant memory. My app looks like:
Imageproc.cuh
...
...
__constant__ int c_rows;
__constant__ int c_cols;
#ifdef __cplusplus
extern "C"
{
#endif
...
...
#ifdef __cplusplus
}
#endif
Imageproc.cu
...
...
int algorithm(float *a, const int rows, const int cols){
...
...
checkCudaError(cudaMemcpyToSymbol(&c_rows, &rows, sizeof(int)));
checkCudaError(cudaMemcpyToSymbol(&c_cols, &cols, sizeof(int)));
dim3 block(T, T);
dim3 grid(cols/T+1, rows/T+1);
kernel<<<grid, block>>>( ... );
...
...
}
It compiles well but when trying to run the program I get invalid device symbol cudaMemcpyToSymbol(&c_rows, &rows, sizeof(int))
Can't I put those variables in constant memory or what am I missing?
If your symbol is declared like this:
then the correct call to
cudaMemcpyToSymbol
is just