How to read values from memories?

Hi all,

I have two .cu files– and How can I retrieve the value of vars from kernel? Do I need to pass them through parameters of the kernel function?

int maxI,gMaxI,a,b,c;







__global__ void myKernel(int a, int b, int c){


                 //Can I directly get gMaxI value here?

                 int d = gMaxI;




single values you can just pass to the kernel. Allocating memory on the device and cudamemcopy-ing data from host to that memory is only necessary for arrays.

Yap, understand. But I am still wondering if it is doable? And BTW, does it has __constant__in CUDA 1.1? I always get errors when I try to use it.

You can do this

myKernel<<<dimGrid,dimBlock>>>(a,b,c, maxI);

global void myKernel(int a, int b, int c, int maxI){

int d = maxI;

--------------------------------------------- or this

constant int maxI;

int dummy = 1;
CUDA_SAFE_CALL( cudaMemcpyToSymbol(maxI, &dummy, 1 * sizeof(int))


global_ void myKernel(int a, int b, int c){

int d = maxI;

Yes, that’s exactly what I have tried. But I got an error: Error 1 fatal error C1057: unexpected end of file in macro expansion c:\Program Files\NVIDIA Corporation\NVIDIA CUDA SDK\projects\SM2D\ 173.

Hmmmm…any idea whaz wrong with it?? :[

not without knowing what is at line 173 of