Suppose one want to use constant memory
so I declare a global struct of my structs called devXc
constant struct Xdef devXc; /* put constant stuff in here */
Then I want to fill it from an instanct of (struct Xdef *X) in host memory.
struct devX *X= setX( …);
that syntax is fine with the compiler.
I want to pass a pointer to devWc into my kernel. I really realy dont like globals, and
everything else is passed in a a pointer
gpuKernel<<<nBlocks,BlockSz>>>(nScn, devP,dev_S, &devXc,devO);
and hope to wake up in my kernel function
1 global void gpuKernel(int nScn, struct Pdef *P, struct Sdef *S, struct Xdef *X, struct Odef *O)
3 int bid = blockIdx.x;
4 int tid = threadIdx.x;
5 int blocksz = blockDim.x;
6 commonKernel(bid,tid, blocksz, nScn, P,S,X,O);
WELL The compiler likes it but I get a launch error immediately.
To use constant memory, do I absolutely have to use a global reference inside the kernel,
and not pass in a pointer devXc to the gpuKernel function?
I really hate globals.
IS there a way I can declare the constant memory as a pure constant struct Xdef *
Then in the host, do a cudaDeviceMalloc into it, and then load it with cudaMemcpyToSymbol?
Is constant memory faster than plain old global memory anyway, or am I doing this pain
for no performance gain making X into constant memory.