From: Frederic Suter Date: Thu, 20 Jul 2017 14:12:56 +0000 (+0200) Subject: kill one simcall, simplify another X-Git-Tag: v3_17~342 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/8639295f6bedeb3c9e1a60a1056925c4fe892fa4 kill one simcall, simplify another --- diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 81cf2385b9..d0fa5c4a6b 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -191,7 +191,7 @@ XBT_PUBLIC(smx_activity_t) simcall_execution_start(const char *name, double priority, double bound); XBT_PUBLIC(smx_activity_t) simcall_execution_parallel_start(const char* name, int host_nb, sg_host_t* host_list, double* flops_amount, - double* bytes_amount, double amount, double rate, double timeout); + double* bytes_amount, double rate, double timeout); XBT_PUBLIC(void) simcall_execution_cancel(smx_activity_t execution); XBT_PUBLIC(void) simcall_execution_set_priority(smx_activity_t execution, double priority); XBT_PUBLIC(void) simcall_execution_set_bound(smx_activity_t execution, double bound); @@ -269,7 +269,6 @@ XBT_PUBLIC(smx_mutex_t) SIMIX_mutex_ref(smx_mutex_t mutex); XBT_PUBLIC(void) SIMIX_mutex_unref(smx_mutex_t mutex); XBT_PUBLIC(void) simcall_mutex_lock(smx_mutex_t mutex); XBT_PUBLIC(int) simcall_mutex_trylock(smx_mutex_t mutex); -XBT_PUBLIC(void) simcall_mutex_unlock(smx_mutex_t mutex); XBT_PUBLIC(smx_cond_t) simcall_cond_init(); XBT_PUBLIC(void) SIMIX_cond_unref(smx_cond_t cond); diff --git a/src/msg/msg_gos.cpp b/src/msg/msg_gos.cpp index 53ea92dd47..feb95778ff 100644 --- a/src/msg/msg_gos.cpp +++ b/src/msg/msg_gos.cpp @@ -70,7 +70,7 @@ msg_error_t MSG_parallel_task_execute_with_timeout(msg_task_t task, double timeo simdata->compute = boost::static_pointer_cast(simcall_execution_parallel_start( task->name, simdata->host_nb, simdata->host_list, simdata->flops_parallel_amount, - simdata->bytes_parallel_amount, 1.0, -1.0, timeout)); + simdata->bytes_parallel_amount, -1.0, timeout)); XBT_DEBUG("Parallel execution action created: %p", simdata->compute.get()); } else { simdata->compute = boost::static_pointer_cast( diff --git a/src/s4u/s4u_mutex.cpp b/src/s4u/s4u_mutex.cpp index 5e63f24149..9e0e5d5844 100644 --- a/src/s4u/s4u_mutex.cpp +++ b/src/s4u/s4u_mutex.cpp @@ -24,7 +24,8 @@ void Mutex::lock() */ void Mutex::unlock() { - simcall_mutex_unlock(mutex_); + smx_actor_t self = SIMIX_process_self(); + simgrid::simix::kernelImmediate([this, self] { return mutex_->unlock(self); }); } /** @brief Acquire the mutex if it's free, and return false (without blocking) if not */ diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 1d1b2a682b..993d28da4a 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -84,8 +84,7 @@ smx_activity_t simcall_execution_start(const char *name, * \return A new SIMIX execution synchronization */ smx_activity_t simcall_execution_parallel_start(const char* name, int host_nb, sg_host_t* host_list, - double* flops_amount, double* bytes_amount, double amount, double rate, - double timeout) + double* flops_amount, double* bytes_amount, double rate, double timeout) { /* checking for infinite values */ for (int i = 0 ; i < host_nb ; ++i) { @@ -98,11 +97,9 @@ smx_activity_t simcall_execution_parallel_start(const char* name, int host_nb, s } } - xbt_assert(std::isfinite(amount), "amount is not finite!"); xbt_assert(std::isfinite(rate), "rate is not finite!"); - return simcall_BODY_execution_parallel_start(name, host_nb, host_list, flops_amount, bytes_amount, amount, rate, - timeout); + return simcall_BODY_execution_parallel_start(name, host_nb, host_list, flops_amount, bytes_amount, rate, timeout); } /** @@ -483,15 +480,6 @@ int simcall_mutex_trylock(smx_mutex_t mutex) return simcall_BODY_mutex_trylock(mutex); } -/** - * \ingroup simix_synchro_management - * - */ -void simcall_mutex_unlock(smx_mutex_t mutex) -{ - simcall_BODY_mutex_unlock(mutex); -} - /** * \ingroup simix_synchro_management * diff --git a/src/simix/popping_accessors.h b/src/simix/popping_accessors.h index 2cf9ba506d..28975af8dd 100644 --- a/src/simix/popping_accessors.h +++ b/src/simix/popping_accessors.h @@ -251,41 +251,29 @@ static inline void simcall_execution_parallel_start__set__bytes_amount(smx_simca { simgrid::simix::marshal(simcall->args[4], arg); } -static inline double simcall_execution_parallel_start__get__amount(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[5]); -} -static inline double simcall_execution_parallel_start__getraw__amount(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[5]); -} -static inline void simcall_execution_parallel_start__set__amount(smx_simcall_t simcall, double arg) -{ - simgrid::simix::marshal(simcall->args[5], arg); -} static inline double simcall_execution_parallel_start__get__rate(smx_simcall_t simcall) { - return simgrid::simix::unmarshal(simcall->args[6]); + return simgrid::simix::unmarshal(simcall->args[5]); } static inline double simcall_execution_parallel_start__getraw__rate(smx_simcall_t simcall) { - return simgrid::simix::unmarshal_raw(simcall->args[6]); + return simgrid::simix::unmarshal_raw(simcall->args[5]); } static inline void simcall_execution_parallel_start__set__rate(smx_simcall_t simcall, double arg) { - simgrid::simix::marshal(simcall->args[6], arg); + simgrid::simix::marshal(simcall->args[5], arg); } static inline double simcall_execution_parallel_start__get__timeout(smx_simcall_t simcall) { - return simgrid::simix::unmarshal(simcall->args[7]); + return simgrid::simix::unmarshal(simcall->args[6]); } static inline double simcall_execution_parallel_start__getraw__timeout(smx_simcall_t simcall) { - return simgrid::simix::unmarshal_raw(simcall->args[7]); + return simgrid::simix::unmarshal_raw(simcall->args[6]); } static inline void simcall_execution_parallel_start__set__timeout(smx_simcall_t simcall, double arg) { - simgrid::simix::marshal(simcall->args[7], arg); + simgrid::simix::marshal(simcall->args[6], arg); } static inline boost::intrusive_ptr simcall_execution_parallel_start__get__result(smx_simcall_t simcall) @@ -1195,19 +1183,6 @@ static inline void simcall_mutex_trylock__set__result(smx_simcall_t simcall, int simgrid::simix::marshal(simcall->result, result); } -static inline smx_mutex_t simcall_mutex_unlock__get__mutex(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args[0]); -} -static inline smx_mutex_t simcall_mutex_unlock__getraw__mutex(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->args[0]); -} -static inline void simcall_mutex_unlock__set__mutex(smx_simcall_t simcall, smx_mutex_t arg) -{ - simgrid::simix::marshal(simcall->args[0], arg); -} - static inline smx_cond_t simcall_cond_init__get__result(smx_simcall_t simcall) { return simgrid::simix::unmarshal(simcall->result); @@ -1632,7 +1607,6 @@ XBT_PRIVATE void simcall_HANDLER_comm_testany(smx_simcall_t simcall, XBT_PRIVATE smx_mutex_t simcall_HANDLER_mutex_init(smx_simcall_t simcall); XBT_PRIVATE void simcall_HANDLER_mutex_lock(smx_simcall_t simcall, smx_mutex_t mutex); XBT_PRIVATE int simcall_HANDLER_mutex_trylock(smx_simcall_t simcall, smx_mutex_t mutex); -XBT_PRIVATE void simcall_HANDLER_mutex_unlock(smx_simcall_t simcall, smx_mutex_t mutex); XBT_PRIVATE void simcall_HANDLER_cond_wait(smx_simcall_t simcall, smx_cond_t cond, smx_mutex_t mutex); XBT_PRIVATE void simcall_HANDLER_cond_wait_timeout(smx_simcall_t simcall, smx_cond_t cond, smx_mutex_t mutex, double timeout); XBT_PRIVATE void simcall_HANDLER_sem_release(smx_simcall_t simcall, smx_sem_t sem); diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index 8d687e5b3e..88b4533e06 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -83,13 +83,14 @@ inline static int simcall_BODY_process_sleep(double duration) { inline static boost::intrusive_ptr simcall_BODY_execution_parallel_start(const char* name, int host_nb, sg_host_t* host_list, double* flops_amount, - double* bytes_amount, double amount, double rate, double timeout) + double* bytes_amount, double rate, double timeout) { /* Go to that function to follow the code flow through the simcall barrier */ - if (0) SIMIX_execution_parallel_start(name, host_nb, host_list, flops_amount, bytes_amount, amount, rate, timeout); + if (0) + SIMIX_execution_parallel_start(name, host_nb, host_list, flops_amount, bytes_amount, rate, timeout); return simcall, const char*, int, sg_host_t*, double*, - double*, double, double, double>(SIMCALL_EXECUTION_PARALLEL_START, name, host_nb, host_list, - flops_amount, bytes_amount, amount, rate, timeout); + double*, double, double>(SIMCALL_EXECUTION_PARALLEL_START, name, host_nb, host_list, flops_amount, + bytes_amount, rate, timeout); } inline static void @@ -236,12 +237,6 @@ inline static int simcall_BODY_mutex_trylock(smx_mutex_t mutex) { return simcall(SIMCALL_MUTEX_TRYLOCK, mutex); } -inline static void simcall_BODY_mutex_unlock(smx_mutex_t mutex) { - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) simcall_HANDLER_mutex_unlock(&SIMIX_process_self()->simcall, mutex); - return simcall(SIMCALL_MUTEX_UNLOCK, mutex); - } - inline static smx_cond_t simcall_BODY_cond_init() { /* Go to that function to follow the code flow through the simcall barrier */ if (0) SIMIX_cond_init(); diff --git a/src/simix/popping_enum.h b/src/simix/popping_enum.h index 9b88602630..0499e1c59d 100644 --- a/src/simix/popping_enum.h +++ b/src/simix/popping_enum.h @@ -45,7 +45,6 @@ typedef enum { SIMCALL_MUTEX_INIT, SIMCALL_MUTEX_LOCK, SIMCALL_MUTEX_TRYLOCK, - SIMCALL_MUTEX_UNLOCK, SIMCALL_COND_INIT, SIMCALL_COND_SIGNAL, SIMCALL_COND_WAIT, diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index d5e4940672..69010c2676 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -51,7 +51,6 @@ const char* simcall_names[] = { "SIMCALL_MUTEX_INIT", "SIMCALL_MUTEX_LOCK", "SIMCALL_MUTEX_TRYLOCK", - "SIMCALL_MUTEX_UNLOCK", "SIMCALL_COND_INIT", "SIMCALL_COND_SIGNAL", "SIMCALL_COND_WAIT", @@ -126,7 +125,7 @@ case SIMCALL_EXECUTION_PARALLEL_START: simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1]), simgrid::simix::unmarshal(simcall->args[2]), simgrid::simix::unmarshal(simcall->args[3]), simgrid::simix::unmarshal(simcall->args[4]), simgrid::simix::unmarshal(simcall->args[5]), - simgrid::simix::unmarshal(simcall->args[6]), simgrid::simix::unmarshal(simcall->args[7]))); + simgrid::simix::unmarshal(simcall->args[6]))); SIMIX_simcall_answer(simcall); break; @@ -249,11 +248,6 @@ case SIMCALL_MUTEX_TRYLOCK: SIMIX_simcall_answer(simcall); break; -case SIMCALL_MUTEX_UNLOCK: - simcall_HANDLER_mutex_unlock(simcall, simgrid::simix::unmarshal(simcall->args[0])); - SIMIX_simcall_answer(simcall); - break; - case SIMCALL_COND_INIT: simgrid::simix::marshal(simcall->result, SIMIX_cond_init()); SIMIX_simcall_answer(simcall); diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index 25fc2e37f9..1dccd291a9 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -43,7 +43,7 @@ int process_join(smx_actor_t process, double timeout) [[block]]; 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 amount, double rate, double timeout) [[nohandler]]; +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]]; @@ -65,7 +65,6 @@ int comm_testany(boost::intrusive_ptrname.c_str()); - free(msg); - msg = tmp; + msg = msg + "\n\t" + process->name.c_str(); } SIMIX_display_process_status(); - THROWF(arg_error, 0, "%s", msg); + THROWF(arg_error, 0, "%s", msg.c_str()); } for (auto arg : auto_restart_processes) delete arg; @@ -186,7 +183,7 @@ SIMIX_execution_start(smx_actor_t issuer, const char* name, double flops_amount, boost::intrusive_ptr SIMIX_execution_parallel_start(const char* name, int host_nb, sg_host_t* host_list, double* flops_amount, - double* bytes_amount, double amount, double rate, double timeout) + double* bytes_amount, double rate, double timeout) { /* alloc structures and initialize */ diff --git a/src/simix/smx_host_private.h b/src/simix/smx_host_private.h index a642409d10..ffdcd20074 100644 --- a/src/simix/smx_host_private.h +++ b/src/simix/smx_host_private.h @@ -62,7 +62,7 @@ XBT_PRIVATE boost::intrusive_ptr SIMIX_execution_start(smx_actor_t issuer, const char* name, double flops_amount, double priority, double bound); XBT_PRIVATE boost::intrusive_ptr SIMIX_execution_parallel_start(const char* name, int host_nb, sg_host_t* host_list, double* flops_amount, - double* bytes_amount, double amount, double rate, double timeout); + double* bytes_amount, double rate, double timeout); #endif diff --git a/src/simix/smx_synchro.cpp b/src/simix/smx_synchro.cpp index 6f5395883f..93f437b012 100644 --- a/src/simix/smx_synchro.cpp +++ b/src/simix/smx_synchro.cpp @@ -221,11 +221,6 @@ int simcall_HANDLER_mutex_trylock(smx_simcall_t simcall, smx_mutex_t mutex) return mutex->try_lock(simcall->issuer); } -void simcall_HANDLER_mutex_unlock(smx_simcall_t simcall, smx_mutex_t mutex) -{ - mutex->unlock(simcall->issuer); -} - /********************************* Condition **********************************/ /** diff --git a/src/xbt/xbt_os_synchro.cpp b/src/xbt/xbt_os_synchro.cpp index 748faa20c7..d27ae6414a 100644 --- a/src/xbt/xbt_os_synchro.cpp +++ b/src/xbt/xbt_os_synchro.cpp @@ -10,6 +10,7 @@ #include "xbt/synchro.h" #include "simgrid/simix.h" /* used implementation */ +#include "src/simix/smx_synchro_private.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_sync, xbt, "Synchronization mechanism"); @@ -31,7 +32,7 @@ int xbt_mutex_try_acquire(xbt_mutex_t mutex) void xbt_mutex_release(xbt_mutex_t mutex) { - simcall_mutex_unlock((smx_mutex_t)mutex); + ((smx_mutex_t)mutex)->unlock(SIMIX_process_self()); } void xbt_mutex_destroy(xbt_mutex_t mutex)