You will find that they state in the programming guide that the constant memory has implied static linkage. Therefore it will only be directly accessible from the translation unit in which it was defined.
Here’s what you can do though:
Place the definition of the constant memory in the same file as your CUDA kernels ie.
static constant WpObb * mmObbPtrListDev[N_OBB_PTRS_MAX] attribute((unused)); /**< @brief the lookup table for obb tree pointers */
static constant WpTriangle * mmTriPtrListDev[N_TRI_PTRS_MAX] attribute((unused)); /**< @brief the lookup table for triangle tree pointers */
static constant WpTransform mmTransformstatesOnDevice[N_TRANSFORMSTATES_MAX] attribute((unused)); /**< array of transformation states. Unused attribute is set to stop compiler warnings */
// direct source include of the algorithms used
(You don’t need the static qualifier on the definitions, but I keep it there to remind me of what is implicit)
From the kernels (in my case, they are located in the same file as the above) I can directly access the constant memory as usual, ie:
GPUStreamKernel.cu, inside a kernel
[codebox]WpObb *obbA = mmObbPtrListDev[batch.ta] + cIdxA;[/codebox]
I have a class which manages the memory on the GPU. This class is compiled with GCC and uses runtime resolution of the constant symbols, which was defined in GPUStreamKernel.cu:
[codebox] size_t arraySize;
if (cudaSuccess != cudaGetSymbolSize(&arraySize, "mmTransformstatesOnDevice"))
throw CudaInvalidSymbolError(" - Could not get mmTransformstatesOnDevice size");
What’s important here is that you pass it a string literal, matching the symbol name. The runtime API will then resolve the symbol, and you are happy to go