Skip to content

Commit 44187b4

Browse files
authored
Merge pull request #1944 from thananon/fix_random_romio
2 parents 4517044 + 23b27c5 commit 44187b4

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

ompi/mca/io/romio314/romio/adio/common/shfp_fname.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
#ifdef HAVE_TIME_H
1818
#include <time.h>
1919
#endif
20+
21+
/*
22+
* Open MPI: we have to use internal opal_random() instead of rand(3)
23+
* to prevent pertubing user's randon seed
24+
*/
25+
#include <opal/util/alfg.h>
26+
2027
/* The following function selects the name of the file to be used to
2128
store the shared file pointer. The shared-file-pointer file is a
2229
hidden file in the same directory as the real file being accessed.
@@ -35,12 +42,18 @@ void ADIOI_Shfp_fname(ADIO_File fd, int rank, int *error_code)
3542
int len;
3643
char *slash, *ptr, tmp[128];
3744
int pid = 0;
45+
opal_rng_buff_t adio_rand_buff;
3846

3947
fd->shared_fp_fname = (char *) ADIOI_Malloc(PATH_MAX);
4048

4149
if (!rank) {
42-
srand(time(NULL));
43-
i = rand();
50+
/*
51+
* Open MPI: we have to use internal opal_random() instead of rand(3)
52+
* to prevent pertubing user's randon seed
53+
*/
54+
opal_srand(&adio_rand_buff,time(NULL));
55+
i = opal_random();
56+
4457
pid = (int)getpid();
4558

4659
if (ADIOI_Strncpy(fd->shared_fp_fname, fd->filename, PATH_MAX)) {

0 commit comments

Comments
 (0)