I am trying to use cuda-gdb to check global device memory. It seems the values are all zero, even after cudaMemcpy. However, in the kernel, the values in the shared memory are good. Any idea? Does cuda-gdb even checks for global device memory at all. It seems host memory and device shared memory are fine. Thanks.
6
votes
3 Answers
14
votes
Suppose d_array is a pointer to device memory,
(cuda-gdb) print d_array
$1 = (double *) 0x13082c3000
To access its value, first convert it to a global memory pointer:
(cuda-gdb) print ((@global double *)d_array)[0]
$2 = 0.5
To access the array:
(cuda-gdb) print ((@global double *)d_array)[0]@3
$3 = {0.5, 0.4, 0.3}
1
votes
0
votes
One easy way to check the data in the global memory is to write the data back from the global memory back to the host and see the values. But I am not sure whether it is possible to check this with cuda-gdb.
By the way, how did you know that the values in the global memory are all zeros. If your final result is entirely zero then it means that there is something wrong in your code. CUDA returns zero if it doesn't know what exactly the value is. For example, mostly CUDA doesn't return NAN, it returns zero instead.