-1

I'm new in the CUDA programming. I'm trying to transform the points of cloud using a transformation matrix. This is my first kernel program. I searched the error on the internet, but I could not find any answer. Also, when I use the row 91, I do not get error. It's weird.

__global__ void transform(double* d_x, double* d_y, double* d_z, double* d_mat,
                          double* d_result_x, double* d_result_y, double* d_result_z, int N)
{
    // Calculate global thread ID (tid)
    int tid = (blockIdx.x*blockDim.x) + threadIdx.x;

    if(tid<N)
    {
        // some codes will be here
    }
}

namespace ThrustFrustum {

   
    void Function(double* h_x, double* h_y, double* h_z, double* h_mat, int N)
    {
        double* d_x, d_y, d_z, d_mat;
        double* d_result_x, d_result_y, d_result_z;

        size_t bytes_point = sizeof(double)*N;
        size_t bytes_mat = sizeof(double)*16;

        cudaMalloc((void**)&d_x, bytes_point);
        cudaMalloc((void**)&d_y, bytes_point);
        cudaMalloc((void**)&d_z, bytes_point);
        cudaMalloc((void**)&d_mat, bytes_mat);
        cudaMalloc((void**)&d_result_x, bytes_point);
        cudaMalloc((void**)&d_result_y, bytes_point);
        cudaMalloc((void**)&d_result_z, bytes_point);

        cudaMemcpy( d_x, h_x, bytes_point, cudaMemcpyHostToDevice); // raw 91
        cudaMemcpy(d_y, h_y, bytes_point, cudaMemcpyHostToDevice); // raw 92
        cudaMemcpy(d_z, h_z, bytes_point, cudaMemcpyHostToDevice);
        cudaMemcpy(d_mat, h_mat, bytes_mat, cudaMemcpyHostToDevice);

        // Threadblock size
        int NUM_THREADS = 256;
        // Grid size
        int NUM_BLOCKS = (int)ceil(N/NUM_THREADS);

        transform<<<NUM_BLOCKS, NUM_THREADS>>>(d_x, d_y,  d_z, d_mat, d_result_x, d_result_y, d_result_z,  N);
    }
}

Error is:

(92): error: argument of type "double" is incompatible with parameter of type "void *"

(93): error: argument of type "double" is incompatible with parameter of type "void *"

(94): error: argument of type "double" is incompatible with parameter of type "void *"

(101): error: argument of type "double" is incompatible with parameter of type "double *"

(101): error: argument of type "double" is incompatible with parameter of type "double *"

(101): error: argument of type "double" is incompatible with parameter of type "double *"

(101): error: argument of type "double" is incompatible with parameter of type "double *"

(101): error: argument of type "double" is incompatible with parameter of type "double *"

1 Answers1

2

This has nothing to do with CUDA or kernels but is a quirk of variable declarations.
The "old school" reading of double *x, y; is "*x is a double, and so is y".

If you want two pointers, you need to write double *x, *y;

Note that this extends in the "natural" way;

int x, *y, z[10], f(double);

Declares an int, a pointer, an array, and a function.

molbdnilo
  • 64,751
  • 3
  • 43
  • 82