Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
move the vanilla def of executeParallelTask in HostModel
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 16 Jan 2016 14:23:07 +0000 (15:23 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 16 Jan 2016 14:25:23 +0000 (15:25 +0100)
Two of the three subclasses were redefining this method to the same
content.

src/surf/host_clm03.cpp
src/surf/host_clm03.hpp
src/surf/host_interface.cpp
src/surf/host_interface.hpp
src/surf/vm_hl13.cpp
src/surf/vm_hl13.hpp

index 2987833..24f3f38 100644 (file)
@@ -72,44 +72,5 @@ void HostCLM03Model::updateActionsState(double /*now*/, double /*delta*/){
   return;
 }
 
   return;
 }
 
-Action *HostCLM03Model::executeParallelTask(int host_nb,
-                                        sg_host_t *host_list,
-                                        double *flops_amount,
-                                        double *bytes_amount,
-                                        double rate){
-#define cost_or_zero(array,pos) ((array)?(array)[pos]:0.0)
-  Action *action =NULL;
-  if ((host_nb == 1)
-      && (cost_or_zero(bytes_amount, 0) == 0.0)){
-    action = host_list[0]->pimpl_cpu->execute(flops_amount[0]);
-  } else if ((host_nb == 1)
-           && (cost_or_zero(flops_amount, 0) == 0.0)) {
-    action = surf_network_model->communicate(host_list[0]->pimpl_netcard,
-                                                host_list[0]->pimpl_netcard,
-                                                                                        bytes_amount[0], rate);
-  } else if ((host_nb == 2)
-             && (cost_or_zero(flops_amount, 0) == 0.0)
-             && (cost_or_zero(flops_amount, 1) == 0.0)) {
-    int i,nb = 0;
-    double value = 0.0;
-
-    for (i = 0; i < host_nb * host_nb; i++) {
-      if (cost_or_zero(bytes_amount, i) > 0.0) {
-        nb++;
-        value = cost_or_zero(bytes_amount, i);
-      }
-    }
-    if (nb == 1){
-      action = surf_network_model->communicate(host_list[0]->pimpl_netcard,
-                                                  host_list[1]->pimpl_netcard,
-                                                                                          value, rate);
-    }
-  } else
-    THROW_UNIMPLEMENTED;      /* This model does not implement parallel tasks for more than 2 hosts */
-#undef cost_or_zero
-  xbt_free(host_list);
-  return action;
-}
-
 }
 }
 }
 }
index 9c9c123..74bff01 100644 (file)
@@ -34,14 +34,7 @@ public:
   double shareResources(double now) override;
 
   void updateActionsState(double now, double delta) override;
   double shareResources(double now) override;
 
   void updateActionsState(double now, double delta) override;
-
-  Action *executeParallelTask(int host_nb,
-                              sg_host_t *host_list,
-                                                         double *flops_amount,
-                                                         double *bytes_amount,
-                                                         double rate) override;
 };
 };
-
 }
 }
 
 }
 }
 
index dfaaa49..34db01b 100644 (file)
@@ -75,6 +75,45 @@ void HostModel::adjustWeightOfDummyCpuActions()
   }
 }
 
   }
 }
 
+Action *HostModel::executeParallelTask(int host_nb,
+    sg_host_t *host_list,
+    double *flops_amount,
+    double *bytes_amount,
+    double rate){
+#define cost_or_zero(array,pos) ((array)?(array)[pos]:0.0)
+  Action *action =NULL;
+  if ((host_nb == 1)
+      && (cost_or_zero(bytes_amount, 0) == 0.0)){
+    action = host_list[0]->pimpl_cpu->execute(flops_amount[0]);
+  } else if ((host_nb == 1)
+           && (cost_or_zero(flops_amount, 0) == 0.0)) {
+    action = surf_network_model->communicate(host_list[0]->pimpl_netcard,
+                                         host_list[0]->pimpl_netcard,
+                       bytes_amount[0], rate);
+  } else if ((host_nb == 2)
+             && (cost_or_zero(flops_amount, 0) == 0.0)
+             && (cost_or_zero(flops_amount, 1) == 0.0)) {
+    int i,nb = 0;
+    double value = 0.0;
+
+    for (i = 0; i < host_nb * host_nb; i++) {
+      if (cost_or_zero(bytes_amount, i) > 0.0) {
+        nb++;
+        value = cost_or_zero(bytes_amount, i);
+      }
+    }
+    if (nb == 1){
+      action = surf_network_model->communicate(host_list[0]->pimpl_netcard,
+                                           host_list[1]->pimpl_netcard,
+                         value, rate);
+    }
+  } else
+    THROW_UNIMPLEMENTED;      /* This model does not implement parallel tasks for more than 2 hosts */
+#undef cost_or_zero
+  xbt_free(host_list);
+  return action;
+}
+
 /************
  * Resource *
  ************/
 /************
  * Resource *
  ************/
index 6ffdfa3..d861c9b 100644 (file)
@@ -57,10 +57,10 @@ public:
 
   virtual void adjustWeightOfDummyCpuActions();
   virtual Action *executeParallelTask(int host_nb,
 
   virtual void adjustWeightOfDummyCpuActions();
   virtual Action *executeParallelTask(int host_nb,
-                                      sg_host_t *host_list,
-                                                                         double *flops_amount,
-                                                                         double *bytes_amount,
-                                                                         double rate)=0;
+      sg_host_t *host_list,
+      double *flops_amount,
+      double *bytes_amount,
+      double rate);
 
   bool shareResourcesIsIdempotent() override {return true;}
 };
 
   bool shareResourcesIsIdempotent() override {return true;}
 };
index 2c25d80..55eaefd 100644 (file)
@@ -127,39 +127,6 @@ double VMHL13Model::shareResources(double now)
   return ret;
 }
 
   return ret;
 }
 
-Action *VMHL13Model::executeParallelTask(int host_nb,
-                                         sg_host_t *host_list,
-                                                                                double *flops_amount,
-                                                                                double *bytes_amount,
-                                                                                double rate){
-#define cost_or_zero(array,pos) ((array)?(array)[pos]:0.0)
-  if ((host_nb == 1)
-      && (cost_or_zero(bytes_amount, 0) == 0.0))
-    return host_list[0]->pimpl_cpu->execute(flops_amount[0]);
-  else if ((host_nb == 1)
-           && (cost_or_zero(flops_amount, 0) == 0.0))
-    return surf_network_model_communicate(surf_network_model, host_list[0], host_list[0],bytes_amount[0], rate);
-  else if ((host_nb == 2)
-             && (cost_or_zero(flops_amount, 0) == 0.0)
-             && (cost_or_zero(flops_amount, 1) == 0.0)) {
-    int i,nb = 0;
-    double value = 0.0;
-
-    for (i = 0; i < host_nb * host_nb; i++) {
-      if (cost_or_zero(bytes_amount, i) > 0.0) {
-        nb++;
-        value = cost_or_zero(bytes_amount, i);
-      }
-    }
-    if (nb == 1)
-      return surf_network_model_communicate(surf_network_model, host_list[0], host_list[1], value, rate);
-  }
-#undef cost_or_zero
-
-  THROW_UNIMPLEMENTED;          /* This model does not implement parallel tasks for more than 2 hosts. */
-  return NULL;
-}
-
 /************
  * Resource *
  ************/
 /************
  * Resource *
  ************/
index 04075eb..1ed2fa0 100644 (file)
@@ -36,11 +36,6 @@ public:
   VirtualMachine *createVM(const char *name, sg_host_t host_PM) override;
   double shareResources(double now);
   void adjustWeightOfDummyCpuActions() override {};
   VirtualMachine *createVM(const char *name, sg_host_t host_PM) override;
   double shareResources(double now);
   void adjustWeightOfDummyCpuActions() override {};
-  Action *executeParallelTask(int host_nb,
-                              sg_host_t *host_list,
-                                                         double *flops_amount,
-                                                         double *bytes_amount,
-                                                         double rate) override;
   void updateActionsState(double /*now*/, double /*delta*/) override;
 };
 
   void updateActionsState(double /*now*/, double /*delta*/) override;
 };