Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Stop setting random seed at initialization.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 1 Mar 2019 09:44:14 +0000 (10:44 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 1 Mar 2019 22:56:51 +0000 (23:56 +0100)
ChangeLog
include/smpi/smpi.h
src/smpi/internals/smpi_global.cpp
src/xbt/xbt_main.cpp

index cce8b08..dadeec7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,7 @@ Core:
    with the Boost.Stacktrace library.
    You won't see your backtraces without this optional dependency.
  - Bump cmake dependency to 3.5 (provided by Ubuntu 16.04).
    with the Boost.Stacktrace library.
    You won't see your backtraces without this optional dependency.
  - Bump cmake dependency to 3.5 (provided by Ubuntu 16.04).
+ - Stop setting random seed with srand() at initialization.
 
 MSG:
  - Drop MSG_process_create_from_stdfunc() from the API.
 
 MSG:
  - Drop MSG_process_create_from_stdfunc() from the API.
index d3f2086..a0835da 100644 (file)
@@ -40,7 +40,6 @@ SG_BEGIN_DECL()
 #define MPI_MAX_OBJECT_NAME    100
 #define MPI_MAX_PORT_NAME      100
 #define MPI_MAX_LIBRARY_VERSION_STRING 100
 #define MPI_MAX_OBJECT_NAME    100
 #define MPI_MAX_PORT_NAME      100
 #define MPI_MAX_LIBRARY_VERSION_STRING 100
-#define SMPI_RAND_SEED 5
 #define MPI_ANY_SOURCE -555
 #define MPI_BOTTOM (void *)-111
 #define MPI_PROC_NULL -666
 #define MPI_ANY_SOURCE -555
 #define MPI_BOTTOM (void *)-111
 #define MPI_PROC_NULL -666
index d63e822..8f4367c 100644 (file)
@@ -661,8 +661,6 @@ static void smpi_init_privatization_no_dlopen(const std::string& executable)
 
 int smpi_main(const char* executable, int argc, char* argv[])
 {
 
 int smpi_main(const char* executable, int argc, char* argv[])
 {
-  srand(SMPI_RAND_SEED);
-
   if (getenv("SMPI_PRETEND_CC") != nullptr) {
     /* Hack to ensure that smpicc can pretend to be a simple compiler. Particularly handy to pass it to the
      * configuration tools */
   if (getenv("SMPI_PRETEND_CC") != nullptr) {
     /* Hack to ensure that smpicc can pretend to be a simple compiler. Particularly handy to pass it to the
      * configuration tools */
index a573123..826489a 100644 (file)
@@ -75,7 +75,6 @@ static BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserv
 
 static void xbt_preinit()
 {
 
 static void xbt_preinit()
 {
-  unsigned int seed = 2147483647;
 #ifdef _WIN32
   SYSTEM_INFO si;
   GetSystemInfo(&si);
 #ifdef _WIN32
   SYSTEM_INFO si;
   GetSystemInfo(&si);
@@ -95,9 +94,9 @@ static void xbt_preinit()
   xbt_log_preinit();
   xbt_dict_preinit();
 
   xbt_log_preinit();
   xbt_dict_preinit();
 
-  srand(seed);
 #ifndef _WIN32
 #ifndef _WIN32
-  srand48(seed);
+  constexpr unsigned seed = 2147483647;
+  srand48(seed); // FIXME: still worthwhile?
 #endif
   atexit(xbt_postexit);
 }
 #endif
   atexit(xbt_postexit);
 }