Show value of constant What's wrong?

Hi.

I would like to display value of constant

My code is

constant int NP_CUDA;

void assign(int NP_T){
cudaMemcpyToSymbol(“NP_CUDA”, &NP_T, sizeof(int), 0, cudaMemcpyHostToDevice);
printf(“NP = %d”,NP_CUDA);
}

Why ? It shows as NP = 0 ???

What’s wrong ? Help me please…

You cannot read constant value in host code. It is readable in cuda kernel.

Thanks for your answer…

I try writing it in CUDA kernel

constant int NP_CUDA;

device void assign(int NP_T){
cudaMemcpyToSymbol(“NP_CUDA”, &NP_T, sizeof(int));
printf(“NP = %d”,NP_CUDA);
}

it don’t display N and stop working at cudaMemcpyToSymbol.

What’s wrong…

You can only the value in the host code by calling cudaMemcpyToSymbol() for constant variables.

Then you can use those constant variables in your kernel code.

And you cannot use printf in kernel code, but you can usecuPrintf

OK!! Thanks… Very much ^.^