Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Code Coverage for static library

Duncan_Soutar
Beginner
2,172 Views

Hi, I wondered if anyone had used the Intel codecov tool for analysis of a static library.

I am building a static library comprising mainly algorithmic content which I want to analyse and also have a driver program which is used to test the library. The driver is linked against a static .lib. If I follow the examples in the documentation and compile everything with /Qcov-gen I get a dyn file in the exe directory and when I use the tools on that it gives me coverage analysis for the exe not for the library. However it is the library I am most interested in.

Currently working on Windows in Visual Studio but also doing Linux and MacOSX builds as well if someone has a solution for that.

0 Kudos
8 Replies
Steven_L_Intel1
Employee
2,172 Views

What options are you using to build the library?

0 Kudos
Duncan_Soutar
Beginner
2,172 Views

Hi Steve

The library source is in a separate directory, it is compiled with /Qcov-gen set at the project level. The files PGOPTI.SPI and PGOPTI.SPL are created in that location. The driver program is in another directory, also compiled with /Qcov-gen, with its own SPI and SPL files.

I am working in Visual Studio. The solution contains projects for the app and the library and I have added /Qcov-gen in each project on the Fortran Command Line tab under additional options. Linking to the static library is implicit, achieved by setting a project dependency in Visual Studio.

Simon.

0 Kudos
Duncan_Soutar
Beginner
2,172 Views

Forgot to mention I have not set any options when building the library. Although I have compiled with /Qcov-gen I could not find anything to do with coverage or profiling in the Librarian tab of the Visual Studio gui.

Simon

0 Kudos
Steven_L_Intel1
Employee
2,172 Views

Would you please attach a ZIP of the buildlog.htm files for both the library and executable project?  You will find these in the Debug or Release folder, depending on configuration. Thanks.

0 Kudos
Duncan_Soutar
Beginner
2,172 Views

Build logs. Note I use a custom location for build products, e.g. Coverage_x64 with transient files such as .obj and .mod in a directory below that, e.g. Coverage_x64/intermediate

0 Kudos
Duncan_Soutar
Beginner
2,172 Views

Hi

I wondered if there was any news regarding this problem. I would like to get a move on with coverage and also profiling which I anticipate will have the same problem/resolution.

Thanks

Simon.

0 Kudos
Kevin_D_Intel
Employee
2,172 Views

Hi Simon - I'm not aware of any news regarding this issue so I will have a look in Steve's absence.

0 Kudos
Kevin_D_Intel
Employee
2,172 Views

Please pardon the delay, Simon.

I created a working example with our latest PSXE 2016 release. My example is a single solution with separate Console and Static library projects, where the latter is a dependent of the former. In each, I initially I only added /Qcov-gen like what I see in your build logs.

With that build what I found is after running the console1.exe to create some .dyn files, you run profmerge to combine .dyn files and then when running the codecov you must use the -spi option to specify the path to the Static lib’s PGOPTI.SPI/SPL files. Those reside at the project-level directory and both the console and static lib have their own. When you do not use the -spi option the code coverage report will only include routines from in the Console program.

For a little more convenience, I also found you can have both projects create a single set of combined PGOPTI.SPI/SPL files. Doing this will also produce a combined code coverage report. For this you do the following:

  1. Create a folder to capture the prof-gen PGOPTI.SPI/SPL files.  For convenience, I created a sub-folder inside the Console project’s directory.
  2. To each project add the /Qprof-dir option (along with /Qcov-gen) to specify the appropriate relative path to the folder created in step 1. The path is relative to each project’s folder. (e.g. for my Static lib, I added /Qprof-dir:..\Console1\CodeC, where in step 1 the folder CodeC was created inside the Console project's folder.)

Following those two setup steps, rebuild the app and run to generate .dyn files (which also will now appear in the folder created in step 1). Next, from an Intel compiler initialized command-prompt, navigate to the folder created in step 1, and then run profmerge and codecov. The resulting code coverage report will now include all routines from the Console and Static library.

Hope that helps!

0 Kudos
Reply