From acd555b41f9a71f6e3ed538f00d1e84fe6d19024 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Wed, 5 Jul 2017 23:39:51 +0200 Subject: [PATCH 1/1] simcall to kernelImmediate --- include/simgrid/s4u/Actor.hpp | 2 +- include/simgrid/simix.h | 2 -- src/msg/msg_process.cpp | 4 +-- src/s4u/s4u_actor.cpp | 12 ++++---- src/simix/ActorImpl.cpp | 5 ---- src/simix/libsmx.cpp | 27 ------------------ src/simix/popping_accessors.h | 50 --------------------------------- src/simix/popping_bodies.cpp | 12 -------- src/simix/popping_enum.h | 2 -- src/simix/popping_generated.cpp | 12 -------- src/simix/simcalls.in | 15 ++++------ 11 files changed, 16 insertions(+), 127 deletions(-) diff --git a/include/simgrid/s4u/Actor.hpp b/include/simgrid/s4u/Actor.hpp index f8febaaecd..a61160fb15 100644 --- a/include/simgrid/s4u/Actor.hpp +++ b/include/simgrid/s4u/Actor.hpp @@ -338,7 +338,7 @@ template inline void sleep_for(std::chrono::durationgetImpl(), host); + process->migrate(host); return MSG_OK; } @@ -443,7 +443,7 @@ msg_error_t MSG_process_resume(msg_process_t process) */ int MSG_process_is_suspended(msg_process_t process) { - return simcall_process_is_suspended(process->getImpl()); + return process->isSuspended(); } smx_context_t MSG_process_get_smx_ctx(msg_process_t process) { diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index f9b2cf90b0..bfc88d3b1f 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -72,7 +72,7 @@ void Actor::onExit(int_f_pvoid_pvoid_t fun, void* data) void Actor::migrate(Host* new_host) { - simcall_process_set_host(pimpl_, new_host); + simgrid::simix::kernelImmediate([this, new_host]() { pimpl_->new_host = new_host; }); } s4u::Host* Actor::host() @@ -117,7 +117,7 @@ void Actor::resume() int Actor::isSuspended() { - return simcall_process_is_suspended(pimpl_); + return simgrid::simix::kernelImmediate([this]() { return pimpl_->suspended; }); } void Actor::setKillTime(double time) { @@ -299,9 +299,10 @@ void resume() simcall_process_resume(SIMIX_process_self()); } -int isSuspended() +bool isSuspended() { - return simcall_process_is_suspended(SIMIX_process_self()); + smx_actor_t process = SIMIX_process_self(); + return simgrid::simix::kernelImmediate([process] { return process->suspended; }); } void kill() @@ -316,7 +317,8 @@ void onExit(int_f_pvoid_pvoid_t fun, void* data) void migrate(Host* new_host) { - simcall_process_set_host(SIMIX_process_self(), new_host); + smx_actor_t process = SIMIX_process_self(); + simgrid::simix::kernelImmediate([process, new_host] { process->new_host = new_host; }); } } } diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index d0f4ae723c..fab8b8cb09 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -529,11 +529,6 @@ void SIMIX_process_killall(smx_actor_t issuer, int reset_pid) SIMIX_process_empty_trash(); } -void simcall_HANDLER_process_set_host(smx_simcall_t simcall, smx_actor_t process, sg_host_t dest) -{ - process->new_host = dest; -} - void SIMIX_process_change_host(smx_actor_t process, sg_host_t dest) { xbt_assert((process != nullptr), "Invalid parameters"); diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 8a0d0fcf5a..0e3ba0c89b 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -189,20 +189,6 @@ void simcall_process_cleanup(smx_actor_t process) simcall_BODY_process_cleanup(process); } -/** - * \ingroup simix_process_management - * \brief Migrates an agent to another location. - * - * This function changes the value of the host on which \a process is running. - * - * \param process the process to migrate - * \param dest name of the new host - */ -void simcall_process_set_host(smx_actor_t process, sg_host_t dest) -{ - simcall_BODY_process_set_host(process, dest); -} - void simcall_process_join(smx_actor_t process, double timeout) { simcall_BODY_process_join(process, timeout); @@ -283,19 +269,6 @@ double simcall_process_get_kill_time(smx_actor_t process) { return SIMIX_timer_get_date(process->kill_timer); } -/** - * \ingroup simix_process_management - * \brief Returns true if the process is suspended . - * - * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion. - * \param process SIMIX process - * \return 1, if the process is suspended, else 0. - */ -int simcall_process_is_suspended(smx_actor_t process) -{ - return simcall_BODY_process_is_suspended(process); -} - /** * \ingroup simix_process_management * \brief Return the properties diff --git a/src/simix/popping_accessors.h b/src/simix/popping_accessors.h index 8f517f0190..45ed9326c8 100644 --- a/src/simix/popping_accessors.h +++ b/src/simix/popping_accessors.h @@ -80,55 +80,6 @@ static inline void simcall_process_resume__set__process(smx_simcall_t simcall, s simgrid::simix::marshal(simcall->args[0], arg); } -static inline smx_actor_t simcall_process_set_host__get__process(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[0]); -} -static inline smx_actor_t simcall_process_set_host__getraw__process(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[0]); -} -static inline void simcall_process_set_host__set__process(smx_simcall_t simcall, smx_actor_t arg) -{ - simgrid::simix::marshal(simcall->args[0], arg); -} -static inline sg_host_t simcall_process_set_host__get__dest(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[1]); -} -static inline sg_host_t simcall_process_set_host__getraw__dest(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[1]); -} -static inline void simcall_process_set_host__set__dest(smx_simcall_t simcall, sg_host_t arg) -{ - simgrid::simix::marshal(simcall->args[1], arg); -} - -static inline smx_actor_t simcall_process_is_suspended__get__process(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[0]); -} -static inline smx_actor_t simcall_process_is_suspended__getraw__process(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[0]); -} -static inline void simcall_process_is_suspended__set__process(smx_simcall_t simcall, smx_actor_t arg) -{ - simgrid::simix::marshal(simcall->args[0], arg); -} -static inline int simcall_process_is_suspended__get__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->result); -} -static inline int simcall_process_is_suspended__getraw__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->result); -} -static inline void simcall_process_is_suspended__set__result(smx_simcall_t simcall, int result){ - simgrid::simix::marshal(simcall->result, result); -} - static inline smx_actor_t simcall_process_join__get__process(smx_simcall_t simcall) { return simgrid::simix::unmarshal(simcall->args[0]); @@ -1817,7 +1768,6 @@ static inline void simcall_run_blocking__set__code(smx_simcall_t simcall, std::f XBT_PRIVATE void simcall_HANDLER_process_kill(smx_simcall_t simcall, smx_actor_t process); XBT_PRIVATE void simcall_HANDLER_process_killall(smx_simcall_t simcall, int reset_pid); XBT_PRIVATE void simcall_HANDLER_process_suspend(smx_simcall_t simcall, smx_actor_t process); -XBT_PRIVATE void simcall_HANDLER_process_set_host(smx_simcall_t simcall, smx_actor_t process, sg_host_t dest); XBT_PRIVATE void simcall_HANDLER_process_join(smx_simcall_t simcall, smx_actor_t process, double timeout); XBT_PRIVATE void simcall_HANDLER_process_sleep(smx_simcall_t simcall, double duration); XBT_PRIVATE boost::intrusive_ptr diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index afb58a35a2..a156c36fe2 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -66,18 +66,6 @@ inline static void simcall_BODY_process_resume(smx_actor_t process) { return simcall(SIMCALL_PROCESS_RESUME, process); } -inline static void simcall_BODY_process_set_host(smx_actor_t process, sg_host_t dest) { - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) simcall_HANDLER_process_set_host(&SIMIX_process_self()->simcall, process, dest); - return simcall(SIMCALL_PROCESS_SET_HOST, process, dest); - } - -inline static int simcall_BODY_process_is_suspended(smx_actor_t process) { - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) SIMIX_process_is_suspended(process); - return simcall(SIMCALL_PROCESS_IS_SUSPENDED, process); - } - inline static int simcall_BODY_process_join(smx_actor_t process, double timeout) { /* Go to that function to follow the code flow through the simcall barrier */ if (0) simcall_HANDLER_process_join(&SIMIX_process_self()->simcall, process, timeout); diff --git a/src/simix/popping_enum.h b/src/simix/popping_enum.h index 21c5fd3ab3..3ea2507c9a 100644 --- a/src/simix/popping_enum.h +++ b/src/simix/popping_enum.h @@ -24,8 +24,6 @@ typedef enum { SIMCALL_PROCESS_CLEANUP, SIMCALL_PROCESS_SUSPEND, SIMCALL_PROCESS_RESUME, - SIMCALL_PROCESS_SET_HOST, - SIMCALL_PROCESS_IS_SUSPENDED, SIMCALL_PROCESS_JOIN, SIMCALL_PROCESS_SLEEP, SIMCALL_EXECUTION_START, diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index 262e7e0cea..3135e6fe80 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -30,8 +30,6 @@ const char* simcall_names[] = { "SIMCALL_PROCESS_CLEANUP", "SIMCALL_PROCESS_SUSPEND", "SIMCALL_PROCESS_RESUME", - "SIMCALL_PROCESS_SET_HOST", - "SIMCALL_PROCESS_IS_SUSPENDED", "SIMCALL_PROCESS_JOIN", "SIMCALL_PROCESS_SLEEP", "SIMCALL_EXECUTION_START", @@ -112,16 +110,6 @@ case SIMCALL_PROCESS_RESUME: SIMIX_simcall_answer(simcall); break; -case SIMCALL_PROCESS_SET_HOST: - simcall_HANDLER_process_set_host(simcall, simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1])); - SIMIX_simcall_answer(simcall); - break; - -case SIMCALL_PROCESS_IS_SUSPENDED: - simgrid::simix::marshal(simcall->result, SIMIX_process_is_suspended(simgrid::simix::unmarshal(simcall->args[0]))); - SIMIX_simcall_answer(simcall); - break; - case SIMCALL_PROCESS_JOIN: simcall_HANDLER_process_join(simcall, simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1])); break; diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index e3cce1a6d7..22c455e503 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -10,10 +10,10 @@ # int foo(int x, int y) [[nohandler]]; # int foo(int x, int y) [[block, nohandler]]; # -# The `block` attribut is used for calls which do not return in the same +# The `block` attribute is used for calls which do not return in the same # scheduling round. The answer requires some interaction with SURF, -# even if this can still occure at the same timestamp under some -# circonstances (eg if the surf_action cannot start because of resources +# even if this can still occur at the same timestamp under some +# circumstances (eg if the surf_action cannot start because of resources # that are down) examples: things that last some time (communicate, execute, # mutex_lock). # @@ -24,25 +24,22 @@ # by the kernel. # The only remaining use of that mechanism is to add the caller # identity as a parameter of internal call, but that could be -# automatized too (eg by having a special parameter type called "self") +# automated too (eg by having a special parameter type called "self") # Please note that in addition to completing this file with your new simcall, # you should complete the libsmx.c file by adding the corresponding function -# (aka. stub). Anyway, if you omit to do it, the invocation of ./simcalls.py will notify you ;) +# (a.k.a. stub). Anyway, if you omit to do it, the invocation of ./simcalls.py will notify you ;) # If you want to remove an handler, it is important to remove although # the corresponding code (simcall_HANDLER_name_of_simcall(xxx) (note that comment the code # is not sufficient, the python script does not check whether the code is commented or not). # Last but not the least, you should declare the new simix call in -# ./include/simgrid/simix.h (otherwise you will get a warning at the -# compilation time) +# ./include/simgrid/simix.h (otherwise you will get a warning at compile time) void process_kill(smx_actor_t process); void process_killall(int reset_pid); void process_cleanup(smx_actor_t process) [[nohandler]]; void process_suspend(smx_actor_t process) [[block]]; void process_resume(smx_actor_t process) [[nohandler]]; -void process_set_host(smx_actor_t process, sg_host_t dest); -int process_is_suspended(smx_actor_t process) [[nohandler]]; int process_join(smx_actor_t process, double timeout) [[block]]; int process_sleep(double duration) [[block]]; -- 2.20.1