Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
properties are now stored in maps and managed by ProperyHolder
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 1 Aug 2017 13:42:36 +0000 (15:42 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 1 Aug 2017 13:44:29 +0000 (15:44 +0200)
everywhere!

31 files changed:
examples/msg/trace-masterworker/trace-masterworker.tesh
include/simgrid/msg.h
include/simgrid/s4u/Host.hpp
include/simgrid/s4u/Storage.hpp
include/simgrid/simix.h
include/simgrid/simix.hpp
src/include/surf/surf.h
src/kernel/routing/NetZoneImpl.cpp
src/kernel/routing/NetZoneImpl.hpp
src/msg/msg_host.cpp
src/msg/msg_io.cpp
src/msg/msg_private.h
src/msg/msg_process.cpp
src/s4u/s4u_actor.cpp
src/s4u/s4u_host.cpp
src/s4u/s4u_storage.cpp
src/simgrid/host.cpp
src/simix/ActorImpl.cpp
src/simix/ActorImpl.hpp
src/simix/libsmx.cpp
src/simix/smx_host.cpp
src/simix/smx_host_private.h
src/surf/PropertyHolder.cpp
src/surf/PropertyHolder.hpp
src/surf/StorageImpl.hpp
src/surf/sg_platf.cpp
src/surf/surf_interface.cpp
src/surf/xml/platf_private.hpp
src/surf/xml/surfxml_sax_cb.cpp
teshsuite/s4u/storage_client_server/storage_client_server.cpp
teshsuite/simdag/basic-parsing-test/basic-parsing-test.tesh

index 5e639c6..7690bfe 100644 (file)
@@ -19,13 +19,13 @@ $ $SG_TEST_EXENV ${bindir:=.}/trace-masterworker$EXEEXT --cfg=tracing:yes --cfg=
 
 p Tracing master/worker application with xml config
 $ $SG_TEST_EXENV ${bindir:=.}/trace-masterworker$EXEEXT ${srcdir:=.}/config_tracing.xml ${srcdir:=.}/../msg/app-masterworker/app-masterworker_d.xml
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/uncategorized' to 'yes'
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/buffer' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing' to 'yes'
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'viva/categorized' to 'trace-masterworker.cat.plist'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/buffer' to 'yes'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/categorized' to 'yes'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/filename' to 'trace-masterworker.trace'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/uncategorized' to 'yes'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'viva/categorized' to 'trace-masterworker.cat.plist'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'viva/uncategorized' to 'trace-masterworker.uncat.plist'
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'tracing/categorized' to 'yes'
 > [4.214821] [msg_trace_masterworker/INFO] Declared tracing categories:
 > [4.214821] [msg_trace_masterworker/INFO] request
 > [4.214821] [msg_trace_masterworker/INFO] finalize
index e13be7c..1f9c363 100644 (file)
@@ -17,6 +17,7 @@
 
 #ifdef __cplusplus
 #include "simgrid/simix.h"
+#include <map>
 namespace simgrid {
 namespace msg {
 class Comm;
@@ -377,36 +378,26 @@ XBT_PUBLIC(void) MSG_task_set_bound(msg_task_t task, double bound);
 XBT_PUBLIC(msg_error_t) MSG_process_join(msg_process_t process, double timeout);
 XBT_PUBLIC(msg_error_t) MSG_process_sleep(double nb_sec);
 
-XBT_PUBLIC(void) MSG_task_set_flops_amount(msg_task_t task,
-                                               double flops_amount);
+XBT_PUBLIC(void) MSG_task_set_flops_amount(msg_task_t task, double flops_amount);
 XBT_PUBLIC(double) MSG_task_get_flops_amount(msg_task_t task);
-XBT_PUBLIC(void) MSG_task_set_bytes_amount(msg_task_t task,
-                                        double bytes_amount);
+XBT_PUBLIC(void) MSG_task_set_bytes_amount(msg_task_t task, double bytes_amount);
 
 XBT_PUBLIC(double) MSG_task_get_remaining_communication(msg_task_t task);
 XBT_PUBLIC(int) MSG_task_is_latency_bounded(msg_task_t task);
 XBT_PUBLIC(double) MSG_task_get_bytes_amount(msg_task_t task);
 
+XBT_PUBLIC(msg_error_t) MSG_task_receive_ext(msg_task_t* task, const char* alias, double timeout, msg_host_t host);
 
-XBT_PUBLIC(msg_error_t)
-    MSG_task_receive_ext(msg_task_t * task, const char *alias, double timeout,
-                     msg_host_t host);
-
-XBT_PUBLIC(msg_error_t)
-    MSG_task_receive_with_timeout(msg_task_t * task, const char *alias,
-                              double timeout);
+XBT_PUBLIC(msg_error_t) MSG_task_receive_with_timeout(msg_task_t* task, const char* alias, double timeout);
 
-XBT_PUBLIC(msg_error_t)
-    MSG_task_receive(msg_task_t * task, const char *alias);
+XBT_PUBLIC(msg_error_t) MSG_task_receive(msg_task_t* task, const char* alias);
 #define MSG_task_recv(t,a) MSG_task_receive(t,a)
 
-
-
 XBT_PUBLIC(msg_error_t)
-    MSG_task_receive_ext_bounded(msg_task_t * task, const char *alias, double timeout,
-                     msg_host_t host, double rate);
+MSG_task_receive_ext_bounded(msg_task_t* task, const char* alias, double timeout, msg_host_t host, double rate);
 
-XBT_PUBLIC(msg_error_t) MSG_task_receive_with_timeout_bounded(msg_task_t * task, const char *alias,  double timeout, double rate);
+XBT_PUBLIC(msg_error_t)
+MSG_task_receive_with_timeout_bounded(msg_task_t* task, const char* alias, double timeout, double rate);
 XBT_PUBLIC(msg_error_t) MSG_task_receive_bounded(msg_task_t * task, const char *alias,double rate);
 #define MSG_task_recv_bounded(t,a,r) MSG_task_receive_bounded(t,a,r)
 
@@ -517,24 +508,21 @@ XBT_PUBLIC(void) MSG_vm_resume(msg_vm_t vm);
 XBT_PUBLIC(msg_host_t) MSG_vm_get_pm(msg_vm_t vm);
 XBT_PUBLIC(void) MSG_vm_set_bound(msg_vm_t vm, double bound);
 
-
 #include "simgrid/instr.h"
 
 /* ****************************************************************************************** */
 /* Used only by the bindings -- unclean pimple, please ignore if you're not writing a binding */
 XBT_PUBLIC(smx_context_t) MSG_process_get_smx_ctx(msg_process_t process);
 
-
 /* Functions renamed in 3.14 */
 #define MSG_mailbox_get_head(m) MSG_mailbox_front(m)
 
-
 SG_END_DECL()
 
 #ifdef __cplusplus
 XBT_PUBLIC(msg_process_t)
 MSG_process_create_from_stdfunc(const char* name, std::function<void()> code, void* data, msg_host_t host,
-                                xbt_dict_t properties);
+                                std::map<std::string, std::string>* properties);
 #endif
 
 #endif
index 33f9710..3c8691e 100644 (file)
@@ -6,6 +6,7 @@
 #ifndef SIMGRID_S4U_HOST_HPP
 #define SIMGRID_S4U_HOST_HPP
 
+#include <map>
 #include <string>
 #include <unordered_map>
 
@@ -86,9 +87,9 @@ public:
 
   double getSpeed();
   int getCoreCount();
-  std::unordered_map<std::string, std::string>* getProperties();
+  std::map<std::string, std::string>* getProperties();
   const char* getProperty(const char* key);
-  void setProperty(const char* key, const char* value);
+  void setProperty(std::string key, std::string value);
   void getProcesses(std::vector<ActorPtr> * list);
   double getPstateSpeed(int pstate_index);
   int getPstatesCount() const;
index e3b1d90..38e30b7 100644 (file)
@@ -36,7 +36,7 @@ public:
   sg_size_t getSizeFree();
   sg_size_t getSizeUsed();
 
-  std::unordered_map<std::string, std::string>* getProperties();
+  std::map<std::string, std::string>* getProperties();
   const char* getProperty(const char* key);
   void setProperty(const char* key, const char* value);
   std::map<std::string, sg_size_t>* getContent();
index e5886a3..44e2635 100644 (file)
@@ -11,7 +11,7 @@
 #include "simgrid/host.h"
 #include "xbt/ex.h"
 #include "xbt/parmap.h"
-
+#include <map>
 /* ******************************** Host ************************************ */
 /** @brief Host datatype
     @ingroup simix_host_management
@@ -140,12 +140,9 @@ XBT_PUBLIC(void) SIMIX_process_set_function(const char* process_host,
  */
 
 XBT_PUBLIC(void) SIMIX_maestro_create(void (*code)(void*), void* data);
-XBT_PUBLIC(smx_actor_t) SIMIX_process_attach(
-  const char* name,
-  void *data,
-  const char* hostname,
-  xbt_dict_t properties,
-  smx_actor_t parent_process);
+XBT_PUBLIC(smx_actor_t)
+SIMIX_process_attach(const char* name, void* data, const char* hostname, std::map<std::string, std::string>* properties,
+                     smx_actor_t parent_process);
 XBT_PUBLIC(void) SIMIX_process_detach();
 
 /*********************************** Host *************************************/
@@ -202,7 +199,7 @@ SG_BEGIN_DECL()
 /* Constructor and Destructor */
 XBT_PUBLIC(smx_actor_t)
 simcall_process_create(const char* name, xbt_main_func_t code, void* data, sg_host_t host, int argc, char** argv,
-                       xbt_dict_t properties);
+                       std::map<std::string, std::string>* properties);
 
 XBT_PUBLIC(void) simcall_process_kill(smx_actor_t process);
 XBT_PUBLIC(void) simcall_process_killall(int reset_pid);
@@ -216,7 +213,6 @@ XBT_PUBLIC(void) simcall_process_suspend(smx_actor_t process);
 /* Getters and Setters */
 XBT_PUBLIC(int) simcall_process_count();
 XBT_PUBLIC(void) simcall_process_set_data(smx_actor_t process, void *data);
-XBT_PUBLIC(xbt_dict_t) simcall_process_get_properties(smx_actor_t host);
 XBT_PUBLIC(void) simcall_process_set_kill_time(smx_actor_t process, double kill_time);
 XBT_PUBLIC(void) simcall_process_on_exit(smx_actor_t process, int_f_pvoid_pvoid_t fun, void *data);
 XBT_PUBLIC(void) simcall_process_join(smx_actor_t process, double timeout);
index 7e0e9e3..eb7e26b 100644 (file)
@@ -7,12 +7,13 @@
 #ifndef SIMGRID_SIMIX_HPP
 #define SIMGRID_SIMIX_HPP
 
-//#include <xbt/function_types.h>
-#include <xbt/future.hpp>
+#include <simgrid/simix.h>
 #include <xbt/functional.hpp>
+#include <xbt/future.hpp>
 #include <xbt/signal.hpp>
 
-#include <simgrid/simix.h>
+#include <map>
+#include <string>
 
 XBT_PUBLIC(void) simcall_run_kernel(std::function<void()> const& code);
 
@@ -97,21 +98,21 @@ extern simgrid::xbt::signal<void()> onDeadlock;
  * void *data: data a pointer to any data one may want to attach to the new object.
  * sg_host_t host: the location where the new process is executed
  * int argc, char **argv: parameters passed to code
- * xbt_dict_t pros: properties
+ * std::map<std::string, std::string>* props: properties
  */
-typedef smx_actor_t (*smx_creation_func_t) (
-                                      /* name */ const char*,
-                                      std::function<void()> code,
-                                      /* userdata */ void*,
-                                      /* hostname */ sg_host_t,
-                                      /* props */ xbt_dict_t,
-                                      /* parent_process */ smx_actor_t);
+typedef smx_actor_t (*smx_creation_func_t)(
+    /* name */ const char*, std::function<void()> code,
+    /* userdata */ void*,
+    /* hostname */ sg_host_t,
+    /* props */ std::map<std::string, std::string>*,
+    /* parent_process */ smx_actor_t);
 
 extern "C"
 XBT_PUBLIC(void) SIMIX_function_register_process_create(smx_creation_func_t function);
 
 XBT_PUBLIC(smx_actor_t)
-simcall_process_create(const char* name, std::function<void()> code, void* data, sg_host_t host, xbt_dict_t properties);
+simcall_process_create(const char* name, std::function<void()> code, void* data, sg_host_t host,
+                       std::map<std::string, std::string>* properties);
 
 XBT_PUBLIC(smx_timer_t) SIMIX_timer_set(double date, simgrid::xbt::Task<void()> callback);
 
index 173dcf4..f1f3ce2 100644 (file)
@@ -17,7 +17,6 @@
 #include "simgrid/datatypes.h"
 #include "simgrid/forward.h"
 
-
 #ifdef __cplusplus
 
 namespace simgrid {
@@ -423,9 +422,6 @@ XBT_PUBLIC(double) surf_get_clock();
  */
 XBT_PUBLIC(void) surf_exit();
 
-/* Prototypes of the functions that handle the properties */
-XBT_PUBLIC_DATA(xbt_dict_t) current_property_set;// the prop set for the currently parsed element (also used in SIMIX)
-
 /* surf parse file related (public because called from a test suite) */
 XBT_PUBLIC(void) parse_platform_file(const char *file);
 
index 30b2750..5f846b1 100644 (file)
@@ -43,7 +43,7 @@ NetZoneImpl::~NetZoneImpl()
 }
 
 simgrid::s4u::Host* NetZoneImpl::createHost(const char* name, std::vector<double>* speedPerPstate, int coreAmount,
-                                            std::unordered_map<std::string, std::string>* props)
+                                            std::map<std::string, std::string>* props)
 {
   simgrid::s4u::Host* res = new simgrid::s4u::Host(name);
 
@@ -56,7 +56,7 @@ simgrid::s4u::Host* NetZoneImpl::createHost(const char* name, std::vector<double
 
   if (props != nullptr)
     for (auto kv : *props)
-      res->setProperty(kv.first.c_str(), kv.second.c_str());
+      res->setProperty(kv.first, kv.second);
 
   simgrid::s4u::Host::onCreation(*res); // notify the signal
 
index fe97e73..e4a297c 100644 (file)
@@ -59,7 +59,7 @@ protected:
 public:
   /** @brief Make an host within that NetZone */
   simgrid::s4u::Host* createHost(const char* name, std::vector<double>* speedPerPstate, int coreAmount,
-                                 std::unordered_map<std::string, std::string>* props);
+                                 std::map<std::string, std::string>* props);
   /** @brief Creates a new route in this NetZone */
   void addBypassRoute(sg_platf_route_cbarg_t e_route) override;
 
index 82a9ad7..cea2d8a 100644 (file)
@@ -166,7 +166,7 @@ xbt_dict_t MSG_host_get_properties(msg_host_t host)
 {
   xbt_assert((host != nullptr), "Invalid parameters (host is nullptr)");
   xbt_dict_t as_dict = xbt_dict_new_homogeneous(xbt_free_f);
-  std::unordered_map<std::string, std::string>* props = host->getProperties();
+  std::map<std::string, std::string>* props = host->getProperties();
   if (props == nullptr)
     return nullptr;
   for (auto elm : *props) {
index 648db4d..776adfe 100644 (file)
@@ -389,7 +389,7 @@ xbt_dict_t MSG_storage_get_properties(msg_storage_t storage)
 {
   xbt_assert((storage != nullptr), "Invalid parameters (storage is nullptr)");
   xbt_dict_t as_dict = xbt_dict_new_homogeneous(xbt_free_f);
-  std::unordered_map<std::string, std::string>* props = storage->getProperties();
+  std::map<std::string, std::string>* props = storage->getProperties();
   if (props == nullptr)
     return nullptr;
   for (auto elm : *props) {
index 6d20389..33d241f 100644 (file)
@@ -103,7 +103,7 @@ XBT_PUBLIC_DATA(MSG_Global_t) msg_global;
 /*************************************************************/
 XBT_PRIVATE void MSG_process_cleanup_from_SIMIX(smx_actor_t smx_proc);
 XBT_PRIVATE smx_actor_t MSG_process_create_from_SIMIX(const char* name, std::function<void()> code, void* data,
-                                                      sg_host_t host, xbt_dict_t properties,
+                                                      sg_host_t host, std::map<std::string, std::string>* properties,
                                                       smx_actor_t parent_process);
 XBT_PRIVATE void MSG_comm_copy_data_from_SIMIX(smx_activity_t comm, void* buff, size_t buff_size);
 
index b3ea3c9..18878b0 100644 (file)
@@ -51,7 +51,7 @@ void MSG_process_cleanup_from_SIMIX(smx_actor_t smx_actor)
 
 /* This function creates a MSG process. It has the prototype enforced by SIMIX_function_register_process_create */
 smx_actor_t MSG_process_create_from_SIMIX(const char* name, std::function<void()> code, void* data, sg_host_t host,
-                                          xbt_dict_t properties, smx_actor_t parent_process)
+                                          std::map<std::string, std::string>* properties, smx_actor_t parent_process)
 {
   msg_process_t p = MSG_process_create_from_stdfunc(name, std::move(code), data, host, properties);
   return p == nullptr ? nullptr : p->getImpl();
@@ -123,7 +123,15 @@ msg_process_t MSG_process_create_with_environment(const char *name, xbt_main_fun
   if (code)
     function = simgrid::xbt::wrapMain(code, argc, static_cast<const char* const*>(argv));
 
-  msg_process_t res = MSG_process_create_from_stdfunc(name, std::move(function), data, host, properties);
+  std::map<std::string, std::string> props;
+  xbt_dict_cursor_t cursor = nullptr;
+  char* key;
+  char* value;
+  xbt_dict_foreach (properties, cursor, key, value)
+    props[key] = value;
+  xbt_dict_free(&properties);
+
+  msg_process_t res = MSG_process_create_from_stdfunc(name, std::move(function), data, host, &props);
   for (int i = 0; i != argc; ++i)
     xbt_free(argv[i]);
   xbt_free(argv);
@@ -133,7 +141,7 @@ msg_process_t MSG_process_create_with_environment(const char *name, xbt_main_fun
 SG_END_DECL()
 
 msg_process_t MSG_process_create_from_stdfunc(const char* name, std::function<void()> code, void* data, msg_host_t host,
-                                              xbt_dict_t properties)
+                                              std::map<std::string, std::string>* properties)
 {
   xbt_assert(code != nullptr && host != nullptr, "Invalid parameters: host and code params must not be nullptr");
   simgrid::msg::ActorExt* msgExt = new simgrid::msg::ActorExt(data);
@@ -161,10 +169,16 @@ SG_BEGIN_DECL()
 msg_process_t MSG_process_attach(const char *name, void *data, msg_host_t host, xbt_dict_t properties)
 {
   xbt_assert(host != nullptr, "Invalid parameters: host and code params must not be nullptr");
+  std::map<std::string, std::string> props;
+  xbt_dict_cursor_t cursor = nullptr;
+  char* key;
+  char* value;
+  xbt_dict_foreach (properties, cursor, key, value)
+    props[key] = value;
+  xbt_dict_free(&properties);
 
   /* Let's create the process: SIMIX may decide to start it right now, even before returning the flow control to us */
-  smx_actor_t process =
-      SIMIX_process_attach(name, new simgrid::msg::ActorExt(data), host->getCname(), properties, nullptr);
+  smx_actor_t process = SIMIX_process_attach(name, new simgrid::msg::ActorExt(data), host->getCname(), &props, nullptr);
   if (not process)
     xbt_die("Could not attach");
   simcall_process_on_exit(process,(int_f_pvoid_pvoid_t)TRACE_msg_process_kill,process);
@@ -355,7 +369,7 @@ const char *MSG_process_get_name(msg_process_t process)
  */
 const char *MSG_process_get_property_value(msg_process_t process, const char *name)
 {
-  return (char*) xbt_dict_get_or_null(MSG_process_get_properties(process), name);
+  return process->getProperty(name);
 }
 
 /** \ingroup m_process_management
@@ -366,7 +380,15 @@ const char *MSG_process_get_property_value(msg_process_t process, const char *na
 xbt_dict_t MSG_process_get_properties(msg_process_t process)
 {
   xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr");
-  return simcall_process_get_properties(process->getImpl());
+  xbt_dict_t as_dict = xbt_dict_new_homogeneous(xbt_free_f);
+  std::map<std::string, std::string>* props =
+      simgrid::simix::kernelImmediate([process] { return process->getImpl()->getProperties(); });
+  if (props == nullptr)
+    return nullptr;
+  for (auto elm : *props) {
+    xbt_dict_set(as_dict, elm.first.c_str(), xbt_strdup(elm.second.c_str()), nullptr);
+  }
+  return as_dict;
 }
 
 /** \ingroup m_process_management
index 6b6f2ef..7dcef8f 100644 (file)
@@ -174,14 +174,12 @@ void Actor::killAll(int resetPid)
 /** Retrieve the property value (or nullptr if not set) */
 const char* Actor::getProperty(const char* key)
 {
-  return (char*)xbt_dict_get_or_null(simcall_process_get_properties(pimpl_), key);
+  return simgrid::simix::kernelImmediate([this, key] { return pimpl_->getProperty(key); });
 }
 
 void Actor::setProperty(const char* key, const char* value)
 {
-  simgrid::simix::kernelImmediate([this, key, value] {
-    xbt_dict_set(simcall_process_get_properties(pimpl_), key, (char*)value, (void_f_pvoid_t) nullptr);
-  });
+  simgrid::simix::kernelImmediate([this, key, value] { pimpl_->setProperty(key, value); });
 }
 
 Actor* Actor::restart()
index 9dafa33..cd08364 100644 (file)
@@ -177,11 +177,9 @@ void Host::routeTo(Host* dest, std::vector<surf::LinkImpl*>* links, double* late
 }
 
 /** Get the properties assigned to a host */
-std::unordered_map<std::string, std::string>* Host::getProperties()
+std::map<std::string, std::string>* Host::getProperties()
 {
-  return simgrid::simix::kernelImmediate([this] {
-    return this->pimpl_->getProperties();
-  });
+  return simgrid::simix::kernelImmediate([this] { return this->pimpl_->getProperties(); });
 }
 
 /** Retrieve the property value (or nullptr if not set) */
@@ -190,7 +188,7 @@ const char* Host::getProperty(const char* key)
   return this->pimpl_->getProperty(key);
 }
 
-void Host::setProperty(const char* key, const char* value)
+void Host::setProperty(std::string key, std::string value)
 {
   simgrid::simix::kernelImmediate([this, key, value] { this->pimpl_->setProperty(key, value); });
 }
index 58ad8f4..38be665 100644 (file)
@@ -60,7 +60,7 @@ sg_size_t Storage::getSize()
   return pimpl_->getSize();
 }
 
-std::unordered_map<std::string, std::string>* Storage::getProperties()
+std::map<std::string, std::string>* Storage::getProperties()
 {
   return simgrid::simix::kernelImmediate([this] { return pimpl_->getProperties(); });
 }
index 07f8017..b86e068 100644 (file)
@@ -181,7 +181,7 @@ void sg_host_set_pstate(sg_host_t host,int pstate) {
 /** @brief Get the properties of an host */
 xbt_dict_t sg_host_get_properties(sg_host_t host) {
   xbt_dict_t as_dict = xbt_dict_new_homogeneous(xbt_free_f);
-  std::unordered_map<std::string, std::string>* props = host->getProperties();
+  std::map<std::string, std::string>* props = host->getProperties();
   if (props == nullptr)
     return nullptr;
   for (auto elm : *props) {
@@ -260,7 +260,7 @@ void sg_host_dump(sg_host_t host)
   XBT_INFO("Displaying host %s", host->getCname());
   XBT_INFO("  - speed: %.0f", host->getSpeed());
   XBT_INFO("  - available speed: %.2f", sg_host_get_available_speed(host));
-  std::unordered_map<std::string, std::string>* props = host->getProperties();
+  std::map<std::string, std::string>* props = host->getProperties();
 
   if (not props->empty()) {
     XBT_INFO("  - properties:");
index 3209e85..318e5ed 100644 (file)
@@ -5,12 +5,12 @@
 
 #include <exception>
 #include <functional>
+#include <map>
 #include <string>
 #include <utility>
 
 #include <boost/range/algorithm.hpp>
 
-#include "xbt/dict.h"
 #include "xbt/ex.hpp"
 #include "xbt/functional.hpp"
 #include "xbt/log.h"
@@ -141,7 +141,6 @@ namespace simix {
 ActorImpl::~ActorImpl()
 {
   delete this->context;
-  xbt_dict_free(&this->properties);
 }
 
 static int dying_daemon(void* exit_status, void* data)
@@ -291,7 +290,7 @@ void SIMIX_maestro_create(void (*code)(void*), void* data)
  * \return the process created
  */
 smx_actor_t SIMIX_process_create(const char* name, std::function<void()> code, void* data, simgrid::s4u::Host* host,
-                                 xbt_dict_t properties, smx_actor_t parent_process)
+                                 std::map<std::string, std::string>* properties, smx_actor_t parent_process)
 {
 
   XBT_DEBUG("Start process %s on host '%s'", name, host->getCname());
@@ -331,7 +330,9 @@ smx_actor_t SIMIX_process_create(const char* name, std::function<void()> code, v
   process->context = SIMIX_context_new(std::move(code), simix_global->cleanup_process_function, process);
 
   /* Add properties */
-  process->properties = properties;
+  if (properties != nullptr)
+    for (auto kv : *properties)
+      process->setProperty(kv.first, kv.second);
 
   /* Make sure that the process is initialized for simix, in case we are called from the Host::onCreation signal */
   if (host->extension<simgrid::simix::Host>() == nullptr)
@@ -354,8 +355,8 @@ smx_actor_t SIMIX_process_create(const char* name, std::function<void()> code, v
   return process;
 }
 
-smx_actor_t SIMIX_process_attach(const char* name, void* data, const char* hostname, xbt_dict_t properties,
-                                 smx_actor_t parent_process)
+smx_actor_t SIMIX_process_attach(const char* name, void* data, const char* hostname,
+                                 std::map<std::string, std::string>* properties, smx_actor_t parent_process)
 {
   // This is mostly a copy/paste from SIMIX_process_new(),
   // it'd be nice to share some code between those two functions.
@@ -364,8 +365,7 @@ smx_actor_t SIMIX_process_attach(const char* name, void* data, const char* hostn
   XBT_DEBUG("Attach process %s on host '%s'", name, hostname);
 
   if (host->isOff()) {
-    XBT_WARN("Cannot launch process '%s' on failed host '%s'",
-      name, hostname);
+    XBT_WARN("Cannot launch process '%s' on failed host '%s'", name, hostname);
     return nullptr;
   }
 
@@ -400,7 +400,9 @@ smx_actor_t SIMIX_process_attach(const char* name, void* data, const char* hostn
   process->context = simix_global->context_factory->attach(simix_global->cleanup_process_function, process);
 
   /* Add properties */
-  process->properties = properties;
+  if (properties != nullptr)
+    for (auto kv : *properties)
+      process->setProperty(kv.first, kv.second);
 
   /* Add the process to it's host process list */
   xbt_swag_insert(process, host->extension<simgrid::simix::Host>()->process_list);
@@ -780,7 +782,8 @@ void SIMIX_process_yield(smx_actor_t self)
     /* Add the process to the list of process to restart, only if the host is down */
     if (self->auto_restart && self->host->isOff()) {
       SIMIX_host_add_auto_restart_process(self->host, self->cname(), self->code, self->userdata,
-                                          SIMIX_timer_get_date(self->kill_timer), self->properties, self->auto_restart);
+                                          SIMIX_timer_get_date(self->kill_timer), self->getProperties(),
+                                          self->auto_restart);
     }
     XBT_DEBUG("Process %s@%s is dead", self->cname(), self->host->getCname());
     self->context->stop();
@@ -882,9 +885,8 @@ void SIMIX_process_auto_restart_set(smx_actor_t process, int auto_restart) {
  * \param properties the properties of the process
  * \param auto_restart either it is autorestarting or not.
  */
-extern "C"
-smx_actor_t simcall_process_create(const char* name, xbt_main_func_t code, void* data, sg_host_t host, int argc,
-                                   char** argv, xbt_dict_t properties)
+extern "C" smx_actor_t simcall_process_create(const char* name, xbt_main_func_t code, void* data, sg_host_t host,
+                                              int argc, char** argv, std::map<std::string, std::string>* properties)
 {
   if (name == nullptr)
     name = "";
@@ -897,7 +899,7 @@ smx_actor_t simcall_process_create(const char* name, xbt_main_func_t code, void*
 }
 
 smx_actor_t simcall_process_create(const char* name, std::function<void()> code, void* data, sg_host_t host,
-                                   xbt_dict_t properties)
+                                   std::map<std::string, std::string>* properties)
 {
   if (name == nullptr)
     name = "";
index 952546b..3d7285f 100644 (file)
@@ -8,8 +8,10 @@
 
 #include "simgrid/s4u/Actor.hpp"
 #include "src/simix/popping_private.h"
+#include "src/surf/PropertyHolder.hpp"
 #include "xbt/swag.h"
 #include <list>
+#include <map>
 
 typedef struct s_smx_process_exit_fun {
   int_f_pvoid_pvoid_t fun;
@@ -27,11 +29,11 @@ public:
   void *data            = nullptr;
   sg_host_t host        = nullptr;
   double kill_time      = 0.0;
-  xbt_dict_t properties = nullptr;
+  std::map<std::string, std::string>* properties = nullptr;
   bool auto_restart     = false;
 };
 
-class ActorImpl {
+class ActorImpl : public simgrid::surf::PropertyHolder {
 public:
   ActorImpl() : piface_(this) {}
   ~ActorImpl();
@@ -59,7 +61,6 @@ public:
   sg_host_t new_host             = nullptr; /* if not null, the host on which the process must migrate to */
   smx_activity_t waiting_synchro = nullptr; /* the current blocking synchro if any */
   std::list<smx_activity_t> comms;          /* the current non-blocking communication synchros */
-  xbt_dict_t properties         = nullptr;
   s_smx_simcall_t simcall;
   void* userdata = nullptr;                      /* kept for compatibility, it should be replaced with moddata */
   std::vector<s_smx_process_exit_fun_t> on_exit; /* list of functions executed when the process dies */
@@ -123,13 +124,9 @@ typedef simgrid::simix::ActorImpl* smx_actor_t;
 
 SG_BEGIN_DECL()
 
-XBT_PRIVATE smx_actor_t SIMIX_process_create(
-                          const char *name,
-                          std::function<void()> code,
-                          void *data,
-                          sg_host_t host,
-                          xbt_dict_t properties,
-                          smx_actor_t parent_process);
+XBT_PRIVATE smx_actor_t SIMIX_process_create(const char* name, std::function<void()> code, void* data, sg_host_t host,
+                                             std::map<std::string, std::string>* properties,
+                                             smx_actor_t parent_process);
 
 XBT_PRIVATE void SIMIX_process_runall();
 XBT_PRIVATE void SIMIX_process_kill(smx_actor_t process, smx_actor_t issuer);
index 15aeec6..045f851 100644 (file)
@@ -247,16 +247,6 @@ void simcall_process_set_kill_time(smx_actor_t process, double kill_time)
 
 /**
  * \ingroup simix_process_management
- * \brief Return the properties
- *
- * This function returns the properties associated with this process
- */
-xbt_dict_t simcall_process_get_properties(smx_actor_t process)
-{
-  return process->properties;
-}
-/**
- * \ingroup simix_process_management
  * \brief Add an on_exit function
  * Add an on_exit function which will be executed when the process exits/is killed.
  */
index fda196e..ed75d52 100644 (file)
@@ -112,9 +112,9 @@ const char* sg_host_self_get_name()
  * The processes will only be restarted once, meaning that you will have to register the process
  * again to restart the process again.
  */
-void SIMIX_host_add_auto_restart_process(
-  sg_host_t host, const char *name, std::function<void()> code,
-  void* data, double kill_time, xbt_dict_t properties, int auto_restart)
+void SIMIX_host_add_auto_restart_process(sg_host_t host, const char* name, std::function<void()> code, void* data,
+                                         double kill_time, std::map<std::string, std::string>* properties,
+                                         int auto_restart)
 {
   smx_process_arg_t arg = new simgrid::simix::ProcessArg();
   arg->name = name;
index ffdcd20..b7028b9 100644 (file)
@@ -6,8 +6,9 @@
 #ifndef SIMIX_HOST_PRIVATE_H
 #define SIMIX_HOST_PRIVATE_H
 
-#include <vector>
 #include <functional>
+#include <map>
+#include <vector>
 
 #include <xbt/base.h>
 #include <xbt/Extendable.hpp>
@@ -39,13 +40,9 @@ namespace simgrid {
 }
 
 SG_BEGIN_DECL()
-XBT_PRIVATE void SIMIX_host_add_auto_restart_process(sg_host_t host,
-                                         const char *name,
-                                         std::function<void()> code,
-                                         void *data,
-                                         double kill_time,
-                                         xbt_dict_t properties,
-                                         int auto_restart);
+XBT_PRIVATE void SIMIX_host_add_auto_restart_process(sg_host_t host, const char* name, std::function<void()> code,
+                                                     void* data, double kill_time,
+                                                     std::map<std::string, std::string>* properties, int auto_restart);
 
 XBT_PRIVATE void SIMIX_host_autorestart(sg_host_t host);
 XBT_PRIVATE void SIMIX_execution_cancel(smx_activity_t synchro);
index 03210a7..a6696ae 100644 (file)
@@ -8,8 +8,6 @@
 namespace simgrid {
 namespace surf {
 
-PropertyHolder::PropertyHolder() = default;
-
 PropertyHolder::~PropertyHolder() {
   delete properties_;
 }
@@ -26,17 +24,18 @@ const char *PropertyHolder::getProperty(const char*key) {
 }
 
 /** @brief Change the value of a given key in the property set */
-void PropertyHolder::setProperty(const char*key, const char*value) {
+void PropertyHolder::setProperty(std::string key, std::string value)
+{
   if (not properties_)
-    properties_       = new std::unordered_map<std::string, std::string>;
+    properties_       = new std::map<std::string, std::string>;
   (*properties_)[key] = value;
 }
 
 /** @brief Return the whole set of properties. Don't mess with it, dude! */
-std::unordered_map<std::string, std::string>* PropertyHolder::getProperties()
+std::map<std::string, std::string>* PropertyHolder::getProperties()
 {
   if (not properties_)
-    properties_ = new std::unordered_map<std::string, std::string>;
+    properties_ = new std::map<std::string, std::string>;
   return properties_;
 }
 
index afbdbc2..7c07fcd 100644 (file)
@@ -5,7 +5,7 @@
 
 #ifndef SRC_SURF_PROPERTYHOLDER_HPP_
 #define SRC_SURF_PROPERTYHOLDER_HPP_
-#include <unordered_map>
+#include <map>
 
 namespace simgrid {
 namespace surf {
@@ -17,19 +17,19 @@ namespace surf {
 class PropertyHolder { // DO NOT DERIVE THIS CLASS, or the diamond inheritance mayhem will get you
 
 public:
-  explicit PropertyHolder();
+  PropertyHolder() = default;
   ~PropertyHolder();
 
   const char *getProperty(const char*id);
-  void setProperty(const char*id, const char*value);
+  void setProperty(std::string id, std::string value);
 
   /* FIXME: This should not be exposed, as users may do bad things with the dict they got (it's not a copy).
    * But some user API expose this call so removing it is not so easy.
    */
-  std::unordered_map<std::string, std::string>* getProperties();
+  std::map<std::string, std::string>* getProperties();
 
 private:
-  std::unordered_map<std::string, std::string>* properties_ = nullptr;
+  std::map<std::string, std::string>* properties_ = nullptr;
 };
 
 } /* namespace surf */
index 6f1f2b9..18835f3 100644 (file)
@@ -213,10 +213,10 @@ public:
   std::string id;
   std::string model;
   std::string content;
-  xbt_dict_t properties;
+  std::map<std::string, std::string>* properties;
   std::map<std::string, std::string>* model_properties;
   sg_size_t size;
-  StorageType(std::string id, std::string model, std::string content, xbt_dict_t properties,
+  StorageType(std::string id, std::string model, std::string content, std::map<std::string, std::string>* properties,
               std::map<std::string, std::string>* model_properties, sg_size_t size)
       : id(id), model(model), content(content), properties(properties), model_properties(model_properties), size(size)
   {
index ec19598..d0ef69e 100644 (file)
@@ -75,14 +75,11 @@ void sg_platf_exit() {
 /** @brief Add an host to the current AS */
 void sg_platf_new_host(sg_platf_host_cbarg_t args)
 {
-  std::unordered_map<std::string, std::string> props;
+  std::map<std::string, std::string> props;
   if (args->properties) {
-    xbt_dict_cursor_t cursor=nullptr;
-    char *key;
-    char* data;
-    xbt_dict_foreach (args->properties, cursor, key, data)
-      props[key] = data;
-    xbt_dict_free(&args->properties);
+    for (auto elm : *args->properties)
+      props.insert({elm.first, elm.second});
+    delete args->properties;
   }
 
   simgrid::s4u::Host* host =
@@ -138,12 +135,9 @@ void sg_platf_new_link(LinkCreationArgs* link)
         surf_network_model->createLink(link_name.c_str(), link->bandwidth, link->latency, link->policy);
 
     if (link->properties) {
-      xbt_dict_cursor_t cursor = nullptr;
-      char* key;
-      char* data;
-      xbt_dict_foreach (link->properties, cursor, key, data)
-        l->setProperty(key, data);
-      xbt_dict_free(&link->properties);
+      for (auto elm : *link->properties)
+        l->setProperty(elm.first, elm.second);
+      delete link->properties;
     }
 
     if (link->latency_trace)
@@ -204,15 +198,11 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster)
     s_sg_platf_host_cbarg_t host;
     memset(&host, 0, sizeof(host));
     host.id = host_id;
-    if ((cluster->properties != nullptr) && (not xbt_dict_is_empty(cluster->properties))) {
-      xbt_dict_cursor_t cursor=nullptr;
-      char *key;
-      char* data;
-      host.properties = xbt_dict_new_homogeneous(free);
-
-      xbt_dict_foreach(cluster->properties,cursor,key,data) {
-        xbt_dict_set(host.properties, key, xbt_strdup(data), nullptr);
-      }
+    if ((cluster->properties != nullptr) && (not cluster->properties->empty())) {
+      host.properties = new std::map<std::string, std::string>;
+
+      for (auto elm : *cluster->properties)
+        host.properties->insert({elm.first, elm.second});
     }
 
     host.speed_per_pstate = cluster->speeds;
@@ -280,7 +270,7 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster)
     xbt_free(host_id);
     rankId++;
   }
-  xbt_dict_free(&cluster->properties);
+  delete cluster->properties;
 
   // Add a router.
   XBT_DEBUG(" ");
@@ -391,12 +381,9 @@ void sg_platf_new_storage(StorageCreationArgs* storage)
   auto s = surf_storage_model->createStorage(storage->id, stype->id, storage->content, storage->attach);
 
   if (storage->properties) {
-    xbt_dict_cursor_t cursor = nullptr;
-    char *key;
-    char* data;
-    xbt_dict_foreach (storage->properties, cursor, key, data)
-      s->setProperty(key, data);
-    xbt_dict_free(&storage->properties);
+    for (auto elm : *storage->properties)
+      s->setProperty(elm.first, elm.second);
+    delete storage->properties;
   }
 }
 
index b13c5ab..7973e5e 100644 (file)
@@ -369,7 +369,7 @@ void surf_exit()
   sg_link_exit();
   for (auto e : storage_types) {
     simgrid::surf::StorageType* stype = e.second;
-    xbt_dict_free(&(stype->properties));
+    delete stype->properties;
     delete stype->model_properties;
     delete stype;
   }
index cdfe6ef..b5ae88c 100644 (file)
@@ -49,7 +49,7 @@ typedef struct {
   tmgr_trace_t speed_trace;
   tmgr_trace_t state_trace;
   const char* coord;
-  xbt_dict_t properties;
+  std::map<std::string, std::string>* properties;
 } s_sg_platf_host_cbarg_t;
 typedef s_sg_platf_host_cbarg_t* sg_platf_host_cbarg_t;
 
@@ -69,7 +69,7 @@ public:
   tmgr_trace_t latency_trace          = nullptr;
   tmgr_trace_t state_trace            = nullptr;
   e_surf_link_sharing_policy_t policy = SURF_LINK_FATPIPE;
-  xbt_dict_t properties               = nullptr;
+  std::map<std::string, std::string>* properties = nullptr;
 };
 
 class PeerCreationArgs {
@@ -110,7 +110,7 @@ typedef struct s_sg_platf_cluster_cbarg {
   double limiter_link;
   e_surf_cluster_topology_t topology;
   const char* topo_parameters;
-  xbt_dict_t properties;
+  std::map<std::string, std::string>* properties;
   const char* router_id;
   e_surf_link_sharing_policy_t sharing_policy;
   e_surf_link_sharing_policy_t bb_sharing_policy;
@@ -132,7 +132,7 @@ public:
   std::string id;
   std::string type_id;
   std::string content;
-  xbt_dict_t properties;
+  std::map<std::string, std::string>* properties;
   std::string attach;
 };
 
@@ -141,7 +141,7 @@ public:
   std::string id;
   std::string model;
   std::string content;
-  xbt_dict_t properties;
+  std::map<std::string, std::string>* properties;
   std::map<std::string, std::string>* model_properties;
   sg_size_t size;
 };
@@ -177,7 +177,7 @@ typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
 typedef struct s_sg_platf_process_cbarg {
   const char **argv;
   int argc;
-  xbt_dict_t properties;
+  std::map<std::string, std::string>* properties;
   const char *host;
   const char *function;
   double start_time;
@@ -192,6 +192,8 @@ typedef struct s_sg_platf_AS_cbarg {
 } s_sg_platf_AS_cbarg_t;
 
 #define SG_PLATF_AS_INITIALIZER {nullptr,0}
+/* The default current property receiver. Setup in the corresponding opening callbacks. */
+extern std::map<std::string, std::string>* current_property_set;
 
 /********** Routing **********/
 void routing_cluster_add_backbone(simgrid::surf::LinkImpl* bb);
index 0d09857..8d77fca 100644 (file)
@@ -319,7 +319,7 @@ static std::vector<double> surf_parse_get_all_speeds(char* speeds, const char* e
 /* make sure these symbols are defined as strong ones in this file so that the linker can resolve them */
 
 /* The default current property receiver. Setup in the corresponding opening callbacks. */
-xbt_dict_t current_property_set = nullptr;
+std::map<std::string, std::string>* current_property_set       = nullptr;
 std::map<std::string, std::string>* current_model_property_set = nullptr;
 int ZONE_TAG                            = 0; // Whether we just opened a zone tag (to see what to do with the properties)
 
@@ -520,11 +520,10 @@ void STag_surfxml_prop()
     simgrid::s4u::NetZone* netzone = simgrid::s4u::Engine::getInstance()->getNetzoneByNameOrNull(A_surfxml_zone_id);
 
     netzone->setProperty(A_surfxml_prop_id, A_surfxml_prop_value);
-  }
-  else{
+  } else {
     if (not current_property_set)
-      current_property_set = xbt_dict_new_homogeneous(&xbt_free_f); // Maybe, it should raise an error
-    xbt_dict_set(current_property_set, A_surfxml_prop_id, xbt_strdup(A_surfxml_prop_value), nullptr);
+      current_property_set = new std::map<std::string, std::string>; // Maybe, it should raise an error
+    current_property_set->insert({A_surfxml_prop_id, A_surfxml_prop_value});
     XBT_DEBUG("add prop %s=%s into current property set %p", A_surfxml_prop_id, A_surfxml_prop_value,
               current_property_set);
   }
@@ -996,19 +995,16 @@ void STag_surfxml_config()
 
 void ETag_surfxml_config()
 {
-  xbt_dict_cursor_t cursor = nullptr;
-  char *key;
-  char *elem;
-  xbt_dict_foreach(current_property_set, cursor, key, elem) {
-    if (xbt_cfg_is_default_value(key)) {
-      std::string cfg = std::string(key) + ":" + elem;
+  for (auto elm : *current_property_set) {
+    if (xbt_cfg_is_default_value(elm.first.c_str())) {
+      std::string cfg = elm.first + ":" + elm.second;
       xbt_cfg_set_parse(cfg.c_str());
     } else
-      XBT_INFO("The custom configuration '%s' is already defined by user!",key);
+      XBT_INFO("The custom configuration '%s' is already defined by user!", elm.first.c_str());
   }
   XBT_DEBUG("End configuration name = %s",A_surfxml_config_id);
 
-  xbt_dict_free(&current_property_set);
+  delete current_property_set;
   current_property_set = nullptr;
 }
 
index 7d71f93..4e44320 100644 (file)
@@ -10,7 +10,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(storage, "Messages specific for this simulation");
 
 static void display_storage_properties(simgrid::s4u::Storage* storage)
 {
-  std::unordered_map<std::string, std::string>* props = storage->getProperties();
+  std::map<std::string, std::string>* props = storage->getProperties();
   if (not props->empty()) {
     XBT_INFO("\tProperties of mounted storage: %s", storage->getName());
 
index ee27b68..099c46b 100644 (file)
@@ -40,16 +40,16 @@ $ ${bindir:=.}/basic-parsing-test ../platforms/four_hosts_floyd.xml
 > Workstation number: 4, link number: 5
 
 $ ${bindir:=.}/basic-parsing-test ../platforms/properties.xml
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'host/model' to 'compound'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'cpu/optim' to 'TI'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'host/model' to 'compound'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '0.000010'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/model' to 'Vegas'
 > Workstation number: 1, link number: 1
 
 $ ${bindir:=.}/basic-parsing-test ../platforms/properties.xml --cfg=cpu/optim:TI
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'cpu/optim' to 'TI'
-> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'host/model' to 'compound'
 > [0.000000] [surf_parse/INFO] The custom configuration 'cpu/optim' is already defined by user!
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'host/model' to 'compound'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'maxmin/precision' to '0.000010'
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/model' to 'Vegas'
 > Workstation number: 1, link number: 1