I want to make a counter in a kernel.
I have the above code:
device int dev_cEe = 0;
int main (int argc, char **argv)
{
int cEe = 0;
…
int callsOfKernel = numberOfBlocks * numberOfThreadsPerBlock;
GPGPUKernel <<<numberOfBlocks, numberOfThreadsPerBlock>>> (const int callsOfKernel);
cudaDeviceSynchronize ();
cudaGetLastError ();
cudaMemcpyFromSymbol (&cEe, dev_cEe, sizeof (int), 0, cudaMemcpyDeviceToHost)
…
}
global void GPGPUKernel (const int callsOfKernel)
{
int id = blockIdx.x * blockDim.x + threadIdx.x;
if (id < callsOfKernel)
atomicAdd (&dev_cEe, 1);
}
The compiling operation in VS2019 finished with:
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
but i have error in cudaMemcpyFromSymbol :
|Error (active)|E0167|argument of type int is incompatible with parameter of type const void *
and in atomicAdd:
|Error (active)|E0020|identifier atomicAdd is undefined
- Why the compiling operator finished with all done but the VS mark errors?
- Does it have errors in cudaMemcpyFromSymbol and atomicAdd?
Thanks to all…