Get count of basic blocks

Get count of basic blocks

Hi everyone

I'm using the Intel Fortran Compiler (v. 12.0.3) on Linux. I'd like to perform profiling with gprof and get a basic block count, but all I have managed to obtain is a count on the program/subroutine/function level. My conclusion is that I've got the compiler flags wrong, but despite looking on the web and reading the ifort man page I can't figure out what I should be doing instead of what I am doing...

There are the flags I use when compiling:

-w -O0 -g -pg -prof-gen

I also tried leaving out -pg (an instruction I had read somewhere), but then I got no output at all.

I know this is no gprof-forum, but anyway, here's how I invoke this tool:

gprof -l -A -x path/to/exe gmon.out > OUT

At first it looks as if all lines were labelled with how often they were ran, but it turns out that each block/line simply obtains the procedure count (in the following short example the function was called 43679 times, and both 'if' and 'else', for example, got labelled with 43679, which makes no sense):

    43679 -> function variance_from_index (indices,array)
                   ! declarations

       43679 ->    if (ubound(indices,1).eq.2) then
       43679 ->       variance_from_index = array(indices(1),indices(2))
       43679 ->        do i=1,ubound(indices,1)-1
       43679 ->           do j=i+1,ubound(indices,1)
       43679 ->                items(1:2)  = (/indices(i),indices(j)/)

If someone on here could help me get the correct counts, I'd be very grateful indeed.

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Best Reply

-prof-gen is for use with the compiler's Profile Guided Optimization, not for use with gprof, etc. I am not a gprof expert so can't help with using that.

However, you can get a basic block count using the "Code Coverage" tool provided as part of the compiler product with the -counts option to the codecov tool. Read more about it in the documentation under Key Features > Tools > Code Coverage Tool.

Retired 12/31/2016

Steve, thank you very much for your reply. It has been very helpful!

Leave a Comment

Please sign in to add a comment. Not a member? Join today