Profiling support
Torsten Bonde Christiansen
torsten at bondechristiansen.dk
Fri Jan 11 21:51:39 CET 2008
Torbjorn Granlund wrote:
> Torsten Bonde Christiansen <torsten at bondechristiansen.dk> writes:
>
> Hi,
>
> I tried to compile gmp-4.2.2 with profiling support, but for some reason
> the gmp functions does not show up in the output.
>
> I've compiled the library both using:
> ./configure --enable-profiling=gprof
> ./configure --enable-profiling=prof
> CFLAGS="-pg -g3 -O0" ./configure
> (including several other variants).
>
> Are you saying that you override CFLAGS. Then you're your own.
>
> and when compiling my own program using:
> gcc -pg -O0 -g3 -o my_prog my_prog.c -lgmp
>
> When executed the program generates the required gmon.out file, but no
> where in the output (using gprof my_prog > my_prog.out) is any of the
> gmp functions displayed.
>
> I thought this could be down to the fact that they use so little time
> executing, that they are discarded by the profiler, but that should not
> be the case since i'm doing some rather nasty modulo operations on
> intergers > 4 machine words.
>
> How about trying with doing more work then? That's easier than
> guessing, and would produce much more accurate results. :-)
>
> Anyone who has an idea to what I could be doing wrong?
>
> Yes, you report a problem without the information we need to have any
> chance at trying to reproduce it. I'd suggest a look in the manual,
> which clearly outlines what a GMP bug report needs to contain.
>
>
I can see (from reading my own mail again) that i must clear have had to
much coffee - it's not exactly as clearly stated as I had hoped.
My problem:
I wish to profile my program, in which much the work being done, is by
using the gmp library. From the online manual it states that in order to
enable profiling the configuration script should have the argument
"--enable-profiling=gprof".
But - even though the compilation works fine, the "make check" is
working fine and the "make install" also works as it should, i'm just
not able to get any profiling information on any gmp functions.
My own program is compiled using the flags "-O0 -g3 -pg" which should be
what is need for profiling (with gprof). The linker for my program is
invoked with the exact same flags so that shouldn't be a problem either.
Strangely enough I get a lot of profiling information on the "normal" C
code in my program (my own functions and glibc libraries that is), but
not a single gmp function shows in the output.
I know that my program spends about 50% of the CPU time doing
calculations using the gmp library, so the reason that nothing is shown,
is NOT that there is not enough wall clock time spent in these functions.
So once again I ask - what in the world could I be doing wrong.
Kind regards,
Torsten Bonde Christiansen.
=================================================================================================
Stuff required by the "Reporting bugs":
gcc: version 4.1.2
gmp: version 4.2.2
configure options: --enable-profiling=gprof --enable-cxx
uname -a: Linux Rainier 2.6.23-gentoo-r3 #1 SMP Wed Dec 12 13:07:49 CET
2007 x86_64 AMD Athlon(tm) 64 Processor 3800+ AuthenticAMD GNU/Linux
config.guess: athlon64-unknown-linux-gnu
Small sample program that should produce some profiling information from
the mpz_... functions:
#include <stdio.h>
#include <gmp.h>
int main(int argc, char * argv[]) {
unsigned int r;
int i;
mpz_t a, b;
mpz_init(a);
mpz_init(b);
mpz_set_ui(a, 2938472938473294);
mpz_set_ui(b, 2342374682734236);
for (i=0; i<10000000; ++i) {
mpz_add(a, a, b);
}
r = mpz_get_ui(a);
printf("Int: %i", r);
}
More information about the gmp-bugs
mailing list