Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
deprecate 2 simix functions
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Fri, 1 Oct 2021 09:14:28 +0000 (11:14 +0200)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Fri, 1 Oct 2021 09:14:28 +0000 (11:14 +0200)
doc/doxygen/uhood_switch.doc
include/simgrid/simix.h
src/bindings/java/jmsg_process.cpp
src/kernel/actor/ActorImpl.cpp
src/mc/mc_base.cpp
src/simix/popping_bodies.cpp
src/simix/simcalls.py
src/smpi/bindings/smpi_pmpi.cpp
src/xbt/xbt_virtu.cpp
teshsuite/kernel/CMakeLists.txt
teshsuite/kernel/simcall-generic/blocking_simcall.hpp

index 3f3dc80..7b579d4 100644 (file)
@@ -479,7 +479,7 @@ auto kernel_sync(F code) -> decltype(code().get())
   typedef decltype(code().get()) T;
   xbt_assert(not SIMIX_is_maestro(), "Can't execute blocking call in kernel mode");
 
-  smx_actor_t self = SIMIX_process_self();
+  auto self = simgrid::kernel::actor::ActorImpl::self();
   simgrid::xbt::Result<T> result;
 
   simcall_run_blocking([&result, self, &code]{
@@ -549,7 +549,7 @@ T simgrid::simix::Future<T>::get()
 {
   if (!valid())
     throw std::future_error(std::future_errc::no_state);
-  smx_actor_t self = SIMIX_process_self();
+  auto self = simgrid::kernel::actor::ActorImpl::self();
   simgrid::xbt::Result<T> result;
   simcall_run_blocking([this, &result, self]{
     try {
index 1b72388..b8cdb77 100644 (file)
@@ -50,8 +50,8 @@ SG_END_DECL
 
 /********************************* Process ************************************/
 SG_BEGIN_DECL
-XBT_PUBLIC smx_actor_t SIMIX_process_self();
-XBT_PUBLIC const char* SIMIX_process_self_get_name();
+XBT_ATTRIB_DEPRECATED_v333("Please use kernel::actor::ActorImpl::self()") XBT_PUBLIC smx_actor_t SIMIX_process_self();
+XBT_ATTRIB_DEPRECATED_v333("Please use xbt_procname()") XBT_PUBLIC const char* SIMIX_process_self_get_name();
 SG_END_DECL
 
 /****************************** Communication *********************************/
index 8547122..88f3347 100644 (file)
@@ -75,7 +75,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_create(JNIEnv* env, jobject
   auto jname        = (jstring)env->GetObjectField(jprocess, jprocess_field_Process_name);
   const char* name  = env->GetStringUTFChars(jname, nullptr);
   auto actor_code   = [jprocess]() { simgrid::kernel::context::java_main_jprocess(jprocess); };
-  smx_actor_t self  = SIMIX_process_self();
+  auto self         = simgrid::kernel::actor::ActorImpl::self();
   sg_host_t host    = jhost_get_native(env, jhost);
   smx_actor_t actor = simgrid::kernel::actor::simcall([name, actor_code, host, self] {
     return simgrid::kernel::actor::ActorImpl::create(std::move(name), std::move(actor_code), nullptr, host, self).get();
index d2af1a6..33c107a 100644 (file)
@@ -26,7 +26,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_process, simix, "Logging specific to SIMIX
  *
  * @return The SIMIX process
  */
-smx_actor_t SIMIX_process_self()
+smx_actor_t SIMIX_process_self() // XBT_ATTRIB_DEPRECATED_v333
 {
   return simgrid::kernel::actor::ActorImpl::self();
 }
@@ -519,7 +519,7 @@ void create_maestro(const std::function<void()>& code)
 } // namespace simgrid
 
 /* needs to be public and without simcall because it is called by exceptions and logging events */
-const char* SIMIX_process_self_get_name()
+const char* SIMIX_process_self_get_name() // XBT_ATTRIB_DEPRECATD_v333
 {
   return SIMIX_is_maestro() ? "maestro" : simgrid::kernel::actor::ActorImpl::self()->get_cname();
 }
index 9341466..eaaf235 100644 (file)
@@ -33,7 +33,7 @@ int MC_random(int min, int max)
     static simgrid::xbt::random::XbtRandom prng;
     return prng.uniform_int(min, max);
   }
-  simgrid::kernel::actor::RandomSimcall observer{SIMIX_process_self(), min, max};
+  simgrid::kernel::actor::RandomSimcall observer{simgrid::kernel::actor::ActorImpl::self(), min, max};
   return simgrid::kernel::actor::simcall([&observer] { return observer.get_value(); }, &observer);
 }
 
index d24df42..dd5c314 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include "src/kernel/EngineImpl.hpp"
+#include "src/kernel/actor/ActorImpl.hpp"
 #include "src/mc/mc_forward.hpp"
 #include "xbt/ex.h"
 #include <functional>
@@ -29,7 +30,7 @@ using simgrid::simix::Simcall;
 template<class R, class... T>
 inline static R simcall(Simcall call, T const&... t)
 {
-  smx_actor_t self = SIMIX_process_self();
+  auto self = simgrid::kernel::actor::ActorImpl::self();
   simgrid::simix::marshal(&self->simcall_, call, t...);
   if (not simgrid::kernel::EngineImpl::get_instance()->is_maestro(self)) {
     XBT_DEBUG("Yield process '%s' on simcall %s", self->get_cname(), SIMIX_simcall_name(self->simcall_));
@@ -43,56 +44,60 @@ inline static R simcall(Simcall call, T const&... t)
 inline static void simcall_BODY_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, unsigned char* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout, double rate)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
-    simcall_HANDLER_comm_recv(&SIMIX_process_self()->simcall_, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, timeout, rate);
+    simcall_HANDLER_comm_recv(&simgrid::kernel::actor::ActorImpl::self()->simcall_, receiver, mbox, dst_buff,
+                              dst_buff_size, match_fun, copy_data_fun, data, timeout, rate);
   return simcall<void, smx_actor_t, smx_mailbox_t, unsigned char*, size_t*, simix_match_func_t, simix_copy_data_func_t, void*, double, double>(Simcall::COMM_RECV, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, timeout, rate);
 }
 
 inline static boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> simcall_BODY_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, unsigned char* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double rate)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
-    simcall_HANDLER_comm_irecv(&SIMIX_process_self()->simcall_, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, rate);
+    simcall_HANDLER_comm_irecv(&simgrid::kernel::actor::ActorImpl::self()->simcall_, receiver, mbox, dst_buff,
+                               dst_buff_size, match_fun, copy_data_fun, data, rate);
   return simcall<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>, smx_actor_t, smx_mailbox_t, unsigned char*, size_t*, simix_match_func_t, simix_copy_data_func_t, void*, double>(Simcall::COMM_IRECV, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, rate);
 }
 
 inline static void simcall_BODY_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, unsigned char* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
-    simcall_HANDLER_comm_send(&SIMIX_process_self()->simcall_, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, copy_data_fun, data, timeout);
+    simcall_HANDLER_comm_send(&simgrid::kernel::actor::ActorImpl::self()->simcall_, sender, mbox, task_size, rate,
+                              src_buff, src_buff_size, match_fun, copy_data_fun, data, timeout);
   return simcall<void, smx_actor_t, smx_mailbox_t, double, double, unsigned char*, size_t, simix_match_func_t, simix_copy_data_func_t, void*, double>(Simcall::COMM_SEND, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, copy_data_fun, data, timeout);
 }
 
 inline static boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> simcall_BODY_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, unsigned char* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, bool detached)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
-    simcall_HANDLER_comm_isend(&SIMIX_process_self()->simcall_, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, clean_fun, copy_data_fun, data, detached);
+    simcall_HANDLER_comm_isend(&simgrid::kernel::actor::ActorImpl::self()->simcall_, sender, mbox, task_size, rate,
+                               src_buff, src_buff_size, match_fun, clean_fun, copy_data_fun, data, detached);
   return simcall<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>, smx_actor_t, smx_mailbox_t, double, double, unsigned char*, size_t, simix_match_func_t, simix_clean_func_t, simix_copy_data_func_t, void*, bool>(Simcall::COMM_ISEND, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, clean_fun, copy_data_fun, data, detached);
 }
 
 inline static bool simcall_BODY_comm_test(simgrid::kernel::activity::CommImpl* comm)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
-    simcall_HANDLER_comm_test(&SIMIX_process_self()->simcall_, comm);
+    simcall_HANDLER_comm_test(&simgrid::kernel::actor::ActorImpl::self()->simcall_, comm);
   return simcall<bool, simgrid::kernel::activity::CommImpl*>(Simcall::COMM_TEST, comm);
 }
 
 inline static ssize_t simcall_BODY_comm_testany(simgrid::kernel::activity::CommImpl** comms, size_t count)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
-    simcall_HANDLER_comm_testany(&SIMIX_process_self()->simcall_, comms, count);
+    simcall_HANDLER_comm_testany(&simgrid::kernel::actor::ActorImpl::self()->simcall_, comms, count);
   return simcall<ssize_t, simgrid::kernel::activity::CommImpl**, size_t>(Simcall::COMM_TESTANY, comms, count);
 }
 
 inline static ssize_t simcall_BODY_comm_waitany(simgrid::kernel::activity::CommImpl** comms, size_t count, double timeout)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
-    simcall_HANDLER_comm_waitany(&SIMIX_process_self()->simcall_, comms, count, timeout);
+    simcall_HANDLER_comm_waitany(&simgrid::kernel::actor::ActorImpl::self()->simcall_, comms, count, timeout);
   return simcall<ssize_t, simgrid::kernel::activity::CommImpl**, size_t, double>(Simcall::COMM_WAITANY, comms, count, timeout);
 }
 
 inline static void simcall_BODY_comm_wait(simgrid::kernel::activity::CommImpl* comm, double timeout)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
-    simcall_HANDLER_comm_wait(&SIMIX_process_self()->simcall_, comm, timeout);
+    simcall_HANDLER_comm_wait(&simgrid::kernel::actor::ActorImpl::self()->simcall_, comm, timeout);
   return simcall<void, simgrid::kernel::activity::CommImpl*, double>(Simcall::COMM_WAIT, comm, timeout);
 }
 
index e0ada4e..e2e93e3 100755 (executable)
@@ -159,7 +159,7 @@ class Simcall(object):
         res.append('  if (false) /* Go to that function to follow the code flow through the simcall barrier */')
         if self.need_handler:
             res.append('    simcall_HANDLER_%s(%s);' % (self.name,
-                                                        ', '.join(["&SIMIX_process_self()->simcall_"] + [arg.name for arg in self.args])))
+                                                        ', '.join(["&simgrid::kernel::actor::ActorImpl::self()->simcall_"] + [arg.name for arg in self.args])))
         else:
             res.append('    SIMIX_%s(%s);' % (self.name,
                                               ', '.join(arg.name for arg in self.args)))
@@ -363,6 +363,7 @@ if __name__ == '__main__':
     # popping_bodies.cpp
     #
     fd = header('popping_bodies.cpp')
+    fd.write('#include "src/kernel/actor/ActorImpl.hpp"\n')
     fd.write('#include "src/kernel/EngineImpl.hpp"\n')
     fd.write('#include "src/mc/mc_forward.hpp"\n')
     fd.write('#include "xbt/ex.h"\n')
@@ -379,7 +380,7 @@ using simgrid::simix::Simcall;
 template<class R, class... T>
 inline static R simcall(Simcall call, T const&... t)
 {
-  smx_actor_t self = SIMIX_process_self();
+  auto self = simgrid::kernel::actor::ActorImpl::self();
   simgrid::simix::marshal(&self->simcall_, call, t...);
   if (not simgrid::kernel::EngineImpl::get_instance()->is_maestro(self)) {
     XBT_DEBUG("Yield process '%s' on simcall %s", self->get_cname(), SIMIX_simcall_name(self->simcall_));
index d1b76c9..1b33f55 100644 (file)
@@ -131,9 +131,9 @@ int PMPI_Abort(MPI_Comm comm, int /*errorcode*/)
   smpi_bench_end();
   CHECK_COMM(1)
   XBT_WARN("MPI_Abort was called, something went probably wrong in this simulation ! Killing all processes sharing the same MPI_COMM_WORLD");
-  smx_actor_t myself = SIMIX_process_self();
+  auto myself = simgrid::kernel::actor::ActorImpl::self();
   for (int i = 0; i < comm->size(); i++){
-    smx_actor_t actor = simgrid::kernel::actor::ActorImpl::by_pid(comm->group()->actor(i));
+    auto actor = simgrid::kernel::actor::ActorImpl::by_pid(comm->group()->actor(i));
     if (actor != nullptr && actor != myself)
       simgrid::kernel::actor::simcall([actor] { actor->exit(); });
   }
index 1b983a0..7670ec2 100644 (file)
@@ -5,17 +5,16 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "simgrid/simix.h"
 #include "src/kernel/actor/ActorImpl.hpp"
 #include "xbt/virtu.h"
 
 int xbt_getpid()
 {
-  const simgrid::kernel::actor::ActorImpl* self = SIMIX_process_self();
+  const auto* self = simgrid::kernel::actor::ActorImpl::self();
   return self == nullptr ? 0 : static_cast<int>(self->get_pid());
 }
 
 const char* xbt_procname(void)
 {
-  return SIMIX_process_self_get_name();
+  return SIMIX_is_maestro() ? "maestro" : simgrid::kernel::actor::ActorImpl::self()->get_cname();
 }
index 2ecaaad..c4dba77 100644 (file)
@@ -2,6 +2,7 @@ foreach(x context-defaults simcall-generic stack-overflow)
   add_executable       (${x}  EXCLUDE_FROM_ALL ${x}/${x}.cpp)
   target_link_libraries(${x}  simgrid)
   set_target_properties(${x}  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
+  set_property(TARGET ${x} APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}")
   add_dependencies(tests ${x})
 
   set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.cpp)
index 3538e71..7c0f74d 100644 (file)
 #include <xbt/sysdep.h>
 
 #include <simgrid/kernel/future.hpp>
-#include <simgrid/simix.h>
-#include <simgrid/simix.hpp>
 #include <xbt/promise.hpp>
 
+#include "src/kernel/actor/ActorImpl.hpp"
+
 namespace simgrid {
 namespace simix {
 
@@ -46,19 +46,19 @@ template <class F> auto kernel_sync(F code) -> decltype(code().get())
   using T = decltype(code().get());
   xbt_assert(not SIMIX_is_maestro(), "Cannot execute blocking call in kernel mode");
 
-  smx_actor_t self = SIMIX_process_self();
-  simgrid::xbt::Result<T> result;
+  auto self = kernel::actor::ActorImpl::self();
+  xbt::Result<T> result;
   simcall_run_blocking(
       [&result, self, &code] {
         try {
           auto future = code();
-          future.then_([&result, self](std::shared_ptr<simgrid::kernel::FutureState<T>> value) {
-            simgrid::xbt::set_promise(result, simgrid::kernel::Future<T>(std::move(value)));
-            simgrid::simix::unblock(self);
+          future.then_([&result, self](std::shared_ptr<kernel::FutureState<T>> value) {
+            xbt::set_promise(result, kernel::Future<T>(std::move(value)));
+            unblock(self);
           });
         } catch (...) {
           result.set_exception(std::current_exception());
-          simgrid::simix::unblock(self);
+          unblock(self);
         }
       },
       nullptr);
@@ -84,20 +84,20 @@ public:
   {
     if (not valid())
       throw std::future_error(std::future_errc::no_state);
-    smx_actor_t self = SIMIX_process_self();
-    simgrid::xbt::Result<T> result;
+    auto self = kernel::actor::ActorImpl::self();
+    xbt::Result<T> result;
     simcall_run_blocking(
         [this, &result, self] {
           try {
             // When the kernel future is ready...
-            this->future_.then_([&result, self](std::shared_ptr<simgrid::kernel::FutureState<T>> value) {
+            this->future_.then_([&result, self](std::shared_ptr<kernel::FutureState<T>> value) {
               // ... wake up the process with the result of the kernel future.
-              simgrid::xbt::set_promise(result, simgrid::kernel::Future<T>(std::move(value)));
-              simgrid::simix::unblock(self);
+              xbt::set_promise(result, kernel::Future<T>(std::move(value)));
+              unblock(self);
             });
           } catch (...) {
             result.set_exception(std::current_exception());
-            simgrid::simix::unblock(self);
+            unblock(self);
           }
         },
         nullptr);
@@ -116,19 +116,19 @@ public:
       return;
     // The future is not ready. We have to delegate to the SimGrid kernel:
     std::exception_ptr exception;
-    smx_actor_t self = SIMIX_process_self();
+    auto self = kernel::actor::ActorImpl::self();
     simcall_run_blocking(
         [this, &exception, self] {
           try {
             // When the kernel future is ready...
-            this->future_.then_([this, self](std::shared_ptr<simgrid::kernel::FutureState<T>> value) {
+            this->future_.then_([this, self](std::shared_ptr<kernel::FutureState<T>> value) {
               // ...store it the simix kernel and wake up.
-              this->future_ = simgrid::kernel::Future<T>(std::move(value));
-              simgrid::simix::unblock(self);
+              this->future_ = kernel::Future<T>(std::move(value));
+              unblock(self);
             });
           } catch (...) {
             exception = std::current_exception();
-            simgrid::simix::unblock(self);
+            unblock(self);
           }
         },
         nullptr);
@@ -136,7 +136,7 @@ public:
 
 private:
   // We wrap an event-based kernel future:
-  simgrid::kernel::Future<T> future_;
+  kernel::Future<T> future_;
 };
 
 /** Start some asynchronous work
@@ -149,12 +149,12 @@ template <class F> auto kernel_async(F code) -> Future<decltype(code().get())>
   using T = decltype(code().get());
 
   // Execute the code in the kernel and get the kernel future:
-  simgrid::kernel::Future<T> future = simgrid::kernel::actor::simcall(std::move(code));
+  kernel::Future<T> future = kernel::actor::simcall(std::move(code));
 
   // Wrap the kernel future in an actor future:
-  return simgrid::simix::Future<T>(std::move(future));
-}
-}
+  return Future<T>(std::move(future));
 }
+} // namespace simix
+} // namespace simgrid
 
 #endif