CudaMalloc() makes page-locked memory fail simple variable assignement

I’ve a problem with page-locked memory.

passing a pointer to device memory in my kernel

the assignment fails and *h_value remains 0

otherwhise, removing the cudaMalloc instruction and

removing the parameters passed to the kernel everything

goes fine.

What could be the problem?



void my_function(void){


int *h_value = NULL;

int *d_value = NULL;

    int size=1024;

dim3 block(1,1);

dim3 grid(1,1);


    cudaMalloc((void**)&d_input_data, size); // **** This line makes kernel increment fail! ******


cudaHostAlloc((void**) &h_value, sizeof( int ) , cudaHostAllocMapped | cudaHostAllocPortable);

cudaHostGetDevicePointer( &d_value , h_value , 0 );

    //init value on host


my_kernel<<<grid,block>>>( d_input_data , d_value );

printf("h_value = %d \n",*h_value);



[codebox]global void ky_kernel( char* device_array, int *value )