Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
No vm when ptask on
authorPaul Bédaride <paul.bedaride@gmail.com>
Tue, 19 Nov 2013 14:16:57 +0000 (15:16 +0100)
committerPaul Bédaride <paul.bedaride@gmail.com>
Tue, 19 Nov 2013 14:19:52 +0000 (15:19 +0100)
src/surf/cpu_cas01.cpp
src/surf/vm_workstation.cpp
src/surf/workstation.cpp
src/surf/workstation.hpp
src/surf/workstation_ptask_L07.cpp
src/surf/workstation_ptask_L07.hpp

index 0ea0217..0ad4498 100644 (file)
@@ -43,8 +43,8 @@ void surf_cpu_model_init_Cas01()
 {
   char *optim = xbt_cfg_get_string(_sg_cfg_set, "cpu/optim");
 
-  if (surf_cpu_model_pm)
-    return;
+  xbt_assert(!surf_cpu_model_pm);
+  xbt_assert(!surf_cpu_model_vm);
 
   if (!strcmp(optim, "TI")) {
     surf_cpu_model_init_ti();
@@ -52,9 +52,13 @@ void surf_cpu_model_init_Cas01()
   }
 
   surf_cpu_model_pm = new CpuCas01Model();
+  surf_cpu_model_vm  = new CpuCas01Model();
+
   cpu_define_callbacks();
-  ModelPtr model = static_cast<ModelPtr>(surf_cpu_model_pm);
-  xbt_dynar_push(model_list, &model);
+  ModelPtr model_pm = static_cast<ModelPtr>(surf_cpu_model_pm);
+  ModelPtr model_vm = static_cast<ModelPtr>(surf_cpu_model_vm);
+  xbt_dynar_push(model_list, &model_pm);
+  xbt_dynar_push(model_list, &model_vm);
 }
 
 CpuCas01Model::CpuCas01Model() : CpuModel("cpu")
index 744576b..072942c 100644 (file)
@@ -14,15 +14,21 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_vm_workstation, surf,
 WorkstationVMModelPtr surf_vm_workstation_model = NULL;
 
 void surf_vm_workstation_model_init_current_default(void){
-  surf_vm_workstation_model = new WorkstationVMModel();
-  xbt_dynar_push(model_list, &surf_vm_workstation_model);
-  xbt_dynar_push(model_list_invoke, &surf_vm_workstation_model);
+  if (surf_cpu_model_vm) {
+    surf_vm_workstation_model = new WorkstationVMModel();
+    ModelPtr model = static_cast<ModelPtr>(surf_vm_workstation_model);
+
+    xbt_dynar_push(model_list, &model);
+    xbt_dynar_push(model_list_invoke, &model);
+  }
 }
+
 /*********
  * Model *
  *********/
 
 WorkstationVMModel::WorkstationVMModel() : WorkstationModel("Virtual Workstation") {
+  p_cpuModel = surf_cpu_model_vm;
 }
 
 /* ind means ''indirect'' that this is a reference on the whole dict_elm
@@ -59,8 +65,10 @@ double WorkstationVMModel::shareResources(double now)
   /* 0. Make sure that we already calculated the resource share at the physical
    * machine layer. */
   {
-    unsigned int index_of_pm_ws_model = xbt_dynar_search(model_list_invoke, &surf_workstation_model);
-    unsigned int index_of_vm_ws_model = xbt_dynar_search(model_list_invoke, &surf_vm_workstation_model);
+       ModelPtr ws_model = static_cast<ModelPtr>(surf_workstation_model);
+       ModelPtr vm_ws_model = static_cast<ModelPtr>(surf_vm_workstation_model);
+    unsigned int index_of_pm_ws_model = xbt_dynar_search(model_list_invoke, &ws_model);
+    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_workstation_model comes before");
 
     /* Another option is that we call sub_ws->share_resource() here. The
index 19dfbd2..c6bec86 100644 (file)
@@ -30,6 +30,7 @@ void surf_workstation_model_init_current_default(void)
   xbt_cfg_setdefault_boolean(_sg_cfg_set, "network/crosstraffic", "yes");
   surf_cpu_model_init_Cas01();
   surf_network_model_init_LegrandVelho();
+  surf_workstation_model->p_cpuModel = surf_cpu_model_pm;
 
   ModelPtr model = static_cast<ModelPtr>(surf_workstation_model);
   xbt_dynar_push(model_list, &model);
index dc871bb..126757d 100644 (file)
@@ -52,6 +52,7 @@ public:
                                         double rate);
  virtual xbt_dynar_t getRoute(WorkstationCLM03Ptr src, WorkstationCLM03Ptr dst);
  virtual ActionPtr communicate(WorkstationCLM03Ptr src, WorkstationCLM03Ptr dst, double size, double rate);
+ CpuModelPtr p_cpuModel;
 };
 
 /************
index 0010a53..5410453 100644 (file)
@@ -25,6 +25,7 @@ WorkstationL07Model::WorkstationL07Model() : WorkstationModel("Workstation ptask
                                                          0.000015, NULL,
                                                          SURF_RESOURCE_ON, NULL,
                                                          SURF_LINK_FATPIPE, NULL));
+  p_cpuModel = surf_cpu_model_pm;
 }
 
 WorkstationL07Model::~WorkstationL07Model() {
@@ -860,4 +861,5 @@ void surf_workstation_model_init_ptask_L07(void)
   surf_workstation_model = new WorkstationL07Model();
   ModelPtr model = static_cast<ModelPtr>(surf_workstation_model);
   xbt_dynar_push(model_list, &model);
+  xbt_dynar_push(model_list_invoke, &model);
 }
index 0fcb23c..1678943 100644 (file)
@@ -59,7 +59,6 @@ public:
   xbt_dynar_t getRoute(WorkstationCLM03Ptr src, WorkstationCLM03Ptr dst);
   ActionPtr communicate(WorkstationCLM03Ptr src, WorkstationCLM03Ptr dst, double size, double rate);
   void addTraces();
-  CpuL07ModelPtr p_cpuModel;
   NetworkL07ModelPtr p_networkModel;
 };
 
@@ -74,6 +73,7 @@ public:
                                  tmgr_trace_t state_trace,
                                  xbt_dict_t cpu_properties);
   void addTraces() {DIE_IMPOSSIBLE;};
+
   WorkstationL07ModelPtr p_workstationModel;
 };