From c5d588d76539d285fb67bef1ab477191622b94a9 Mon Sep 17 00:00:00 2001 From: SUTER Frederic Date: Fri, 1 Oct 2021 11:14:28 +0200 Subject: [PATCH] deprecate 2 simix functions --- doc/doxygen/uhood_switch.doc | 4 +- include/simgrid/simix.h | 4 +- src/bindings/java/jmsg_process.cpp | 2 +- src/kernel/actor/ActorImpl.cpp | 4 +- src/mc/mc_base.cpp | 2 +- src/simix/popping_bodies.cpp | 23 +++++---- src/simix/simcalls.py | 5 +- src/smpi/bindings/smpi_pmpi.cpp | 4 +- src/xbt/xbt_virtu.cpp | 5 +- teshsuite/kernel/CMakeLists.txt | 1 + .../simcall-generic/blocking_simcall.hpp | 48 +++++++++---------- 11 files changed, 54 insertions(+), 48 deletions(-) diff --git a/doc/doxygen/uhood_switch.doc b/doc/doxygen/uhood_switch.doc index 3f3dc808f5..7b579d4cbd 100644 --- a/doc/doxygen/uhood_switch.doc +++ b/doc/doxygen/uhood_switch.doc @@ -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 result; simcall_run_blocking([&result, self, &code]{ @@ -549,7 +549,7 @@ T simgrid::simix::Future::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 result; simcall_run_blocking([this, &result, self]{ try { diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 1b723886f9..b8cdb77786 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -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 *********************************/ diff --git a/src/bindings/java/jmsg_process.cpp b/src/bindings/java/jmsg_process.cpp index 85471221be..88f3347c98 100644 --- a/src/bindings/java/jmsg_process.cpp +++ b/src/bindings/java/jmsg_process.cpp @@ -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(); diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index d2af1a6f31..33c107a081 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -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& 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(); } diff --git a/src/mc/mc_base.cpp b/src/mc/mc_base.cpp index 9341466998..eaaf235c84 100644 --- a/src/mc/mc_base.cpp +++ b/src/mc/mc_base.cpp @@ -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); } diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index d24df42745..dd5c314ef0 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -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 @@ -29,7 +30,7 @@ using simgrid::simix::Simcall; template 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(Simcall::COMM_RECV, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, timeout, rate); } inline static boost::intrusive_ptr 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, 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(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 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, 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(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(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(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(Simcall::COMM_WAIT, comm, timeout); } diff --git a/src/simix/simcalls.py b/src/simix/simcalls.py index e0ada4e2b4..e2e93e34b1 100755 --- a/src/simix/simcalls.py +++ b/src/simix/simcalls.py @@ -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 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_)); diff --git a/src/smpi/bindings/smpi_pmpi.cpp b/src/smpi/bindings/smpi_pmpi.cpp index d1b76c9ce8..1b33f5536e 100644 --- a/src/smpi/bindings/smpi_pmpi.cpp +++ b/src/smpi/bindings/smpi_pmpi.cpp @@ -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(); }); } diff --git a/src/xbt/xbt_virtu.cpp b/src/xbt/xbt_virtu.cpp index 1b983a0ecc..7670ec2d71 100644 --- a/src/xbt/xbt_virtu.cpp +++ b/src/xbt/xbt_virtu.cpp @@ -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(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(); } diff --git a/teshsuite/kernel/CMakeLists.txt b/teshsuite/kernel/CMakeLists.txt index 2ecaaadf43..c4dba77046 100644 --- a/teshsuite/kernel/CMakeLists.txt +++ b/teshsuite/kernel/CMakeLists.txt @@ -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) diff --git a/teshsuite/kernel/simcall-generic/blocking_simcall.hpp b/teshsuite/kernel/simcall-generic/blocking_simcall.hpp index 3538e710f2..7c0f74d9dc 100644 --- a/teshsuite/kernel/simcall-generic/blocking_simcall.hpp +++ b/teshsuite/kernel/simcall-generic/blocking_simcall.hpp @@ -14,10 +14,10 @@ #include #include -#include -#include #include +#include "src/kernel/actor/ActorImpl.hpp" + namespace simgrid { namespace simix { @@ -46,19 +46,19 @@ template 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 result; + auto self = kernel::actor::ActorImpl::self(); + xbt::Result result; simcall_run_blocking( [&result, self, &code] { try { auto future = code(); - future.then_([&result, self](std::shared_ptr> value) { - simgrid::xbt::set_promise(result, simgrid::kernel::Future(std::move(value))); - simgrid::simix::unblock(self); + future.then_([&result, self](std::shared_ptr> value) { + xbt::set_promise(result, kernel::Future(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 result; + auto self = kernel::actor::ActorImpl::self(); + xbt::Result result; simcall_run_blocking( [this, &result, self] { try { // When the kernel future is ready... - this->future_.then_([&result, self](std::shared_ptr> value) { + this->future_.then_([&result, self](std::shared_ptr> value) { // ... wake up the process with the result of the kernel future. - simgrid::xbt::set_promise(result, simgrid::kernel::Future(std::move(value))); - simgrid::simix::unblock(self); + xbt::set_promise(result, kernel::Future(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> value) { + this->future_.then_([this, self](std::shared_ptr> value) { // ...store it the simix kernel and wake up. - this->future_ = simgrid::kernel::Future(std::move(value)); - simgrid::simix::unblock(self); + this->future_ = kernel::Future(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 future_; + kernel::Future future_; }; /** Start some asynchronous work @@ -149,12 +149,12 @@ template auto kernel_async(F code) -> Future using T = decltype(code().get()); // Execute the code in the kernel and get the kernel future: - simgrid::kernel::Future future = simgrid::kernel::actor::simcall(std::move(code)); + kernel::Future future = kernel::actor::simcall(std::move(code)); // Wrap the kernel future in an actor future: - return simgrid::simix::Future(std::move(future)); -} -} + return Future(std::move(future)); } +} // namespace simix +} // namespace simgrid #endif -- 2.20.1