Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[platf] Kill sg_process_cb
[simgrid.git] / src / surf / sg_platf.cpp
index 5425bc1..d476a19 100644 (file)
 #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
@@ -40,8 +41,6 @@ xbt_dynar_t sg_platf_storage_type_cb_list = NULL; // of sg_platf_storage_cb_t
 xbt_dynar_t sg_platf_mstorage_cb_list = NULL; // of sg_platf_storage_cb_t
 xbt_dynar_t sg_platf_mount_cb_list = NULL; // of sg_platf_storage_cb_t
 
-xbt_dynar_t sg_platf_process_cb_list = NULL;
-
 /* ***************************************** */
 /* TUTORIAL: New TAG                         */
 
@@ -86,8 +85,6 @@ void sg_platf_init(void) {
   sg_platf_mstorage_cb_list = xbt_dynar_new(sizeof(sg_platf_storage_cb_t), NULL);
   sg_platf_mount_cb_list = xbt_dynar_new(sizeof(sg_platf_storage_cb_t), NULL);
 
-  sg_platf_process_cb_list = xbt_dynar_new(sizeof(sg_platf_process_cb_t), NULL);
-
   /* ***************************************** */
   /* TUTORIAL: New TAG                         */
 
@@ -121,8 +118,6 @@ void sg_platf_exit(void) {
   xbt_dynar_free(&sg_platf_mstorage_cb_list);
   xbt_dynar_free(&sg_platf_mount_cb_list);
 
-  xbt_dynar_free(&sg_platf_process_cb_list);
-
   /* ***************************************** */
   /* TUTORIAL: New TAG                         */
 
@@ -134,11 +129,33 @@ void sg_platf_exit(void) {
   surf_parse_models_setup_already_called = 0;
 }
 
-void sg_platf_new_host(sg_platf_host_cbarg_t h){
+void sg_platf_new_host(sg_platf_host_cbarg_t host)
+{
+
+  xbt_assert(! sg_host_by_name(host->id),
+                    "Refusing to create a second host named '%s'.", host->id);
+
+  RoutingEdge *net = NULL;
+  As* current_routing = routing_get_current();
+  if (current_routing)
+    net = routing_add_host(current_routing, host);
+
+  Cpu *cpu = surf_cpu_model_pm->createCpu(
+        host->id,
+        host->power_peak,
+        host->pstate,
+        host->power_scale,
+        host->power_trace,
+        host->core_amount,
+        host->initial_state,
+        host->state_trace,
+        host->properties);
+  surf_host_model->createHost(host->id, net, cpu);
+
   unsigned int iterator;
   sg_platf_host_cb_t fun;
   xbt_dynar_foreach(sg_platf_host_cb_list, iterator, fun) {
-    fun(h);
+    fun(host);
   }
 }
 void sg_platf_new_host_link(sg_platf_host_link_cbarg_t h){
@@ -261,13 +278,6 @@ void sg_platf_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect) {
     fun(trace_connect);
   }
 }
-void sg_platf_new_process(sg_platf_process_cbarg_t process){
-  unsigned int iterator;
-  sg_platf_process_cb_t fun;
-  xbt_dynar_foreach(sg_platf_process_cb_list, iterator, fun) {
-    fun(process);
-  }
-}
 
 void sg_platf_route_begin (sg_platf_route_cbarg_t route){
   route->link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
@@ -421,9 +431,6 @@ void sg_platf_rng_stream_init(unsigned long seed[6]) {
   RngStream_SetPackageSeed(seed);
   sg_platf_rng_stream = RngStream_CreateStream(NULL);
 }
-void sg_platf_process_add_cb(sg_platf_process_cb_t fct) {
-  xbt_dynar_push(sg_platf_process_cb_list, &fct);
-}
 
 RngStream sg_platf_rng_stream_get(const char* id) {
   RngStream stream = NULL;