Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a command-line option to choose the routing schema to use
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 2 Jul 2009 08:00:10 +0000 (08:00 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 2 Jul 2009 08:00:10 +0000 (08:00 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6440 48e7efb5-ca39-0410-a469-dd3cf9ba447f

ChangeLog
src/surf/network.c
src/surf/surf_config.c
src/surf/surf_private.h
src/surf/surf_routing.c
src/surf/workstation_ptask_L07.c

index 898566b..3a73949 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,7 @@ SimGrid (3.3.2-svn) unstable; urgency=low
     => kill now useless network_card concept
     - Use dynar to represent routes (instead of void** + int*)
     - kill link_set (use surf_network_model->resource_set instead)
     => kill now useless network_card concept
     - Use dynar to represent routes (instead of void** + int*)
     - kill link_set (use surf_network_model->resource_set instead)
+    - Add a command-line option to choose the routing schema to use
 
   * Simplify model declaration
     (less redirections, less function to write when defining a model)
 
   * Simplify model declaration
     (less redirections, less function to write when defining a model)
index 6a6984b..c5b61f6 100644 (file)
@@ -514,7 +514,7 @@ static void surf_network_model_init_internal(void)
   if (!network_maxmin_system)
     network_maxmin_system = lmm_system_new();
 
   if (!network_maxmin_system)
     network_maxmin_system = lmm_system_new();
 
-  routing_model_full_create(sizeof(link_CM02_t),
+  routing_model_create(sizeof(link_CM02_t),
       link_new(xbt_strdup("__loopback__"),
           498000000, NULL, 0.000015, NULL,
           SURF_LINK_ON, NULL, SURF_LINK_FATPIPE, NULL));
       link_new(xbt_strdup("__loopback__"),
           498000000, NULL, 0.000015, NULL,
           SURF_LINK_ON, NULL, SURF_LINK_FATPIPE, NULL));
index 096bd61..7533ba2 100644 (file)
@@ -122,18 +122,6 @@ void surf_config_init(int *argc, char **argv)
     char *description = xbt_malloc(1024), *p = description;
     char *default_value;
     int i;
     char *description = xbt_malloc(1024), *p = description;
     char *default_value;
     int i;
-    sprintf(description,
-            "The model to use for the workstation. Possible values: ");
-    while (*(++p) != '\0');
-    for (i = 0; surf_workstation_model_description[i].name; i++)
-      p +=
-        sprintf(p, "%s%s", (i == 0 ? "" : ", "),
-                surf_workstation_model_description[i].name);
-    default_value = xbt_strdup("CLM03");
-    xbt_cfg_register(&_surf_cfg_set,
-                     "workstation_model", description, xbt_cfgelm_string,
-                     &default_value, 1, 1, &_surf_cfg_cb__workstation_model,
-                     NULL);
 
     sprintf(description, "The model to use for the CPU. Possible values: ");
     p = description;
 
     sprintf(description, "The model to use for the CPU. Possible values: ");
     p = description;
@@ -160,8 +148,29 @@ void surf_config_init(int *argc, char **argv)
                      "network_model", description, xbt_cfgelm_string,
                      &default_value, 1, 1, &_surf_cfg_cb__network_model,
                      NULL);
                      "network_model", description, xbt_cfgelm_string,
                      &default_value, 1, 1, &_surf_cfg_cb__network_model,
                      NULL);
+
+    sprintf(description,
+            "The model to use for the workstation. Possible values: ");
+    p = description;
+    while (*(++p) != '\0');
+    for (i = 0; surf_workstation_model_description[i].name; i++)
+      p +=
+        sprintf(p, "%s%s", (i == 0 ? "" : ", "),
+                surf_workstation_model_description[i].name);
+    default_value = xbt_strdup("CLM03");
+    xbt_cfg_register(&_surf_cfg_set,
+                     "workstation_model", description, xbt_cfgelm_string,
+                     &default_value, 1, 1, &_surf_cfg_cb__workstation_model,
+                     NULL);
+
     xbt_free(description);
 
     xbt_free(description);
 
+    default_value = xbt_strdup("Full");
+    xbt_cfg_register(&_surf_cfg_set, "routing",
+                     "Model to use to store the routing information",
+                     xbt_cfgelm_string, &default_value, 0, 0, NULL,
+                     NULL);
+
     xbt_cfg_register(&_surf_cfg_set, "TCP_gamma",
                      "Size of the biggest TCP window", xbt_cfgelm_double,
                      NULL, 1, 1, _surf_cfg_cb__tcp_gamma, NULL);
     xbt_cfg_register(&_surf_cfg_set, "TCP_gamma",
                      "Size of the biggest TCP window", xbt_cfgelm_double,
                      NULL, 1, 1, _surf_cfg_cb__tcp_gamma, NULL);
@@ -181,6 +190,7 @@ void surf_config_init(int *argc, char **argv)
       xbt_cfg_set_string(_surf_cfg_set, "path", initial_path);
     }
 
       xbt_cfg_set_string(_surf_cfg_set, "path", initial_path);
     }
 
+
     surf_config_cmd_line(argc, argv);
   }
 }
     surf_config_cmd_line(argc, argv);
   }
 }
index 95b0cf3..bd93581 100644 (file)
@@ -96,6 +96,6 @@ struct s_routing {
   void (*finalize)(void);
   int host_count;
 };
   void (*finalize)(void);
   int host_count;
 };
-XBT_PUBLIC(routing_t) routing_model_full_create(size_t size_of_link,void *loopback);
+XBT_PUBLIC(void) routing_model_create(size_t size_of_link,void *loopback);
 
 #endif /* _SURF_SURF_PRIVATE_H */
 
 #endif /* _SURF_SURF_PRIVATE_H */
index c46d312..1ed0b66 100644 (file)
@@ -6,19 +6,51 @@
 #include "surf_private.h"
 #include "xbt/dynar.h"
 #include "xbt/str.h"
 #include "surf_private.h"
 #include "xbt/dynar.h"
 #include "xbt/str.h"
+#include "xbt/config.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route,surf,"Routing part of surf");// FIXME: connect this under windows
 
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route,surf,"Routing part of surf");// FIXME: connect this under windows
 
+routing_t used_routing = NULL;
+
+/* Prototypes of each model */
+static void routing_model_full_create(size_t size_of_link,void *loopback);
+
+/* Definition of each model */
+struct model_type {
+  const char *name;
+  const char *desc;
+  void (*fun)(size_t,void*);
+};
+struct model_type models[] =
+{ {"Full", "Full routing data (fast, large memory requirements, fully expressive)", routing_model_full_create },
+    {NULL,NULL}};
+
+
+void routing_model_create(size_t size_of_links, void* loopback) {
+
+  char * wanted=xbt_cfg_get_string(_surf_cfg_set,"routing");
+  int cpt;
+  for (cpt=0;models[cpt].name;cpt++) {
+    if (!strcmp(wanted,models[cpt].name)) {
+      (*(models[cpt].fun))(size_of_links,loopback);
+      return;
+    }
+  }
+  fprintf(stderr,"Routing model %s not found. Existing models:\n",wanted);
+  for (cpt=0;models[cpt].name;cpt++)
+    if (!strcmp(wanted,models[cpt].name))
+      fprintf(stderr,"   %s: %s\n",models[cpt].name,models[cpt].desc);
+  exit(1);
+}
+
+/* ************************************************************************** */
+/* *************************** FULL ROUTING ********************************* */
 typedef struct {
   s_routing_t generic_routing;
   xbt_dynar_t *routing_table;
   void *loopback;
   size_t size_of_link;
 typedef struct {
   s_routing_t generic_routing;
   xbt_dynar_t *routing_table;
   void *loopback;
   size_t size_of_link;
-}s_routing_full_t,*routing_full_t;
-
-routing_t used_routing = NULL;
-/* ************************************************************************** */
-/* *************************** FULL ROUTING ********************************* */
+} s_routing_full_t,*routing_full_t;
 
 #define ROUTE_FULL(i,j) ((routing_full_t)used_routing)->routing_table[(i)+(j)*(used_routing)->host_count]
 
 
 #define ROUTE_FULL(i,j) ((routing_full_t)used_routing)->routing_table[(i)+(j)*(used_routing)->host_count]
 
@@ -124,26 +156,24 @@ static void routing_full_finalize(void) {
   }
 }
 
   }
 }
 
-routing_t routing_model_full_create(size_t size_of_link,void *loopback) {
+static void routing_model_full_create(size_t size_of_link,void *loopback) {
   /* initialize our structure */
   /* initialize our structure */
-  routing_full_t res = xbt_new0(s_routing_full_t,1);
-  res->generic_routing.name = "Full";
-  res->generic_routing.host_count = 0;
-  res->generic_routing.get_route = routing_full_get_route;
-  res->generic_routing.finalize = routing_full_finalize;
-  res->size_of_link = size_of_link;
-  res->loopback = loopback;
+  routing_full_t routing = xbt_new0(s_routing_full_t,1);
+  routing->generic_routing.name = "Full";
+  routing->generic_routing.host_count = 0;
+  routing->generic_routing.get_route = routing_full_get_route;
+  routing->generic_routing.finalize = routing_full_finalize;
+  routing->size_of_link = size_of_link;
+  routing->loopback = loopback;
 
   /* Set it in position */
 
   /* Set it in position */
-  used_routing = (routing_t) res;
+  used_routing = (routing_t) routing;
 
   /* Setup the parsing callbacks we need */
 
   /* Setup the parsing callbacks we need */
-  used_routing->host_id = xbt_dict_new();
+  routing->generic_routing.host_id = xbt_dict_new();
   surfxml_add_callback(STag_surfxml_host_cb_list, &routing_full_parse_Shost);
   surfxml_add_callback(ETag_surfxml_platform_cb_list, &routing_full_parse_end);
   surfxml_add_callback(STag_surfxml_route_cb_list,
   surfxml_add_callback(STag_surfxml_host_cb_list, &routing_full_parse_Shost);
   surfxml_add_callback(ETag_surfxml_platform_cb_list, &routing_full_parse_end);
   surfxml_add_callback(STag_surfxml_route_cb_list,
-                       &routing_full_parse_Sroute_set_endpoints);
+      &routing_full_parse_Sroute_set_endpoints);
   surfxml_add_callback(ETag_surfxml_route_cb_list, &routing_full_parse_Eroute);
   surfxml_add_callback(ETag_surfxml_route_cb_list, &routing_full_parse_Eroute);
-
-  return used_routing;
 }
 }
index 1256da6..a1b38fa 100644 (file)
@@ -845,8 +845,8 @@ static void model_init_internal(void)
   if (!ptask_maxmin_system)
     ptask_maxmin_system = lmm_system_new();
 
   if (!ptask_maxmin_system)
     ptask_maxmin_system = lmm_system_new();
 
-  routing_model_full_create(sizeof(link_L07_t),
-        link_new(xbt_strdup("__MSG_loopback__"),
+  routing_model_create(sizeof(link_L07_t),
+        link_new(xbt_strdup("__loopback__"),
             498000000, NULL, 0.000015, NULL,
             SURF_LINK_ON, NULL, SURF_LINK_FATPIPE, NULL));
 
             498000000, NULL, 0.000015, NULL,
             SURF_LINK_ON, NULL, SURF_LINK_FATPIPE, NULL));