Andrew Bonello wrote:[color=blue]
> Hi
>
> I have written a C++ program (Redhat Linux 7.2, gcc v2.96). The
> program makes a sequence of calls to rand() after having seeded the
> random number generator using srand( 0 ). Under normal circumstances,
> for a given input state, the sequence of random numbers generated is
> exactly reproduced each time the program is run. So, if I run the tool
> 3 times in succession, the path of execution is completely identical
> each time as far as the sequence of random numbers is concerned.
>
> I also want to profile the performance of this program, and so
> recompiled and linked using the -pg option to allow gprof to be run
> after execution.
>
> However, I now find that the sequence of random numbers generated at
> each subsequent run of the program is NOT reproducible. It looks like
> linking with -pg is what caused the problem. Obviously, since the path
> of execution is now different each time, the profiling results are
> rather less meaningful.
>
> Has anyone observed this behaviour? If so, can you recommend any ways
> to get reproducible random number sequences WITH the -pg linking
> option?[/color]
Since this problem statement is specific to GNU G++ (and the GNU
profiling tools), the GNU G++ newsgroups / mailing lists are probably
the best/right places to ask for assistance. On Usenet, the GNU G++
"help" group is,
gnu.g++.help
For mailing list info, visit the GCC web site at
http://gcc.gnu.org
FWIW, you should also post a short, complete, compilable C++ program
sample that exactly demonstrates the problem you're describing. Without
some actual code to look at, the g++ folks can only make guesses as to
the "real" problem (e.g., compiler bug, code bug, linker bug, programmer
error ;-), etc.).
--
Jim
To reply by email, remove "link" and change "now.here" to "yahoo"
jfischer_link5809{at}now.here.com