From 420f3c7926f73c6186636a2be9a8c57ca064e1cd Mon Sep 17 00:00:00 2001 From: navarro Date: Wed, 24 Oct 2012 08:34:01 -0700 Subject: [PATCH 1/1] Add a surf function to get configuration parameters of surf_cfg_set -> Fix windows smpi shared memory between 2 DLLs --- src/include/surf/surf.h | 5 +++++ src/smpi/smpi_base.c | 6 +++--- src/smpi/smpi_bench.c | 7 +++---- src/smpi/smpi_global.c | 2 +- src/surf/network.c | 4 ++-- src/surf/surf.c | 21 +++++++++++++++++++++ 6 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 2790a3da34..ffe8fa5ec0 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -673,6 +673,11 @@ XBT_PUBLIC_DATA(xbt_dynar_t) model_list; /*** SURF Globals **************************/ /*******************************************/ XBT_PUBLIC_DATA(xbt_cfg_t) _surf_cfg_set; +XBT_PUBLIC(int) surf_cfg_get_int(char* name); +XBT_PUBLIC(double) surf_cfg_get_double(char* name); +XBT_PUBLIC(char*) surf_cfg_get_string(char* name); +XBT_PUBLIC(void) surf_cfg_get_peer(const char *name, char **peer, int *port); +XBT_PUBLIC(xbt_dynar_t) surf_cfg_get_dynar(char* name); /** \ingroup SURF_simulation * \brief Initialize SURF diff --git a/src/smpi/smpi_base.c b/src/smpi/smpi_base.c index 9ad302a889..b3c0351d90 100644 --- a/src/smpi/smpi_base.c +++ b/src/smpi/smpi_base.c @@ -152,7 +152,7 @@ void smpi_mpi_start(MPI_Request request) "Cannot (re)start a non-finished communication"); if(request->flags & RECV) { print_request("New recv", request); - if (request->size < xbt_cfg_get_int(_surf_cfg_set, "smpi/async_small_thres")) + if (request->size < surf_cfg_get_int("smpi/async_small_thres")) mailbox = smpi_process_mailbox_small(); else mailbox = smpi_process_mailbox(); @@ -167,7 +167,7 @@ void smpi_mpi_start(MPI_Request request) /* return;*/ /* }*/ print_request("New send", request); - if (request->size < xbt_cfg_get_int(_surf_cfg_set, "smpi/async_small_thres")) { // eager mode + if (request->size < surf_cfg_get_int("smpi/async_small_thres")) { // eager mode mailbox = smpi_process_remote_mailbox_small(receiver); }else{ XBT_DEBUG("Send request %p is not in the permanent receive mailbox (buf: %p)",request,request->buf); @@ -440,7 +440,7 @@ void smpi_mpi_iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* print_request("New iprobe", request); // We have to test both mailboxes as we don't know if we will receive one one or another - if (xbt_cfg_get_int(_surf_cfg_set, "smpi/async_small_thres")>0){ + if (surf_cfg_get_int("smpi/async_small_thres")>0){ mailbox = smpi_process_mailbox_small(); XBT_DEBUG("trying to probe the perm recv mailbox"); request->action = simcall_comm_iprobe(mailbox, request->src, request->tag, &match_recv, (void*)request); diff --git a/src/smpi/smpi_bench.c b/src/smpi/smpi_bench.c index 58c8c5a852..cf8ac0d546 100644 --- a/src/smpi/smpi_bench.c +++ b/src/smpi/smpi_bench.c @@ -136,14 +136,13 @@ void smpi_execute_flops(double flops) { static void smpi_execute(double duration) { /* FIXME: a global variable would be less expensive to consult than a call to xbt_cfg_get_double() right on the critical path */ - if (duration >= xbt_cfg_get_double(_surf_cfg_set, "smpi/cpu_threshold")) { + if (duration >= surf_cfg_get_double("smpi/cpu_threshold")) { XBT_DEBUG("Sleep for %f to handle real computation time", duration); smpi_execute_flops(duration * - xbt_cfg_get_double(_surf_cfg_set, - "smpi/running_power")); + surf_cfg_get_double("smpi/running_power")); } else { XBT_DEBUG("Real computation took %f while option smpi/cpu_threshold is set to %f => ignore it", - duration, xbt_cfg_get_double(_surf_cfg_set, "smpi/cpu_threshold")); + duration, surf_cfg_get_double("smpi/cpu_threshold")); } } diff --git a/src/smpi/smpi_global.c b/src/smpi/smpi_global.c index 8c02fb48b3..a6ca1dc21a 100644 --- a/src/smpi/smpi_global.c +++ b/src/smpi/smpi_global.c @@ -358,7 +358,7 @@ int MAIN__(void) else SIMIX_run(); - if (xbt_cfg_get_int(_surf_cfg_set, "smpi/display_timing")) + if (surf_cfg_get_int("smpi/display_timing")) XBT_INFO("Simulation time: %g seconds.", SIMIX_get_clock()); smpi_global_destroy(); diff --git a/src/surf/network.c b/src/surf/network.c index e295c736cb..b6f836bcce 100644 --- a/src/surf/network.c +++ b/src/surf/network.c @@ -118,7 +118,7 @@ static double smpi_bandwidth_factor(double size) { if (!smpi_bw_factor) smpi_bw_factor = - parse_factor(xbt_cfg_get_string(_surf_cfg_set, "smpi/bw_factor")); + parse_factor(surf_cfg_get_string("smpi/bw_factor")); unsigned int iter = 0; s_smpi_factor_t fact; @@ -139,7 +139,7 @@ static double smpi_latency_factor(double size) { if (!smpi_lat_factor) smpi_lat_factor = - parse_factor(xbt_cfg_get_string(_surf_cfg_set, "smpi/lat_factor")); + parse_factor(surf_cfg_get_string("smpi/lat_factor")); unsigned int iter = 0; s_smpi_factor_t fact; diff --git a/src/surf/surf.c b/src/surf/surf.c index 136390ed33..b6aaa569a5 100644 --- a/src/surf/surf.c +++ b/src/surf/surf.c @@ -55,6 +55,26 @@ static const char *disk_drives_letter_table[MAX_DRIVE] = { }; #endif /* #ifdef _XBT_WIN32 */ +int surf_cfg_get_int(char* name) +{ + return xbt_cfg_get_int(_surf_cfg_set,name); +} +double surf_cfg_get_double(char* name) +{ + return xbt_cfg_get_double(_surf_cfg_set,name); +} +char* surf_cfg_get_string(char* name) +{ + return xbt_cfg_get_string(_surf_cfg_set,name); +} +void surf_cfg_get_peer(const char *name, char **peer, int *port) +{ + xbt_cfg_get_peer(_surf_cfg_set,name, peer, port); +} +xbt_dynar_t surf_cfg_get_dynar(char* name) +{ + return xbt_cfg_get_dynar(_surf_cfg_set,name); +} /* * Returns the initial path. On Windows the initial path is * the current directory for the current process in the other @@ -425,6 +445,7 @@ void surf_init(int *argc, char **argv) history = tmgr_history_new(); surf_config_init(argc, argv); + surf_action_init(); if (MC_is_active()) MC_memory_init(); -- 2.20.1