2

I am interested in using the differential code coverage functionality in ifort. The documentation appears to address this thoroughly but I have failed to apply it to my reduced example. Heres what I have:

program test
    integer :: userinput
    print *, 'enter 1 or 0'
    read *, userinput

    if (userinput.eq.1) then
        print *, 'You have entered ONE'
    else
        print *, 'You have not entered ONE'
    end if
end program test

A simple program that can take one of two paths. If the user enters 1 then it goes into the if ... then statement, if the user enters 0 then it goes into the else... statement.

The goal of differential code coverage (as stated by intel docs) is as follows:

compare the profiles from two runs of an application: a reference run and a new run identifying the code that is covered by the new run but not covered by the reference run

So if we take a reference run where the user enters 0 and a new run where the user enters 1, the differential code coverage should be able to identify that the new run covers the if statement whereas the reference run does not (reference run goes into the else statement). I followed the docs as closely as possible. The source file is called test.f90. Here are the compile lines i'm using:

ifort test.f90 /Qcov-gen

Which generates PGOPTI.SPI, PGOPTI, test.exe and test.obj. I then run the executable and enter 0, I get the correct message "You have not entered ONE". This causes a .dyn file to be created (due to the Qcov-gen option). I then do the following:

profmerge

Which generates additional files pgopti.dpi, pgopti.dpi.lock. At this point I think I have enough material to generate my reference data. This I attempt using the following:

codecov -prj Project_Name -dpi pgopti.dpi -ref pgopti.dpi

Which generates html files similar to the ones displayed when code coverage is run in Visual Studio for Intel Fortran. I also get 100% code coverage which seems incorrect. The docs then show this command:

codecov -prj Project_Name -spi pgopti.spi -dpi pgopti.dpi 

Which does not appear to provide an opportunity for a new run.

Could someone please explain how to do a simple differential code coverage on this particular example? I'm eventually trying to extrapolate this to a larger project but I'm trying to take baby steps to get there.

user32882
  • 5,094
  • 5
  • 43
  • 82
  • 1
    I may have missed this in your description, but you don't seem to mention running the program a second time and entering 1, which is presumably required for the differential part. – d_1999 Sep 26 '17 at 07:34
  • without even looking at the docs it strikes me as obvious that the `dpi` and `ref` should not be the same file.. as a wild guess, run once , copy all the pgopti.* to pgopti_ref.* and use that as your -ref and run again with different input to get new pgopti.* – agentp Sep 26 '17 at 12:22

0 Answers0