From 6d66c399ea878db4ccfd7aafb7a157ec6a101d88 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 23 Nov 2015 00:08:33 +0100 Subject: [PATCH] Simplify how shareResources() is called in each models - 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 | 3 +-- src/surf/host_clm03.cpp | 2 -- src/surf/host_ptask_L07.cpp | 1 - src/surf/surf_c_bindings.cpp | 24 +++++++++++------------- src/surf/vm_hl13.cpp | 17 ----------------- 5 files changed, 12 insertions(+), 35 deletions(-) diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 182a93c9c5..a605c4c8db 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -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; diff --git a/src/surf/host_clm03.cpp b/src/surf/host_clm03.cpp index e18f0420c9..19b53bc988 100644 --- a/src/surf/host_clm03.cpp +++ b/src/surf/host_clm03.cpp @@ -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); } diff --git a/src/surf/host_ptask_L07.cpp b/src/surf/host_ptask_L07.cpp index 390f3c3e94..0c5645abbf 100644 --- a/src/surf/host_ptask_L07.cpp +++ b/src/surf/host_ptask_L07.cpp @@ -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); } diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index 4c3a58dd54..096bab428a 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -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); diff --git a/src/surf/vm_hl13.cpp b/src/surf/vm_hl13.cpp index 40b73a9929..d33a5cde2e 100644 --- a/src/surf/vm_hl13.cpp +++ b/src/surf/vm_hl13.cpp @@ -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. * -- 2.20.1