Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove unused variables.
[simgrid.git] / src / surf / surf.cpp
index 010de57..d7fec1b 100644 (file)
@@ -3,6 +3,7 @@
 #include "network.hpp"
 #include "cpu.hpp"
 #include "workstation.hpp"
+#include "vm_workstation.hpp"
 #include "simix/smx_host_private.h"
 #include "surf_routing.hpp"
 #include "simgrid/sg_config.h"
@@ -73,8 +74,12 @@ static void remove_watched_host(void *key)
   xbt_dynar_free(&hosts);
 }*/
 
+/* model_list_invoke contains only surf_workstation and surf_vm_workstation.
+ * The callback functions of cpu_model and network_model will be called from
+ * those of these workstation models. */
+xbt_dynar_t model_list = NULL; /* for destroying all models correctly */
+xbt_dynar_t model_list_invoke = NULL;  /* for invoking callbacks */
 
-xbt_dynar_t model_list = NULL;
 tmgr_history_t history = NULL;
 lmm_system_t maxmin_system = NULL;
 xbt_dynar_t surf_path = NULL;
@@ -136,6 +141,13 @@ s_surf_model_description_t surf_workstation_model_description[] = {
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
 
+s_surf_model_description_t surf_vm_workstation_model_description[] = {
+  {"default",
+   "Default vm workstation model.)",
+   surf_vm_workstation_model_init_current_default},
+  {NULL, NULL, NULL}      /* this array must be NULL terminated */
+};
+
 s_surf_model_description_t surf_optimization_mode_description[] = {
   {"Lazy",
    "Lazy action management (partial invalidation in lmm + heap in action remaining).",
@@ -161,8 +173,6 @@ static xbt_parmap_t surf_parmap = NULL; /* parallel map on models */
 #endif
 
 static double *surf_mins = NULL; /* return value of share_resources for each model */
-static int surf_min_index;       /* current index in surf_mins */
-static double min;               /* duration determined by surf_solve */
 
 double NOW = 0;
 
@@ -338,7 +348,9 @@ void surf_init(int *argc, char **argv)
 
   xbt_init(argc, argv);
   if (!model_list)
-    model_list = xbt_dynar_new(sizeof(surf_model_private_t), NULL);
+    model_list = xbt_dynar_new(sizeof(ModelPtr), NULL);
+  if (!model_list_invoke)
+    model_list_invoke = xbt_dynar_new(sizeof(ModelPtr), NULL);
   if (!history)
     history = tmgr_history_new();
 
@@ -349,7 +361,6 @@ void surf_init(int *argc, char **argv)
 
   sg_config_init(argc, argv);
 
-  surf_action_init();
   if (MC_is_active())
     MC_memory_init();
 }
@@ -369,6 +380,7 @@ void surf_exit(void)
   xbt_dynar_foreach(model_list, iter, model)
     delete model;
   xbt_dynar_free(&model_list);
+  xbt_dynar_free(&model_list_invoke);
   routing_exit();
 
   if (maxmin_system) {
@@ -379,7 +391,6 @@ void surf_exit(void)
     tmgr_history_free(history);
     history = NULL;
   }
-  surf_action_exit();
 
 #ifdef CONTEXT_THREADS
   xbt_parmap_destroy(surf_parmap);
@@ -412,7 +423,7 @@ Model::Model(string name)
    m_actSuspendCB(0), m_actCancelCB(0), m_actResumeCB(0),
    p_maxminSystem(0)
 {
-  ActionPtr action;
+  ActionPtr action = NULL;
   p_readyActionSet = xbt_swag_new(xbt_swag_offset(*action, p_stateHookup));
   p_runningActionSet = xbt_swag_new(xbt_swag_offset(*action, p_stateHookup));
   p_failedActionSet = xbt_swag_new(xbt_swag_offset(*action, p_stateHookup));
@@ -514,7 +525,7 @@ double Model::shareResourcesLazy(double now)
   return min;
 }
 
-double Model::shareResourcesFull(double now) {
+double Model::shareResourcesFull(double /*now*/) {
   THROW_UNIMPLEMENTED;
 }
 
@@ -586,12 +597,12 @@ void Model::updateActionsState(double now, double delta)
        xbt_die("Invalid cpu update mechanism!");
 }
 
-void Model::updateActionsStateLazy(double now, double delta)
+void Model::updateActionsStateLazy(double /*now*/, double /*delta*/)
 {
 
 }
 
-void Model::updateActionsStateFull(double now, double delta)
+void Model::updateActionsStateFull(double /*now*/, double /*delta*/)
 {
 
 }
@@ -676,6 +687,11 @@ e_surf_resource_state_t Resource::getState()
   return p_stateCurrent;
 }
 
+void Resource::setState(e_surf_resource_state_t state)
+{
+  p_stateCurrent = state;
+}
+
 bool Resource::isOn()
 {
   return m_running;
@@ -730,26 +746,6 @@ const char *surf_action_state_names[6] = {
   "SURF_ACTION_NOT_IN_THE_SYSTEM"
 };
 
-/**
- * \brief Initializes the action module of Surf.
- */
-void surf_action_init(void) {
-
-  /* the action mallocator will always provide actions of the following size,
-   * so this size should be set to the maximum size of the surf action structures
-   */
-  /*FIXME:action_mallocator_allocated_size = sizeof(s_surf_action_network_CM02_t);
-  action_mallocator = xbt_mallocator_new(65536, surf_action_mallocator_new_f,
-      surf_action_mallocator_free_f, surf_action_mallocator_reset_f);*/
-}
-
-/**
- * \brief Uninitializes the action module of Surf.
- */
-void surf_action_exit(void) {
-  //FIXME:xbt_mallocator_free(action_mallocator);
-}
-
 Action::Action(){}
 
 Action::Action(ModelPtr model, double cost, bool failed):
@@ -1000,7 +996,7 @@ void ActionLmm::updateRemainingLazy(double now)
     double_update(&m_remains, m_lastValue * delta);
 
 #ifdef HAVE_TRACING
-    if (p_model == static_cast<ModelPtr>(surf_cpu_model) && TRACE_is_enabled()) {
+    if (p_model == static_cast<ModelPtr>(surf_cpu_model_pm) && TRACE_is_enabled()) {
       ResourcePtr cpu = static_cast<ResourcePtr>(lmm_constraint_id(lmm_get_cnst_from_var(p_model->p_maxminSystem, p_variable, 0)));
       TRACE_surf_host_set_utilization(cpu->m_name, p_category, m_lastValue, m_lastUpdate, now - m_lastUpdate);
     }