| The CSF2 has been replaced by the CSF3 - please use that system! This documentation may be out of date. Please read the CSF3 documentation instead. To display this old CSF2 page click here. |
gprof (GNU Profiler)
Overview
gprof is the GNU Profiler that can be used, in combination with compiler flags, to determine where time has been spent during program execution.
Restrictions on use
None
Set up procedure
None
Running the application
Your application needs compiling with -p -g (Intel) or -pg (GNU). When such applications are run they create, or append, to gmon.out. gprof uses the information in this file to give various program profiles. A basic (abridged) example is
ifort -O0 -p -g primes_skel.f90 chkPrime.f90 -o prime_profile.exe
time ./prime_profile.exe > primes.txt
real 0m2.688s
user 0m2.654s
sys 0m0.023s
gprof prime_profile.exe gmon.out
Flat profile:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
69.73 1.56 1.56 1000000 0.00 0.00 chkprime_
24.66 2.11 0.55 sqrtf.A
2.69 2.17 0.06 cvtas__nan_x
1.35 2.20 0.03 sqrtf.L
0.90 2.22 0.02 sqrtf
0.67 2.23 0.02 1 0.02 1.57 MAIN__
This illustrates that nearly 70% of the time was spent in the chkprime() function.
See the man gprof for options available.
Note that production codes should be run under the batch system, not on the login node
