Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 2 Apr 2019 14:51:11 +0000 (16:51 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 2 Apr 2019 14:51:11 +0000 (16:51 +0200)
30 files changed:
ChangeLog
include/simgrid/s4u/Comm.hpp
include/simgrid/simix.h
include/xbt/dict.h
src/include/simgrid/sg_config.hpp
src/instr/instr_paje_events.cpp
src/instr/instr_paje_events.hpp
src/kernel/activity/CommImpl.cpp
src/kernel/activity/CommImpl.hpp
src/mc/mc_base.cpp
src/mc/mc_state.cpp
src/simdag/sd_global.cpp
src/simgrid/sg_config.cpp
src/simix/libsmx.cpp
src/simix/popping_accessors.hpp
src/simix/popping_bodies.cpp
src/simix/popping_generated.cpp
src/simix/popping_private.hpp
src/simix/simcalls.in
src/simix/smx_global.cpp
src/smpi/include/smpi_comm.hpp
src/smpi/include/smpi_request.hpp
src/smpi/internals/smpi_global.cpp
src/smpi/mpi/smpi_request.cpp
src/surf/surf_interface.cpp
src/surf/surf_interface.hpp
src/xbt/dict.cpp
teshsuite/simdag/CMakeLists.txt
teshsuite/xbt/log_usage/log_usage.tesh
tools/cmake/Tests.cmake

index 0fa7201..725ee01 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 SimGrid (3.23) NOT RELEASED (Release Target: June 21. 2019, 15:54 UTC)
 
+XBT:
+ - Drop xbt_dict_dump.
+
 ----------------------------------------------------------------------------
 
 SimGrid (3.22) April 1. 2019
index 2502a97..e944fab 100644 (file)
@@ -31,7 +31,7 @@ class XBT_PUBLIC Comm : public Activity {
   std::string tracing_category_       = "";
   std::atomic_int_fast32_t refcount_{0};
   /* FIXME: expose these elements in the API */
-  int detached_                                                           = 0;
+  bool detached_                                                          = false;
   int (*match_fun_)(void*, void*, kernel::activity::CommImpl*)            = nullptr;
   void (*clean_fun_)(void*)                                               = nullptr;
   void (*copy_data_function_)(kernel::activity::CommImpl*, void*, size_t) = nullptr;
index 1a6bb09..8034635 100644 (file)
@@ -211,7 +211,7 @@ XBT_PUBLIC smx_activity_t simcall_comm_isend(smx_actor_t sender, smx_mailbox_t m
                                              int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
                                              void (*clean_fun)(void*),
                                              void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
-                                             void* data, int detached);
+                                             void* data, bool detached);
 
 XBT_PUBLIC void simcall_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size,
                                   int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
index 2ee6f60..589af4a 100644 (file)
@@ -79,7 +79,6 @@ XBT_PUBLIC xbt_dictelm_t xbt_dict_get_elm_or_null(xbt_dict_t dict, const char* k
 XBT_PUBLIC void xbt_dict_remove(xbt_dict_t dict, const char* key);
 XBT_PUBLIC void xbt_dict_reset(xbt_dict_t dict);
 XBT_PUBLIC int xbt_dict_length(xbt_dict_t dict);
-XBT_PUBLIC void xbt_dict_dump(xbt_dict_t dict, void (*output)(void*));
 XBT_PUBLIC int xbt_dict_is_empty(xbt_dict_t dict);
 
 /** @} */
index 5e602a5..a9c8c10 100644 (file)
@@ -11,7 +11,6 @@
 /** Config Globals */
 
 XBT_PUBLIC_DATA int _sg_cfg_init_status;
-XBT_PUBLIC_DATA bool _sg_cfg_exit_asap;
 
 XBT_PUBLIC void sg_config_init(int* argc, char** argv);
 XBT_PUBLIC void sg_config_finalize();
index ed016d8..c30b301 100644 (file)
@@ -83,10 +83,6 @@ void VariableEvent::print()
   tracing_file << stream_.str() << std::endl;
 }
 
-StateEvent::~StateEvent(){
-  delete extra_;
-}
-
 void StateEvent::print()
 {
   if (trace_format == simgrid::instr::TraceFormat::Paje) {
index d57c644..d1004b1 100644 (file)
@@ -70,11 +70,10 @@ class StateEvent : public PajeEvent {
   std::string filename = "(null)";
   int linenumber       = -1;
 #endif
-  TIData* extra_;
+  std::unique_ptr<TIData> extra_;
 
 public:
   StateEvent(Container* container, Type* type, e_event_type event_type, EntityValue* value, TIData* extra);
-  ~StateEvent();
   void print() override;
 };
 
index 73cf3ac..5f19980 100644 (file)
@@ -35,7 +35,7 @@ XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend(
     size_t src_buff_size, int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
     void (*clean_fun)(void*), // used to free the synchro in case of problem after a detached send
     void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), // used to copy data if not default one
-    void* data, int detached)
+    void* data, bool detached)
 {
   XBT_DEBUG("send from mailbox %p", mbox);
 
@@ -73,7 +73,7 @@ XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend(
   }
 
   if (detached) {
-    other_comm->detached  = true;
+    other_comm->detached_ = true;
     other_comm->clean_fun = clean_fun;
   } else {
     other_comm->clean_fun = nullptr;
@@ -341,7 +341,7 @@ void SIMIX_comm_copy_buffer_callback(simgrid::kernel::activity::CommImpl* comm,
 {
   XBT_DEBUG("Copy the data over");
   memcpy(comm->dst_buff_, buff, buff_size);
-  if (comm->detached) { // if this is a detached send, the source buffer was duplicated by SMPI sender to make the
+  if (comm->detached_) { // if this is a detached send, the source buffer was duplicated by SMPI sender to make the
                         // original buffer available to the application ASAP
     xbt_free(buff);
     comm->src_buff_ = nullptr;
@@ -397,12 +397,11 @@ CommImpl& CommImpl::set_dst_buff(void* buff, size_t* size)
 
 CommImpl::~CommImpl()
 {
-  XBT_DEBUG("Really free communication %p in state %d (detached = %d)", this, static_cast<int>(state_),
-            static_cast<int>(detached));
+  XBT_DEBUG("Really free communication %p in state %d (detached = %d)", this, static_cast<int>(state_), detached_);
 
   cleanupSurf();
 
-  if (detached && state_ != SIMIX_DONE) {
+  if (detached_ && state_ != SIMIX_DONE) {
     /* the communication has failed and was detached:
      * we have to free the buffer */
     if (clean_fun)
@@ -508,7 +507,7 @@ void CommImpl::cancel()
 {
   /* if the synchro is a waiting state means that it is still in a mbox so remove from it and delete it */
   if (state_ == SIMIX_WAITING) {
-    if (not detached) {
+    if (not detached_) {
       mbox->remove(this);
       state_ = SIMIX_CANCELED;
     }
@@ -554,7 +553,7 @@ void CommImpl::post()
     state_ = SIMIX_DONE;
 
   XBT_DEBUG("SIMIX_post_comm: comm %p, state %d, src_proc %p, dst_proc %p, detached: %d", this, (int)state_,
-            src_actor_.get(), dst_actor_.get(), detached);
+            src_actor_.get(), dst_actor_.get(), detached_);
 
   /* destroy the surf actions associated with the Simix communication */
   cleanupSurf();
@@ -641,7 +640,7 @@ void CommImpl::finish()
                     "detached:%d",
                     this, src_actor_ ? src_actor_->get_host()->get_cname() : nullptr,
                     dst_actor_ ? dst_actor_->get_host()->get_cname() : nullptr, simcall->issuer->get_cname(),
-                    simcall->issuer, detached);
+                    simcall->issuer, detached_);
           if (src_actor_ == simcall->issuer) {
             XBT_DEBUG("I'm source");
           } else if (dst_actor_ == simcall->issuer) {
@@ -700,7 +699,7 @@ void CommImpl::finish()
 
     simcall->issuer->waiting_synchro = nullptr;
     simcall->issuer->comms.remove(this);
-    if (detached) {
+    if (detached_) {
       if (simcall->issuer == src_actor_) {
         if (dst_actor_)
           dst_actor_->comms.remove(this);
index 9bda708..0339005 100644 (file)
@@ -48,7 +48,7 @@ public:
                                      (comm.mbox set to nullptr when the communication is removed from the mailbox
                                      (used as garbage collector)) */
 #endif
-  bool detached = false; /* If detached or not */
+  bool detached_ = false; /* If detached or not */
 
   void (*clean_fun)(void*) = nullptr; /* Function to clean the detached src_buf if something goes wrong */
   int (*match_fun)(void*, void*, CommImpl*) = nullptr; /* Filter function used by the other side. It is used when
index d441926..64643ea 100644 (file)
@@ -97,7 +97,7 @@ bool actor_is_enabled(smx_actor_t actor)
           return true;
       }
       /* On the other hand if it hasn't a timeout, check if the comm is ready.*/
-      else if (act->detached && act->src_actor_ == nullptr &&
+      else if (act->detached_ && act->src_actor_ == nullptr &&
                act->type_ == simgrid::kernel::activity::CommImpl::Type::READY)
         return (act->dst_actor_ != nullptr);
       return (act->src_actor_ && act->dst_actor_);
index 035c8d7..436b425 100644 (file)
@@ -114,7 +114,7 @@ static inline smx_simcall_t MC_state_get_request_for_process(simgrid::mc::State*
       if (act->src_actor_.get() && act->dst_actor_.get())
         state->transition.argument = 0;
       else if (act->src_actor_.get() == nullptr && act->type_ == simgrid::kernel::activity::CommImpl::Type::READY &&
-               act->detached == 1)
+               act->detached_)
         state->transition.argument = 0;
       else
         state->transition.argument = -1;
index bc5f199..f6974f9 100644 (file)
@@ -157,16 +157,13 @@ void SD_init_nocheck(int *argc, char **argv)
 {
   xbt_assert(sd_global == nullptr, "SD_init() already called");
 
-  sd_global = new simgrid::sd::Global();
-
   surf_init(argc, argv);
 
+  sd_global = new simgrid::sd::Global();
+
   simgrid::config::set_default<std::string>("host/model", "ptask_L07");
   if (simgrid::config::get_value<bool>("clean-atexit"))
     atexit(SD_exit);
-  if (_sg_cfg_exit_asap) {
-    exit(0);
-  }
 }
 
 /** @brief set a configuration variable
index 6358b59..29ed310 100644 (file)
@@ -41,15 +41,6 @@ void sg_config_continue_after_help()
  */
 int _sg_cfg_init_status = 0;
 
-/* instruct the upper layer (simix or simdag) to exit as soon as possible */
-bool _sg_cfg_exit_asap = false;
-
-#define sg_cfg_exit_early()                                                                                            \
-  do {                                                                                                                 \
-    _sg_cfg_exit_asap = true;                                                                                          \
-    return;                                                                                                            \
-  } while (0)
-
 /* Parse the command line, looking for options */
 static void sg_config_cmd_line(int *argc, char **argv)
 {
@@ -102,10 +93,8 @@ static void sg_config_cmd_line(int *argc, char **argv)
       printf("\n");
       model_help("network", surf_network_model_description);
       printf("\nLong description of all optimization levels accepted by the models of this simulator:\n");
-      for (int k = 0; surf_optimization_mode_description[k].name; k++)
-        printf("  %s: %s\n",
-               surf_optimization_mode_description[k].name,
-               surf_optimization_mode_description[k].description);
+      for (auto const& item : surf_optimization_mode_description)
+        printf("  %s: %s\n", item.name, item.description);
       printf("Both network and CPU models have 'Lazy' as default optimization level\n\n");
       shall_exit = true;
     } else if (parse_args && not strcmp(argv[i], "--help-tracing")) {
@@ -120,7 +109,7 @@ static void sg_config_cmd_line(int *argc, char **argv)
     *argc = j;
   }
   if (shall_exit)
-    sg_cfg_exit_early();
+    exit(0);
 }
 
 /* callback of the plugin variable */
@@ -132,12 +121,12 @@ static void _sg_cfg_cb__plugin(const std::string& value)
     return;
 
   if (value == "help") {
-    model_help("plugin", surf_plugin_description);
-    sg_cfg_exit_early();
+    model_help("plugin", *surf_plugin_description);
+    exit(0);
   }
 
-  int plugin_id = find_model_description(surf_plugin_description, value);
-  surf_plugin_description[plugin_id].model_init_preparse();
+  int plugin_id = find_model_description(*surf_plugin_description, value);
+  (*surf_plugin_description)[plugin_id].model_init_preparse();
 }
 
 /* callback of the host/model variable */
@@ -147,7 +136,7 @@ static void _sg_cfg_cb__host_model(const std::string& value)
 
   if (value == "help") {
     model_help("host", surf_host_model_description);
-    sg_cfg_exit_early();
+    exit(0);
   }
 
   /* Make sure that the model exists */
@@ -161,7 +150,7 @@ static void _sg_cfg_cb__cpu_model(const std::string& value)
 
   if (value == "help") {
     model_help("CPU", surf_cpu_model_description);
-    sg_cfg_exit_early();
+    exit(0);
   }
 
   /* New Module missing */
@@ -175,7 +164,7 @@ static void _sg_cfg_cb__optimization_mode(const std::string& value)
 
   if (value == "help") {
     model_help("optimization", surf_optimization_mode_description);
-    sg_cfg_exit_early();
+    exit(0);
   }
 
   /* New Module missing */
@@ -189,7 +178,7 @@ static void _sg_cfg_cb__storage_mode(const std::string& value)
 
   if (value == "help") {
     model_help("storage", surf_storage_model_description);
-    sg_cfg_exit_early();
+    exit(0);
   }
 
   find_model_description(surf_storage_model_description, value);
@@ -202,7 +191,7 @@ static void _sg_cfg_cb__network_model(const std::string& value)
 
   if (value == "help") {
     model_help("network", surf_network_model_description);
-    sg_cfg_exit_early();
+    exit(0);
   }
 
   /* New Module missing */
@@ -224,28 +213,24 @@ static void _sg_cfg_cb_contexts_parallel_mode(const std::string& mode_name)
 }
 
 /* build description line with possible values */
-static void describe_model(char *result,int resultsize,
-                           const s_surf_model_description_t model_description[],
-                           const char *name,
-                           const char *description)
+static void declare_model_flag(const std::string& name, const std::string& value,
+                               const std::function<void(std::string const&)>& callback,
+                               const std::vector<surf_model_description_t>& model_description, const std::string& type,
+                               const std::string& descr)
 {
-  result[0] = '\0';
-  char *p = result;
-  p += snprintf(result,resultsize-1, "%s. Possible values: %s", description,
-            model_description[0].name ? model_description[0].name : "n/a");
-  for (int i = 1; model_description[i].name; i++)
-    p += snprintf(p,resultsize-(p-result)-1, ", %s", model_description[i].name);
-  p += snprintf(p,resultsize-(p-result)-1, ".\n       (use 'help' as a value to see the long description of each %s)", name);
-
-  xbt_assert(p<result+resultsize-1,"Buffer too small to display the model description of %s",name);
+  std::string description = descr + ". Possible values: ";
+  std::string sep         = "";
+  for (auto const& item : model_description) {
+    description += sep + item.name;
+    sep = ", ";
+  }
+  description += ".\n       (use 'help' as a value to see the long description of each " + type + ")";
+  simgrid::config::declare_flag<std::string>(name, description, value, callback);
 }
 
 /* create the config set, register what should be and parse the command line*/
 void sg_config_init(int *argc, char **argv)
 {
-  const int descsize = 1024;
-  char description[descsize];
-
   /* Create the configuration support */
   if (_sg_cfg_init_status != 0) { /* Only create stuff if not already inited */
     XBT_WARN("Call to sg_config_init() after initialization ignored");
@@ -253,24 +238,22 @@ void sg_config_init(int *argc, char **argv)
   }
 
   /* Plugins configuration */
-  describe_model(description, descsize, surf_plugin_description, "plugin", "The plugins");
-  simgrid::config::declare_flag<std::string>("plugin", description, "", &_sg_cfg_cb__plugin);
+  declare_model_flag("plugin", "", &_sg_cfg_cb__plugin, *surf_plugin_description, "plugin", "The plugins");
 
-  describe_model(description, descsize, surf_cpu_model_description, "model", "The model to use for the CPU");
-  simgrid::config::declare_flag<std::string>("cpu/model", description, "Cas01", &_sg_cfg_cb__cpu_model);
+  declare_model_flag("cpu/model", "Cas01", &_sg_cfg_cb__cpu_model, surf_cpu_model_description, "model",
+                     "The model to use for the CPU");
 
-  describe_model(description, descsize, surf_storage_model_description, "model", "The model to use for the storage");
-  simgrid::config::declare_flag<std::string>("storage/model", description, "default", &_sg_cfg_cb__storage_mode);
+  declare_model_flag("storage/model", "default", &_sg_cfg_cb__storage_mode, surf_storage_model_description, "model",
+                     "The model to use for the storage");
 
-  describe_model(description, descsize, surf_network_model_description, "model", "The model to use for the network");
-  simgrid::config::declare_flag<std::string>("network/model", description, "LV08", &_sg_cfg_cb__network_model);
+  declare_model_flag("network/model", "LV08", &_sg_cfg_cb__network_model, surf_network_model_description, "model",
+                     "The model to use for the network");
 
-  describe_model(description, descsize, surf_optimization_mode_description, "optimization mode",
-                 "The optimization modes to use for the network");
-  simgrid::config::declare_flag<std::string>("network/optim", description, "Lazy", &_sg_cfg_cb__optimization_mode);
+  declare_model_flag("network/optim", "Lazy", &_sg_cfg_cb__optimization_mode, surf_optimization_mode_description,
+                     "optimization mode", "The optimization modes to use for the network");
 
-  describe_model(description, descsize, surf_host_model_description, "model", "The model to use for the host");
-  simgrid::config::declare_flag<std::string>("host/model", description, "default", &_sg_cfg_cb__host_model);
+  declare_model_flag("host/model", "default", &_sg_cfg_cb__host_model, surf_host_model_description, "model",
+                     "The model to use for the host");
 
   simgrid::config::bind_flag(sg_surf_precision, "surf/precision",
                              "Numerical precision used when updating simulation times (in seconds)");
@@ -489,9 +472,6 @@ void sg_config_init(int *argc, char **argv)
 
 void sg_config_finalize()
 {
-  if (not _sg_cfg_init_status)
-    return;                     /* Not initialized yet. Nothing to do */
-
   simgrid::config::finalize();
   _sg_cfg_init_status = 0;
 }
index 2840515..cd27911 100644 (file)
@@ -110,7 +110,7 @@ smx_activity_t simcall_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double
                                   int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
                                   void (*clean_fun)(void*),
                                   void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
-                                  void* data, int detached)
+                                  void* data, bool detached)
 {
   /* checking for infinite values */
   xbt_assert(std::isfinite(task_size), "task_size is not finite!");
index 0d92249..e4dc4f0 100644 (file)
@@ -98,8 +98,7 @@ static inline simgrid::kernel::activity::ExecImpl* simcall_execution_wait__getra
 {
   return simgrid::simix::unmarshal_raw<simgrid::kernel::activity::ExecImpl*>(simcall->args[0]);
 }
-static inline void simcall_execution_wait__set__execution(smx_simcall_t simcall,
-                                                          simgrid::kernel::activity::ExecImpl* arg)
+static inline void simcall_execution_wait__set__execution(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* arg)
 {
   simgrid::simix::marshal<simgrid::kernel::activity::ExecImpl*>(simcall->args[0], arg);
 }
@@ -124,8 +123,7 @@ static inline simgrid::kernel::activity::ExecImpl* simcall_execution_test__getra
 {
   return simgrid::simix::unmarshal_raw<simgrid::kernel::activity::ExecImpl*>(simcall->args[0]);
 }
-static inline void simcall_execution_test__set__execution(smx_simcall_t simcall,
-                                                          simgrid::kernel::activity::ExecImpl* arg)
+static inline void simcall_execution_test__set__execution(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* arg)
 {
   simgrid::simix::marshal<simgrid::kernel::activity::ExecImpl*>(simcall->args[0], arg);
 }
@@ -383,17 +381,17 @@ static inline void simcall_comm_isend__set__data(smx_simcall_t simcall, void* ar
 {
   simgrid::simix::marshal<void*>(simcall->args[9], arg);
 }
-static inline int simcall_comm_isend__get__detached(smx_simcall_t simcall)
+static inline bool simcall_comm_isend__get__detached(smx_simcall_t simcall)
 {
-  return simgrid::simix::unmarshal<int>(simcall->args[10]);
+  return simgrid::simix::unmarshal<bool>(simcall->args[10]);
 }
-static inline int simcall_comm_isend__getraw__detached(smx_simcall_t simcall)
+static inline bool simcall_comm_isend__getraw__detached(smx_simcall_t simcall)
 {
-  return simgrid::simix::unmarshal_raw<int>(simcall->args[10]);
+  return simgrid::simix::unmarshal_raw<bool>(simcall->args[10]);
 }
-static inline void simcall_comm_isend__set__detached(smx_simcall_t simcall, int arg)
+static inline void simcall_comm_isend__set__detached(smx_simcall_t simcall, bool arg)
 {
-  simgrid::simix::marshal<int>(simcall->args[10], arg);
+  simgrid::simix::marshal<bool>(simcall->args[10], arg);
 }
 static inline boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> simcall_comm_isend__get__result(smx_simcall_t simcall)
 {
@@ -1033,16 +1031,13 @@ XBT_PRIVATE void simcall_HANDLER_process_sleep(smx_simcall_t simcall, double dur
 XBT_PRIVATE void simcall_HANDLER_execution_wait(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* execution);
 XBT_PRIVATE void simcall_HANDLER_execution_test(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* execution);
 XBT_PRIVATE void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout);
-XBT_PRIVATE boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, int detached);
+XBT_PRIVATE boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, bool detached);
 XBT_PRIVATE void simcall_HANDLER_comm_recv(smx_simcall_t simcall, smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout, double rate);
 XBT_PRIVATE boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> simcall_HANDLER_comm_irecv(smx_simcall_t simcall, smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double rate);
-XBT_PRIVATE void simcall_HANDLER_comm_waitany(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl** comms,
-                                              size_t count, double timeout);
-XBT_PRIVATE void simcall_HANDLER_comm_wait(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl* comm,
-                                           double timeout);
+XBT_PRIVATE void simcall_HANDLER_comm_waitany(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl** comms, size_t count, double timeout);
+XBT_PRIVATE void simcall_HANDLER_comm_wait(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl* comm, double timeout);
 XBT_PRIVATE void simcall_HANDLER_comm_test(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl* comm);
-XBT_PRIVATE void simcall_HANDLER_comm_testany(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl** comms,
-                                              size_t count);
+XBT_PRIVATE void simcall_HANDLER_comm_testany(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl** comms, size_t count);
 XBT_PRIVATE void simcall_HANDLER_mutex_lock(smx_simcall_t simcall, smx_mutex_t mutex);
 XBT_PRIVATE int simcall_HANDLER_mutex_trylock(smx_simcall_t simcall, smx_mutex_t mutex);
 XBT_PRIVATE void simcall_HANDLER_mutex_unlock(smx_simcall_t simcall, smx_mutex_t mutex);
index 17dfef1..4234bb9 100644 (file)
@@ -78,11 +78,11 @@ inline static void simcall_BODY_comm_send(smx_actor_t sender, smx_mailbox_t mbox
   return simcall<void, smx_actor_t, smx_mailbox_t, double, double, void*, size_t, simix_match_func_t, simix_copy_data_func_t, void*, double>(SIMCALL_COMM_SEND, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, copy_data_fun, data, timeout);
 }
 
-inline static boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> simcall_BODY_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, int detached)
+inline static boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> simcall_BODY_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, bool detached)
 {
   if (0) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_comm_isend(&SIMIX_process_self()->simcall, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, clean_fun, copy_data_fun, data, detached);
-  return simcall<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>, smx_actor_t, smx_mailbox_t, double, double, void*, size_t, simix_match_func_t, simix_clean_func_t, simix_copy_data_func_t, void*, int>(SIMCALL_COMM_ISEND, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, clean_fun, copy_data_fun, data, detached);
+  return simcall<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>, smx_actor_t, smx_mailbox_t, double, double, void*, size_t, simix_match_func_t, simix_clean_func_t, simix_copy_data_func_t, void*, bool>(SIMCALL_COMM_ISEND, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, clean_fun, copy_data_fun, data, detached);
 }
 
 inline static void simcall_BODY_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout, double rate)
@@ -103,8 +103,7 @@ inline static int simcall_BODY_comm_waitany(simgrid::kernel::activity::CommImpl*
 {
   if (0) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_comm_waitany(&SIMIX_process_self()->simcall, comms, count, timeout);
-  return simcall<int, simgrid::kernel::activity::CommImpl**, size_t, double>(SIMCALL_COMM_WAITANY, comms, count,
-                                                                             timeout);
+  return simcall<int, simgrid::kernel::activity::CommImpl**, size_t, double>(SIMCALL_COMM_WAITANY, comms, count, timeout);
 }
 
 inline static void simcall_BODY_comm_wait(simgrid::kernel::activity::CommImpl* comm, double timeout)
index 9306f6c..71542d4 100644 (file)
@@ -76,13 +76,11 @@ case SIMCALL_PROCESS_SLEEP:
   break;
 
 case SIMCALL_EXECUTION_WAIT:
-  simcall_HANDLER_execution_wait(simcall,
-                                 simgrid::simix::unmarshal<simgrid::kernel::activity::ExecImpl*>(simcall->args[0]));
+  simcall_HANDLER_execution_wait(simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::ExecImpl*>(simcall->args[0]));
   break;
 
 case SIMCALL_EXECUTION_TEST:
-  simcall_HANDLER_execution_test(simcall,
-                                 simgrid::simix::unmarshal<simgrid::kernel::activity::ExecImpl*>(simcall->args[0]));
+  simcall_HANDLER_execution_test(simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::ExecImpl*>(simcall->args[0]));
   break;
 
 case SIMCALL_COMM_SEND:
@@ -90,7 +88,7 @@ case SIMCALL_COMM_SEND:
   break;
 
 case SIMCALL_COMM_ISEND:
-  simgrid::simix::marshal<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>>(simcall->result, simcall_HANDLER_comm_isend(simcall, simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]), simgrid::simix::unmarshal<smx_mailbox_t>(simcall->args[1]), simgrid::simix::unmarshal<double>(simcall->args[2]), simgrid::simix::unmarshal<double>(simcall->args[3]), simgrid::simix::unmarshal<void*>(simcall->args[4]), simgrid::simix::unmarshal<size_t>(simcall->args[5]), simgrid::simix::unmarshal<simix_match_func_t>(simcall->args[6]), simgrid::simix::unmarshal<simix_clean_func_t>(simcall->args[7]), simgrid::simix::unmarshal<simix_copy_data_func_t>(simcall->args[8]), simgrid::simix::unmarshal<void*>(simcall->args[9]), simgrid::simix::unmarshal<int>(simcall->args[10])));
+  simgrid::simix::marshal<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>>(simcall->result, simcall_HANDLER_comm_isend(simcall, simgrid::simix::unmarshal<smx_actor_t>(simcall->args[0]), simgrid::simix::unmarshal<smx_mailbox_t>(simcall->args[1]), simgrid::simix::unmarshal<double>(simcall->args[2]), simgrid::simix::unmarshal<double>(simcall->args[3]), simgrid::simix::unmarshal<void*>(simcall->args[4]), simgrid::simix::unmarshal<size_t>(simcall->args[5]), simgrid::simix::unmarshal<simix_match_func_t>(simcall->args[6]), simgrid::simix::unmarshal<simix_clean_func_t>(simcall->args[7]), simgrid::simix::unmarshal<simix_copy_data_func_t>(simcall->args[8]), simgrid::simix::unmarshal<void*>(simcall->args[9]), simgrid::simix::unmarshal<bool>(simcall->args[10])));
   SIMIX_simcall_answer(simcall);
   break;
 
@@ -104,14 +102,11 @@ case SIMCALL_COMM_IRECV:
   break;
 
 case SIMCALL_COMM_WAITANY:
-  simcall_HANDLER_comm_waitany(
-      simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::CommImpl**>(simcall->args[0]),
-      simgrid::simix::unmarshal<size_t>(simcall->args[1]), simgrid::simix::unmarshal<double>(simcall->args[2]));
+  simcall_HANDLER_comm_waitany(simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::CommImpl**>(simcall->args[0]), simgrid::simix::unmarshal<size_t>(simcall->args[1]), simgrid::simix::unmarshal<double>(simcall->args[2]));
   break;
 
 case SIMCALL_COMM_WAIT:
-  simcall_HANDLER_comm_wait(simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::CommImpl*>(simcall->args[0]),
-                            simgrid::simix::unmarshal<double>(simcall->args[1]));
+  simcall_HANDLER_comm_wait(simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::CommImpl*>(simcall->args[0]), simgrid::simix::unmarshal<double>(simcall->args[1]));
   break;
 
 case SIMCALL_COMM_TEST:
@@ -119,9 +114,7 @@ case SIMCALL_COMM_TEST:
   break;
 
 case SIMCALL_COMM_TESTANY:
-  simcall_HANDLER_comm_testany(simcall,
-                               simgrid::simix::unmarshal<simgrid::kernel::activity::CommImpl**>(simcall->args[0]),
-                               simgrid::simix::unmarshal<size_t>(simcall->args[1]));
+  simcall_HANDLER_comm_testany(simcall, simgrid::simix::unmarshal<simgrid::kernel::activity::CommImpl**>(simcall->args[0]), simgrid::simix::unmarshal<size_t>(simcall->args[1]));
   break;
 
 case SIMCALL_MUTEX_LOCK:
index c20bd04..b6a60d9 100644 (file)
@@ -23,6 +23,7 @@ typedef void (*FPtr)(void); // Hide the ugliness
 
 /* Pack all possible scalar types in an union */
 union u_smx_scalar {
+  bool b;
   char c;
   short s;
   int i;
@@ -94,6 +95,7 @@ template <typename T> struct marshal_t {
   inline T unmarshal_raw(type<T>, u_smx_scalar const& simcall)                                                         \
   { /* Exactly same as unmarshal. It differs only for intrusive_ptr */ return simcall.field; }
 
+SIMIX_MARSHAL(bool, b);
 SIMIX_MARSHAL(char, c);
 SIMIX_MARSHAL(short, s);
 SIMIX_MARSHAL(int, i);
index a657616..5eeaa1a 100644 (file)
@@ -43,7 +43,7 @@ int           execution_wait(simgrid::kernel::activity::ExecImpl* execution) [[b
 int           execution_test(simgrid::kernel::activity::ExecImpl* execution) [[block]];
 
 void           comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout) [[block]];
-boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, int detached);
+boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, bool detached);
 void           comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout, double rate) [[block]];
 boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double rate);
 int            comm_waitany(simgrid::kernel::activity::CommImpl** comms, size_t count, double timeout) [[block]];
index 4a300d8..b463c5a 100644 (file)
@@ -192,10 +192,10 @@ void SIMIX_global_init(int *argc, char **argv)
 #endif
 
   if (simix_global == nullptr) {
+    surf_init(argc, argv); /* Initialize SURF structures */
+
     simix_global.reset(new simgrid::simix::Global());
     simix_global->maestro_process = nullptr;
-
-    surf_init(argc, argv);      /* Initialize SURF structures */
     SIMIX_context_mod_init();
 
     // Either create a new context with maestro or create
@@ -220,9 +220,6 @@ void SIMIX_global_init(int *argc, char **argv)
 
   if (simgrid::config::get_value<bool>("clean-atexit"))
     atexit(SIMIX_clean);
-
-  if (_sg_cfg_exit_asap)
-    exit(0);
 }
 
 int smx_cleaned = 0;
index 6d68c96..e6bba6d 100644 (file)
@@ -7,6 +7,7 @@
 #define SMPI_COMM_HPP_INCLUDED
 
 #include <list>
+#include <string>
 #include "smpi_keyvals.hpp"
 #include "smpi_group.hpp"
 #include "smpi_topo.hpp"
index a4fa0d5..82e5993 100644 (file)
@@ -38,16 +38,16 @@ class Request : public F2C {
   // We can't override src, tag, and size, because the request may be reused later
   int real_src_;
   int real_tag_;
-  int truncated_;
+  bool truncated_;
   size_t real_size_;
   MPI_Comm comm_;
   smx_activity_t action_;
   unsigned flags_;
-  int detached_;
+  bool detached_;
   MPI_Request detached_sender_;
   int refcount_;
   MPI_Op op_;
-  int cancelled_;
+  int cancelled_; // tri-state
   smpi_mpi_generalized_request_funcs generalized_funcs;
   MPI_Request* nbc_requests_;
   int nbc_requests_size_;
@@ -62,7 +62,7 @@ public:
   int dst() { return dst_; }
   int tag() { return tag_; }
   int flags() { return flags_; }
-  int detached() { return detached_; }
+  bool detached() { return detached_; }
   MPI_Datatype type() { return old_type_; }
   void print_request(const char* message);
   void start();
index 26aafa4..408be49 100644 (file)
@@ -216,7 +216,7 @@ void smpi_comm_copy_buffer_callback(simgrid::kernel::activity::CommImpl* comm, v
   XBT_DEBUG("Copying %zu bytes from %p to %p", buff_size, tmpbuff, comm->dst_buff_);
   memcpy_private(comm->dst_buff_, tmpbuff, private_blocks);
 
-  if (comm->detached) {
+  if (comm->detached_) {
     // if this is a detached send, the source buffer was duplicated by SMPI
     // sender to make the original buffer available to the application ASAP
     xbt_free(buff);
index e10dea9..6287d7c 100644 (file)
@@ -61,10 +61,10 @@ Request::Request(void* buf, int count, MPI_Datatype datatype, int src, int dst,
   if(op != MPI_REPLACE && op != MPI_OP_NULL)
     op_->ref();
   action_          = nullptr;
-  detached_        = 0;
+  detached_        = false;
   detached_sender_ = nullptr;
   real_src_        = 0;
-  truncated_       = 0;
+  truncated_       = false;
   real_size_       = 0;
   real_tag_        = 0;
   if (flags & MPI_REQ_PERSISTENT)
@@ -126,8 +126,8 @@ int Request::match_recv(void* a, void* b, simgrid::kernel::activity::CommImpl*)
     if(ref->tag_ == MPI_ANY_TAG)
       ref->real_tag_ = req->tag_;
     if(ref->real_size_ < req->real_size_)
-      ref->truncated_ = 1;
-    if(req->detached_==1)
+      ref->truncated_ = true;
+    if (req->detached_)
       ref->detached_sender_=req; //tie the sender to the receiver, as it is detached and has to be freed in the receiver
     if(req->cancelled_==0)
       req->cancelled_=-1;//mark as uncancellable
@@ -151,8 +151,8 @@ int Request::match_send(void* a, void* b, simgrid::kernel::activity::CommImpl*)
     if(req->tag_ == MPI_ANY_TAG)
       req->real_tag_ = ref->tag_;
     if(req->real_size_ < ref->real_size_)
-      req->truncated_ = 1;
-    if(ref->detached_==1)
+      req->truncated_ = true;
+    if (ref->detached_)
       req->detached_sender_=ref; //tie the sender to the receiver, as it is detached and has to be freed in the receiver
     if(req->cancelled_==0)
       req->cancelled_=-1;//mark as uncancellable
@@ -409,7 +409,7 @@ void Request::start()
         ((flags_ & MPI_REQ_RMA) != 0 ||
          static_cast<int>(size_) < simgrid::config::get_value<int>("smpi/send-is-detached-thresh"))) {
       void *oldbuf = nullptr;
-      detached_ = 1;
+      detached_    = true;
       XBT_DEBUG("Send request %p is detached", this);
       this->ref();
       if (not(old_type_->flags() & DT_FLAG_DERIVED)) {
@@ -430,7 +430,7 @@ void Request::start()
 
     //if we are giving back the control to the user without waiting for completion, we have to inject timings
     double sleeptime = 0.0;
-    if (detached_ != 0 || ((flags_ & (MPI_REQ_ISEND | MPI_REQ_SSEND)) != 0)) { // issend should be treated as isend
+    if (detached_ || ((flags_ & (MPI_REQ_ISEND | MPI_REQ_SSEND)) != 0)) { // issend should be treated as isend
       // isend and send timings may be different
       sleeptime = ((flags_ & MPI_REQ_ISEND) != 0)
                       ? simgrid::s4u::Actor::self()->get_host()->extension<simgrid::smpi::Host>()->oisend(size_)
@@ -797,14 +797,13 @@ void Request::finish_wait(MPI_Request* request, MPI_Status * status)
     return;
   }
 
-  if (not((req->detached_ != 0) && ((req->flags_ & MPI_REQ_SEND) != 0)) 
-  && ((req->flags_ & MPI_REQ_PREPARED) == 0)
-  && ((req->flags_ & MPI_REQ_GENERALIZED) == 0)) {
+  if (not(req->detached_ && ((req->flags_ & MPI_REQ_SEND) != 0)) && ((req->flags_ & MPI_REQ_PREPARED) == 0) &&
+      ((req->flags_ & MPI_REQ_GENERALIZED) == 0)) {
     if(status != MPI_STATUS_IGNORE) {
       int src = req->src_ == MPI_ANY_SOURCE ? req->real_src_ : req->src_;
       status->MPI_SOURCE = req->comm_->group()->rank(src);
       status->MPI_TAG = req->tag_ == MPI_ANY_TAG ? req->real_tag_ : req->tag_;
-      status->MPI_ERROR = req->truncated_ != 0 ? MPI_ERR_TRUNCATE : MPI_SUCCESS;
+      status->MPI_ERROR  = req->truncated_ ? MPI_ERR_TRUNCATE : MPI_SUCCESS;
       // this handles the case were size in receive differs from size in send
       status->count = req->real_size_;
     }
@@ -1060,7 +1059,7 @@ int Request::waitsome(int incount, MPI_Request requests[], int *indices, MPI_Sta
   indices[count] = index;
   count++;
   for (int i = 0; i < incount; i++) {
-    if((requests[i] != MPI_REQUEST_NULL)) {
+    if (requests[i] != MPI_REQUEST_NULL) {
       test(&requests[i], pstat,&flag);
       if (flag==1){
         indices[count] = i;
index 8beb759..21b718b 100644 (file)
@@ -36,24 +36,23 @@ std::vector<std::string> surf_path;
 std::set<std::string> watched_hosts;
 extern std::map<std::string, simgrid::kernel::resource::StorageType*> storage_types;
 
-s_surf_model_description_t* surf_plugin_description = nullptr;
-XBT_PUBLIC void simgrid_add_plugin_description(const char* name, const char* description, void_f_void_t init_fun)
-{
-  static int plugin_amount = 0;
-
-  /* no need to check for plugin name conflict: the compiler already ensures that the generated
-   * simgrid_##id##_plugin_register() is unique */
+std::vector<surf_model_description_t>* surf_plugin_description = nullptr;
 
-  plugin_amount++;
-  surf_plugin_description = static_cast<s_surf_model_description_t*>(
-      xbt_realloc(surf_plugin_description, sizeof(s_surf_model_description_t) * (plugin_amount + 2)));
+static void XBT_ATTRIB_DESTRUCTOR(800) simgrid_free_plugin_description()
+{
+  delete surf_plugin_description;
+  surf_plugin_description = nullptr;
+}
 
-  surf_plugin_description[plugin_amount - 1] = {name, description, init_fun};
-  surf_plugin_description[plugin_amount]     = {nullptr, nullptr, nullptr}; // this array must be null terminated
+XBT_PUBLIC void simgrid_add_plugin_description(const char* name, const char* description, void_f_void_t init_fun)
+{
+  if (not surf_plugin_description)
+    surf_plugin_description = new std::vector<surf_model_description_t>;
+  surf_plugin_description->emplace_back(surf_model_description_t{name, description, init_fun});
 }
 
 /* Don't forget to update the option description in smx_config when you change this */
-s_surf_model_description_t surf_network_model_description[] = {
+const std::vector<surf_model_description_t> surf_network_model_description = {
     {"LV08", "Realistic network analytic model (slow-start modeled by multiplying latency by 13.01, bandwidth by .97; "
              "bottleneck sharing uses a payload of S=20537 for evaluating RTT). ",
      &surf_network_model_init_LegrandVelho},
@@ -78,7 +77,6 @@ s_surf_model_description_t surf_network_model_description[] = {
     {"Vegas",
      "Model from Steven H. Low using lagrange_solve instead of lmm_solve (experts only; check the code for more info).",
      &surf_network_model_init_Vegas},
-    {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
 };
 
 #if ! HAVE_SMPI
@@ -95,28 +93,29 @@ void surf_network_model_init_NS3() {
 }
 #endif
 
-s_surf_model_description_t surf_cpu_model_description[] = {
-  {"Cas01", "Simplistic CPU model (time=size/power).", &surf_cpu_model_init_Cas01},
-  {nullptr, nullptr,  nullptr}      /* this array must be nullptr terminated */
+const std::vector<surf_model_description_t> surf_cpu_model_description = {
+    {"Cas01", "Simplistic CPU model (time=size/power).", &surf_cpu_model_init_Cas01},
 };
 
-s_surf_model_description_t surf_host_model_description[] = {
-  {"default",   "Default host model. Currently, CPU:Cas01 and network:LV08 (with cross traffic enabled)", &surf_host_model_init_current_default},
-  {"compound",  "Host model that is automatically chosen if you change the network and CPU models", &surf_host_model_init_compound},
-  {"ptask_L07", "Host model somehow similar to Cas01+CM02 but allowing parallel tasks", &surf_host_model_init_ptask_L07},
-  {nullptr, nullptr, nullptr}      /* this array must be nullptr terminated */
+const std::vector<surf_model_description_t> surf_host_model_description = {
+    {"default", "Default host model. Currently, CPU:Cas01 and network:LV08 (with cross traffic enabled)",
+     &surf_host_model_init_current_default},
+    {"compound", "Host model that is automatically chosen if you change the network and CPU models",
+     &surf_host_model_init_compound},
+    {"ptask_L07", "Host model somehow similar to Cas01+CM02 but allowing parallel tasks",
+     &surf_host_model_init_ptask_L07},
 };
 
-s_surf_model_description_t surf_optimization_mode_description[] = {
-  {"Lazy", "Lazy action management (partial invalidation in lmm + heap in action remaining).", nullptr},
-  {"TI",   "Trace integration. Highly optimized mode when using availability traces (only available for the Cas01 CPU model for now).", nullptr},
-  {"Full", "Full update of remaining and variables. Slow but may be useful when debugging.", nullptr},
-  {nullptr, nullptr, nullptr}      /* this array must be nullptr terminated */
+const std::vector<surf_model_description_t> surf_optimization_mode_description = {
+    {"Lazy", "Lazy action management (partial invalidation in lmm + heap in action remaining).", nullptr},
+    {"TI", "Trace integration. Highly optimized mode when using availability traces (only available for the Cas01 CPU "
+           "model for now).",
+     nullptr},
+    {"Full", "Full update of remaining and variables. Slow but may be useful when debugging.", nullptr},
 };
 
-s_surf_model_description_t surf_storage_model_description[] = {
-  {"default", "Simplistic storage model.", &surf_storage_model_init_default},
-  {nullptr, nullptr,  nullptr}      /* this array must be nullptr terminated */
+const std::vector<surf_model_description_t> surf_storage_model_description = {
+    {"default", "Simplistic storage model.", &surf_storage_model_init_default},
 };
 
 double NOW = 0;
@@ -185,25 +184,29 @@ FILE* surf_fopen(const std::string& name, const char* mode)
 }
 
 /** Displays the long description of all registered models, and quit */
-void model_help(const char *category, s_surf_model_description_t * table)
+void model_help(const char* category, const std::vector<surf_model_description_t>& table)
 {
   printf("Long description of the %s models accepted by this simulator:\n", category);
-  for (int i = 0; table[i].name; i++)
-    printf("  %s: %s\n", table[i].name, table[i].description);
+  for (auto const& item : table)
+    printf("  %s: %s\n", item.name, item.description);
 }
 
-int find_model_description(s_surf_model_description_t* table, const std::string& name)
+int find_model_description(const std::vector<surf_model_description_t>& table, const std::string& name)
 {
-  for (int i = 0; table[i].name; i++)
-    if (name == table[i].name)
-      return i;
+  auto pos = std::find_if(table.begin(), table.end(),
+                          [&name](const surf_model_description_t& item) { return item.name == name; });
+  if (pos != table.end())
+    return std::distance(table.begin(), pos);
 
-  if (not table[0].name)
+  if (table.empty())
     xbt_die("No model is valid! This is a bug.");
 
-  std::string name_list = std::string(table[0].name);
-  for (int i = 1; table[i].name; i++)
-    name_list = name_list + ", " + table[i].name;
+  std::string sep;
+  std::string name_list;
+  for (auto const& item : table) {
+    name_list += sep + item.name;
+    sep = ", ";
+  }
 
   xbt_die("Model '%s' is invalid! Valid models are: %s.", name.c_str(), name_list.c_str());
   return -1;
@@ -314,8 +317,6 @@ void surf_exit()
   for (auto const& model : all_existing_models)
     delete model;
 
-  xbt_free(surf_plugin_description);
-
   tmgr_finalize();
   sg_platf_exit();
 
index 6a602cc..82ca23e 100644 (file)
@@ -206,37 +206,36 @@ XBT_PUBLIC void surf_storage_model_init_default();
  *  Model Descriptions
  * -------------------- */
 /** @brief Resource model description */
-struct surf_model_description {
+struct surf_model_description_t {
   const char* name;
   const char* description;
   void_f_void_t model_init_preparse;
 };
-typedef struct surf_model_description s_surf_model_description_t;
 
-XBT_PUBLIC int find_model_description(s_surf_model_description_t* table, const std::string& name);
-XBT_PUBLIC void model_help(const char* category, s_surf_model_description_t* table);
+XBT_PUBLIC int find_model_description(const std::vector<surf_model_description_t>& table, const std::string& name);
+XBT_PUBLIC void model_help(const char* category, const std::vector<surf_model_description_t>& table);
 
-#define SIMGRID_REGISTER_PLUGIN(id, desc, init)                       \
-  void simgrid_##id##_plugin_register();                              \
-  void XBT_ATTRIB_CONSTRUCTOR(800) simgrid_##id##_plugin_register() { \
-    simgrid_add_plugin_description(#id, desc, init);                  \
+#define SIMGRID_REGISTER_PLUGIN(id, desc, init)                                                                        \
+  static void XBT_ATTRIB_CONSTRUCTOR(800) simgrid_##id##_plugin_register()                                             \
+  {                                                                                                                    \
+    simgrid_add_plugin_description(#id, desc, init);                                                                   \
   }
 
 XBT_PUBLIC void simgrid_add_plugin_description(const char* name, const char* description, void_f_void_t init_fun);
 
 /** @brief The list of all available plugins */
-XBT_PUBLIC_DATA s_surf_model_description_t* surf_plugin_description;
+XBT_PUBLIC_DATA std::vector<surf_model_description_t>* surf_plugin_description;
 /** @brief The list of all available optimization modes (both for cpu and networks).
  *  These optimization modes can be set using --cfg=cpu/optim:... and --cfg=network/optim:... */
-XBT_PUBLIC_DATA s_surf_model_description_t surf_optimization_mode_description[];
+XBT_PUBLIC_DATA const std::vector<surf_model_description_t> surf_optimization_mode_description;
 /** @brief The list of all cpu models (pick one with --cfg=cpu/model) */
-XBT_PUBLIC_DATA s_surf_model_description_t surf_cpu_model_description[];
+XBT_PUBLIC_DATA const std::vector<surf_model_description_t> surf_cpu_model_description;
 /** @brief The list of all network models (pick one with --cfg=network/model) */
-XBT_PUBLIC_DATA s_surf_model_description_t surf_network_model_description[];
+XBT_PUBLIC_DATA const std::vector<surf_model_description_t> surf_network_model_description;
 /** @brief The list of all storage models (pick one with --cfg=storage/model) */
-XBT_PUBLIC_DATA s_surf_model_description_t surf_storage_model_description[];
+XBT_PUBLIC_DATA const std::vector<surf_model_description_t> surf_storage_model_description;
 /** @brief The list of all host models (pick one with --cfg=host/model:) */
-XBT_PUBLIC_DATA s_surf_model_description_t surf_host_model_description[];
+XBT_PUBLIC_DATA const std::vector<surf_model_description_t> surf_host_model_description;
 
 /**********
  * Action *
index e15c41d..94be19e 100644 (file)
@@ -397,40 +397,6 @@ int xbt_dict_is_empty(xbt_dict_t dict)
   return not dict || (xbt_dict_length(dict) == 0);
 }
 
-/**
- * @brief Outputs the content of the structure (debugging purpose)
- *
- * @param dict the exibitionist
- * @param output a function to dump each data in the tree
- *
- * Outputs the content of the structure. (for debugging purpose).
- * @a output is a function to output the data. If nullptr, data won't be displayed.
- */
-void xbt_dict_dump(xbt_dict_t dict, void_f_pvoid_t output)
-{
-  xbt_dictelm_t element;
-  printf("Dict %p:\n", dict);
-  if (dict != nullptr) {
-    for (int i = 0; i < dict->table_size; i++) {
-      element = dict->table[i];
-      if (element) {
-        printf("[\n");
-        while (element != nullptr) {
-          printf(" %s -> '", element->key);
-          if (output != nullptr) {
-            output(element->content);
-          }
-          printf("'\n");
-          element = element->next;
-        }
-        printf("]\n");
-      } else {
-        printf("[]\n");
-      }
-    }
-  }
-}
-
 /**
  * Create the dict mallocators.
  * This is an internal XBT function called during the lib initialization.
index e13e3e2..53fb168 100644 (file)
@@ -78,9 +78,10 @@ foreach(x availability basic0 basic1 basic3 basic4 basic5 basic6 basic-link-test
 endforeach()
 
 # test for code coverage
-foreach(x version help help-logs help-log-categories help-aliases help-models help-tracing)
-  ADD_TEST(test-${x} ${CMAKE_BINARY_DIR}/teshsuite/simdag/basic-parsing-test/basic-parsing-test --${x})
-endforeach()
+ADD_TEST(test-help-version ${TESH_WRAPPER_UNBOXED} ${CMAKE_BINARY_DIR}/teshsuite/simdag/basic-parsing-test/basic-parsing-test
+  --version --help --help-aliases --help-models --help-tracing)
+ADD_TEST(test-help-logs    ${TESH_WRAPPER_UNBOXED} ${CMAKE_BINARY_DIR}/teshsuite/simdag/basic-parsing-test/basic-parsing-test
+  --help-logs --help-log-categories)
 
 ADD_TESH(tesh-simdag-parser-bypass   --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simdag/basic-parsing-test --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/basic-parsing-test --setenv srcdir=${CMAKE_HOME_DIRECTORY} basic-parsing-test-bypass.tesh)
 ADD_TESH(tesh-simdag-parser-sym-full --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simdag/basic-parsing-test --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/basic-parsing-test basic-parsing-test-sym-full.tesh)
index 2a23033..3d96f66 100644 (file)
@@ -87,7 +87,3 @@ $ cat ${bindir:=.}/log_usage_1.log
 > [  0.000000] [0:maestro@] false alarm!
 
 $ rm -f ${bindir:=.}/log_usage.log ${bindir:=.}/log_usage_0.log ${bindir:=.}/log_usage_1.log
-
-# Would be nice for code coverage, but the early exit leads to lots of memory leaks
-#! output ignore
-#$ $SG_TEST_EXENV ${bindir:=.}/log_usage --help-logs --help-log-categories
index c175f19..f587730 100644 (file)
@@ -30,6 +30,8 @@ IF(enable_memcheck)
     message(STATUS "Error: Command valgrind not found --> enable_memcheck autoset to false.")
   endif()
 ENDIF()
+SET(TESH_WRAPPER_UNBOXED "${TESH_WRAPPER}")
+SEPARATE_ARGUMENTS(TESH_WRAPPER_UNBOXED)
 
 #some tests may take forever on non futexes systems, using busy_wait with n cores < n workers
 # default to posix for these tests if futexes are not supported