From: Frederic Suter Date: Fri, 18 Aug 2017 08:43:43 +0000 (+0200) Subject: modernize three simcalls X-Git-Tag: v3_17~152^2~28 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f986630d917217a11060a58df5d8bd49b2c99e10 modernize three simcalls --- diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index 610678fe55..229a387ca0 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -545,9 +545,8 @@ void SIMIX_process_throw(smx_actor_t process, xbt_errcat_t cat, int value, const simgrid::kernel::activity::ExecImplPtr exec = boost::dynamic_pointer_cast(process->waiting_synchro); - if (exec != nullptr) { - SIMIX_execution_cancel(process->waiting_synchro); - } + if (exec != nullptr && exec->surf_exec) + exec->surf_exec->cancel(); simgrid::kernel::activity::CommImplPtr comm = boost::dynamic_pointer_cast(process->waiting_synchro); diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index d8a0a0f711..b26dcb7393 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -111,7 +111,14 @@ smx_activity_t simcall_execution_parallel_start(const char* name, int host_nb, s */ void simcall_execution_cancel(smx_activity_t execution) { - simcall_BODY_execution_cancel(execution); + simgrid::simix::kernelImmediate([execution] { + XBT_DEBUG("Cancel synchro %p", execution.get()); + simgrid::kernel::activity::ExecImplPtr exec = + boost::static_pointer_cast(execution); + + if (exec->surf_exec) + exec->surf_exec->cancel(); + }); } /** @@ -126,8 +133,13 @@ void simcall_execution_set_priority(smx_activity_t execution, double priority) { /* checking for infinite values */ xbt_assert(std::isfinite(priority), "priority is not finite!"); + simgrid::simix::kernelImmediate([execution, priority] { - simcall_BODY_execution_set_priority(execution, priority); + simgrid::kernel::activity::ExecImplPtr exec = + boost::static_pointer_cast(execution); + if (exec->surf_exec) + exec->surf_exec->setSharingWeight(priority); + }); } /** @@ -140,7 +152,12 @@ void simcall_execution_set_priority(smx_activity_t execution, double priority) */ void simcall_execution_set_bound(smx_activity_t execution, double bound) { - simcall_BODY_execution_set_bound(execution, bound); + simgrid::simix::kernelImmediate([execution, bound] { + simgrid::kernel::activity::ExecImplPtr exec = + boost::static_pointer_cast(execution); + if (exec->surf_exec) + static_cast(exec->surf_exec)->setBound(bound); + }); } /** diff --git a/src/simix/popping_accessors.h b/src/simix/popping_accessors.h index eb130f4bd7..a101a80017 100644 --- a/src/simix/popping_accessors.h +++ b/src/simix/popping_accessors.h @@ -279,81 +279,6 @@ simcall_execution_parallel_start__set__result(smx_simcall_t simcall, simgrid::simix::marshal>(simcall->result, result); } -static inline boost::intrusive_ptr -simcall_execution_cancel__get__execution(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal>(simcall->args[0]); -} -static inline simgrid::kernel::activity::ActivityImpl* -simcall_execution_cancel__getraw__execution(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[0]); -} -static inline void -simcall_execution_cancel__set__execution(smx_simcall_t simcall, - boost::intrusive_ptr arg) -{ - simgrid::simix::marshal>(simcall->args[0], arg); -} - -static inline boost::intrusive_ptr -simcall_execution_set_priority__get__execution(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal>(simcall->args[0]); -} -static inline simgrid::kernel::activity::ActivityImpl* -simcall_execution_set_priority__getraw__execution(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[0]); -} -static inline void -simcall_execution_set_priority__set__execution(smx_simcall_t simcall, - boost::intrusive_ptr arg) -{ - simgrid::simix::marshal>(simcall->args[0], arg); -} -static inline double simcall_execution_set_priority__get__priority(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[1]); -} -static inline double simcall_execution_set_priority__getraw__priority(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[1]); -} -static inline void simcall_execution_set_priority__set__priority(smx_simcall_t simcall, double arg) -{ - simgrid::simix::marshal(simcall->args[1], arg); -} - -static inline boost::intrusive_ptr -simcall_execution_set_bound__get__execution(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal>(simcall->args[0]); -} -static inline simgrid::kernel::activity::ActivityImpl* -simcall_execution_set_bound__getraw__execution(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[0]); -} -static inline void -simcall_execution_set_bound__set__execution(smx_simcall_t simcall, - boost::intrusive_ptr arg) -{ - simgrid::simix::marshal>(simcall->args[0], arg); -} -static inline double simcall_execution_set_bound__get__bound(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[1]); -} -static inline double simcall_execution_set_bound__getraw__bound(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[1]); -} -static inline void simcall_execution_set_bound__set__bound(smx_simcall_t simcall, double arg) -{ - simgrid::simix::marshal(simcall->args[1], arg); -} - static inline boost::intrusive_ptr simcall_execution_wait__get__execution(smx_simcall_t simcall) { diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index 3a1bd5edbb..4f3e9a7ef1 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -87,35 +87,6 @@ inline static int simcall_BODY_process_sleep(double duration) { bytes_amount, rate, timeout); } - inline static void - simcall_BODY_execution_cancel(boost::intrusive_ptr execution) - { - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) SIMIX_execution_cancel(execution); - return simcall>(SIMCALL_EXECUTION_CANCEL, - execution); - } - - inline static void - simcall_BODY_execution_set_priority(boost::intrusive_ptr execution, - double priority) - { - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) SIMIX_execution_set_priority(execution, priority); - return simcall, double>( - SIMCALL_EXECUTION_SET_PRIORITY, execution, priority); - } - - inline static void - simcall_BODY_execution_set_bound(boost::intrusive_ptr execution, - double bound) - { - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) SIMIX_execution_set_bound(execution, bound); - return simcall, double>( - SIMCALL_EXECUTION_SET_BOUND, execution, bound); - } - inline static int simcall_BODY_execution_wait(boost::intrusive_ptr execution) { /* Go to that function to follow the code flow through the simcall barrier */ diff --git a/src/simix/popping_enum.h b/src/simix/popping_enum.h index a2f3155909..8e44e9752a 100644 --- a/src/simix/popping_enum.h +++ b/src/simix/popping_enum.h @@ -26,9 +26,6 @@ typedef enum { SIMCALL_PROCESS_SLEEP, SIMCALL_EXECUTION_START, SIMCALL_EXECUTION_PARALLEL_START, - SIMCALL_EXECUTION_CANCEL, - SIMCALL_EXECUTION_SET_PRIORITY, - SIMCALL_EXECUTION_SET_BOUND, SIMCALL_EXECUTION_WAIT, SIMCALL_PROCESS_ON_EXIT, SIMCALL_COMM_IPROBE, diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index e52c41f726..7f4fc93b45 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -32,9 +32,6 @@ const char* simcall_names[] = { "SIMCALL_PROCESS_SLEEP", "SIMCALL_EXECUTION_START", "SIMCALL_EXECUTION_PARALLEL_START", - "SIMCALL_EXECUTION_CANCEL", - "SIMCALL_EXECUTION_SET_PRIORITY", - "SIMCALL_EXECUTION_SET_BOUND", "SIMCALL_EXECUTION_WAIT", "SIMCALL_PROCESS_ON_EXIT", "SIMCALL_COMM_IPROBE", @@ -118,26 +115,6 @@ case SIMCALL_EXECUTION_PARALLEL_START: SIMIX_simcall_answer(simcall); break; -case SIMCALL_EXECUTION_CANCEL: - SIMIX_execution_cancel( - simgrid::simix::unmarshal>(simcall->args[0])); - SIMIX_simcall_answer(simcall); - break; - -case SIMCALL_EXECUTION_SET_PRIORITY: - SIMIX_execution_set_priority( - simgrid::simix::unmarshal>(simcall->args[0]), - simgrid::simix::unmarshal(simcall->args[1])); - SIMIX_simcall_answer(simcall); - break; - -case SIMCALL_EXECUTION_SET_BOUND: - SIMIX_execution_set_bound( - simgrid::simix::unmarshal>(simcall->args[0]), - simgrid::simix::unmarshal(simcall->args[1])); - SIMIX_simcall_answer(simcall); - break; - case SIMCALL_EXECUTION_WAIT: simcall_HANDLER_execution_wait( simcall, diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index c13413f840..83970631aa 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -43,9 +43,6 @@ int process_sleep(double duration) [[block]]; boost::intrusive_ptr execution_start(const char* name, double flops_amount, double priority, double bound); boost::intrusive_ptr execution_parallel_start(const char* name, int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount, double rate, double timeout) [[nohandler]]; -void execution_cancel(boost::intrusive_ptr execution) [[nohandler]]; -void execution_set_priority(boost::intrusive_ptr execution, double priority) [[nohandler]]; -void execution_set_bound(boost::intrusive_ptr execution, double bound) [[nohandler]]; int execution_wait(boost::intrusive_ptr execution) [[block]]; void process_on_exit(smx_actor_t process, int_f_pvoid_pvoid_t fun, void* data) [[nohandler]]; diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index ed75d52815..458d4339fc 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -216,32 +216,6 @@ SIMIX_execution_parallel_start(const char* name, int host_nb, sg_host_t* host_li return exec; } -void SIMIX_execution_cancel(smx_activity_t synchro) -{ - XBT_DEBUG("Cancel synchro %p", synchro.get()); - simgrid::kernel::activity::ExecImplPtr exec = - boost::static_pointer_cast(synchro); - - if (exec->surf_exec) - exec->surf_exec->cancel(); -} - -void SIMIX_execution_set_priority(smx_activity_t synchro, double priority) -{ - simgrid::kernel::activity::ExecImplPtr exec = - boost::static_pointer_cast(synchro); - if(exec->surf_exec) - exec->surf_exec->setSharingWeight(priority); -} - -void SIMIX_execution_set_bound(smx_activity_t synchro, double bound) -{ - simgrid::kernel::activity::ExecImplPtr exec = - boost::static_pointer_cast(synchro); - if(exec->surf_exec) - static_cast(exec->surf_exec)->setBound(bound); -} - void simcall_HANDLER_execution_wait(smx_simcall_t simcall, smx_activity_t synchro) { simgrid::kernel::activity::ExecImplPtr exec = diff --git a/src/simix/smx_host_private.h b/src/simix/smx_host_private.h index b7028b9db0..d9a6b57cfe 100644 --- a/src/simix/smx_host_private.h +++ b/src/simix/smx_host_private.h @@ -45,9 +45,6 @@ XBT_PRIVATE void SIMIX_host_add_auto_restart_process(sg_host_t host, const char* std::map* properties, int auto_restart); XBT_PRIVATE void SIMIX_host_autorestart(sg_host_t host); -XBT_PRIVATE void SIMIX_execution_cancel(smx_activity_t synchro); -XBT_PRIVATE void SIMIX_execution_set_priority(smx_activity_t synchro, double priority); -XBT_PRIVATE void SIMIX_execution_set_bound(smx_activity_t synchro, double bound); XBT_PRIVATE void SIMIX_execution_finish(simgrid::kernel::activity::ExecImplPtr exec);