Sample programs compiing to debug Compiling CUDA sample programs for debugging

There are several programs (CUDA) in the example files. They are compiled by a make file. I just want to compile them so that I can walk through them line by line. Tha would mean something like this

nvcc -g -G -o program

How do I compile them so I can have that capability. I just want to walk through the code and learn about CUDA. I do not think the line above would do it. There are many other files that need to be added such as kernel files.

Any help appreciated.


James M. Yunker

I think if you build the SDK with the additional flag dbg=1, like this:

avid@cuda:~/NVIDIA_GPU_Computing_SDK/C$ make dbg=1

you will get versions of all of the SDK examples built with debugging symbols in a new directory

avid@cuda:~/NVIDIA_GPU_Computing_SDK/C$ ls bin/linux/debug/

3dfd				  deviceQuery		 matrixMulDynlinkJIT   scan					  simpleZeroCopy

alignedTypes		  deviceQueryDrv	  MersenneTwister	   scanLargeArray			smokeParticles

asyncAPI			  dwtHaar1D		   MonteCarlo			simpleAtomicIntrinsics	SobelFilter

bandwidthTest		 dxtc				MonteCarloMultiGPU	simpleCUBLAS			  SobolQRNG

bicubicTexture		eigenvalues		 nbody				 simpleCUFFT			   sortingNetworks

binomialOptions	   fastWalshTransform  oceanFFT			  simpleGL				  template

BlackScholes		  fluidsGL			particles			 simpleMultiGPU			threadFenceReduction

boxFilter			 histogram		   postProcessGL		 simplePitchLinearTexture  threadMigration

clock				 imageDenoising	  ptxjit				simpleStreams			 transpose

convolutionFFT2D	  lineOfSight		 quasirandomGenerator  simpleTemplates		   transposeNew

convolutionSeparable  Mandelbrot		  radixSort			 simpleTexture			 volumeRender

convolutionTexture	marchingCubes	   recursiveGaussian	 simpleTexture3D

cppIntegration		matrixMul		   reduction			 simpleTextureDrv

dct8x8				matrixMulDrv		scalarProd			simpleVoteIntrinsics

and you should be able to run them in cuda-gdb.

I tried dbg=1 and compilation gave some obsure error. I then tried debug=1 and it gave no error, it also had the debugging properties in the executable. Is there any reason one would work (debug=1) and the other (dbg=1) would not?


debug=1 does absolutely nothing, that will compile the executables with release settings. If you have executables in the debug directory, they were made by your dbg=1 command. You can confirm this for yourself by looking in the C/common/ file. You won’t find any debug option in that Makefile. You will however, see this;

# Debug/release configuration

ifeq ($(dbg),1)





		BINSUBDIR   := debug




		BINSUBDIR   := release


		NVCCFLAGS   += --compiler-options -fno-strict-aliasing

		CXXFLAGS	+= -fno-strict-aliasing

		CFLAGS	  += -fno-strict-aliasing


ie. if dbg has a value of 1, compile for debugging, otherwise compile for release. You can happily run:

make newport_j=1

and it will compile just as if you had typed only make. Those trailing arguments to make just set variables inside the make environment. If the makefile doesn’t use those variables, then nothing happens.