Questions about the head file and host funcs

I am doing a project with cuda and I found that the constants I defined in the .h file can’t be read by the host and device code so I have to put every delaration in each file.

The kernel file doesn’t accept #define M N format, so I have to do this like int M = N;
Is that possible to use #define thing?

Another question is I have to use random function in the kernel file, but the kernel file doesn’t accept srand(m), rand(), how to make it possible to use host funtion in device code?

Thanks in advance.


Look at the MersenneTwister example on how to generate random numbers inside a kernel, you cannot just use the host function.

#define macros just work inside kernels, you must be doing something wrong.