cudacuda-gdb

compiling with -G flag leading to ptxas parsing error/syntax error


I am using a popular repo: siboehm/SGEMM_CUDA.

When building without debugging: i.e.

mkdir build && cd build && \
cmake .. && cmake --build .  

the program compiles, links and runs without error.
Important compilation commands used in the build process:

/usr/local/cuda-12.3/bin/nvcc \
-forward-unknown-to-host-compiler  \
-I/usr/local/cuda-12.3/include \
-I/home/jasneetsingh/Desktop/cuda_experiments/SGEMM_CUDA/src \
--generate-code=arch=compute_86,code=[compute_86,sm_86] \
-MD -MT CMakeFiles/sgemm.dir/src/runner.cu.o \
-MF CMakeFiles/sgemm.dir/src/runner.cu.o.d \
-x cu -c \
/home/jasneetsingh/Desktop/cuda_experiments/SGEMM_CUDA/src/runner.cu \
-o CMakeFiles/sgemm.dir/src/runner.cu.o 

but when using debug i.e.

mkdir build && cd build && \
cmake .. -DCMAKE_BUILD_TYPE=Debug && \
cmake --build .

this error comes when executing the command (in CMake build):

/usr/local/cuda-12.3/bin/nvcc \
-forward-unknown-to-host-compiler  \
-I/usr/local/cuda-12.3/include \
-I/home/jasneetsingh/Desktop/cuda_experiments/SGEMM_CUDA/src \
-g \
--generate-code=arch=compute_86,code=[compute_86,sm_86] \
-G \
-src-in-ptx \
-MD -MT CMakeFiles/sgemm.dir/src/runner.cu.o \
-MF CMakeFiles/sgemm.dir/src/runner.cu.o.d \
-x cu -c \
/home/jasneetsingh/Desktop/cuda_experiments/SGEMM_CUDA/src/runner.cu \
-o CMakeFiles/sgemm.dir/src/runner.cu.o
    ptxas /tmp/tmpxft_00004480_00000000-6_runner.ptx, line 881; fatal : Parsing error near '': syntax error
    ptxas fatal : Ptx assembly aborted due to errors
    gmake[2]: *** [CMakeFiles/sgemm.dir/build.make:90: CMakeFiles/sgemm.dir/src/runner.cu.o] Error 255
    gmake[2]: Leaving directory '/home/jasneetsingh/Desktop/cuda_experiments/SGEMM_CUDA/build'

It must have something to do with -G flag.

My system info:


Solution

  • As stated my problem was inability set up breakpoints inside the kernel, since I was unable to compile with -G flag using CMAKE. Comment from @robertcrovella solved this problem.
    i.e. I removed the -src-in-ptx and compilation was successful and breakpoints were being placed in cuda kernel