Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
don't convert host to name to host. Perl epoch is over.
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 15 Sep 2016 07:29:42 +0000 (09:29 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 15 Sep 2016 07:29:42 +0000 (09:29 +0200)
12 files changed:
include/simgrid/simix.h
include/simgrid/simix.hpp
src/msg/msg_private.h
src/msg/msg_process.cpp
src/s4u/s4u_actor.cpp
src/simix/ActorImpl.cpp
src/simix/ActorImpl.hpp
src/simix/smx_host.cpp
src/simix/smx_host_private.h
src/surf/sg_platf.cpp
teshsuite/simix/generic_simcalls/generic_simcalls.cpp
teshsuite/simix/stack_overflow/stack_overflow.c

index a765cd4..a0e8e67 100644 (file)
@@ -281,7 +281,7 @@ XBT_PUBLIC(void) simcall_vm_shutdown(sg_host_t vm);
 XBT_PUBLIC(smx_actor_t) simcall_process_create(const char *name,
                                           xbt_main_func_t code,
                                           void *data,
-                                          const char *hostname,
+                                          sg_host_t host,
                                           double kill_time,
                                           int argc, char **argv,
                                           xbt_dict_t properties,
index 0da87db..66cdfb1 100644 (file)
@@ -110,7 +110,7 @@ typedef smx_actor_t (*smx_creation_func_t) (
                                       /* name */ const char*,
                                       std::function<void()> code,
                                       /* userdata */ void*,
-                                      /* hostname */ const char*,
+                                      /* hostname */ sg_host_t,
                                       /* kill_time */ double,
                                       /* props */ xbt_dict_t,
                                       /* auto_restart */ int,
@@ -122,7 +122,7 @@ XBT_PUBLIC(void) SIMIX_function_register_process_create(smx_creation_func_t func
 XBT_PUBLIC(smx_actor_t) simcall_process_create(const char *name,
                                           std::function<void()> code,
                                           void *data,
-                                          const char *hostname,
+                                          sg_host_t host,
                                           double kill_time,
                                           xbt_dict_t properties,
                                           int auto_restart);
index 3482e3c..6bca0ba 100644 (file)
@@ -148,7 +148,7 @@ XBT_PRIVATE void __MSG_file_destroy(msg_file_priv_t host);
 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,
-                                   const char *hostname, double kill_time,
+                                   sg_host_t host, double kill_time,
                                    xbt_dict_t properties, int auto_restart,
                                    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 17b02ef..866d533 100644 (file)
@@ -56,13 +56,11 @@ void MSG_process_cleanup_from_SIMIX(smx_actor_t smx_proc)
 
 /* 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, const char *hostname,
+  const char *name, std::function<void()> code, void *data, sg_host_t host,
   double kill_time, xbt_dict_t properties,
   int auto_restart, smx_actor_t parent_process)
 {
-  msg_host_t host = MSG_host_by_name(hostname);
-  msg_process_t p = MSG_process_create_with_environment(
-    name, std::move(code), data, host, properties);
+  msg_process_t p = MSG_process_create_with_environment(name, std::move(code), data, host, properties);
   if (p) {
     MSG_process_set_kill_time(p,kill_time);
     MSG_process_auto_restart_set(p,auto_restart);
@@ -161,7 +159,7 @@ msg_process_t MSG_process_create_with_environment(
   /* Let's create the process: SIMIX may decide to start it right now,
    * even before returning the flow control to us */
   process = simcall_process_create(
-    name, std::move(code), simdata, sg_host_get_name(host), -1,  properties, 0);
+    name, std::move(code), simdata, host, -1,  properties, 0);
 
   if (!process) {
     /* Undo everything we have just changed */
index 1b46b96..fbd34dc 100644 (file)
@@ -36,8 +36,7 @@ ActorPtr Actor::createActor(const char* name, s4u::Host *host, double killTime,
   // TODO, when autorestart is used, the std::function is copied so the new
   // instance will get a fresh (reinitialized) state. Is this what we want?
   smx_actor_t process = simcall_process_create(
-    name, std::move(code), nullptr, host->name().c_str(),
-    killTime, nullptr, 0);
+    name, std::move(code), nullptr, host, killTime, nullptr, 0);
   return ActorPtr(&process->getIface());
 }
 
@@ -47,8 +46,7 @@ ActorPtr Actor::createActor(const char* name, s4u::Host *host, double killTime,
   simgrid::simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(function);
   simgrid::simix::ActorCode code = factory(std::move(args));
   smx_actor_t process = simcall_process_create(
-    name, std::move(code), nullptr, host->name().c_str(),
-    killTime, nullptr, 0);
+    name, std::move(code), nullptr, host, killTime, nullptr, 0);
   return ActorPtr(&process->getIface());
 }
 
index d283b1e..3a5fe2c 100644 (file)
@@ -218,7 +218,6 @@ void SIMIX_process_stop(smx_actor_t arg) {
   if (arg->auto_restart && arg->host->isOff()) {
     SIMIX_host_add_auto_restart_process(arg->host, arg->name.c_str(),
                                         arg->code, arg->data,
-                                        sg_host_get_name(arg->host),
                                         SIMIX_timer_get_date(arg->kill_timer),
                                         arg->properties,
                                         arg->auto_restart);
@@ -241,20 +240,18 @@ smx_actor_t SIMIX_process_create(
                           const char *name,
                           std::function<void()> code,
                           void *data,
-                          const char *hostname,
+                          sg_host_t host,
                           double kill_time,
                           xbt_dict_t properties,
                           int auto_restart,
                           smx_actor_t parent_process)
 {
   smx_actor_t process = nullptr;
-  sg_host_t host = sg_host_by_name(hostname);
 
-  XBT_DEBUG("Start process %s on host '%s'", name, hostname);
+  XBT_DEBUG("Start process %s on host '%s'", name, host->name().c_str());
 
   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, host->name().c_str());
     return nullptr;
   }
   else {
@@ -962,7 +959,7 @@ smx_actor_t SIMIX_process_restart(smx_actor_t process, smx_actor_t issuer) {
   simgrid::simix::ProcessArg arg;
   arg.name = process->name;
   arg.code = process->code;
-  arg.hostname = sg_host_get_name(process->host);
+  arg.host = process->host;
   arg.kill_time = SIMIX_timer_get_date(process->kill_timer);
   arg.data = process->data;
   arg.properties = nullptr;
@@ -972,7 +969,7 @@ smx_actor_t SIMIX_process_restart(smx_actor_t process, smx_actor_t issuer) {
   SIMIX_process_kill(process, issuer);
 
   //start the new process
-  return simix_global->create_process_function(arg.name.c_str(), std::move(arg.code), arg.data, arg.hostname,
+  return simix_global->create_process_function(arg.name.c_str(), std::move(arg.code), arg.data, arg.host,
       arg.kill_time, arg.properties, arg.auto_restart, nullptr);
 }
 
@@ -1000,7 +997,7 @@ void SIMIX_segment_index_set(smx_actor_t proc, int index){
 smx_actor_t simcall_process_create(const char *name,
                               xbt_main_func_t code,
                               void *data,
-                              const char *hostname,
+                              sg_host_t host,
                               double kill_time,
                               int argc, char **argv,
                               xbt_dict_t properties,
@@ -1014,19 +1011,19 @@ smx_actor_t simcall_process_create(const char *name,
   xbt_free(argv);
   smx_actor_t res = simcall_process_create(name,
     std::move(wrapped_code),
-    data, hostname, kill_time, properties, auto_restart);
+    data, host, kill_time, properties, auto_restart);
   return res;
 }
 
 smx_actor_t simcall_process_create(
   const char *name, std::function<void()> code, void *data,
-  const char *hostname, double kill_time,
+  sg_host_t host, double kill_time,
   xbt_dict_t properties, int auto_restart)
 {
   if (name == nullptr)
     name = "";
   smx_actor_t self = SIMIX_process_self();
   return simgrid::simix::kernelImmediate([&] {
-    return SIMIX_process_create(name, std::move(code), data, hostname, kill_time, properties, auto_restart, self);
+    return SIMIX_process_create(name, std::move(code), data, host, kill_time, properties, auto_restart, self);
   });
 }
index 9719f32..b53e78e 100644 (file)
@@ -32,7 +32,7 @@ public:
   std::string name;
   std::function<void()> code;
   void *data            = nullptr;
-  const char *hostname  = nullptr;
+  sg_host_t host        = nullptr;
   double kill_time      = 0.0;
   xbt_dict_t properties = nullptr;
   bool auto_restart     = false;
@@ -110,7 +110,7 @@ XBT_PRIVATE smx_actor_t SIMIX_process_create(
                           const char *name,
                           std::function<void()> code,
                           void *data,
-                          const char *hostname,
+                          sg_host_t host,
                           double kill_time,
                           xbt_dict_t properties,
                           int auto_restart,
index 9537df4..bc21bdd 100644 (file)
@@ -62,11 +62,11 @@ namespace simgrid {
     void Host::turnOn()
     {
       for (auto arg : boot_processes) {
-        XBT_DEBUG("Booting Process %s(%s) right now", arg->name.c_str(), arg->hostname);
+        XBT_DEBUG("Booting Process %s(%s) right now", arg->name.c_str(), arg->host->name().c_str());
         simix_global->create_process_function(arg->name.c_str(),
             arg->code,
             nullptr,
-            arg->hostname,
+            arg->host,
             arg->kill_time,
             arg->properties,
             arg->auto_restart,
@@ -132,14 +132,13 @@ void _SIMIX_host_free_process_arg(void *data)
  */
 void SIMIX_host_add_auto_restart_process(
   sg_host_t host, const char *name, std::function<void()> code,
-  void* data, const char *hostname, double kill_time,
-  xbt_dict_t properties, int auto_restart)
+  void* data, double kill_time, xbt_dict_t properties, int auto_restart)
 {
   smx_process_arg_t arg = new simgrid::simix::ProcessArg();
   arg->name = name;
   arg->code = std::move(code);
   arg->data = data;
-  arg->hostname = hostname;
+  arg->host = host;
   arg->kill_time = kill_time;
   arg->properties = properties;
   arg->auto_restart = auto_restart;
@@ -159,8 +158,8 @@ void SIMIX_host_autorestart(sg_host_t host)
 
   for (auto arg : process_list) {
 
-    XBT_DEBUG("Restarting Process %s(%s) right now", arg->name.c_str(), arg->hostname);
-    simix_global->create_process_function(arg->name.c_str(), arg->code, nullptr, arg->hostname, arg->kill_time,
+    XBT_DEBUG("Restarting Process %s@%s right now", arg->name.c_str(), arg->host->name().c_str());
+    simix_global->create_process_function(arg->name.c_str(), arg->code, nullptr, arg->host, arg->kill_time,
         arg->properties, arg->auto_restart, nullptr);
   }
   process_list.clear();
index 964a730..230060c 100644 (file)
@@ -47,7 +47,6 @@ XBT_PRIVATE void SIMIX_host_add_auto_restart_process(sg_host_t host,
                                          const char *name,
                                          std::function<void()> code,
                                          void *data,
-                                         const char *hostname,
                                          double kill_time,
                                          xbt_dict_t properties,
                                          int auto_restart);
index dfcb753..e1971f0 100644 (file)
@@ -592,7 +592,7 @@ void sg_platf_new_process(sg_platf_process_cbarg_t process)
   arg->name = std::string(process->argv[0]);
   arg->code = code;
   arg->data = nullptr;
-  arg->hostname = sg_host_get_name(host);
+  arg->host = host;
   arg->kill_time = kill_time;
   arg->properties = current_property_set;
 
@@ -604,18 +604,18 @@ void sg_platf_new_process(sg_platf_process_cbarg_t process)
     arg->name = std::string(process->argv[0]);
     arg->code = std::move(code);
     arg->data = nullptr;
-    arg->hostname = sg_host_get_name(host);
+    arg->host = host;
     arg->kill_time = kill_time;
     arg->properties = current_property_set;
 
-    XBT_DEBUG("Process %s(%s) will be started at time %f",
-      arg->name.c_str(), arg->hostname, start_time);
+    XBT_DEBUG("Process %s@%s will be started at time %f",
+      arg->name.c_str(), arg->host->name().c_str(), start_time);
     SIMIX_timer_set(start_time, [=]() {
       simix_global->create_process_function(
                                             arg->name.c_str(),
                                             std::move(arg->code),
                                             arg->data,
-                                            arg->hostname,
+                                            arg->host,
                                             arg->kill_time,
                                             arg->properties,
                                             arg->auto_restart,
@@ -628,7 +628,7 @@ void sg_platf_new_process(sg_platf_process_cbarg_t process)
 
     process_created = simix_global->create_process_function(
         arg->name.c_str(), std::move(code), nullptr,
-        sg_host_get_name(host), kill_time,
+        host, kill_time,
         current_property_set, auto_restart, nullptr);
 
     /* verify if process has been created (won't be the case if the host is currently dead, but that's fine) */
index a1e0800..8d13517 100644 (file)
@@ -108,7 +108,7 @@ int main(int argc, char *argv[])
   xbt_assert(argc == 2, "Usage: %s platform.xml\n", argv[0]);
   SIMIX_function_register("master", example::master);
   SIMIX_create_environment(argv[1]);
-  simcall_process_create("master", example::master, NULL, "Tremblay", -1, 0, NULL, NULL, 0);
+  simcall_process_create("master", example::master, NULL, sg_host_by_name("Tremblay"), -1, 0, NULL, NULL, 0);
   SIMIX_run();
   return 0;
 }
index 9a951fe..3431827 100644 (file)
@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
 
   SIMIX_function_register("master", master);
   SIMIX_create_environment(argv[1]);
-  simcall_process_create("master", master, NULL, "Tremblay", -1, 0, NULL, NULL, 0);
+  simcall_process_create("master", master, NULL, sg_host_by_name("Tremblay"), -1, 0, NULL, NULL, 0);
   SIMIX_run();
 
   return 0;