Invalid device character when copying to CUDA read only memory

I have several files for the application when processing images. Since the number of rows and columns for an image does not change when performing some image processing algorithm, I tried to put these values โ€‹โ€‹in read-only memory. My application looks like this:

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 I try to run the program, I get invalid device symbol cudaMemcpyToSymbol(&c_rows, &rows, sizeof(int))

Can I put these variables in read-only memory or what am I missing?

+4
source share
1 answer

If your character is declared as follows:

 __constant__ int c_rows; 

then the correct call to cudaMemcpyToSymbol is just

 int rows = 5; cudaMemcpyToSymbol(c_rows, &rows, sizeof(int))); 
+8
source

Source: https://habr.com/ru/post/1480249/


All Articles