![]() |
MAOS
Multithreaded Adaptive Optics Simulator
|
Configure a separate build directory with --enable-debug to compile without optimization (-g3 -O0) and with the DEBUG macro set to 1. In a debug build:
P() checks that array indices are within bounds and calls error() otherwise (see Fundamental Math Types).The GNU gdb can be used for basic troubleshooting. error() raises SIGUSR2, so gdb stops at the location of the error. When the program crashes or calls error(), the signal handler prints a backtrace. If gdb is not able to find the problem, valgrind is good at detecting out of bounds memory access and use after free.
For CUDA related debugging, use cuda-gdb.
Increase the verbosity with the environment variable MAOS_LOG_LEVEL (from -5 to 5, default 0). Levels 1 to 3 enable the dbg(), dbg2(), and dbg3() output.
Set the environment variable MAOS_MEM_DEBUG=1 before launching maos to track memory allocation and free. Unreleased memory is printed at exit together with the backtrace of its allocation, which helps to find memory leaks. Memory accounting is enabled by default in debug builds; set MAOS_MEM_DEBUG=0 to disable it. Related options:
MAOS_MEM_VERBOSE=1 prints every allocation and free.MAOS_MEM_FUNTRACE=1 records the file, line, and function of the allocation instead of the backtrace.SIGUSR1 to a running process (kill -USR1 pid) enables memory accounting from that point on.The accounting covers memory allocated through malloc, calloc, realloc, and free in C code, which sys/mem.h redirects to the accounting wrappers.
Configure with --enable-gcov (which also enables --enable-debug) to compile with gcov instrumentation. Then:
make check runs the unit tests. If lcov and genhtml are installed, the check-local target in test/Makefile.am collects the coverage of the whole build and writes an HTML report to test/coverage/ in the build directory.make doc runs the unit tests from a clean coverage state, and test/unittest_coverage.sh summarizes the line coverage of sys, math, and lib using gcov. The summary is included in the unit test page of the manual (Unit Test Status).maos run instead, run maos and then scripts/gcov.sh at the root of the build directory, which uses lcov and genhtml to write the report to out/index.html.MAOS is multi-threaded, and the gprof based profiling does not generate useful information. Instead, use a system wide sampling profiler, such as perf, OProfile, or Intel VTune, to find the hotspots. Setting MAOS_PARALLEL=0 disables running the main tasks of each time step in parallel, which helps to obtain more accurate timing of each part, and MAOS_NO_WFS=1, MAOS_NO_EVL=1, or MAOS_NO_RECON=1 skip the WFS, performance evaluation, or reconstruction. The option -n sets the number of threads.
For example, with OProfile:
operf ./maos [options] opreport -cgf -l maos | gprof2dot.py -f oprofile | dot -Tpng -o output.png
gprof2dot.py can be found in the scripts folder. With perf, use
perf record -g ./maos [options] perf report