Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce number of direct accesses to simix_global.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 1 Nov 2019 16:56:56 +0000 (17:56 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 2 Nov 2019 20:20:25 +0000 (21:20 +0100)
src/kernel/actor/ActorImpl.cpp
src/s4u/s4u_Actor.cpp
src/s4u/s4u_Host.cpp
src/simix/smx_global.cpp
src/simix/smx_private.hpp

index 78be44f..5f5bb59 100644 (file)
@@ -222,6 +222,7 @@ void ActorImpl::exit()
 
 void ActorImpl::kill(ActorImpl* actor)
 {
 
 void ActorImpl::kill(ActorImpl* actor)
 {
+  xbt_assert(actor != simix_global->maestro_process, "Killing maestro is a rather bad idea");
   if (actor->finished_) {
     XBT_DEBUG("Ignoring request to kill actor %s@%s that is already dead", actor->get_cname(),
               actor->host_->get_cname());
   if (actor->finished_) {
     XBT_DEBUG("Ignoring request to kill actor %s@%s that is already dead", actor->get_cname(),
               actor->host_->get_cname());
@@ -553,12 +554,7 @@ void SIMIX_process_self_set_data(void* data)
    by exceptions and logging events */
 const char* SIMIX_process_self_get_name()
 {
    by exceptions and logging events */
 const char* SIMIX_process_self_get_name()
 {
-
-  smx_actor_t process = SIMIX_process_self();
-  if (process == nullptr || process == simix_global->maestro_process)
-    return "maestro";
-
-  return process->get_cname();
+  return SIMIX_is_maestro() ? "maestro" : SIMIX_process_self()->get_cname();
 }
 
 /**
 }
 
 /**
index 154d5fb..80cd55a 100644 (file)
@@ -13,7 +13,6 @@
 #include "src/include/mc/mc.h"
 #include "src/kernel/activity/ExecImpl.hpp"
 #include "src/mc/mc_replay.hpp"
 #include "src/include/mc/mc.h"
 #include "src/kernel/activity/ExecImpl.hpp"
 #include "src/mc/mc_replay.hpp"
-#include "src/simix/smx_private.hpp"
 #include "src/surf/HostImpl.hpp"
 
 #include <algorithm>
 #include "src/surf/HostImpl.hpp"
 
 #include <algorithm>
@@ -219,10 +218,7 @@ double Actor::get_kill_time()
 void Actor::kill()
 {
   kernel::actor::ActorImpl* self = SIMIX_process_self();
 void Actor::kill()
 {
   kernel::actor::ActorImpl* self = SIMIX_process_self();
-  kernel::actor::simcall([this, self] {
-    xbt_assert(pimpl_ != simix_global->maestro_process, "Killing maestro is a rather bad idea");
-    self->kill(pimpl_);
-  });
+  kernel::actor::simcall([this, self] { self->kill(pimpl_); });
 }
 
 // ***** Static functions *****
 }
 
 // ***** Static functions *****
@@ -278,8 +274,7 @@ namespace this_actor {
  */
 bool is_maestro()
 {
  */
 bool is_maestro()
 {
-  kernel::actor::ActorImpl* self = SIMIX_process_self();
-  return self == nullptr || self == simix_global->maestro_process;
+  return SIMIX_is_maestro();
 }
 
 void sleep_for(double duration)
 }
 
 void sleep_for(double duration)
index 881f967..71710c4 100644 (file)
@@ -9,7 +9,6 @@
 #include "simgrid/s4u/Exec.hpp"
 #include "simgrid/s4u/VirtualMachine.hpp"
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
 #include "simgrid/s4u/Exec.hpp"
 #include "simgrid/s4u/VirtualMachine.hpp"
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
-#include "src/simix/smx_private.hpp"
 #include "src/surf/HostImpl.hpp"
 
 #include <algorithm>
 #include "src/surf/HostImpl.hpp"
 
 #include <algorithm>
@@ -655,18 +654,13 @@ void sg_host_get_actor_list(sg_host_t host, xbt_dynar_t whereto)
 
 sg_host_t sg_host_self()
 {
 
 sg_host_t sg_host_self()
 {
-  simgrid::kernel::actor::ActorImpl* self = SIMIX_process_self();
-  return (self == nullptr) ? nullptr : self->get_host();
+  return SIMIX_is_maestro() ? nullptr : SIMIX_process_self()->get_host();
 }
 
 /* needs to be public and without simcall for exceptions and logging events */
 const char* sg_host_self_get_name()
 {
 }
 
 /* needs to be public and without simcall for exceptions and logging events */
 const char* sg_host_self_get_name()
 {
-  sg_host_t host = sg_host_self();
-  if (host == nullptr || SIMIX_process_self() == simix_global->maestro_process)
-    return "";
-
-  return host->get_cname();
+  return SIMIX_is_maestro() ? "" : SIMIX_process_self()->get_host()->get_cname();
 }
 
 double sg_host_load(sg_host_t host)
 }
 
 double sg_host_load(sg_host_t host)
index a006997..04673e2 100644 (file)
@@ -600,6 +600,8 @@ void SIMIX_display_process_status()
 
 int SIMIX_is_maestro()
 {
 
 int SIMIX_is_maestro()
 {
-  smx_actor_t self = SIMIX_process_self();
-  return simix_global == nullptr /*SimDag*/ || self == nullptr || self == simix_global->maestro_process;
+  if (simix_global == nullptr) // SimDag
+    return true;
+  simgrid::kernel::actor::ActorImpl* self = SIMIX_process_self();
+  return self == nullptr || self == simix_global->maestro_process;
 }
 }
index 2689334..18b0131 100644 (file)
@@ -21,8 +21,6 @@ namespace simgrid {
 namespace simix {
 
 class Global {
 namespace simix {
 
 class Global {
-  friend XBT_PUBLIC bool simgrid::s4u::this_actor::is_maestro();
-
 public:
   bool execute_tasks();
   /**
 public:
   bool execute_tasks();
   /**