Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add the properties as argument to NetZoneImpl->createHost
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 12 Jan 2017 16:53:02 +0000 (17:53 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 14 Jan 2017 00:54:17 +0000 (01:54 +0100)
This allows to incorporate the onHostCreation to that function instead
of having each host creator specifying that they just created an host

This was mandatory because the plugin energy needs the properties to
be setup when the signal is called.

src/kernel/routing/NetZoneImpl.cpp
src/kernel/routing/NetZoneImpl.hpp
src/s4u/s4u_host.cpp
src/surf/sg_platf.cpp

index b48032b..d4637b3 100644 (file)
@@ -42,7 +42,8 @@ NetZoneImpl::~NetZoneImpl()
   simgrid::s4u::Engine::instance()->netcardUnregister(netcard_);
 }
 
   simgrid::s4u::Engine::instance()->netcardUnregister(netcard_);
 }
 
-simgrid::s4u::Host* NetZoneImpl::createHost(const char* name, std::vector<double>* speedPerPstate, int coreAmount)
+simgrid::s4u::Host* NetZoneImpl::createHost(const char* name, std::vector<double>* speedPerPstate, int coreAmount,
+                                            std::unordered_map<std::string, std::string>* props)
 {
   simgrid::s4u::Host* res = new simgrid::s4u::Host(name);
 
 {
   simgrid::s4u::Host* res = new simgrid::s4u::Host(name);
 
@@ -53,6 +54,12 @@ simgrid::s4u::Host* NetZoneImpl::createHost(const char* name, std::vector<double
 
   surf_cpu_model_pm->createCpu(res, speedPerPstate, coreAmount);
 
 
   surf_cpu_model_pm->createCpu(res, speedPerPstate, coreAmount);
 
+  if (props != nullptr)
+    for (auto kv : *props)
+      res->setProperty(kv.first.c_str(), kv.second.c_str());
+
+  simgrid::s4u::Host::onCreation(*res);
+
   return res;
 }
 
   return res;
 }
 
index ef725ab..bac785d 100644 (file)
@@ -58,7 +58,8 @@ protected:
 
 public:
   /** @brief Make an host within that NetZone */
 
 public:
   /** @brief Make an host within that NetZone */
-  simgrid::s4u::Host* createHost(const char* name, std::vector<double>* speedPerPstate, int coreAmount);
+  simgrid::s4u::Host* createHost(const char* name, std::vector<double>* speedPerPstate, int coreAmount,
+                                 std::unordered_map<std::string, std::string>* props);
   /** @brief Creates a new route in this NetZone */
   void addBypassRoute(sg_platf_route_cbarg_t e_route) override;
 
   /** @brief Creates a new route in this NetZone */
   void addBypassRoute(sg_platf_route_cbarg_t e_route) override;
 
index e58eead..bffb071 100644 (file)
@@ -46,6 +46,7 @@ Host::Host(const char* name)
 {
   xbt_assert(Host::by_name_or_null(name) == nullptr, "Refusing to create a second host named '%s'.", name);
   host_list[name_] = this;
 {
   xbt_assert(Host::by_name_or_null(name) == nullptr, "Refusing to create a second host named '%s'.", name);
   host_list[name_] = this;
+  new simgrid::surf::HostImpl(this, nullptr);
 }
 
 Host::~Host()
 }
 
 Host::~Host()
index 49897a1..3271fc0 100644 (file)
@@ -65,20 +65,22 @@ void sg_platf_exit() {
 /** @brief Add an host to the current AS */
 void sg_platf_new_host(sg_platf_host_cbarg_t args)
 {
 /** @brief Add an host to the current AS */
 void sg_platf_new_host(sg_platf_host_cbarg_t args)
 {
-  simgrid::s4u::Host* host = routing_get_current()->createHost(args->id, &args->speed_per_pstate, args->core_amount);
-
-  new simgrid::surf::HostImpl(host, mount_list);
-  xbt_lib_set(storage_lib, args->id, ROUTING_STORAGE_HOST_LEVEL, static_cast<void*>(mount_list));
-  mount_list = nullptr;
-
+  std::unordered_map<std::string, std::string> props;
   if (args->properties) {
     xbt_dict_cursor_t cursor=nullptr;
     char *key,*data;
     xbt_dict_foreach (args->properties, cursor, key, data)
   if (args->properties) {
     xbt_dict_cursor_t cursor=nullptr;
     char *key,*data;
     xbt_dict_foreach (args->properties, cursor, key, data)
-      host->setProperty(key, data);
+      props[key] = data;
     xbt_dict_free(&args->properties);
   }
 
     xbt_dict_free(&args->properties);
   }
 
+  simgrid::s4u::Host* host =
+      routing_get_current()->createHost(args->id, &args->speed_per_pstate, args->core_amount, &props);
+
+  host->pimpl_->storage_ = mount_list;
+  xbt_lib_set(storage_lib, args->id, ROUTING_STORAGE_HOST_LEVEL, static_cast<void*>(mount_list));
+  mount_list = nullptr;
+
   /* Change from the defaults */
   if (args->state_trace)
     host->pimpl_cpu->setStateTrace(args->state_trace);
   /* Change from the defaults */
   if (args->state_trace)
     host->pimpl_cpu->setStateTrace(args->state_trace);
@@ -89,8 +91,6 @@ void sg_platf_new_host(sg_platf_host_cbarg_t args)
   if (args->coord && strcmp(args->coord, ""))
     new simgrid::kernel::routing::vivaldi::Coords(host->pimpl_netcard, args->coord);
 
   if (args->coord && strcmp(args->coord, ""))
     new simgrid::kernel::routing::vivaldi::Coords(host->pimpl_netcard, args->coord);
 
-  simgrid::s4u::Host::onCreation(*host);
-
   if (TRACE_is_enabled() && TRACE_needs_platform())
     sg_instr_new_host(*host);
 }
   if (TRACE_is_enabled() && TRACE_needs_platform())
     sg_instr_new_host(*host);
 }
@@ -555,10 +555,9 @@ void sg_platf_new_peer(sg_platf_peer_cbarg_t peer)
 
   std::vector<double> speedPerPstate;
   speedPerPstate.push_back(peer->speed);
 
   std::vector<double> speedPerPstate;
   speedPerPstate.push_back(peer->speed);
-  simgrid::s4u::Host* host = as->createHost(peer->id, &speedPerPstate, 1);
+  simgrid::s4u::Host* host = as->createHost(peer->id, &speedPerPstate, 1, nullptr);
 
   as->setPeerLink(host->pimpl_netcard, peer->bw_in, peer->bw_out, peer->coord);
 
   as->setPeerLink(host->pimpl_netcard, peer->bw_in, peer->bw_out, peer->coord);
-  simgrid::s4u::Host::onCreation(*host);
 
   /* Change from the defaults */
   if (peer->state_trace)
 
   /* Change from the defaults */
   if (peer->state_trace)