How to view variables in nSight/CUDA runtime?
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: [code]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]; } [/code] When I stop at a breakpoint, set at the last line ("20. c[i]..."), the Locals window shows[code] @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__ [/code] 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
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

#1
Posted 09/14/2017 08:32 PM   
Hi, did you compile your app in debug mode, please make sure that nvcc has "-g".
Hi, did you compile your app in debug mode, please make sure that nvcc has "-g".

#2
Posted 09/19/2017 09:29 AM   
Yes, this is a debug build. The nvcc options include both -G and -g. Here is the compiler command line (omitting several libraries): [code]1>------ Build started: Project: MyProject, Configuration: Debug x64 ------ 1>Compiling CUDA source file MyCUDA.cu... 1> 1>C:\MyProject>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin\nvcc.exe" -gencode=arch=compute_30,code=\"sm_30,compute_30\" --use-local-env --cl-version 2017 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX86\x64" -x cu -IC:\MyProject\ -IC:\MyLibraries\Library\Utility -IC:\Miscellaneous_Libraries\Utilities ... -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include" -G --keep --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -Xptxas -v -g -DWIN64 -D_WINDOWS -D_DEBUG -DMyBuild -Xcompiler "/EHsc /W3 /nologo /Od /FS /Zi /RTC1 /MTd " -o x64\Debug\MyCUDA.cu.obj "C:\MyProject\MyCUDA.cu" [/code]
Yes, this is a debug build. The nvcc options include both -G and -g. Here is the compiler command line (omitting several libraries):

1>------ Build started: Project: MyProject, Configuration: Debug x64 ------
1>Compiling CUDA source file MyCUDA.cu...
1>
1>C:\MyProject>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin\nvcc.exe" -gencode=arch=compute_30,code=\"sm_30,compute_30\" --use-local-env --cl-version 2017 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX86\x64" -x cu -IC:\MyProject\ -IC:\MyLibraries\Library\Utility -IC:\Miscellaneous_Libraries\Utilities ... -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include" -G --keep --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -Xptxas -v -g -DWIN64 -D_WINDOWS -D_DEBUG -DMyBuild -Xcompiler "/EHsc /W3 /nologo /Od /FS /Zi /RTC1 /MTd " -o x64\Debug\MyCUDA.cu.obj "C:\MyProject\MyCUDA.cu"

#3
Posted 09/19/2017 05:20 PM   
The bug has been submitted, looks like that nsight cannot handle the array and struct var very well.
The bug has been submitted, looks like that nsight cannot handle the array and struct var very well.

#4
Posted 09/21/2017 03:12 AM   
Scroll To Top

Add Reply