Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics
[simgrid.git] / src / surf / host_ptask_L07.cpp
index 5f77143..298496a 100644 (file)
@@ -202,10 +202,9 @@ L07Action::L07Action(Model *model, int host_nb,
   int nb_used_host = 0; /* Only the hosts with something to compute (>0 flops) are counted) */
   double latency = 0.0;
 
-
   this->p_netcardList->reserve(host_nb);
   for (int i = 0; i<host_nb; i++)
-         this->p_netcardList->push_back(host_list[i]->pimpl_netcard);
+    this->p_netcardList->push_back(host_list[i]->pimpl_netcard);
 
   /* Compute the number of affected resources... */
   if(bytes_amount != NULL) {
@@ -213,20 +212,17 @@ L07Action::L07Action(Model *model, int host_nb,
 
     for (int i = 0; i < host_nb; i++) {
       for (int j = 0; j < host_nb; j++) {
-        xbt_dynar_t route=NULL;
 
         if (bytes_amount[i * host_nb + j] > 0) {
           double lat=0.0;
-          unsigned int cpt;
-          void *_link;
-          LinkL07 *link;
+          xbt_dynar_t route=NULL;
 
-          routing_platf->getRouteAndLatency((*this->p_netcardList)[i], (*this->p_netcardList)[j],
-                                                        &route, &lat);
+          routing_platf->getRouteAndLatency((*p_netcardList)[i], (*p_netcardList)[j], &route, &lat);
           latency = MAX(latency, lat);
 
+          void *_link;
           xbt_dynar_foreach(route, cpt, _link) {
-            link = static_cast<LinkL07*>(_link);
+            LinkL07 *link = static_cast<LinkL07*>(_link);
             xbt_dict_set(ptask_parallel_task_link_set, link->getName(), link, NULL);
           }
         }
@@ -261,15 +257,15 @@ L07Action::L07Action(Model *model, int host_nb,
   if(bytes_amount != NULL) {
     for (int i = 0; i < host_nb; i++) {
       for (int j = 0; j < host_nb; j++) {
-        void *_link;
 
         xbt_dynar_t route=NULL;
         if (bytes_amount[i * host_nb + j] == 0.0)
           continue;
 
-        routing_platf->getRouteAndLatency((*this->p_netcardList)[i], (*this->p_netcardList)[j],
+        routing_platf->getRouteAndLatency((*p_netcardList)[i], (*p_netcardList)[j],
                                                     &route, NULL);
 
+        void *_link;
         xbt_dynar_foreach(route, cpt, _link) {
           LinkL07 *link = static_cast<LinkL07*>(_link);
           lmm_expand_add(model->getMaxminSystem(), link->getConstraint(),
@@ -283,6 +279,7 @@ L07Action::L07Action(Model *model, int host_nb,
     this->setCost(1.0);
     this->setRemains(0.0);
   }
+  xbt_free(host_list);
 }
 
 Action *NetworkL07Model::communicate(NetCard *src, NetCard *dst,
@@ -340,28 +337,18 @@ void HostL07Model::addTraces()
   xbt_dict_cursor_t cursor = NULL;
   char *trace_name, *elm;
 
-  if (!trace_connect_list_host_avail)
+  if (!trace_connect_list_host_speed)
     return;
 
   /* Connect traces relative to cpu */
-  xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
-    tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuL07 *host = static_cast<CpuL07*>(sg_host_by_name(elm)->pimpl_cpu);
-
-    xbt_assert(host, "Host %s undefined", elm);
-    xbt_assert(trace, "Trace %s undefined", trace_name);
-
-    host->p_stateEvent = future_evt_set->add_trace(trace, 0.0, host);
-  }
-
-  xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
+  xbt_dict_foreach(trace_connect_list_host_speed, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    CpuL07 *host = static_cast<CpuL07*>(sg_host_by_name(elm)->pimpl_cpu);
+    Cpu *cpu = sg_host_by_name(elm)->pimpl_cpu;
 
-    xbt_assert(host, "Host %s undefined", elm);
+    xbt_assert(cpu, "Host %s undefined", elm);
     xbt_assert(trace, "Trace %s undefined", trace_name);
 
-    host->p_speedEvent = future_evt_set->add_trace(trace, 0.0, host);
+    cpu->set_speed_trace(trace);
   }
 
   /* Connect traces relative to network */
@@ -375,7 +362,7 @@ void HostL07Model::addTraces()
     link->p_stateEvent = future_evt_set->add_trace(trace, 0.0, link);
   }
 
-  xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
+  xbt_dict_foreach(trace_connect_list_link_bw, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
     LinkL07 *link = static_cast<LinkL07*>(Link::byName(elm));
 
@@ -385,7 +372,7 @@ void HostL07Model::addTraces()
     link->p_bwEvent = future_evt_set->add_trace(trace, 0.0, link);
   }
 
-  xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
+  xbt_dict_foreach(trace_connect_list_link_lat, cursor, trace_name, elm) {
     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
     LinkL07 *link = static_cast<LinkL07*>(Link::byName(elm));
 
@@ -561,6 +548,7 @@ void LinkL07::updateLatency(double value, double date)
  **********/
 
 L07Action::~L07Action(){
+  delete p_netcardList;
   free(p_communicationAmount);
   free(p_computationAmount);
 }
@@ -604,7 +592,7 @@ int L07Action::unref()
   m_refcount--;
   if (!m_refcount) {
     if (action_hook.is_linked())
-         p_stateSet->erase(p_stateSet->iterator_to(*this));
+      p_stateSet->erase(p_stateSet->iterator_to(*this));
     if (getVariable())
       lmm_variable_free(getModel()->getMaxminSystem(), getVariable());
     delete this;