Skip to content

Add optional instrumentation for Verrou

Henri Menke requested to merge verrou into main

Description

This MR adds optional instrumentation for Verrou to Octopus. Hitherto, the main challenge/annoyance with Verrou has been that it either instruments all or nothing. This makes it very hard to track down the region of interest where floating-point errors occur. Verrou does offer active instrumentation via the command line flag --instr-atstart=no paired with the C macros VERROU_START_INSTRUMENTATION and VERROU_STOP_INSTRUMENTATION which use Valgrind's Client Request facilities to only instrument selected portions of the code.

Unfortunately, Octopus is written in Fortran so using C macros is out of the question and recompiling every time another section should be instrumented is tedious. Therefore I have implemented dynamic instrumentation which can be controlled from the input file.

Example

Debug = instrument
%InstrumentFunctions
  "electrons/kpoints.F90.kpoints_init" | verrou
%

By setting --vr-verbose=yes we can see in the terminal when the code enables and disables the dynamic instrumentation

$ valgrind --tool=verrou --rounding-mode=random --instr-atstart=no --vr-verbose=yes octopus
[... other output ...]

--101421-- Client Request: instrumentation switched ON

[... other output ...]

--101421-- Client Request: instrumentation switched OFF

[... other output ...]

Limitations

Currently only a single instrumentation tool exists (namely Verrou) and only a single function can be instrumented. Instrumenting more than one function is complex for multiple reasons.

  1. We would need a table that stores all the functions that are instrumented and on every PUSH_SUB/POP_SUB we need to look up in the table whether the current function is to be instrumented and with what tool. For few instrumented functions linear search might be okay, but for more than a dozen we'd need a hashtable.
  2. There needs to be some sort of stack per instrumentation tool, because we could have instrumented functions calling other instrumented functions, but the first VERROU_STOP_INSTRUMENTATION turns off all instrumentation regardless of how many times VERROU_START_INSTRUMENTATION was called before.

News snippet

Checklist

  • I have checked that my code follows the Octopus coding standards
  • I have added tests for all the new features added in this request.

Merge request reports

Loading