Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill some useless getter simcalls
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 15 Feb 2017 23:35:50 +0000 (00:35 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 15 Feb 2017 23:40:55 +0000 (00:40 +0100)
They were rather misleading since they did not do any simcall,
actually. The code around the getters of data in the actors is still
somehow magical:

smpi_switch_data_segment((static_cast<smpi_process_data_t>((static_cast<simdata_process_t>(comm->dst_proc->data)->data))->index));

I love this one. Once I'm done, it will become:

smpi_switch_data_segment(comm->dst_proc->extension<SmpiActorExt>()->index);

I pretend that it is clearer. Maybe to me only? :-3

include/simgrid/simix.h
src/msg/msg_process.cpp
src/simix/ActorImpl.cpp
src/simix/ActorImpl.hpp
src/simix/libsmx.cpp
src/smpi/smpi_global.cpp

index 4105374..b2b8b32 100644 (file)
@@ -279,7 +279,6 @@ XBT_PUBLIC(void) simcall_process_resume(smx_actor_t process);
 
 /* Getters and Setters */
 XBT_PUBLIC(int) simcall_process_count();
-XBT_PUBLIC(void *) simcall_process_get_data(smx_actor_t process);
 XBT_PUBLIC(void) simcall_process_set_data(smx_actor_t process, void *data);
 XBT_PUBLIC(void) simcall_process_set_host(smx_actor_t process, sg_host_t dest);
 XBT_PUBLIC(int) simcall_process_is_suspended(smx_actor_t process);
index d02ae9c..e5e089a 100644 (file)
@@ -34,7 +34,7 @@ void MSG_process_cleanup_from_SIMIX(smx_actor_t smx_proc)
     msg_proc = (simdata_process_t) SIMIX_process_self_get_data();
     SIMIX_process_self_set_data(nullptr);
   } else {
-    msg_proc = (simdata_process_t) simcall_process_get_data(smx_proc);
+    msg_proc = (simdata_process_t)smx_proc->data;
     simcall_process_set_data(smx_proc, nullptr);
   }
 
@@ -241,7 +241,7 @@ msg_error_t MSG_process_join(msg_process_t process, double timeout){
  */
 msg_error_t MSG_process_migrate(msg_process_t process, msg_host_t host)
 {
-  simdata_process_t simdata = (simdata_process_t) simcall_process_get_data(process);
+  simdata_process_t simdata = (simdata_process_t)process->data;
   simdata->m_host = host;
   msg_host_t now = simdata->m_host;
   TRACE_msg_process_change_host(process, now, host);
@@ -265,7 +265,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 */
-  simdata_process_t simdata = (simdata_process_t) simcall_process_get_data(process);
+  simdata_process_t simdata = (simdata_process_t)process->data;
   if (simdata)
     return simdata->data;
   else
@@ -281,7 +281,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!");
 
-  simdata_process_t simdata = (simdata_process_t) simcall_process_get_data(process);
+  simdata_process_t simdata = (simdata_process_t)process->data;
   simdata->data = data;
 
   return MSG_OK;
@@ -307,7 +307,7 @@ msg_host_t MSG_process_get_host(msg_process_t process)
     simdata = (simdata_process_t) SIMIX_process_self_get_data();
   }
   else {
-    simdata = (simdata_process_t) simcall_process_get_data(process);
+    simdata = (simdata_process_t)process->data;
   }
   return simdata ? simdata->m_host : nullptr;
 }
index 7ae8a53..4aaa713 100644 (file)
@@ -644,7 +644,7 @@ void* SIMIX_process_self_get_data()
   if (!self) {
     return nullptr;
   }
-  return SIMIX_process_get_data(self);
+  return self->data;
 }
 
 void SIMIX_process_self_set_data(void *data)
@@ -654,11 +654,6 @@ void SIMIX_process_self_set_data(void *data)
   SIMIX_process_set_data(self, data);
 }
 
-void* SIMIX_process_get_data(smx_actor_t process)
-{
-  return process->data;
-}
-
 void SIMIX_process_set_data(smx_actor_t process, void *data)
 {
   process->data = data;
index e31313d..add8ca3 100644 (file)
@@ -120,7 +120,6 @@ XBT_PRIVATE void SIMIX_process_change_host(smx_actor_t process, sg_host_t dest);
 XBT_PRIVATE smx_activity_t SIMIX_process_suspend(smx_actor_t process, smx_actor_t issuer);
 XBT_PRIVATE void SIMIX_process_resume(smx_actor_t process);
 XBT_PRIVATE int SIMIX_process_get_PID(smx_actor_t self);
-XBT_PRIVATE void* SIMIX_process_get_data(smx_actor_t process);
 XBT_PRIVATE void SIMIX_process_set_data(smx_actor_t process, void *data);
 XBT_PRIVATE smx_actor_t SIMIX_process_get_by_name(const char* name);
 XBT_PRIVATE int SIMIX_process_is_suspended(smx_actor_t process);
index bbc509c..d97e17a 100644 (file)
@@ -251,17 +251,6 @@ int simcall_process_count()
   return simgrid::simix::kernelImmediate(SIMIX_process_count);
 }
 
-/**
- * \ingroup simix_process_management
- * \brief Return the user data of a #smx_actor_t.
- * \param process a SIMIX process
- * \return the user data of this process
- */
-void* simcall_process_get_data(smx_actor_t process)
-{
-  return SIMIX_process_get_data(process);
-}
-
 /**
  * \ingroup simix_process_management
  * \brief Set the user data of a #smx_actor_t.
index 47a3374..3bdbfe7 100644 (file)
@@ -133,8 +133,7 @@ void smpi_process_init(int *argc, char ***argv)
     data->instance_id = instance_id;
     data->replaying   = false;
 
-    simdata_process_t simdata = static_cast<simdata_process_t>(simcall_process_get_data(proc));
-    simdata->data             = data;
+    static_cast<simdata_process_t>(proc->data)->data = data;
 
     if (*argc > 3) {
       memmove(&(*argv)[0], &(*argv)[2], sizeof(char *) * (*argc - 2));
@@ -227,7 +226,7 @@ int smpi_global_size()
 
 smpi_process_data_t smpi_process_data()
 {
-  simdata_process_t simdata = static_cast<simdata_process_t>(SIMIX_process_self_get_data());
+  simdata_process_t simdata = static_cast<simdata_process_t>(SIMIX_process_self()->data);
   return static_cast<smpi_process_data_t>(simdata->data);
 }
 
@@ -400,8 +399,8 @@ 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<smpi_process_data_t>((static_cast<simdata_process_t>(SIMIX_process_get_data(comm->src_proc))->data))->index));
+       smpi_switch_data_segment(
+           (static_cast<smpi_process_data_t>((static_cast<simdata_process_t>(comm->src_proc->data)->data))->index));
        tmpbuff = static_cast<void*>(xbt_malloc(buff_size));
        memcpy(tmpbuff, buff, buff_size);
   }
@@ -409,7 +408,8 @@ void smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t b
   if((smpi_privatize_global_variables) && ((char*)comm->dst_buff >= smpi_start_data_exe)
       && ((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<smpi_process_data_t>((static_cast<simdata_process_t>(SIMIX_process_get_data(comm->dst_proc))->data))->index));
+       smpi_switch_data_segment(
+           (static_cast<smpi_process_data_t>((static_cast<simdata_process_t>(comm->dst_proc->data)->data))->index));
   }
 
   memcpy(comm->dst_buff, tmpbuff, buff_size);