From a937fbd0e884f8e83c4fefce16f8989328369ac9 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 1 Mar 2019 10:44:14 +0100 Subject: [PATCH] Stop setting random seed at initialization. --- ChangeLog | 1 + include/smpi/smpi.h | 1 - src/smpi/internals/smpi_global.cpp | 2 -- src/xbt/xbt_main.cpp | 5 ++--- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index cce8b0810f..dadeec766e 100644 --- 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). + - Stop setting random seed with srand() at initialization. MSG: - Drop MSG_process_create_from_stdfunc() from the API. diff --git a/include/smpi/smpi.h b/include/smpi/smpi.h index d3f2086336..a0835daeab 100644 --- a/include/smpi/smpi.h +++ b/include/smpi/smpi.h @@ -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 SMPI_RAND_SEED 5 #define MPI_ANY_SOURCE -555 #define MPI_BOTTOM (void *)-111 #define MPI_PROC_NULL -666 diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index d63e822c17..8f4367ce50 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -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[]) { - 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 */ diff --git a/src/xbt/xbt_main.cpp b/src/xbt/xbt_main.cpp index a573123518..826489ac42 100644 --- a/src/xbt/xbt_main.cpp +++ b/src/xbt/xbt_main.cpp @@ -75,7 +75,6 @@ static BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserv static void xbt_preinit() { - unsigned int seed = 2147483647; #ifdef _WIN32 SYSTEM_INFO si; GetSystemInfo(&si); @@ -95,9 +94,9 @@ static void xbt_preinit() xbt_log_preinit(); xbt_dict_preinit(); - srand(seed); #ifndef _WIN32 - srand48(seed); + constexpr unsigned seed = 2147483647; + srand48(seed); // FIXME: still worthwhile? #endif atexit(xbt_postexit); } -- 2.20.1