cudamemcpytosymbol usage

Hi,

This is probably a stupid question, but I don’t know how to use the cudaMemCpyToSymbol correctly. I’m trying to copy local host memory to constant device memory.

So let’s say I have the following simplified example:

__device__ __constant__ float symbol;

void initSymbol(){

	float symbolCPU = 3.0f;

	cudaMemCpyToSymbol ( symbol, symbolCPU, sizeof(float), 0, cudaCpyHostToDevice);

}

What is wrong with this?

Well, you supply 5 inputs to the function, where I can only see 3 in the programming guide. You need to at least remove the last 2 inputs. And I also think you need to supply the address of the host float.

Actually, The reference manual also gives 5 inputs.

Anyway, I deleted the last two inputs and made the second argument a reference.

But my main mistake was something else. It was that I tried to calculate symbolCPU with other GPU variables. I’ve fixed the problem and now it works.

Thanks anyway!

Okay, good to know about the fact the reference manual has 2 more. That might mean that you can do a cudaMemCopyToSymbol(…, cudaMemCopyDeviceToDevice)