global constants

I’m trying to access some global constants from a CUDA kernel. It seems that const ints are visible to the kernels, but const floats are not. Does anyone have any ideas about this???

I’ve included a minimal code below that demonstrates the problem. I’m trying to compile on Windows XP using Visual Studio 2005 and CUDA 2.3 Beta.



[codebox]#include <stdio.h>

const int global_int = 5;

const float global_float = 5.0f;

global void kernel();

int main()



return 0;


global void kernel()


int local_int = global_int;

float local_float = global_float; // Code will not compile if this line is included



You are trying to access host memory from the device in both cases, which is not allowed.

You need to declare the global variables as constant or device and use cudaMemcpyToSymbol to access them from the host code.