mercredi 21 août 2019

Type mismatch in CUDA when invoking Kernel

I'm trying to port some code onto a GPU using CUDA 9.0. I ran into the problem that the Kernel appears to expect a different type inside the kernel than outside the Kernel.

I have boiled down the problem to the following lines, which should show the problem. I hope this should be enough code to expose the error source.

I definitely do not have a second kernel named similar or equal, of course all streams are defined and for testing purposes I commented out any inner implementation of the kernel.

Real is a typedef, that sets here to float. For trial purposes I have replaced the Real with float, which leads me to the same result.

// Kernel definition
__global__ void doStuff(Real *masses)
{
  int i = blockIdx.x*blockDim.x + threadIdx.x;

// no inner implementation, yet
}

// prepare the loop

for(...)
{
  Real *masses, *d_masses;
  masses = getMasses();

  cudaMalloc(&d_masses, numActiveParticles * sizeof(Real));
  cudaMemcpyAsync(d_masses, masses, numActiveParticles * sizeof(Real), cudaMemcpyHostToDevice, dataStream1);

  cudaStreamSynchronize(dataStream1);
  doStuff<<<256, 256, 0, executionStream>>>(d_masses);

  // ....
}

The error message that I am getting now is:

error: argument of type "Real *" is incompatible with parameter of type 
"unsigned int"

and when I replace everything with float:

error: argument of type "float *" is incompatible with parameter of type 
"unsigned int"

Help would be much appreciated, and thank you all in advance,

Best regards

R

Aucun commentaire:

Enregistrer un commentaire