Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Platform generation can now be used with MSG
authorJean-Baptiste Hervé <jean-baptiste.herve@esial.net>
Fri, 3 Aug 2012 12:00:49 +0000 (14:00 +0200)
committerJean-Baptiste Hervé <jean-baptiste.herve@esial.net>
Fri, 3 Aug 2012 12:00:49 +0000 (14:00 +0200)
Some stuff had to be done by SIMIX and MSG right after the XML platform parsing. It is now done by callbacks, registered in SURF at initialization. So that stuff is also done when you create a random platform with the generator.
Add some ugly code to avoid the deletion of these registered callbacks before the parsing.

src/msg/msg_environment.c
src/msg/msg_global.c
src/msg/msg_private.h
src/simix/smx_environment.c
src/simix/smx_global.c
src/simix/smx_private.h
src/surf/platf_generator.c
src/surf/sg_platf.c
src/surf/surfxml_parseplatf.c

index 5814f78..eb889cb 100644 (file)
  */
 void MSG_create_environment(const char *file)
 {
  */
 void MSG_create_environment(const char *file)
 {
+  SIMIX_create_environment(file);
+}
+
+void MSG_post_create_environment(void) {
   xbt_lib_cursor_t cursor;
   void **data;
   char *name;
 
   xbt_lib_cursor_t cursor;
   void **data;
   char *name;
 
-  SIMIX_create_environment(file);
-
   /* Initialize MSG hosts */
   xbt_lib_foreach(host_lib, cursor, name, data) {
     if(data[SIMIX_HOST_LEVEL])
   /* Initialize MSG hosts */
   xbt_lib_foreach(host_lib, cursor, name, data) {
     if(data[SIMIX_HOST_LEVEL])
index 16f3507..dc424fc 100644 (file)
@@ -59,6 +59,8 @@ void MSG_init_nocheck(int *argc, char **argv) {
 
     SIMIX_function_register_process_create(MSG_process_create_from_SIMIX);
     SIMIX_function_register_process_cleanup(MSG_process_cleanup_from_SIMIX);
 
     SIMIX_function_register_process_create(MSG_process_create_from_SIMIX);
     SIMIX_function_register_process_cleanup(MSG_process_cleanup_from_SIMIX);
+
+    sg_platf_postparse_add_cb(MSG_post_create_environment);
   }
 #ifdef HAVE_TRACING
   TRACE_start();
   }
 #ifdef HAVE_TRACING
   TRACE_start();
index 97af923..6c95445 100644 (file)
@@ -153,5 +153,7 @@ void MSG_comm_copy_data_from_SIMIX(smx_action_t comm, void* buff, size_t buff_si
 void _MSG_action_init(void);
 void _MSG_action_exit(void);
 
 void _MSG_action_init(void);
 void _MSG_action_exit(void);
 
+void MSG_post_create_environment(void);
+
 SG_END_DECL()
 #endif
 SG_END_DECL()
 #endif
index 76c1e32..dd4709a 100644 (file)
@@ -33,10 +33,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_environment, simix,
  */
 void SIMIX_create_environment(const char *file)
 {
  */
 void SIMIX_create_environment(const char *file)
 {
-  xbt_lib_cursor_t cursor = NULL;
-  char *name = NULL;
-  void **workstation = NULL;
-
   double start, end;
 
   start = xbt_os_time();
   double start, end;
 
   start = xbt_os_time();
@@ -44,6 +40,14 @@ void SIMIX_create_environment(const char *file)
   end = xbt_os_time();
   XBT_DEBUG("PARSE TIME: %lg", (end - start));
 
   end = xbt_os_time();
   XBT_DEBUG("PARSE TIME: %lg", (end - start));
 
+}
+
+void SIMIX_post_create_environment(void) {
+
+  void **workstation = NULL;
+  xbt_lib_cursor_t cursor = NULL;
+  char *name = NULL;
+
   xbt_lib_foreach(host_lib, cursor, name, workstation) {
     if(workstation[SURF_WKS_LEVEL])
       SIMIX_host_create(name, workstation[SURF_WKS_LEVEL], NULL);
   xbt_lib_foreach(host_lib, cursor, name, workstation) {
     if(workstation[SURF_WKS_LEVEL])
       SIMIX_host_create(name, workstation[SURF_WKS_LEVEL], NULL);
index db0f051..57020ba 100644 (file)
@@ -95,6 +95,11 @@ void SIMIX_global_init(int *argc, char **argv)
 
     /* Prepare to display some more info when dying on Ctrl-C pressing */
     signal(SIGINT, inthandler);
 
     /* Prepare to display some more info when dying on Ctrl-C pressing */
     signal(SIGINT, inthandler);
+
+    /* register a function to be called by SURF after the environment creation */
+    sg_platf_init();
+    sg_platf_postparse_add_cb(SIMIX_post_create_environment);
+
   }
   if (!simix_timers) {
     simix_timers = xbt_heap_new(8, &free);
   }
   if (!simix_timers) {
     simix_timers = xbt_heap_new(8, &free);
index 8dcf056..88bd7b7 100644 (file)
@@ -309,4 +309,7 @@ static XBT_INLINE void* SIMIX_context_get_data(smx_context_t context)
 }
 
 XBT_PUBLIC(int) SIMIX_process_get_maxpid(void);
 }
 
 XBT_PUBLIC(int) SIMIX_process_get_maxpid(void);
+
+void SIMIX_post_create_environment(void);
+
 #endif
 #endif
index 895e9f8..0726ae8 100644 (file)
@@ -383,7 +383,6 @@ void platf_generate(void) {
 
   nodes = xbt_graph_get_nodes(platform_graph);
 
 
   nodes = xbt_graph_get_nodes(platform_graph);
 
-  sg_platf_init();
   sg_platf_begin();
   surf_parse_init_callbacks();
   routing_register_callbacks();
   sg_platf_begin();
   surf_parse_init_callbacks();
   routing_register_callbacks();
index 874a000..0e4060f 100644 (file)
@@ -35,6 +35,11 @@ static RngStream sg_platf_rng_stream = NULL;
 
 /** Module management function: creates all internal data structures */
 void sg_platf_init(void) {
 
 /** Module management function: creates all internal data structures */
 void sg_platf_init(void) {
+
+  //FIXME : Ugly, but useful...
+  if(sg_platf_host_cb_list)
+    return; //Already initialized, so do nothing...
+
   sg_platf_host_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL);
   sg_platf_host_link_cb_list = xbt_dynar_new(sizeof(sg_platf_host_link_cb_t), NULL);
   sg_platf_router_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL);
   sg_platf_host_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL);
   sg_platf_host_link_cb_list = xbt_dynar_new(sizeof(sg_platf_host_link_cb_t), NULL);
   sg_platf_router_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL);
index 9555060..631c6de 100644 (file)
@@ -134,7 +134,7 @@ void parse_platform_file(const char *file)
 {
   int parse_status;
 
 {
   int parse_status;
 
-  surf_parse_reset_callbacks();
+  surf_parse_init_callbacks();
 
   /* Register classical callbacks */
   surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties);
 
   /* Register classical callbacks */
   surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties);