Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[surf] Use the pointers to simgrid::Host instead of looking by name
authorGabriel Corona <gabriel.corona@loria.fr>
Thu, 17 Dec 2015 13:56:57 +0000 (14:56 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Thu, 17 Dec 2015 16:14:31 +0000 (17:14 +0100)
src/surf/cpu_interface.hpp
src/surf/host_interface.hpp
src/surf/host_ptask_L07.cpp
src/surf/network_ns3.cpp
src/surf/surf_c_bindings.cpp
src/surf/surf_routing.cpp
src/surf/virtual_machine.cpp
src/surf/vm_hl13.cpp

index 3ba667a..e28d4d3 100644 (file)
@@ -185,6 +185,8 @@ public:
   double m_speedScale;           /*< Percentage of CPU available according to the trace, in [O,1] */
   simgrid::Host* m_host = nullptr;
 
+  simgrid::Host* getHost() { return m_host; }
+
   /* Note (hypervisor): */
   lmm_constraint_t *p_constraintCore=NULL;
   void **p_constraintCoreId=NULL;
index ed143b8..5c081d2 100644 (file)
@@ -279,6 +279,7 @@ public:
   void getParams(vm_params_t params);
   /** @brief Sets the params of that VM/PM */
   void setParams(vm_params_t params);
+  simgrid::Host* getHost() { return p_host; }
 private:
   s_vm_params_t p_params;
 };
index 2f573c0..fea3be0 100644 (file)
@@ -454,7 +454,7 @@ Action *CpuL07::execute(double size)
   double *flops_amount = xbt_new0(double, 1);
   double *bytes_amount = xbt_new0(double, 1);
 
-  host_list[0] = sg_host_by_name(getName());
+  host_list[0] = getHost();
   flops_amount[0] = size;
 
   return static_cast<CpuL07Model*>(getModel())
index 84996b1..d4cb31c 100644 (file)
@@ -41,7 +41,7 @@ static void simgrid_ns3_add_host(simgrid::surf::Host* host)
 {
   const char* id = host->getName();
   XBT_DEBUG("NS3_ADD_HOST '%s'", id);
-  simgrid::Host::by_name_or_create(id)->set_facet(NS3_HOST_LEVEL, ns3_add_host(id));
+  host->getHost()->set_facet(NS3_HOST_LEVEL, ns3_add_host(id));
 }
 
 static void parse_ns3_add_link(sg_platf_link_cbarg_t link)
index 740ed9d..4b6ca5a 100644 (file)
@@ -385,8 +385,6 @@ void surf_host_set_params(sg_host_t host, vm_params_t params){
 }
 
 void surf_vm_destroy(sg_host_t resource){
-  /* Before clearing the entries in host_lib, we have to pick up resources. */
-  const char* name = resource->id().c_str();
   /* We deregister objects from host_lib, without invoking the freeing callback
    * of each level.
    *
@@ -395,8 +393,7 @@ void surf_vm_destroy(sg_host_t resource){
    */
   sg_host_surfcpu_destroy(resource);
   sg_host_edge_destroy(resource,1);
-  // TODO, use backlink from simgrid::surf::Host to simgrid::Host
-  simgrid::Host::by_name_or_null(name)->set_facet((simgrid::surf::Host*)nullptr);
+  resource->set_facet<simgrid::surf::Host>(nullptr);
 
   /* TODO: comment out when VM storage is implemented. */
   // host->set_facet(SURF_STORAGE_LEVEL, nullptr);
index b267423..4ad2e76 100644 (file)
@@ -172,7 +172,8 @@ simgrid::surf::RoutingEdge *routing_add_host(
                                                    SURF_NETWORK_ELEMENT_HOST,
                                                    current_routing);
   routingEdge->setId(current_routing->parsePU(routingEdge));
-  sg_host_edge_set(sg_host_by_name_or_create(host->id), routingEdge);
+  sg_host_t h = sg_host_by_name_or_create(host->id);
+  sg_host_edge_set(h, routingEdge);
   XBT_DEBUG("Having set name '%s' id '%d'", host->id, routingEdge->getId());
   simgrid::surf::routingEdgeCreatedCallbacks(routingEdge);
 
@@ -196,7 +197,7 @@ simgrid::surf::RoutingEdge *routing_add_host(
     }
     xbt_dynar_shrink(ctn, 0);
     xbt_dynar_free(&ctn_str);
-    simgrid::Host::by_name_or_create(host->id)->set_facet(COORD_HOST_LEVEL, (void *) ctn);
+    h->set_facet(COORD_HOST_LEVEL, (void *) ctn);
     XBT_DEBUG("Having set host coordinates for '%s'",host->id);
   }
 
index 9fc07fc..943d23e 100644 (file)
@@ -62,7 +62,7 @@ void VirtualMachine::setState(e_surf_resource_state_t state){
  **/
 sg_host_t VirtualMachine::getPm()
 {
-  return simgrid::Host::by_name_or_null(p_subWs->getName());
+  return p_subWs->getHost();
 }
 
 /**********
index 037749c..f0c0ce8 100644 (file)
@@ -340,8 +340,7 @@ void VMHL13::setAffinity(Cpu *cpu, unsigned long mask){
  **/
 sg_host_t VMHL13::getPm()
 {
-  // TODO, store pointer to the PM?
-  return simgrid::Host::by_name_or_null(p_subWs->getName());
+  return p_subWs->getHost();
 }
 
 /* Adding a task to a VM updates the VCPU task on its physical machine. */