Hi All,
Doing quick test with rand()/srand() I found that MPI_Init() seems to be
calling a function in their family that is affecting the values in the user
application. Please see below my simple test and the results. Yes, moving the
second call to srand() after MPI_init() solves the problem. However, I'm
confused since this was supposedly addressed in version 1.7.5. From release
notes:
1.7.5 20 Mar 2014:
- OMPI now uses its own internal random number generator and will not perturb
srand() and friends.
I tested on OMPI 1.10.2 and 1.10.3. The result is deterministic.
Any ideas?
Thanks,
Regards,
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
int main(int argc, char *argv[])
{
int rand1;
int rand2;
int name_len;
srand(100000);
rand1 = rand();
srand(100000);
MPI_Init(&argc, &argv);
rand2 = rand();
if (rand1 != rand2) {
printf("%d != %d\n", rand1, rand2);
fflush(stdout);
}
else {
printf("%d == %d\n", rand1, rand2);
fflush(stdout);
}
MPI_Finalize();
return 0;
}
host1:/tmp> mpirun -np 1 -host host1 -mca pml ob1 -mca btl tcp,self ./rand1
964940668 != 865007240
_MAC