A
Andrew Bonello
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?
Thanks
Andrew.
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?
Thanks
Andrew.