HowTo: Using gcov (the GNU coverage tool) with LMDZ : Différence entre versions
(→HowTo: Using the GNU coverage tool gcov with LMDZ) |
|||
(3 révisions intermédiaires par le même utilisateur non affichées) | |||
Ligne 5 : | Ligne 5 : | ||
# compiling your code with the right options | # compiling your code with the right options | ||
# running the code to output the statistics that gcov will analyze | # running the code to output the statistics that gcov will analyze | ||
− | # running gcov on the data | + | # running gcov on the data files created in the previous step to analyze the code coverage |
=== Running gcov on LMDZ === | === Running gcov on LMDZ === | ||
− | We will be using [[https://gcovr.com/en/stable/ gcovr]] a utility using gcov and providing different types | + | We will be using [[https://gcovr.com/en/stable/ gcovr]] a utility using gcov and providing different types of outputs |
'''''Compiling LMDZ''''' | '''''Compiling LMDZ''''' | ||
Ligne 16 : | Ligne 16 : | ||
%BASE_FFLAGS -cpp -ffree-line-length-0 -fdefault-real-8 -DNC_DOUBLE '''-pg --coverage -fprofile-arcs -ftest-coverage -fprofile-abs-path''' | %BASE_FFLAGS -cpp -ffree-line-length-0 -fdefault-real-8 -DNC_DOUBLE '''-pg --coverage -fprofile-arcs -ftest-coverage -fprofile-abs-path''' | ||
+ | .... | ||
+ | %BASE_LD -Wl,-rpath=/data/fairhead/Test_coverage/LMDZ20211102.trunk/netcdf-4.0.1/lib '''-pg -lgcov''' | ||
'''''Running LMDZ''''' | '''''Running LMDZ''''' | ||
Ligne 26 : | Ligne 28 : | ||
gcovr -r . -v --html-details gcm_details libo/local_32x32x39_phylmd_seq.e/.config/tmp/ | gcovr -r . -v --html-details gcm_details libo/local_32x32x39_phylmd_seq.e/.config/tmp/ | ||
^ | ^ | ||
− | this is where the gcda and gcno files are saved by the compiler | + | this is where the gcda and gcno files are saved by the compiler. They're created where the source files were actually compiled. |
− | to create html files | + | |
− | + | to create html files with the prefix <code>gcm_details</code> and the name of the routine included in the file. Each file in your code will have a corresponding html file giving the usage for each line of the routine included in that file. | |
+ | You'll find [[https://web.lmd.jussieu.fr/~fairhead/Labo/LMDZ_Coverage/sequential/example-html-details.html here]] an example of the output for the actual LMDZ code. | ||
[[Category:HowTo]] | [[Category:HowTo]] |
Version actuelle en date du 2 mai 2022 à 10:58
If you want a summary of the lines (and branches) in your code that are actually executed, you can use the GNU [coverage tool]. This entails the following three steps:
- compiling your code with the right options
- running the code to output the statistics that gcov will analyze
- running gcov on the data files created in the previous step to analyze the code coverage
Running gcov on LMDZ
We will be using [gcovr] a utility using gcov and providing different types of outputs
Compiling LMDZ
You will need to add the following flags to your compilation flags in the arch.fcm.file:
%BASE_FFLAGS -cpp -ffree-line-length-0 -fdefault-real-8 -DNC_DOUBLE -pg --coverage -fprofile-arcs -ftest-coverage -fprofile-abs-path .... %BASE_LD -Wl,-rpath=/data/fairhead/Test_coverage/LMDZ20211102.trunk/netcdf-4.0.1/lib -pg -lgcov
Running LMDZ
You just run gcm.e as you usually do. This will create a bunch of gcda and gcno files that are used by gcov in the following step
Running gcovr
You then launch the gcovr command as
gcovr -r . -v --html-details gcm_details libo/local_32x32x39_phylmd_seq.e/.config/tmp/ ^ this is where the gcda and gcno files are saved by the compiler. They're created where the source files were actually compiled.
to create html files with the prefix gcm_details
and the name of the routine included in the file. Each file in your code will have a corresponding html file giving the usage for each line of the routine included in that file.
You'll find [here] an example of the output for the actual LMDZ code.