profiling wierdness

Dave Steffen steffend@helicon.physics.colostate.edu
Wed Sep 23 15:55:00 GMT 1998


Hi Folks,

First for the trivia: 

platform is a dual Pentium-II system running Linux (Redhat 5.1)
compiler is egcs-1.1b (Reading specs from /opt/egcs/lib/gcc-lib/i686-pc-linux-g
nu/egcs-2.91.57/specs gcc version egcs-2.91.57 19980901 (egcs-1.1 release))

Now for the problem:

	I've got some numerical code I'm trying (desperately) to speed
up. I'm compiling with 

	c++ -ansi -pg ....

and (right now) am using no optimization, so I can tell what
improvements I'm getting because of improving the algorithm.

	So I run my program:
helicon: kubo -XYHxyh -e ".1" -O "-5 5 .1" -P .66
	And I profile:
helicon: gprof kubo | c++filt > kubo.prof
	And I get
  %   cumulative   self              self     total           
 time   seconds   seconds    calls  us/call  us/call  name    
 56.86      0.29     0.29 19000000     0.02     0.02  double 
dot_product<Sparse_
vector_STLvec<double>, double>(Sparse_vector_STLvec<double> const &, double 
cons
t *)
 15.69      0.37     0.08 19001940     0.00     0.00  vector<ai<int, double>, 
__default_alloc_template<true, 0> >::end(void) const

	and so forth, for a total run time of .51 seconds. Which I
don't believe, so I run my program again, and profile again:

helicon: kubo -XYHxyh -e ".1" -O "-5 5 .1" -P .66
helicon: gprof kubo | c++filt > kubo.prof

	This time I get  %   cumulative   self              self     total           
 time   seconds   seconds    calls  us/call  us/call  name    
 66.67      0.02     0.02        9  2222.22  2222.22  C_matrix<double>
::set(double const &)
 33.33      0.03     0.01     1440     6.94     6.94  ai<int, double>::ai(int 
co nst &, double const &)

	and so forth, for for a total run time of .03 secons, which I
don't believe either. Note that the #1 user of time is a different
function. So I repeat the process; this time I get

  %   cumulative   self              self     total           
 time   seconds   seconds    calls  us/call  us/call  name    
 44.21      0.42     0.42 19000000     0.02     0.04  double 
dot_product<Sparse_
vector_STLvec<double>, double>(Sparse_vector_STLvec<double> const &, double 
const *)
 15.79      0.57     0.15 30600640     0.00     0.00  ai<int, double>
::index(void) const

	and so forth, for a total run time of .95 seconds.

Hmm...

	Explicity deleting 'gmon.out' between runs doesn't seem to
help; on three runs, gprof gives me total run times of .36, .00
(apparently nothing executed?), and .01.

	And in case you're wondering, 'time'ing the run gives results
like "0.11user 47.19system 0:47.30elapsed 99%CPU", and these numbers
are very consistent. Also, the code executes correctly and generates
identical output for all the above runs.

	Compiling with "-p" instead of "-pg" gives similar results:
.99,.93, and .01 seconds for 3 runs. Compiling with "-profile" results
in a seg fault when I execute the program (not when compiling, though;
the compilation appears to be successful.)

	SO: I'm very confused. Does anyone know what's going on? Is
there any way for me to get reasonably accurate profiling information?

Any help would be greatly appreciated. Thanks.






More information about the Gcc mailing list