Passing a single int or char to kernel

Hi I would pass an integer to my kernel.

My code:

int* numInt;
int* d_num;
size_t sint=sizeof(int);

numInt=(int*)malloc(sizeof(int));
*numInt = 10;

cutilSafeCall( cudaMalloc( (void**) &d_num, sizeof(unsigned int) ));
cutilSafeCall( cudaMemcpyAsync( d_num, numInt, sint ,cudaMemcpyHostToDevice, 0) ); <<line 641

i get this error @ runtime :
cudaSafeCall() Runtime API error in file <bandwidthTest.cu>, line 641 : invalid argument.

What’s wrong?

The host memory has to be page locked for the asynchronous copy calls, so use cudaMallocHost() to allocate numint, otherwise you need to use cudaMemcpy() instead.