Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Simplify how shareResources() is called in each models
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 22 Nov 2015 23:08:33 +0000 (00:08 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 22 Nov 2015 23:08:36 +0000 (00:08 +0100)
- Host->shareResources() is in charge of calling the ones of Cpu, Net
  and Storage
- VM->shareResources() must be called after the Host one

So, don't make a list `model_list_invoke` of two elements that must be
called in a very specific order. Instead, directly call these methodes
in surf_solve().

A next step could be to put the content of Host->shareResources and
maybe VM->shareResources() in surf_solve so that Host and VM can stop
being resources just to dispatch calls to the real resources.

But L07 must be dealed with before (eg by moving the content of
Host07->shareResource() into Cpu07->shareResources() and leaving
Link07->shareResources() empty).

src/include/surf/surf.h
src/surf/host_clm03.cpp
src/surf/host_ptask_L07.cpp
src/surf/surf_c_bindings.cpp
src/surf/vm_hl13.cpp

index 182a93c..a605c4c 100644 (file)
@@ -1037,10 +1037,9 @@ XBT_PUBLIC_DATA(s_surf_model_description_t)
  *  \brief List of initialized models
  */
 XBT_PUBLIC_DATA(xbt_dynar_t) all_existing_models;
-XBT_PUBLIC_DATA(xbt_dynar_t) model_list_invoke;
 
 /** \ingroup SURF_simulation
- *  \brief List of hosts that have juste restarted and whose autorestart process should be restarted.
+ *  \brief List of hosts that have just restarted and whose autorestart process should be restarted.
  */
 XBT_PUBLIC_DATA(xbt_dynar_t) host_that_restart;
 
index e18f042..19b53bc 100644 (file)
@@ -29,7 +29,6 @@ void surf_host_model_init_current_default(void)
 
   Model *model = surf_host_model;
   xbt_dynar_push(all_existing_models, &model);
-  xbt_dynar_push(model_list_invoke, &model);
   sg_platf_host_add_cb(host_parse_init);
 }
 
@@ -42,7 +41,6 @@ void surf_host_model_init_compound()
 
   Model *model = surf_host_model;
   xbt_dynar_push(all_existing_models, &model);
-  xbt_dynar_push(model_list_invoke, &model);
   sg_platf_host_add_cb(host_parse_init);
 }
 
index 390f3c3..0c5645a 100644 (file)
@@ -42,7 +42,6 @@ void surf_host_model_init_ptask_L07(void)
   surf_host_model = new HostL07Model();
   Model *model = surf_host_model;
   xbt_dynar_push(all_existing_models, &model);
-  xbt_dynar_push(model_list_invoke, &model);
 }
 
 
index 4c3a58d..096bab4 100644 (file)
@@ -73,19 +73,17 @@ double surf_solve(double max_date)
     surf_min = max_date - NOW;
   }
 
-  XBT_DEBUG("Looking for next action end for all models except NS3");
-  xbt_dynar_foreach(model_list_invoke, iter, model) {
-         double next_action_end = -1.0;
-         if (model->shareResourcesIsIdempotent()) {
-           XBT_DEBUG("Running for Resource [%s]", typeid(model).name());
-           next_action_end = model->shareResources(NOW);
-           XBT_DEBUG("Resource [%s] : next action end = %f",
-               typeid(model).name(), next_action_end);
-         }
-         if ((surf_min < 0.0 || next_action_end < surf_min)
-                         && next_action_end >= 0.0) {
-                 surf_min = next_action_end;
-         }
+  /* Physical models MUST be resolved first */
+  XBT_DEBUG("Looking for next event in physical models");
+  double next_event_phy = surf_host_model->shareResources(NOW);
+  if ((surf_min < 0.0 || next_event_phy < surf_min) && next_event_phy >= 0.0) {
+         surf_min = next_event_phy;
+  }
+  if (surf_vm_model != NULL) {
+         XBT_DEBUG("Looking for next event in virtual models");
+         double next_event_virt = surf_vm_model->shareResources(NOW);
+         if ((surf_min < 0.0 || next_event_virt < surf_min) && next_event_virt >= 0.0)
+                 surf_min = next_event_virt;
   }
 
   XBT_DEBUG("Min for resources (remember that NS3 don't update that value) : %f", surf_min);
index 40b73a9..d33a5cd 100644 (file)
@@ -15,7 +15,6 @@ void surf_vm_model_init_HL13(void){
     Model *model = surf_vm_model;
 
     xbt_dynar_push(all_existing_models, &model);
-    xbt_dynar_push(model_list_invoke, &model);
   }
 }
 
@@ -50,22 +49,6 @@ double VMHL13Model::shareResources(double now)
 {
   /* TODO: update action's cost with the total cost of processes on the VM. */
 
-
-  /* 0. Make sure that we already calculated the resource share at the physical
-   * machine layer. */
-  {
-    XBT_ATTRIB_UNUSED Model *ws_model = surf_host_model;
-    XBT_ATTRIB_UNUSED Model *vm_ws_model = surf_vm_model;
-    XBT_ATTRIB_UNUSED unsigned int index_of_pm_ws_model = xbt_dynar_search(model_list_invoke, &ws_model);
-    XBT_ATTRIB_UNUSED unsigned int index_of_vm_ws_model = xbt_dynar_search(model_list_invoke, &vm_ws_model);
-    xbt_assert((index_of_pm_ws_model < index_of_vm_ws_model), "Cannot assume surf_host_model comes before");
-
-    /* Another option is that we call sub_ws->share_resource() here. The
-     * share_resource() function has no side-effect. We can call it here to
-     * ensure that. */
-  }
-
-
   /* 1. Now we know how many resource should be assigned to each virtual
    * machine. We update constraints of the virtual machine layer.
    *