Programming Parallel Computers 2019

Help with debugging

Debug builds

The makefiles in your repository support the following options that may help with debugging. The grading scripts also make use of some of these.

Debugging CPU code

You can disable optimizations by building with DEBUG=1, for example:

make clean
make DEBUG=1
./grading test

You can also enable AddressSanitizer, which helps to catch many memory access errors:

make clean
make DEBUG=2
./grading test

You can also enable the C++ standard library debug mode, which helps to catch e.g. out-of-bounds accesses with standard containers:

make clean
make DEBUG=3
./grading test

Debugging GPU code

In CUDA tasks, you can also use make DEBUG=1 for debug builds. This will compile with nvcc -g -G so that you can easily debug your code with cuda-gdb.

Other debugging options are not supported for CUDA code.

Remember to clean up!

After experimenting with the debug builds, please always remember to run make clean afterwards.