Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove Host::communicate() (use network instead)
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 20 Jul 2015 20:39:48 +0000 (22:39 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 20 Jul 2015 20:39:52 +0000 (22:39 +0200)
This is my latest attempt to untangle things in surf: empty the Host
class and move everything to network/cpu/storage instead.

12 files changed:
src/include/surf/surf.h
src/simix/smx_network.c
src/surf/host_clm03.cpp
src/surf/host_clm03.hpp
src/surf/host_interface.hpp
src/surf/host_ptask_L07.cpp
src/surf/host_ptask_L07.hpp
src/surf/surf_c_bindings.cpp
src/surf/vm_hl13.cpp
src/surf/vm_hl13.hpp
teshsuite/surf/surf_usage/surf_usage.c
teshsuite/surf/surf_usage/surf_usage2.c

index 15b1b8e..fc2a668 100644 (file)
@@ -263,18 +263,6 @@ XBT_PUBLIC(surf_action_t) surf_host_model_execute_parallel_task(surf_host_model_
                                             double *bytes_amount,
                                             double rate);
 
-/**
- * @brief Create a communication between two hosts
- *
- * @param model The model which handle the communication
- * @param src The source host
- * @param dst The destination host
- * @param size The amount of data (in bytes) needed to transfer
- * @param rate [description]
- * @return The action corresponding to the communication
- */
-XBT_PUBLIC(surf_action_t) surf_host_model_communicate(surf_host_model_t model, surf_resource_t src, surf_resource_t dst, double size, double rate);
-
 /**
  * @brief Get the route between two hosts
  * @details [long description]
@@ -295,8 +283,7 @@ XBT_PUBLIC(xbt_dynar_t) surf_host_model_get_route(surf_host_model_t model, surf_
 XBT_PUBLIC(void) surf_vm_model_create(const char *name, surf_resource_t host_PM);
 
 /**
- * @brief Create a communication between two routing edges [TODO]
- * @details [long description]
+ * @brief Create a communication between two routing edges
  *
  * @param model The model which handle the communication
  * @param src The source host
@@ -305,7 +292,7 @@ XBT_PUBLIC(void) surf_vm_model_create(const char *name, surf_resource_t host_PM)
  * @param rate [description]
  * @return The action corresponding to the communication
  */
-XBT_PUBLIC(surf_action_t) surf_network_model_communicate(surf_network_model_t model, sg_routing_edge_t src, sg_routing_edge_t dst, double size, double rate);
+XBT_PUBLIC(surf_action_t) surf_network_model_communicate(surf_network_model_t model, sg_host_t src, sg_host_t dst, double size, double rate);
 
 /**
  * @brief Get the name of a surf resource (cpu, host, network, …)
index d0dcb2d..fd2a61b 100644 (file)
@@ -733,7 +733,7 @@ static XBT_INLINE void SIMIX_comm_start(smx_synchro_t synchro)
     XBT_DEBUG("Starting communication %p from '%s' to '%s'", synchro,
               SIMIX_host_get_name(sender), SIMIX_host_get_name(receiver));
 
-    synchro->comm.surf_comm = surf_host_model_communicate(surf_host_model,
+    synchro->comm.surf_comm = surf_network_model_communicate(surf_network_model,
                                                                    sender, receiver,
                                                                    synchro->comm.task_size, synchro->comm.rate);
 
index 5c98156..740b9ef 100644 (file)
@@ -95,8 +95,9 @@ Action *HostCLM03Model::executeParallelTask(int host_nb,
     action = static_cast<HostCLM03*>(host_list[0])->execute(flops_amount[0]);
   } else if ((host_nb == 1)
            && (cost_or_zero(flops_amount, 0) == 0.0)) {
-    action = communicate(static_cast<HostCLM03*>(host_list[0]),
-               static_cast<HostCLM03*>(host_list[0]),bytes_amount[0], rate);
+    action = surf_network_model->communicate(static_cast<HostCLM03*>(host_list[0])->p_netElm,
+                                                static_cast<HostCLM03*>(host_list[0])->p_netElm,
+                                                                                        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)) {
@@ -110,22 +111,17 @@ Action *HostCLM03Model::executeParallelTask(int host_nb,
       }
     }
     if (nb == 1){
-      action = communicate(static_cast<HostCLM03*>(host_list[0]),
-                 static_cast<HostCLM03*>(host_list[1]),value, rate);
+      action = surf_network_model->communicate(static_cast<HostCLM03*>(host_list[0])->p_netElm,
+                                                  static_cast<HostCLM03*>(host_list[1])->p_netElm,
+                                                                                          value, rate);
     }
   } else
-    THROW_UNIMPLEMENTED;      /* This model does not implement parallel tasks */
+    THROW_UNIMPLEMENTED;      /* This model does not implement parallel tasks for more than 2 hosts */
 #undef cost_or_zero
   xbt_free(host_list);
   return action;
 }
 
-Action *HostCLM03Model::communicate(Host *src, Host *dst, double size, double rate){
-  return surf_network_model->communicate(src->p_netElm, dst->p_netElm, size, rate);
-}
-
-
-
 /************
  * Resource *
  ************/
index d786d92..d625716 100644 (file)
@@ -38,7 +38,6 @@ public:
                                         double *flops_amount,
                                         double *bytes_amount,
                                         double rate);
- Action *communicate(Host *src, Host *dst, double size, double rate);
 };
 
 /************
index cfbce47..71fd688 100644 (file)
@@ -73,8 +73,6 @@ public:
                                         double *bytes_amount,
                                         double rate)=0;
 
-  virtual Action *communicate(Host *src, Host *dst, double size, double rate)=0;
-
   bool shareResourcesIsIdempotent() {return true;}
 };
 
index 1203758..b8a9d6f 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "cpu_interface.hpp"
 #include "surf_routing.hpp"
+#include "xbt/lib.h"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_host);
 
@@ -283,7 +284,7 @@ Host *HostL07Model::createHost(const char *name)
   return wk;
 }
 
-Action *HostL07Model::communicate(Host *src, Host *dst,
+Action *NetworkL07Model::communicate(RoutingEdge *src, RoutingEdge *dst,
                                        double size, double rate)
 {
   void **host_list = xbt_new0(void *, 2);
@@ -291,11 +292,11 @@ Action *HostL07Model::communicate(Host *src, Host *dst,
   double *bytes_amount = xbt_new0(double, 4);
   Action *res = NULL;
 
-  host_list[0] = src;
-  host_list[1] = dst;
+  host_list[0] = xbt_lib_get_level(xbt_lib_get_elm_or_null(host_lib, src->getName()), SURF_HOST_LEVEL);
+  host_list[1] = xbt_lib_get_level(xbt_lib_get_elm_or_null(host_lib, dst->getName()), SURF_HOST_LEVEL);
   bytes_amount[1] = size;
 
-  res = executeParallelTask(2, host_list,
+  res = p_hostModel->executeParallelTask(2, host_list,
                                     flops_amount,
                                     bytes_amount, rate);
 
index ac3bf98..dba8616 100644 (file)
@@ -44,7 +44,6 @@ public:
                                         double *bytes_amount,
                                         double rate);
   xbt_dynar_t getRoute(Host *src, Host *dst);
-  Action *communicate(Host *src, Host *dst, double size, double rate);
   void addTraces();
   NetworkModel *p_networkModel;
 };
@@ -79,7 +78,7 @@ public:
                                                   e_surf_link_sharing_policy_t
                                                   policy, xbt_dict_t properties);
 
-  Action *communicate(RoutingEdge */*src*/, RoutingEdge */*dst*/, double /*size*/, double /*rate*/) {DIE_IMPOSSIBLE;};
+  Action *communicate(RoutingEdge *src, RoutingEdge *dst, double size, double rate);
   void addTraces() {DIE_IMPOSSIBLE;};
   bool shareResourcesIsIdempotent() {return true;}
 
index c346440..9abcc61 100644 (file)
@@ -234,10 +234,6 @@ surf_action_t surf_host_model_execute_parallel_task(surf_host_model_t model,
   return static_cast<Action*>(model->executeParallelTask(host_nb, host_list, flops_amount, bytes_amount, rate));
 }
 
-surf_action_t surf_host_model_communicate(surf_host_model_t model, surf_resource_t src, surf_resource_t dst, double size, double rate){
-  return model->communicate(get_casted_host(src), get_casted_host(dst), size, rate);
-}
-
 xbt_dynar_t surf_host_model_get_route(surf_host_model_t /*model*/,
                                              surf_resource_t src, surf_resource_t dst){
   xbt_dynar_t route = NULL;
@@ -250,8 +246,8 @@ void surf_vm_model_create(const char *name, surf_resource_t ind_phys_host){
   surf_vm_model->createVM(name, ind_phys_host);
 }
 
-surf_action_t surf_network_model_communicate(surf_network_model_t model, sg_routing_edge_t src, sg_routing_edge_t dst, double size, double rate){
-  return model->communicate(src, dst, size, rate);
+surf_action_t surf_network_model_communicate(surf_network_model_t model, sg_host_t src, sg_host_t dst, double size, double rate){
+  return model->communicate(sg_host_edge(src), sg_host_edge(dst), size, rate);
 }
 
 const char *surf_resource_name(surf_cpp_resource_t resource){
index 68cfc56..1a1777c 100644 (file)
@@ -27,10 +27,6 @@ VMHL13Model::VMHL13Model() : VMModel() {}
 
 void VMHL13Model::updateActionsState(double /*now*/, double /*delta*/) {}
 
-Action *VMHL13Model::communicate(Host *src, Host *dst, double size, double rate){
-  return surf_network_model->communicate(src->p_netElm, dst->p_netElm, size, rate);
-}
-
 /* ind means ''indirect'' that this is a reference on the whole dict_elm
  * structure (i.e not on the surf_resource_private infos) */
 
@@ -187,7 +183,7 @@ Action *VMHL13Model::executeParallelTask(int host_nb,
     return static_cast<HostCLM03*>(host_list[0])->execute(flops_amount[0]);
   else if ((host_nb == 1)
            && (cost_or_zero(flops_amount, 0) == 0.0))
-    return communicate(static_cast<HostCLM03*>(host_list[0]), static_cast<HostCLM03*>(host_list[0]),bytes_amount[0], rate);
+    return surf_network_model->communicate(static_cast<HostCLM03*>(host_list[0])->p_netElm, static_cast<HostCLM03*>(host_list[0])->p_netElm,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)) {
@@ -201,11 +197,11 @@ Action *VMHL13Model::executeParallelTask(int host_nb,
       }
     }
     if (nb == 1)
-      return communicate(static_cast<HostCLM03*>(host_list[0]), static_cast<HostCLM03*>(host_list[1]),value, rate);
+      return surf_network_model->communicate(static_cast<HostCLM03*>(host_list[0])->p_netElm, static_cast<HostCLM03*>(host_list[1])->p_netElm,value, rate);
   }
 #undef cost_or_zero
 
-  THROW_UNIMPLEMENTED;          /* This model does not implement parallel tasks */
+  THROW_UNIMPLEMENTED;          /* This model does not implement parallel tasks for more than 2 hosts. */
   return NULL;
 }
 
index 41b06ef..aee4191 100644 (file)
@@ -31,7 +31,6 @@ public:
   VM *createVM(const char *name, surf_resource_t host_PM);
   double shareResources(double now);
   void adjustWeightOfDummyCpuActions() {};
-  Action *communicate(Host *src, Host *dst, double size, double rate);
   Action *executeParallelTask(int host_nb,
                                           void **host_list,
                                           double *flops_amount,
index 81f2e72..46fbbbd 100644 (file)
@@ -41,10 +41,8 @@ const char *string_action(e_surf_action_state_t state)
 void test(char *platform);
 void test(char *platform)
 {
-  void *cpuA = NULL;
-  void *cpuB = NULL;
-  void *cardA = NULL;
-  void *cardB = NULL;
+  sg_host_t cpuA = NULL;
+  sg_host_t cpuB = NULL;
   surf_action_t actionA = NULL;
   surf_action_t actionB = NULL;
   surf_action_t actionC = NULL;
@@ -82,15 +80,9 @@ void test(char *platform)
 
   /*********************** Network *******************************/
   XBT_DEBUG("%p", surf_network_model);
-  cardA = sg_routing_edge_by_name_or_null("Cpu A");
-  cardB = sg_routing_edge_by_name_or_null("Cpu B");
-
-  /* Let's check that those two processors exist */
-  XBT_DEBUG("Cpu A: %p", cardA);
-  XBT_DEBUG("Cpu B: %p", cardB);
 
   /* Let's do something on it */
-  surf_network_model_communicate(surf_network_model, cardA, cardB, 150.0, -1.0);
+  surf_network_model_communicate(surf_network_model, cpuA, cpuB, 150.0, -1.0);
 
   surf_solve(-1.0);                 /* Takes traces into account. Returns 0.0 */
   do {
index 585415b..8d3791e 100644 (file)
@@ -64,7 +64,7 @@ void test(char *platform)
   surf_host_execute(hostB, 1000.0);
   surf_host_sleep(hostB, 7.32);
 
-  surf_host_model_communicate(surf_host_model, hostA, hostB, 150.0, -1.0);
+  surf_network_model_communicate(surf_network_model, hostA, hostB, 150.0, -1.0);
 
   surf_solve(-1.0);                 /* Takes traces into account. Returns 0.0 */
   do {