Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
code simplifications around host construction
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 16 Oct 2016 14:54:47 +0000 (16:54 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 16 Oct 2016 14:56:25 +0000 (16:56 +0200)
Storage list is passed as a parameter, not through a global dict of
storages.

src/surf/HostImpl.cpp
src/surf/HostImpl.hpp
src/surf/sg_platf.cpp

index 1185bec..c425691 100644 (file)
@@ -29,10 +29,11 @@ simgrid::xbt::Extension<simgrid::s4u::Host, HostImpl> HostImpl::EXTENSION_ID;
 /*********
  * Model *
  *********/
 /*********
  * Model *
  *********/
-HostImpl *HostModel::createHost(const char *name, kernel::routing::NetCard *netElm, Cpu *cpu){
-  xbt_dynar_t storageList = (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL);
-
+HostImpl* HostModel::createHost(const char* name, Cpu* cpu, kernel::routing::NetCard* netcard, xbt_dynar_t storageList)
+{
   HostImpl *host = new simgrid::surf::HostImpl(surf_host_model, name, storageList, cpu);
   HostImpl *host = new simgrid::surf::HostImpl(surf_host_model, name, storageList, cpu);
+  xbt_lib_set(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL, (void*)storageList);
+
   XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->storage_));
   return host;
 }
   XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->storage_));
   return host;
 }
index 32d9417..a032f6c 100644 (file)
@@ -51,7 +51,7 @@ class HostModel : public Model {
 public:
   HostModel() : Model() {}
 
 public:
   HostModel() : Model() {}
 
-  HostImpl *createHost(const char *name, kernel::routing::NetCard *net, Cpu *cpu);
+  HostImpl* createHost(const char* name, Cpu* cpu, kernel::routing::NetCard* net, xbt_dynar_t storageList);
 
   virtual void adjustWeightOfDummyCpuActions();
   virtual Action *executeParallelTask(int host_nb, sg_host_t *host_list,
 
   virtual void adjustWeightOfDummyCpuActions();
   virtual Action *executeParallelTask(int host_nb, sg_host_t *host_list,
index 59997d9..1d9ddd0 100644 (file)
@@ -72,7 +72,7 @@ void sg_platf_exit() {
   surf_parse_lex_destroy();
 }
 
   surf_parse_lex_destroy();
 }
 
-/** @brief Add an "host" to the current AS */
+/** @brief Add an host to the current AS */
 void sg_platf_new_host(sg_platf_host_cbarg_t host)
 {
   simgrid::kernel::routing::AsImpl* current_routing = routing_get_current();
 void sg_platf_new_host(sg_platf_host_cbarg_t host)
 {
   simgrid::kernel::routing::AsImpl* current_routing = routing_get_current();
@@ -85,11 +85,6 @@ void sg_platf_new_host(sg_platf_host_cbarg_t host)
   simgrid::s4u::Host* h = new simgrid::s4u::Host(host->id);
   h->pimpl_netcard = netcard;
 
   simgrid::s4u::Host* h = new simgrid::s4u::Host(host->id);
   h->pimpl_netcard = netcard;
 
-  if(mount_list) {
-    xbt_lib_set(storage_lib, host->id, ROUTING_STORAGE_HOST_LEVEL, (void *) mount_list);
-    mount_list = nullptr;
-  }
-
   if (host->coord && strcmp(host->coord, "")) {
     unsigned int cursor;
     char*str;
   if (host->coord && strcmp(host->coord, "")) {
     unsigned int cursor;
     char*str;
@@ -114,7 +109,9 @@ void sg_platf_new_host(sg_platf_host_cbarg_t host)
     cpu->setStateTrace(host->state_trace);
   if (host->speed_trace)
     cpu->setSpeedTrace(host->speed_trace);
     cpu->setStateTrace(host->state_trace);
   if (host->speed_trace)
     cpu->setSpeedTrace(host->speed_trace);
-  surf_host_model->createHost(host->id, netcard, cpu)->attach(h);
+
+  surf_host_model->createHost(host->id, cpu, netcard, mount_list)->attach(h);
+  mount_list = nullptr;
 
   if (host->properties) {
     xbt_dict_cursor_t cursor=nullptr;
 
   if (host->properties) {
     xbt_dict_cursor_t cursor=nullptr;