Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
data is now userdata for process/actor
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 6 Jul 2017 11:43:51 +0000 (13:43 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 6 Jul 2017 11:43:51 +0000 (13:43 +0200)
src/msg/msg_process.cpp
src/simix/ActorImpl.cpp
src/simix/ActorImpl.hpp
src/simix/libsmx.cpp
src/smpi/smpi_global.cpp
src/smpi/smpi_process.cpp

index 14d0097..2cabc47 100644 (file)
@@ -35,7 +35,7 @@ void MSG_process_cleanup_from_SIMIX(smx_actor_t smx_actor)
     msg_actor = (simgrid::msg::ActorExt*)SIMIX_process_self_get_data();
     SIMIX_process_self_set_data(nullptr);
   } else {
-    msg_actor = (simgrid::msg::ActorExt*)smx_actor->data;
+    msg_actor = (simgrid::msg::ActorExt*)smx_actor->userdata;
     simcall_process_set_data(smx_actor, nullptr);
   }
 
@@ -232,7 +232,7 @@ void* MSG_process_get_data(msg_process_t process)
   xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
 
   /* get from SIMIX the MSG process data, and then the user data */
-  simgrid::msg::ActorExt* msgExt = (simgrid::msg::ActorExt*)process->getImpl()->data;
+  simgrid::msg::ActorExt* msgExt = (simgrid::msg::ActorExt*)process->getImpl()->userdata;
   if (msgExt)
     return msgExt->data;
   else
@@ -248,7 +248,7 @@ msg_error_t MSG_process_set_data(msg_process_t process, void *data)
 {
   xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!");
 
-  static_cast<simgrid::msg::ActorExt*>(process->getImpl()->data)->data = data;
+  static_cast<simgrid::msg::ActorExt*>(process->getImpl()->userdata)->data = data;
 
   return MSG_OK;
 }
index f7d2dca..9cc63bb 100644 (file)
@@ -178,7 +178,7 @@ ActorImpl* ActorImpl::restart(ActorImpl* issuer)
   arg.code         = code;
   arg.host         = host;
   arg.kill_time    = SIMIX_timer_get_date(kill_timer);
-  arg.data         = data;
+  arg.data         = userdata;
   arg.properties   = nullptr;
   arg.auto_restart = auto_restart;
 
@@ -258,7 +258,7 @@ void create_maestro(std::function<void()> code)
   maestro = new simgrid::simix::ActorImpl();
   maestro->pid = simix_process_maxpid++;
   maestro->name = "";
-  maestro->data = nullptr;
+  maestro->userdata = nullptr;
 
   if (not code) {
     maestro->context = SIMIX_context_new(std::function<void()>(), nullptr, maestro);
@@ -309,7 +309,7 @@ smx_actor_t SIMIX_process_create(const char* name, std::function<void()> code, v
   process->pid            = simix_process_maxpid++;
   process->name           = simgrid::xbt::string(name);
   process->host           = host;
-  process->data           = data;
+  process->userdata       = data;
   process->simcall.issuer = process;
 
   if (parent_process != nullptr) {
@@ -375,7 +375,7 @@ smx_actor_t SIMIX_process_attach(const char* name, void* data, const char* hostn
   process->pid = simix_process_maxpid++;
   process->name = std::string(name);
   process->host = host;
-  process->data = data;
+  process->userdata       = data;
   process->simcall.issuer = process;
 
   if (parent_process != nullptr) {
@@ -645,20 +645,14 @@ void* SIMIX_process_self_get_data()
   if (not self) {
     return nullptr;
   }
-  return self->data;
+  return self->getUserData();
 }
 
 void SIMIX_process_self_set_data(void *data)
 {
-  smx_actor_t self = SIMIX_process_self();
-
-  SIMIX_process_set_data(self, data);
+  SIMIX_process_self()->setUserData(data);
 }
 
-void SIMIX_process_set_data(smx_actor_t process, void *data)
-{
-  process->data = data;
-}
 
 /* needs to be public and without simcall because it is called
    by exceptions and logging events */
@@ -788,11 +782,8 @@ void SIMIX_process_yield(smx_actor_t self)
     SIMIX_process_on_exit_runall(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->data,
-                                          SIMIX_timer_get_date(self->kill_timer),
-                                          self->properties,
-                                          self->auto_restart);
+      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);
     }
     XBT_DEBUG("Process %s@%s is dead", self->cname(), self->host->getCname());
     self->context->stop();
index e4517b9..6baac2c 100644 (file)
@@ -61,7 +61,7 @@ public:
   std::list<smx_activity_t> comms;          /* the current non-blocking communication synchros */
   xbt_dict_t properties         = nullptr;
   s_smx_simcall_t simcall;
-  void *data          = nullptr; /* kept for compatibility, it should be replaced with moddata */
+  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 */
 
   std::function<void()> code;
@@ -110,6 +110,8 @@ public:
   smx_activity_t suspend(ActorImpl* issuer);
   void resume();
   smx_activity_t sleep(double duration);
+  void setUserData(void* data) { userdata = data; }
+  void* getUserData() { return userdata; }
 };
 
 }
index e90bfa4..47b9266 100644 (file)
@@ -229,7 +229,7 @@ int simcall_process_count()
  */
 void simcall_process_set_data(smx_actor_t process, void *data)
 {
-  simgrid::simix::kernelImmediate(std::bind(SIMIX_process_set_data, process, data));
+  simgrid::simix::kernelImmediate([process, data] { process->setUserData(data); });
 }
 
 /**
index 015834f..4a0758d 100644 (file)
@@ -79,7 +79,7 @@ simgrid::smpi::Process* smpi_process()
   smx_actor_t me = SIMIX_process_self();
   if (me == nullptr) // This happens sometimes (eg, when linking against NS3 because it pulls openMPI...)
     return nullptr;
-  simgrid::msg::ActorExt* msgExt = static_cast<simgrid::msg::ActorExt*>(me->data);
+  simgrid::msg::ActorExt* msgExt = static_cast<simgrid::msg::ActorExt*>(me->userdata);
   return static_cast<simgrid::smpi::Process*>(msgExt->data);
 }
 
@@ -180,7 +180,7 @@ void smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t b
        XBT_DEBUG("Privatization : We are copying from a zone inside global memory... Saving data to temp buffer !");
 
        smpi_switch_data_segment(
-           static_cast<simgrid::smpi::Process*>((static_cast<simgrid::msg::ActorExt*>(comm->src_proc->data)->data))
+           static_cast<simgrid::smpi::Process*>((static_cast<simgrid::msg::ActorExt*>(comm->src_proc->userdata)->data))
                ->index());
        tmpbuff = static_cast<void*>(xbt_malloc(buff_size));
        memcpy_private(tmpbuff, buff, private_blocks);
@@ -190,7 +190,7 @@ void smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t b
       && ((char*)comm->dst_buff < smpi_start_data_exe + smpi_size_data_exe )){
        XBT_DEBUG("Privatization : We are copying to a zone inside global memory - Switch data segment");
        smpi_switch_data_segment(
-           static_cast<simgrid::smpi::Process*>((static_cast<simgrid::msg::ActorExt*>(comm->dst_proc->data)->data))
+           static_cast<simgrid::smpi::Process*>((static_cast<simgrid::msg::ActorExt*>(comm->dst_proc->userdata)->data))
                ->index());
   }
   XBT_DEBUG("Copying %zu bytes from %p to %p", buff_size, tmpbuff,comm->dst_buff);
index 92d552e..60f5760 100644 (file)
@@ -76,7 +76,7 @@ void Process::set_data(int index, int* argc, char*** argv)
     instance_id_ = instance_id;
     index_ = index;
 
-    static_cast<simgrid::msg::ActorExt*>(SIMIX_process_self()->data)->data = this;
+    static_cast<simgrid::msg::ActorExt*>(SIMIX_process_self()->userdata)->data = this;
 
     if (*argc > 3) {
       memmove(&(*argv)[0], &(*argv)[2], sizeof(char *) * (*argc - 2));