I am trying to use the constant memory in the code with constant memory assigned value from kernel not using cudacopytosymbol.
#include
usi
Constant memory is, as the name implies, constant/read-only with respect to device code. What you are trying to do is illegal and can't be made to work.
To set values in constant memory, you currently have two choices:
cudaMemcpyToSymbol
API call (or its equivalents)In the latter case something like this would work:
__constant__ int constBuf[N] = { 16, 2, 77, 40, 12, 3, 5, 3, 6, 6 };
__global__ void foo( int *results )
{
int tdx = threadIdx.x;
int idx = blockIdx.x * blockDim.x + tdx;
if( tdx < N )
{
results[idx] = constBuf[tdx]; // Note changes here!
}
}