Intel Visual Fortran Pro for Linux Notes On gprof Use

Submit New Article

Last Modified On :   July 1, 2009 4:33 PM PDT
Rate
 



Problem : I used the '-pg' option with ifort to compile my code for gprof profiling.  After running my program I used gprof to view the results from the profile stored in gmon.out.  I see my main program and some of my functions and subroutines profiles.  However, several of my main subroutines and functions are not shown and I know they use a lot of cpu cycles.  Why are my functions not appearing in the gprof profile?


Environment : Linux.  Intel Fortran for Linux. Compile your application with the -pg option.  Run your application.  Then bring up your profile report with the command:
gprof <applicaton executable name> gmon.out


Root Cause : There are 2 possible causes.  You could be experiencing the effects of one or both of these root causes.
  1. inlining (a performance optimization) may have replaced the calls to your user functions with inline expansion of those functions

  2. Intel Fortran for Linux versions 11.0.081 and older compilers generate symbolic names for contained procedures that gprof does not recognize.


Resolutions : Each listed below:

  1. Inlining removing function calls: disable inline optimization.  To turn off the inlining of user functions.  This is done by compiling with the option -fno-inline-functions.
  2. Contained Procedures have symbolic names incompatible with gprof for versions 11.0.081 and older: There are 2 solutions:
  • Upgrade your Intel Fortran for Linux to versions 11.0.083 or 11.1 (original release or any update version thereafter).  There was a fix to these newer compilers to create symbol names for contained procedures that gprof is able to track (see information below).
  • For 11.0.081 and older compilers, you can explicitly change the symbolic names using the ATTRIBUTES ALIAS to force the exported symbol name to be compatible with gprof.  An example:
program gproftest
integer :: i = 0
do  while ( i < 1,1000000 )
call suba(i)
end do
contains
!DEC$ ATTRIBUTES ALIAS:'suba':: suba
subroutine suba(i)
integer, intent(inout) :: i
i = i + 1
end subroutine suba
end program gproftest


It may seem redundant to use ALIAS to force the name of 'suba' to 'suba' but it does have an effect on the way the symbolic name for suba is generated by the compiler and stored in the object file.   With the code above, we can see the symbolic name for suba is "suba":

ifort -c -pg gproftest.f90
nm gproftest.o | grep -i suba
0000000000000080 t suba


The symbol for suba is undecorated and compatible with gprof profile analysis.  By contrast, if we do not use the ATTRIBUTES ALIAS (this is with the 11.0.081 and older compilers)

program gproftest
integer :: i = 0
do  while ( i < 1,1000000 )
call suba(i)
end do
contains
subroutine suba(i)
integer, intent(inout) :: i
i = i + 1
end subroutine suba
end program gproftest


ifort -c -pg gproftest.f90
nm gproftest.o | grep -i suba
0000000000000080 t gproftest_.suba_


As we see above, the decoration for internal procedure 'suba' gets extensive decoration with the older 11.0.081 compiler and includes the "." (dot) decorator.

gprof was adapted to work with gfortran and g95 which uses the internal procedure name + dot "." + followed by a numeric value for names that contain a dot.  Here is a example of symbolic names used by various compilers:

ifort 11.0.081 gproftest_.suba_
gfortran 4.4 suba.1532
g95 4.0.0 suba_.383
NAG Fort gproftest_IP_suba


Again, the Intel compiler used in this example is the older 11.0.081 compiler.   gprof is not able to recognize the symbol in the form used by the older Intel compilers.  gprof, when it sees the dot "." in the name is expecting a numeric to follow, such as used by gfortran and g95.  Thus, this decoration scheme used by older Intel compilers for internal procedures is incompatible.

As of Intel Fortran Compiler Professional Edition for Linux version 11.0.083 and newer Intel adapted a decoration scheme similar to that used by the NAG Fortran compiler:

ifort -v
Version 11.1
ifort -pg -c gproftest.f90
nm gproftest.o | grep -i suba
0000000000000080 t gproftest_IP_suba_


Summary:

to get full information on internal procedures and functions that could be inlined, it is recommended to:

  1. Use the latest Intel Fortran Compiler Pro for Linux version 11.1
  2. Disable function inlining using the -fno-inline-functions




This article applies to: Intel® Fortran Compiler for Linux* Knowledge Base