Complex code: code folding

Real-world scientific code does not look much like the examples above. It looks more like the following:

Typical Fortran code in MAP

Here, small amounts of processing are distributed over many lines, and it is difficult to see which parts of the program are responsible for the majority of the resource usage.

To understand the performance of complex blocks of code like this, Linaro MAP allows code folding. Each logical block of code such as an if-statement or a function call has a small [-] next to it. Clicking this folds those lines of code into one and shows one single sparkline for the entire block:

Folded Fortran code in MAP

This helps you identify the conditional blocks where most of the processing occurs.

When exploring a new source file, a good way to understand its performance is to use the View ‣ Fold All menu item to collapse all the functions in the file to single lines, then scroll through it looking for functions that take an unusual amount of time or show an unusual pattern of I/O or MPI overhead. These can then be expanded to show their most basic blocks, and the largest of these can be expanded again and so on.