Help, Cuda Debug Question

Hi guys,

I am facing a strange problem. What I am trying to do is to debug a cuda program in the emulation mode in Ubuntu, I think I have put the correct compiler parameters for nvcc. When I start debugging, I do see the highlighted line, but the problem is that for some reason, if I go trace the execution line by line by pressing F6, the execution order does NOT go by line order! It seems to me that it jumps arbitrarily, sometimes it even executes those lines which are commented out. Could someone give me some points on this? I am attaching the Makefile that I am using as follow. Thanks a lot for the help!! This problem really drives me crazy!

[codebox]filename = MemCoales02

executable = $(filename)

objects = $(filename).o

source = $(filename).cu

(executable) : (objects)

emulation + debug mode

gcc -o $(executable) $(objects) -L/usr/local/cuda/lib64  -lcudart -lcublasemu -L/home/mj/NVIDIA_GPU_Computing_SDK/C/lib/ -L/home/mj/NVIDIA_GPU_Computing_SDK/C/common/lib -lcutil -lcblas -lm

(objects) : (source)

emulation + debug mode

/usr/local/cuda/bin/nvcc -o $(objects) -c -g --compiler-options='-fPIC' -deviceemu -arch=sm_11 -O3 -I/home/mj/NVIDIA_GPU_Computing_SDK/C/common/inc/ $(source)

all :

${MAKE} $(executable)

clean :

rm $(objects)

rm $(executable)[/codebox]

You have optimization turned on in nvcc, so remove the -O3 and add -G and you might find it works better.

Amazing! That solves the problem! Thanks a lot. But could you explain a little bit what makes the differences by changing from -O3 to -G? I cant really tell too much specific reason by just reading the spec from nvcc.

You are turning off code optimization and including debugging symbols. By doing so, you are telling the compiler to compiled code which is faithful to your C input, rather than something which the compiler thinks would be stronger/fast/better.