It is possible access to a constant inside the cuda kernel?
If I have the follow kernel in a file kernel.cu:
And I have MY_CONSTANT in a file constants.h, can the kernel access to the constant?
If constants.h contains something like
#define MY_CONSTANT (-5)
and you have an
in kernel.cu prior to the kernel definition, that should work just fine. Have you tried it?
Yes, it should work, if the constant is declared using a compiler macro
#define MY_CONSTANT 32
or via a global constant variable of POD type:
const int MY_CONSTANT=32;
note that a is a pointer type in your example, maybe you meant:
*a += MY_CONSTANT;
Thank you, I try it and all works fine!