C code is giving errors saying I should use a class type

25 Views Asked by At

I am rewriting some image processing code, and I am getting strange errors.

The errors are all "expression must have class type but it has type "unsigned char *"

Note that this is C code, not C++ code.

The errors occur when I call a specific function. The function is:

   void gpu_memcpy_upload_to_device(unsigned char* h_dest, const void* h_src, size_t count) {
     CUDA_CHECKED(cudaMemcpyAsync(d_dest, h_src, count, cudaMemcpyHostToDevice,0));
   }

I call the function in several places, three times it is called without error, and five times it is called I get the error listed above.

The three calls that compile cleanly are:

uint8_t* g_d_ccm = NULL;
gpu_malloc((void**)&g_d_ccm, SizeCCM);
gpu_memcpy_upload_to_device(g_d_ccm, g_ccm, SizeCCM);

uint8_t* d_pixels_8_or_16;
gpu_malloc((void**)&d_pixels_8_or_16, size);
gpu_memcpy_upload_to_device(d_pixels_8_or_16, h_pixels_8_or_16, size);

uint8_t* d_bayered_8_16 = NULL;
gpu_malloc((void**)&d_bayered_8_16, SizePixelBuf);
gpu_memcpy_upload_to_device(d_bayered_8_16, h_pixels_8_or_16, SizePixelBuf);

There is other code mixed in, but this code is what is used to set the first parameter, which is the parameter where the error is occurring, but not for these calls.

The five calls that give me the error are:

unsigned char* d_min_vals;
unsigned char* d_max_vals;
gpu_malloc((void**)&d_min_vals, sizeof(float) * 3);
gpu_malloc((void**)&d_max_vals, sizeof(float) * 3);
gpu_memcpy_upload_to_device(d_min_vals, h_min_vals, sizeof(float) * 3);
gpu_memcpy_upload_to_device(d_max_vals, h_max_vals, sizeof(float) * 3);

unsigned char* d_bayered_planes;
gpu_malloc((void**)&d_bayered_planes, num_bytes);
gpu_memcpy_upload_to_device(d_bayered_planes, h_bayered_planes, num_bytes);

unsigned char* d_rgb_betas;
gpu_malloc((void**)&d_rgb_betas, sizeof(h_rgb_betas[0])* 3);
gpu_memcpy_upload_to_device(d_rgb_betas, h_rgb_betas, sizeof(h_rgb_betas[0])* 3);

unsigned char* d_bayered_planes; 
gpu_malloc((void**)&d_bayered_planes, num_bytes);
gpu_memcpy_upload_to_device(d_bayered_planes, h_bayered_planes, num_bytes);

I know that uint8_t is used as an alias for unsigned char, but the five calls the have the error also complained unless I used unsigned char as the declaration.

The full error messages are:

gpu-util/gpu-util.cu(428): error: expression must have class type but it has type "unsigned char *"

gpu-util/gpu-util.cu(429): error: expression must have class type but it has type "unsigned char *"

gpu-util/gpu-util.cu(445): error: expression must have class type but it has type "unsigned char *"

gpu-util/gpu-util.cu(638): error: expression must have class type but it has type "unsigned char *"

gpu-util/gpu-util.cu(670): error: expression must have class type but it has type "unsigned char *"

I don't know if doing this down in the cuda code caused the error messages or not. I apprecate any help I can get with this problem.

My description in the previous field describes what I have mostly tried. I did try using an ampersand in the first parameter to help, and also tried using uint8_t as the declaration, but those changes did not help.

0

There are 0 best solutions below