Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 9 Aug 2016 21:56:09 +0000 (23:56 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 9 Aug 2016 21:56:09 +0000 (23:56 +0200)
19 files changed:
src/include/surf/surf.h
src/simdag/sd_global.cpp
src/simix/smx_global.cpp
src/surf/HostImpl.cpp
src/surf/cpu_cas01.cpp
src/surf/cpu_ti.cpp
src/surf/host_clm03.cpp
src/surf/network_cm02.cpp
src/surf/network_constant.cpp
src/surf/network_ib.cpp
src/surf/network_smpi.cpp
src/surf/ptask_L07.cpp
src/surf/storage_interface.cpp
src/surf/storage_n11.cpp
src/surf/surf_c_bindings.cpp
src/surf/surf_interface.cpp
src/surf/surf_interface.hpp
src/surf/vm_hl13.cpp
teshsuite/surf/surf_usage2/surf_usage2.cpp

index 3616544..bc29606 100644 (file)
@@ -370,9 +370,7 @@ XBT_PUBLIC(int) surf_host_file_move(sg_host_t host, surf_file_t fd, const char*
  *  - SEEK_END: end of the file
  * @return MSG_OK if successful, otherwise MSG_TASK_CANCELED
  */
-XBT_PUBLIC(int) surf_host_file_seek(sg_host_t host,
-                                           surf_file_t fd, sg_offset_t offset,
-                                           int origin);
+XBT_PUBLIC(int) surf_host_file_seek(sg_host_t host, surf_file_t fd, sg_offset_t offset, int origin);
 
 /**
  * @brief Get the content of a storage
@@ -693,11 +691,6 @@ XBT_PUBLIC(void) surf_vm_model_init_HL13();
  */
 XBT_PUBLIC_DATA(s_surf_model_description_t) surf_vm_model_description[];
 
-/** \ingroup SURF_models
- *  \brief List of initialized models
- */
-XBT_PUBLIC_DATA(xbt_dynar_t) all_existing_models;
-
 /** \ingroup SURF_simulation
  *  \brief List of hosts that have just restarted and whose autorestart process should be restarted.
  */
index 6879f57..7b8a101 100644 (file)
@@ -46,7 +46,6 @@ std::set<SD_task_t>* simulate(double how_long){
   double total_time = 0.0;
   /* main loop */
   while (elapsed_time >= 0 && (how_long < 0 || 0.00001 < (how_long -total_time)) && !sd_global->watch_point_reached) {
-    surf_model_t model = nullptr;
 
     XBT_DEBUG("Total time: %f", total_time);
 
@@ -56,8 +55,7 @@ std::set<SD_task_t>* simulate(double how_long){
       total_time += elapsed_time;
 
     /* let's see which tasks are done */
-    unsigned int iter;
-    xbt_dynar_foreach(all_existing_models, iter, model) {
+    for (auto model : *all_existing_models) {
       surf_action_t action = surf_model_extract_done_action_set(model);
       while (action != nullptr) {
         SD_task_t task = static_cast<SD_task_t>(action->getData());
index 32e9b58..90a9c48 100644 (file)
@@ -348,11 +348,9 @@ static int process_syscall_color(void *p)
 /** Wake up all processes waiting for a Surf action to finish */
 static void SIMIX_wake_processes()
 {
-  unsigned int iter;
-  surf_model_t model;
   surf_action_t action;
 
-  xbt_dynar_foreach(all_existing_models, iter, model) {
+  for(auto model : *all_existing_models) {
     XBT_DEBUG("Handling the processes whose action failed (if any)");
     while ((action = surf_model_extract_failed_action_set(model))) {
       XBT_DEBUG("   Handling Action %p",action);
index c7e5ec9..eef8795 100644 (file)
@@ -13,8 +13,7 @@
 #include "network_interface.hpp"
 #include "virtual_machine.hpp"
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_host, surf,
-                                "Logging specific to the SURF host module");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_host, surf, "Logging specific to the SURF host module");
 
 simgrid::surf::HostModel *surf_host_model = nullptr;
 
@@ -100,9 +99,7 @@ Action *HostModel::executeParallelTask(int host_nb,
       }
     }
     if (nb == 1) {
-      action = surf_network_model->communicate(host_list[0]->pimpl_netcard,
-                                              host_list[1]->pimpl_netcard,
-                                              value, rate);
+      action = surf_network_model->communicate(host_list[0]->pimpl_netcard, host_list[1]->pimpl_netcard, value, rate);
     } else if (nb == 0) {
        xbt_die("Cannot have a communication with no flop to exchange in this model. You should consider using the ptask model");
     } else {       
@@ -183,15 +180,15 @@ simgrid::surf::Storage *HostImpl::findStorageOnMountList(const char* mount)
   unsigned int cursor;
 
   XBT_DEBUG("Search for storage name '%s' on '%s'", mount, getName());
-  xbt_dynar_foreach(p_storage,cursor,mnt)
-  {
+  xbt_dynar_foreach(p_storage,cursor,mnt){
     XBT_DEBUG("See '%s'",mnt.name);
     if(!strcmp(mount,mnt.name)){
       st = static_cast<simgrid::surf::Storage*>(mnt.storage);
       break;
     }
   }
-  if(!st) xbt_die("Can't find mount '%s' for '%s'", mount, getName());
+  if(!st)
+    xbt_die("Can't find mount '%s' for '%s'", mount, getName());
   return st;
 }
 
index d361db6..6321e49 100644 (file)
@@ -26,10 +26,10 @@ void surf_cpu_model_init_Cas01()
   }
 
   surf_cpu_model_pm = new simgrid::surf::CpuCas01Model();
-  xbt_dynar_push(all_existing_models, &surf_cpu_model_pm);
+  all_existing_models->push_back(surf_cpu_model_pm);
 
   surf_cpu_model_vm  = new simgrid::surf::CpuCas01Model();
-  xbt_dynar_push(all_existing_models, &surf_cpu_model_vm);
+  all_existing_models->push_back(surf_cpu_model_vm);
 }
 
 namespace simgrid {
index 64df3a0..c6e5c23 100644 (file)
@@ -334,10 +334,10 @@ void surf_cpu_model_init_ti()
   xbt_assert(!surf_cpu_model_vm,"CPU model already initialized. This should not happen.");
 
   surf_cpu_model_pm = new simgrid::surf::CpuTiModel();
-  xbt_dynar_push(all_existing_models, &surf_cpu_model_pm);
+  all_existing_models->push_back(surf_cpu_model_pm);
 
   surf_cpu_model_vm = new simgrid::surf::CpuTiModel();
-  xbt_dynar_push(all_existing_models, &surf_cpu_model_vm);
+  all_existing_models->push_back(surf_cpu_model_vm);
 }
 
 namespace simgrid {
index b7241b2..0c95e43 100644 (file)
@@ -31,7 +31,7 @@ void surf_host_model_init_current_default()
   surf_cpu_model_init_Cas01();
   surf_network_model_init_LegrandVelho();
 
-  xbt_dynar_push(all_existing_models, &surf_host_model);
+  all_existing_models->push_back(surf_host_model);
 }
 
 void surf_host_model_init_compound()
@@ -40,7 +40,7 @@ void surf_host_model_init_compound()
   xbt_assert(surf_network_model, "No network model defined yet!");
 
   surf_host_model = new simgrid::surf::HostCLM03Model();
-  xbt_dynar_push(all_existing_models, &surf_host_model);
+  all_existing_models->push_back(surf_host_model);
 }
 
 namespace simgrid {
index 77f3801..a2f7152 100644 (file)
@@ -41,7 +41,7 @@ void surf_network_model_init_LegrandVelho()
     return;
 
   surf_network_model = new simgrid::surf::NetworkCm02Model();
-  xbt_dynar_push(all_existing_models, &surf_network_model);
+  all_existing_models->push_back(surf_network_model);
 
   xbt_cfg_setdefault_double("network/latency-factor",      13.01);
   xbt_cfg_setdefault_double("network/bandwidth-factor",     0.97);
@@ -66,7 +66,7 @@ void surf_network_model_init_CM02()
     return;
 
   surf_network_model = new simgrid::surf::NetworkCm02Model();
-  xbt_dynar_push(all_existing_models, &surf_network_model);
+  all_existing_models->push_back(surf_network_model);
 
   xbt_cfg_setdefault_double("network/latency-factor",   1.0);
   xbt_cfg_setdefault_double("network/bandwidth-factor", 1.0);
@@ -89,7 +89,7 @@ void surf_network_model_init_Reno()
     return;
 
   surf_network_model = new simgrid::surf::NetworkCm02Model();
-  xbt_dynar_push(all_existing_models, &surf_network_model);
+  all_existing_models->push_back(surf_network_model);
 
   lmm_set_default_protocol_function(func_reno_f, func_reno_fp, func_reno_fpi);
   surf_network_model->f_networkSolve = lagrange_solve;
@@ -106,7 +106,7 @@ void surf_network_model_init_Reno2()
     return;
 
   surf_network_model = new simgrid::surf::NetworkCm02Model();
-  xbt_dynar_push(all_existing_models, &surf_network_model);
+  all_existing_models->push_back(surf_network_model);
 
   lmm_set_default_protocol_function(func_reno2_f, func_reno2_fp, func_reno2_fpi);
   surf_network_model->f_networkSolve = lagrange_solve;
@@ -122,7 +122,7 @@ void surf_network_model_init_Vegas()
     return;
 
   surf_network_model = new simgrid::surf::NetworkCm02Model();
-  xbt_dynar_push(all_existing_models, &surf_network_model);
+  all_existing_models->push_back(surf_network_model);
 
   lmm_set_default_protocol_function(func_vegas_f, func_vegas_fp, func_vegas_fpi);
   surf_network_model->f_networkSolve = lagrange_solve;
index 1564f4d..297a964 100644 (file)
@@ -15,7 +15,7 @@ void surf_network_model_init_Constant()
 {
   xbt_assert(surf_network_model == nullptr);
   surf_network_model = new simgrid::surf::NetworkConstantModel();
-  xbt_dynar_push(all_existing_models, &surf_network_model);
+  all_existing_models->push_back(surf_network_model);
 
   routing_model_create(nullptr);
 }
index 2dd9bc4..2c170bb 100644 (file)
@@ -88,7 +88,7 @@ void surf_network_model_init_IB()
     return;
 
   surf_network_model = new simgrid::surf::NetworkIBModel();
-  xbt_dynar_push(all_existing_models, &surf_network_model);
+  all_existing_models->push_back(surf_network_model);
   networkActionStateChangedCallbacks.connect(IB_action_state_changed_callback);
   Link::onCommunicate.connect(IB_action_init_callback);
   simgrid::s4u::Host::onCreation.connect(IB_create_host_callback);
index bb83b01..298d06c 100644 (file)
@@ -88,7 +88,7 @@ void surf_network_model_init_SMPI()
   if (surf_network_model)
     return;
   surf_network_model = new simgrid::surf::NetworkSmpiModel();
-  xbt_dynar_push(all_existing_models, &surf_network_model);
+  all_existing_models->push_back(surf_network_model);
 
   xbt_cfg_setdefault_double("network/sender-gap", 10e-6);
   xbt_cfg_setdefault_double("network/weight-S", 8775);
index f28844b..437bd9c 100644 (file)
@@ -27,7 +27,7 @@ void surf_host_model_init_ptask_L07()
   xbt_assert(!surf_network_model, "network model type already defined");
 
   surf_host_model = new simgrid::surf::HostL07Model();
-  xbt_dynar_push(all_existing_models, &surf_host_model);
+  all_existing_models->push_back(surf_host_model);
 }
 
 
index 8fd56a8..df30827 100644 (file)
@@ -8,8 +8,7 @@
 #include "surf_private.h"
 #include "xbt/file.h" /* xbt_getline */
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_storage, surf,
-                                "Logging specific to the SURF storage module");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_storage, surf, "Logging specific to the SURF storage module");
 
 xbt_lib_t file_lib;
 xbt_lib_t storage_lib;
index 39a7917..07146a7 100644 (file)
@@ -57,7 +57,7 @@ void storage_register_callbacks()
 void surf_storage_model_init_default()
 {
   surf_storage_model = new simgrid::surf::StorageN11Model();
-  xbt_dynar_push(all_existing_models, &surf_storage_model);
+  all_existing_models->push_back(surf_storage_model);
 }
 
 namespace simgrid {
index f3262ae..561b457 100644 (file)
@@ -33,8 +33,6 @@ void surf_presolve()
   tmgr_trace_iterator_t event = nullptr;
   double value = -1.0;
   simgrid::surf::Resource *resource = nullptr;
-  simgrid::surf::Model *model = nullptr;
-  unsigned int iter;
 
   XBT_DEBUG ("Consume all trace events occurring before the starting time.");
   while ((next_event_date = future_evt_set->next_date()) != -1.0) {
@@ -49,7 +47,7 @@ void surf_presolve()
   }
 
   XBT_DEBUG ("Set every models in the right state by updating them to 0.");
-  xbt_dynar_foreach(all_existing_models, iter, model)
+  for (auto model : *all_existing_models)
       model->updateActionsState(NOW, 0.0);
 }
 
@@ -60,9 +58,7 @@ double surf_solve(double max_date)
   double model_next_action_end = -1.0;
   double value = -1.0;
   simgrid::surf::Resource *resource = nullptr;
-  simgrid::surf::Model *model = nullptr;
   tmgr_trace_iterator_t event = nullptr;
-  unsigned int iter;
 
   if (max_date > 0.0) {
     xbt_assert(max_date > NOW,"You asked to simulate up to %f, but that's in the past already", max_date);
@@ -147,7 +143,7 @@ double surf_solve(double max_date)
   NOW = NOW + time_delta;
 
   // Inform the models of the date change
-  xbt_dynar_foreach(all_existing_models, iter, model) {
+  for (auto model : *all_existing_models) {
     model->updateActionsState(NOW, time_delta);
   }
 
index 6510224..8a7caad 100644 (file)
@@ -27,7 +27,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_kernel, surf, "Logging specific to SURF (ke
 
 /* model_list_invoke contains only surf_host and surf_vm.
  * The callback functions of cpu_model and network_model will be called from those of these host models. */
-xbt_dynar_t all_existing_models = nullptr; /* to destroy models correctly */
+std::vector<surf_model_t> * all_existing_models = nullptr; /* to destroy models correctly */
 xbt_dynar_t model_list_invoke = nullptr;  /* to invoke callbacks */
 
 simgrid::trace_mgr::future_evt_set *future_evt_set = nullptr;
@@ -305,7 +305,7 @@ void surf_init(int *argc, char **argv)
 
   xbt_init(argc, argv);
   if (!all_existing_models)
-    all_existing_models = xbt_dynar_new(sizeof(simgrid::surf::Model*), nullptr);
+    all_existing_models = new std::vector<simgrid::surf::Model*>();
   if (!model_list_invoke)
     model_list_invoke = xbt_dynar_new(sizeof(simgrid::surf::Model*), nullptr);
   if (!future_evt_set)
@@ -322,11 +322,7 @@ void surf_init(int *argc, char **argv)
 
 void surf_exit()
 {
-  unsigned int iter;
-  simgrid::surf::Model *model = nullptr;
-
-  TRACE_end();                  /* Just in case it was not called by the upper
-                                 * layer (or there is no upper layer) */
+  TRACE_end();                  /* Just in case it was not called by the upper layer (or there is no upper layer) */
 
   sg_config_finalize();
 
@@ -341,9 +337,9 @@ void surf_exit()
   xbt_lib_free(&file_lib);
   xbt_dict_free(&watched_hosts_lib);
 
-  xbt_dynar_foreach(all_existing_models, iter, model)
+  for (auto model : *all_existing_models)
     delete model;
-  xbt_dynar_free(&all_existing_models);
+  delete all_existing_models;
   xbt_dynar_free(&model_list_invoke);
   routing_exit();
 
index 819ed57..13749c2 100644 (file)
@@ -80,7 +80,10 @@ XBT_PUBLIC_DATA(xbt_dict_t) traces_set_list;
 
 XBT_PRIVATE void surf_action_lmm_update_index_heap(void *action, int i);
 
-XBT_PUBLIC_DATA(xbt_dynar_t) all_existing_models;
+/** \ingroup SURF_models
+ *  \brief List of initialized models
+ */
+XBT_PUBLIC_DATA(std::vector<surf_model_t>*) all_existing_models;
 
 namespace simgrid {
 namespace surf {
index 47bb68d..4a4d61b 100644 (file)
@@ -14,8 +14,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_vm);
 void surf_vm_model_init_HL13(){
   if (surf_cpu_model_vm) {
     surf_vm_model = new simgrid::surf::VMHL13Model();
-    simgrid::surf::Model *model = surf_vm_model;
-    xbt_dynar_push(all_existing_models, &model);
+    all_existing_models->push_back(surf_vm_model);
   }
 }
 
index da719bf..f849953 100644 (file)
@@ -48,14 +48,12 @@ int main(int argc, char **argv)
   surf_solve(-1.0);                 /* Takes traces into account. Returns 0.0 */
   do {
     surf_action_t action = nullptr;
-    unsigned int iter;
-    surf_model_t model = nullptr;
     running = 0;
 
     now = surf_get_clock();
     XBT_INFO("Next Event : %g", now);
 
-    xbt_dynar_foreach(all_existing_models, iter, model) {
+    for (auto model: *all_existing_models) {
       if (surf_model_running_action_set_size((surf_model_t)model)) {
         XBT_DEBUG("\t Running that model");
         running = 1;