Totalview® User Guide : PART V Using the CUDA Debugger : Chapter 26 CUDA Debugging Tutorial
Chapter 26 CUDA Debugging Tutorial
This chapter discusses how to build and debug a simple CUDA program using TotalView.
Compiling for Debugging
When compiling an NVIDIA CUDA program for debugging, it is necessary to pass the -g -G options to the nvcc compiler driver. These options disable most compiler optimization and include symbolic debugging information in the driver executable file, making it possible to debug the application. For example, to compile the sample CUDA program named tx_cuda_matmul.cu for debugging, use the following commands to compile and execute the application:
% /usr/local/bin/nvcc -g -G -c tx_cuda_matmul.cu -o tx_cuda_matmul.o
% /usr/local/bin/nvcc -g -G -Xlinker=-R/usr/local/cuda/lib64 \
tx_cuda_matmul.o -o tx_cuda_matmul
% ./tx_cuda_matmul
A:
[ 0][ 0] 0.000000
...output deleted for brevity...
[ 1][ 1] 131.000000
%
Access the source code for this CUDA program tx_cuda_matmul.cu program at "Sample CUDA Program".