cudaMemcpyToSymbol(.....) input parameter issue

Hi,

I was using constant memory and started by copying memory this way

cudaMemcpyToSymbol(constant_device_data, host_data, data_size, cudaMemcpyHostToDevice);

This however, gave me corrupt data on the device. When I instead use these input paramters (removing the enum)

cudaMemcpyToSymbol(constant_device_data, host_data, data_size);

the issue is resolved.

Why is this? What was I doing wrong in the first case ?

Thanks
Jim

According to cuda_runtime_api.h, the prototype for cudaMemcpyToSymbol is as follows:

[codebox]extern host cudaError_t CUDARTAPI cudaMemcpyToSymbol(const char *symbol, const void *src, size_t count, size_t offset __dv(0), enum cudaMemcpyKind kind __dv(cudaMemcpyHostToDevice));

[/codebox]

Your problem was that you were supplying the enum for cudaMemcpyHostToDevice (which is a 1) as the offset. You should be able to go back to your original code if you just pass a 0 offset (or whatever number you might need there).

Ah, ok of course…

I guess i should RTFM instead of google it. :)

thanks!