Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[surf] Hardcode some of the sg_platf_host callbacks
authorGabriel Corona <gabriel.corona@loria.fr>
Wed, 25 Nov 2015 09:19:16 +0000 (10:19 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Wed, 25 Nov 2015 09:27:28 +0000 (10:27 +0100)
The goal is to remove this layer of callbacks.

Moreover the order of execution of those callbacks is important.

Currently, it breaks the ability to have platform and deployment data
in the same XML however.

13 files changed:
doc/doxygen/inside_extending.doc
include/surf/surf_routing.h
src/bindings/java/surf_swig.cpp
src/surf/cpu_cas01.cpp
src/surf/cpu_ti.cpp
src/surf/host_clm03.cpp
src/surf/host_ptask_L07.cpp
src/surf/sg_platf.cpp
src/surf/surf_routing.cpp
teshsuite/simix/stack_overflow/stack_overflow.c
teshsuite/simix/stack_overflow/stack_overflow.tesh
teshsuite/simix/stack_overflow/stack_overflow.xml
teshsuite/simix/stack_overflow/stack_overflow_platform.xml [new file with mode: 0644]

index a88c6b5..17748fa 100644 (file)
@@ -44,7 +44,6 @@ void surf_cpu_model_init_plop()
 
   surf_cpu_model_pm = new CpuPlopModel();
 
 
   surf_cpu_model_pm = new CpuPlopModel();
 
-  sg_platf_host_add_cb(cpu_parse_init);
   sg_platf_postparse_add_cb(cpu_add_traces);
 
   xbt_dynar_push(model_list, &surf_cpu_model_pm);
   sg_platf_postparse_add_cb(cpu_add_traces);
 
   xbt_dynar_push(model_list, &surf_cpu_model_pm);
index ff26201..e4ddcd9 100644 (file)
@@ -37,6 +37,7 @@ XBT_PUBLIC_DATA(int) ROUTING_STORAGE_TYPE_LEVEL;   //Routing storage_type level
 void routing_AS_begin(sg_platf_AS_cbarg_t AS);
 void routing_AS_end(sg_platf_AS_cbarg_t AS);
 
 void routing_AS_begin(sg_platf_AS_cbarg_t AS);
 void routing_AS_end(sg_platf_AS_cbarg_t AS);
 
+void routing_parse_init(sg_platf_host_cbarg_t host);
 void routing_cluster_add_backbone(void* bb);
 
 SG_END_DECL()
 void routing_cluster_add_backbone(void* bb);
 
 SG_END_DECL()
index bacbfa7..f27fdf2 100644 (file)
@@ -39,7 +39,6 @@ CpuModel *java_cpu_model;
 static void java_cpu_model_init_preparse() {
   surf_cpu_model_pm = java_cpu_model;
   xbt_dynar_push(all_existing_models, &java_cpu_model);
 static void java_cpu_model_init_preparse() {
   surf_cpu_model_pm = java_cpu_model;
   xbt_dynar_push(all_existing_models, &java_cpu_model);
-  sg_platf_host_add_cb(cpu_parse_init);
 }
 
 void setCpuModel(CpuModel *cpuModel){
 }
 
 void setCpuModel(CpuModel *cpuModel){
index 3d94de9..8644a7b 100644 (file)
@@ -30,7 +30,6 @@ void surf_cpu_model_init_Cas01()
   surf_cpu_model_pm = new CpuCas01Model();
   surf_cpu_model_vm  = new CpuCas01Model();
 
   surf_cpu_model_pm = new CpuCas01Model();
   surf_cpu_model_vm  = new CpuCas01Model();
 
-  sg_platf_host_add_cb(cpu_parse_init);
   sg_platf_postparse_add_cb(cpu_add_traces);
 
   Model *model_pm = surf_cpu_model_pm;
   sg_platf_postparse_add_cb(cpu_add_traces);
 
   Model *model_pm = surf_cpu_model_pm;
index 6d2ad3e..87aac97 100644 (file)
@@ -381,7 +381,6 @@ int CpuTiTrace::binarySearch(double *array, double a, int low, int high)
 
 static void cpu_ti_define_callbacks()
 {
 
 static void cpu_ti_define_callbacks()
 {
-  sg_platf_host_add_cb(cpu_parse_init);
   sg_platf_postparse_add_cb(cpu_add_traces);
 }
 
   sg_platf_postparse_add_cb(cpu_add_traces);
 }
 
index 227855f..29118fb 100644 (file)
@@ -29,7 +29,6 @@ void surf_host_model_init_current_default(void)
 
   Model *model = surf_host_model;
   xbt_dynar_push(all_existing_models, &model);
 
   Model *model = surf_host_model;
   xbt_dynar_push(all_existing_models, &model);
-  sg_platf_host_add_cb(host_parse_init);
 }
 
 void surf_host_model_init_compound()
 }
 
 void surf_host_model_init_compound()
@@ -41,7 +40,6 @@ void surf_host_model_init_compound()
 
   Model *model = surf_host_model;
   xbt_dynar_push(all_existing_models, &model);
 
   Model *model = surf_host_model;
   xbt_dynar_push(all_existing_models, &model);
-  sg_platf_host_add_cb(host_parse_init);
 }
 
 Host *HostCLM03Model::createHost(const char *name){
 }
 
 Host *HostCLM03Model::createHost(const char *name){
index d7ff6f3..f7af590 100644 (file)
@@ -34,8 +34,6 @@ void surf_host_model_init_ptask_L07(void)
   xbt_assert(!surf_network_model, "network model type already defined");
 
   // Define the callbacks to parse the XML
   xbt_assert(!surf_network_model, "network model type already defined");
 
   // Define the callbacks to parse the XML
-  sg_platf_host_add_cb(cpu_parse_init);
-  sg_platf_host_add_cb(host_parse_init);
   sg_platf_link_add_cb(ptask_netlink_parse_init);
   sg_platf_postparse_add_cb(host_add_traces);
 
   sg_platf_link_add_cb(ptask_netlink_parse_init);
   sg_platf_postparse_add_cb(host_add_traces);
 
index 5425bc1..54229a8 100644 (file)
 #include "xbt/dict.h"
 #include "xbt/RngStream.h"
 #include "simgrid/platf_interface.h"
 #include "xbt/dict.h"
 #include "xbt/RngStream.h"
 #include "simgrid/platf_interface.h"
+#include "surf/surf_routing.h"
 
 
-extern "C" {
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse);
-}
+#include "cpu_interface.hpp"
+#include "host_interface.hpp"
 
 
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse);
 xbt_dynar_t sg_platf_host_cb_list = NULL;   // of sg_platf_host_cb_t
 xbt_dynar_t sg_platf_host_link_cb_list = NULL;   // of sg_platf_host_link_cb_t
 xbt_dynar_t sg_platf_link_cb_list = NULL;   // of sg_platf_link_cb_t
 xbt_dynar_t sg_platf_host_cb_list = NULL;   // of sg_platf_host_cb_t
 xbt_dynar_t sg_platf_host_link_cb_list = NULL;   // of sg_platf_host_link_cb_t
 xbt_dynar_t sg_platf_link_cb_list = NULL;   // of sg_platf_link_cb_t
@@ -135,6 +136,10 @@ void sg_platf_exit(void) {
 }
 
 void sg_platf_new_host(sg_platf_host_cbarg_t h){
 }
 
 void sg_platf_new_host(sg_platf_host_cbarg_t h){
+  routing_parse_init(h);
+  cpu_parse_init(h);
+  host_parse_init(h);
+
   unsigned int iterator;
   sg_platf_host_cb_t fun;
   xbt_dynar_foreach(sg_platf_host_cb_list, iterator, fun) {
   unsigned int iterator;
   sg_platf_host_cb_t fun;
   xbt_dynar_foreach(sg_platf_host_cb_list, iterator, fun) {
index 97fa809..a80a7f6 100644 (file)
@@ -110,7 +110,7 @@ struct s_model_type routing_models[] = {
 /**
  * \brief Add a "host_link" to the network element list
  */
 /**
  * \brief Add a "host_link" to the network element list
  */
-static void parse_S_host_link(sg_platf_host_link_cbarg_t host)
+static void parse_S_host(sg_platf_host_link_cbarg_t host)
 {
   RoutingEdge *info = sg_host_edge(sg_host_by_name(host->id));
   xbt_assert(info, "Host '%s' not found!", host->id);
 {
   RoutingEdge *info = sg_host_edge(sg_host_by_name(host->id));
   xbt_assert(info, "Host '%s' not found!", host->id);
@@ -140,8 +140,11 @@ static void parse_S_host_link(sg_platf_host_link_cbarg_t host)
 /**
  * \brief Add a "host" to the network element list
  */
 /**
  * \brief Add a "host" to the network element list
  */
-static void parse_S_host(sg_platf_host_cbarg_t host)
+void routing_parse_init(sg_platf_host_cbarg_t host)
 {
 {
+  if (! current_routing)
+    return;
+
   if (current_routing->p_hierarchy == SURF_ROUTING_NULL)
     current_routing->p_hierarchy = SURF_ROUTING_BASE;
   xbt_assert(!sg_host_by_name(host->id),
   if (current_routing->p_hierarchy == SURF_ROUTING_NULL)
     current_routing->p_hierarchy = SURF_ROUTING_BASE;
   xbt_assert(!sg_host_by_name(host->id),
@@ -1273,9 +1276,8 @@ static void check_disk_attachment()
 
 void routing_register_callbacks()
 {
 
 void routing_register_callbacks()
 {
-  sg_platf_host_add_cb(parse_S_host);
   sg_platf_router_add_cb(parse_S_router);
   sg_platf_router_add_cb(parse_S_router);
-  sg_platf_host_link_add_cb(parse_S_host_link);
+  sg_platf_host_link_add_cb(parse_S_host);
   sg_platf_route_add_cb(parse_E_route);
   sg_platf_ASroute_add_cb(parse_E_ASroute);
   sg_platf_bypassRoute_add_cb(parse_E_bypassRoute);
   sg_platf_route_add_cb(parse_E_route);
   sg_platf_ASroute_add_cb(parse_E_ASroute);
   sg_platf_bypassRoute_add_cb(parse_E_bypassRoute);
index 0ae6ffa..92bb770 100644 (file)
@@ -44,14 +44,14 @@ int main(int argc, char *argv[])
 {
   SIMIX_global_init(&argc, argv);
 
 {
   SIMIX_global_init(&argc, argv);
 
-  if (argc != 2) {
-    printf("Usage: %s platform_and_deployment.xml\n", argv[0]);
+  if (argc != 3) {
+    printf("Usage: %s platform.xml deployment.xml\n", argv[0]);
     exit(EXIT_FAILURE);
   }
 
   SIMIX_function_register("master", master);
   SIMIX_create_environment(argv[1]);
     exit(EXIT_FAILURE);
   }
 
   SIMIX_function_register("master", master);
   SIMIX_create_environment(argv[1]);
-  SIMIX_launch_application(argv[1]);
+  SIMIX_launch_application(argv[2]);
   SIMIX_run();
 
   return 0;
   SIMIX_run();
 
   return 0;
index aaff9b2..e7937c2 100644 (file)
@@ -1,5 +1,5 @@
 ! expect signal SIGSEGV
 ! expect signal SIGSEGV
-$ ${bindir:=.}/stack_overflow --cfg=contexts/stack_size:96 stack_overflow.xml
+$ ${bindir:=.}/stack_overflow --cfg=contexts/stack_size:96 stack_overflow_platform.xml stack_overflow.xml
 > [Tremblay:master:(0) 0.000000] [test/INFO] Launching our nice bugged recursive function...
 > Access violation detected.
 > This can result from a programming error in your code or, although less likely,
 > [Tremblay:master:(0) 0.000000] [test/INFO] Launching our nice bugged recursive function...
 > Access violation detected.
 > This can result from a programming error in your code or, although less likely,
index 8ac632a..5277d7a 100644 (file)
@@ -2,11 +2,6 @@
 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
 <platform version="3">
 
 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
 <platform version="3">
 
-  <!-- The hosts -->
-  <AS  id="AS0"  routing="Full">
-   <host id="Tremblay" power="98.095Mf"/>
-  </AS>
-
   <!-- The master process (with some arguments) -->
   <process host="Tremblay" function="master">
   </process>
   <!-- The master process (with some arguments) -->
   <process host="Tremblay" function="master">
   </process>
diff --git a/teshsuite/simix/stack_overflow/stack_overflow_platform.xml b/teshsuite/simix/stack_overflow/stack_overflow_platform.xml
new file mode 100644 (file)
index 0000000..33e7b04
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+
+  <!-- The hosts -->
+  <AS  id="AS0"  routing="Full">
+   <host id="Tremblay" power="98.095Mf"/>
+  </AS>
+
+</platform>