Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a surf function to get configuration parameters of surf_cfg_set
authornavarro <pierre.navarro@imag.fr>
Wed, 24 Oct 2012 15:34:01 +0000 (08:34 -0700)
committernavarro <pierre.navarro@imag.fr>
Thu, 25 Oct 2012 17:20:55 +0000 (10:20 -0700)
-> Fix windows smpi shared memory between 2 DLLs

src/include/surf/surf.h
src/smpi/smpi_base.c
src/smpi/smpi_bench.c
src/smpi/smpi_global.c
src/surf/network.c
src/surf/surf.c

index 2790a3d..ffe8fa5 100644 (file)
@@ -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
index 9ad302a..b3c0351 100644 (file)
@@ -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);
index 58c8c5a..cf8ac0d 100644 (file)
@@ -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"));
   }
 }
 
index 8c02fb4..a6ca1dc 100644 (file)
@@ -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();
index e295c73..b6f836b 100644 (file)
@@ -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;
index 136390e..b6aaa56 100644 (file)
@@ -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();