For C++/CUDA, I am trying to debug a kernel, but I cannot see some of the local variables. I added some code to the sample addKernel to illustrate:
struct Test
{
unsigned long long iLL, jLL, kLL;
int i, j, k;
double piLL;
};
__global__ void addKernel(int *c, const int *a, const int *b)
{
int i = threadIdx.x;
int j = 12345;
float f = 1234.5;
double pi = 3.1415926535;
bool b0 = false, b1 = true;
char ch = 123;
char s[10] = "A string.";
Test t;
t.i = 100; t.j = 200; t.k = 12345678;
t.iLL = 0xfedcba9876543210; t.jLL = 0x1111222233334444; t.kLL = ~0ULL;
t.piLL = 3.14159265358979323846;
c[i] = a[i] + b[i];
}
When I stop at a breakpoint, set at the last line (“20. c[i]…”), the Locals window shows
@flatBlockIdx 0 long
@flatThreadIdx 0 long
+threadIdx {x = 0, y = 0, z = 0} const uint3
+blockIdx {x = 0, y = 0, z = 0} const uint3
+blockDim {x = 5, y = 1, z = 1} const dim3
+gridDim {x = 1, y = 1, z = 1} const dim3
@gridId 1 const long long
-s 0x0000000000fffc10 {0 ' char[10] __local__
[0] 0 ' __local__ char&
[1] 0 ' __local__ char&
[2] 0 ' __local__ char&
[3] 0 ' __local__ char&
[4] 0 ' __local__ char&
[5] 0 ' __local__ char&
[6] 0 ' __local__ char&
[7] 0 ' __local__ char&
[8] 0 ' __local__ char&
[9] 0 ' __local__ char&
-t {iLL = 0, jLL = 0, kLL = 0, i = 0, ...} __local__ Test
iLL 0 __local__ unsigned long long
jLL 0 __local__ unsigned long long
kLL 0 __local__ unsigned long long
i 0 __local__ int
j 0 __local__ int
k 0 __local__ int
piLL 0 __local__ double
i 0 int
j 12345 int
f 0 float
pi 0 double
b0 false bool
b1 true bool
ch 123 '{' char
+a 0x0000000b02800200 1 __device__ const int* __parameter__
+b 0x0000000b02800400 10 __device__ const int* __parameter__
+c 0x0000000b02800000 0 __device__ int* __parameter__
Notice that neither the values of the array ‘s’, nor the members of the structure ‘t’, are displayed properly. How can I get nSight to show these?
GeForce GTX 1050 Ti, CUDA 9.0 runtime, NSight 5.4, Visual Studio Community 2017 v15.3.4, 64-bit Windows 7