Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use a deque instead of an intrusive hook for all VMs
[simgrid.git] / src / surf / surf_interface.cpp
index 2406d05..62f899e 100644 (file)
@@ -17,6 +17,7 @@
 #include "virtual_machine.hpp"
 #include "src/instr/instr_private.h" // TRACE_is_enabled(). FIXME: remove by subscribing tracing to the surf signals
 #include "simgrid/s4u/engine.hpp"
+#include <vector>
 
 XBT_LOG_NEW_CATEGORY(surf, "All SURF categories");
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_kernel, surf, "Logging specific to SURF (kernel)");
@@ -27,12 +28,12 @@ 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;
 xbt_dynar_t surf_path = nullptr;
-xbt_dynar_t host_that_restart = xbt_dynar_new(sizeof(char*), nullptr);
+std::vector<sg_host_t> host_that_restart;
 xbt_dict_t watched_hosts_lib;
 
 namespace simgrid {
@@ -246,16 +247,25 @@ void sg_version_check(int lib_version_major,int lib_version_minor,int lib_versio
       fprintf(stderr,
           "FATAL ERROR: Your program was compiled with SimGrid version %d.%d.%d, "
           "and then linked against SimGrid %d.%d.%d. Please fix this.\n",
-              SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH,
-        lib_version_major,lib_version_minor,lib_version_patch);
+          lib_version_major,lib_version_minor,lib_version_patch,
+          SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH);
       abort();
     }
     if (lib_version_patch != SIMGRID_VERSION_PATCH) {
+      if(SIMGRID_VERSION_PATCH >= 90 || lib_version_patch >=90){
+        fprintf(stderr,
+        "FATAL ERROR: Your program was compiled with SimGrid version %d.%d.%d, "
+        "and then linked against SimGrid %d.%d.%d. \n"
+        "One of them is a development version, and should not be mixed with the stable release. Please fix this.\n",
+        lib_version_major,lib_version_minor,lib_version_patch,
+        SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH);
+        abort();
+      }
         fprintf(stderr,
             "Warning: Your program was compiled with SimGrid version %d.%d.%d, "
             "and then linked against SimGrid %d.%d.%d. Proceeding anyway.\n",
-                SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH,
-          lib_version_major,lib_version_minor,lib_version_patch);
+            lib_version_major,lib_version_minor,lib_version_patch,
+            SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH);
     }
 }
 
@@ -291,12 +301,11 @@ void surf_init(int *argc, char **argv)
   });
 
   XBT_DEBUG("Add SURF levels");
-  simgrid::surf::HostImpl::classInit();
   SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,surf_storage_free);
 
   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)
@@ -313,15 +322,8 @@ 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) */
-
-  sg_config_finalize();
+  TRACE_end();                  /* Just in case it was not called by the upper layer (or there is no upper layer) */
 
-  xbt_dynar_free(&host_that_restart);
   xbt_dynar_free(&surf_path);
 
   xbt_dict_free(&host_list);
@@ -332,9 +334,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();