1

I would like to profile some c++ code using gprof. I compile the program exactly like normal but with -pg added at the end; i.e. something like

g++ prog.cpp $(OBJECTS) -lgmp -lgmpxx -lmpfr -lmpc -msse2 -std=c++11 -O2 -o prog_P -pg

However when I run the resulting executable I get a bunch of errors that are not normally there. Specifically they are from the zkcm multiprecision library:

Warning: in zkcm_gauss::gauss, partial pivoting failed.

This is bad news for my LU decomposition. Any ideas?

EDIT: I use cygwin

whoan
  • 8,143
  • 4
  • 39
  • 48
jorgen
  • 3,425
  • 4
  • 31
  • 53
  • 1
    Try a different profiler ? – Paul R Sep 12 '14 at 13:56
  • 1
    Do have a suggestion for which one? I forgot to mention that I use cygwin, where Valgrind is not supported. – jorgen Sep 12 '14 at 14:14
  • 2
    I would suggest you to try on Linux (in particular because it has `valgrind`). You really should compile with the `-Wall` flag. And try with `-O1` first. Are you sure your program is not buggy, have you tested it ? – Basile Starynkevitch Sep 12 '14 at 14:17
  • Funnily enough `-Wall` made a bunch of warnings from the `zkcm` library appear (but none seem that important, like `comparison between signed and unsigned integer` and `unused variable`). I tried `-O1` as well, with the same result. I guess I can try a linux machine next time I have access to one.. – jorgen Sep 12 '14 at 14:24
  • 1
    The profiling option adds additional code; so the question is: How can that change the original program? In general, "partial pivoting failed" seems to have to do with error accumulation in a matrix growing excessively (cf. www.math.sjsu.edu/~foster/geppfail.pdf). The only possibility I see how additional code could affect numerical calculations is that floating point hardware registers used for the matrix computations are used by the profiling code so that some values of the original program are now transitioning through memory, with lesser precision, thus accumulating larger errors. – Peter - Reinstate Monica Sep 12 '14 at 14:52
  • 1
    It doesn't matter. Even if you get `gprof` to work, you're going to be left wondering what the results mean. If you are using a profiler, use a good one, like [*Zoom*](http://www.rotateright.com/). Lots of people use [*this simple but effective method*](http://stackoverflow.com/a/378024/23771). – Mike Dunlavey Sep 12 '14 at 16:57
  • 1
    [*Here's an explanation*](http://stackoverflow.com/a/25724978/23771) of why some profilers are more effective than others at finding ways to speed up your code. – Mike Dunlavey Sep 15 '14 at 18:45

0 Answers0