From: Frederic Suter Date: Fri, 21 Jul 2017 12:05:57 +0000 (+0200) Subject: Revert "kill one simcall, simplify another" X-Git-Tag: v3_17~333 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b283430cb109f0ef78eaeba48f8942b512c659d2 Revert "kill one simcall, simplify another" This reverts commit 8639295f6bedeb3c9e1a60a1056925c4fe892fa4. --- diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index d28bf42f39..021f9f5811 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 rate, double timeout); + double* bytes_amount, double 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); @@ -268,6 +268,7 @@ 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 feb95778ff..53ea92dd47 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, timeout)); + simdata->bytes_parallel_amount, 1.0, -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 9e0e5d5844..5e63f24149 100644 --- a/src/s4u/s4u_mutex.cpp +++ b/src/s4u/s4u_mutex.cpp @@ -24,8 +24,7 @@ void Mutex::lock() */ void Mutex::unlock() { - smx_actor_t self = SIMIX_process_self(); - simgrid::simix::kernelImmediate([this, self] { return mutex_->unlock(self); }); + simcall_mutex_unlock(mutex_); } /** @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 db526d4aa4..424d8510f2 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -84,7 +84,8 @@ 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 rate, double timeout) + double* flops_amount, double* bytes_amount, double amount, double rate, + double timeout) { /* checking for infinite values */ for (int i = 0 ; i < host_nb ; ++i) { @@ -97,9 +98,11 @@ 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, rate, timeout); + return simcall_BODY_execution_parallel_start(name, host_nb, host_list, flops_amount, bytes_amount, amount, rate, + timeout); } /** @@ -472,6 +475,15 @@ 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 a7f4b162b9..00ee1499d2 100644 --- a/src/simix/popping_accessors.h +++ b/src/simix/popping_accessors.h @@ -251,30 +251,42 @@ 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__rate(smx_simcall_t simcall) +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__rate(smx_simcall_t simcall) +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__rate(smx_simcall_t simcall, double arg) +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__timeout(smx_simcall_t simcall) +static inline double simcall_execution_parallel_start__get__rate(smx_simcall_t simcall) { return simgrid::simix::unmarshal(simcall->args[6]); } -static inline double simcall_execution_parallel_start__getraw__timeout(smx_simcall_t simcall) +static inline double simcall_execution_parallel_start__getraw__rate(smx_simcall_t simcall) { return simgrid::simix::unmarshal_raw(simcall->args[6]); } -static inline void simcall_execution_parallel_start__set__timeout(smx_simcall_t simcall, double arg) +static inline void simcall_execution_parallel_start__set__rate(smx_simcall_t simcall, double arg) { simgrid::simix::marshal(simcall->args[6], arg); } +static inline double simcall_execution_parallel_start__get__timeout(smx_simcall_t simcall) +{ + return simgrid::simix::unmarshal(simcall->args[7]); +} +static inline double simcall_execution_parallel_start__getraw__timeout(smx_simcall_t simcall) +{ + return simgrid::simix::unmarshal_raw(simcall->args[7]); +} +static inline void simcall_execution_parallel_start__set__timeout(smx_simcall_t simcall, double arg) +{ + simgrid::simix::marshal(simcall->args[7], arg); +} static inline boost::intrusive_ptr simcall_execution_parallel_start__get__result(smx_simcall_t simcall) { @@ -1147,6 +1159,19 @@ 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); @@ -1484,6 +1509,7 @@ XBT_PRIVATE void simcall_HANDLER_comm_testany(smx_simcall_t simcall, size_t count); 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_acquire(smx_simcall_t simcall, smx_sem_t sem); diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index 01267968ef..ba18225497 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -83,14 +83,13 @@ 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 rate, double timeout) + double* bytes_amount, double 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, rate, timeout); + if (0) SIMIX_execution_parallel_start(name, host_nb, host_list, flops_amount, bytes_amount, amount, rate, timeout); return simcall, const char*, int, sg_host_t*, double*, - double*, double, double>(SIMCALL_EXECUTION_PARALLEL_START, name, host_nb, host_list, flops_amount, - bytes_amount, rate, timeout); + double*, double, double, double>(SIMCALL_EXECUTION_PARALLEL_START, name, host_nb, host_list, + flops_amount, bytes_amount, amount, rate, timeout); } inline static void @@ -225,6 +224,12 @@ 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 be3e298963..8c5c93730d 100644 --- a/src/simix/popping_enum.h +++ b/src/simix/popping_enum.h @@ -43,6 +43,7 @@ typedef enum { SIMCALL_COMM_TESTANY, 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 592c22f245..a240ef3ac7 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -49,6 +49,7 @@ const char* simcall_names[] = { "SIMCALL_COMM_TESTANY", "SIMCALL_MUTEX_LOCK", "SIMCALL_MUTEX_TRYLOCK", + "SIMCALL_MUTEX_UNLOCK", "SIMCALL_COND_INIT", "SIMCALL_COND_SIGNAL", "SIMCALL_COND_WAIT", @@ -119,7 +120,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[6]), simgrid::simix::unmarshal(simcall->args[7]))); SIMIX_simcall_answer(simcall); break; @@ -232,6 +233,11 @@ 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 bf67a8e2d5..a2713965b9 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 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 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]]; @@ -63,6 +63,7 @@ int comm_testany(boost::intrusive_ptrname.c_str(); + tmp = bprintf("%s\n\t%s", msg, process->name.c_str()); + free(msg); + msg = tmp; } SIMIX_display_process_status(); - THROWF(arg_error, 0, "%s", msg.c_str()); + THROWF(arg_error, 0, "%s", msg); } for (auto arg : auto_restart_processes) delete arg; @@ -183,7 +186,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 rate, double timeout) + double* bytes_amount, double 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 ffdcd20074..a642409d10 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 rate, double timeout); + double* bytes_amount, double amount, double rate, double timeout); #endif diff --git a/src/simix/smx_synchro.cpp b/src/simix/smx_synchro.cpp index 66375d4ac6..bad673a5e0 100644 --- a/src/simix/smx_synchro.cpp +++ b/src/simix/smx_synchro.cpp @@ -216,6 +216,11 @@ 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 d27ae6414a..748faa20c7 100644 --- a/src/xbt/xbt_os_synchro.cpp +++ b/src/xbt/xbt_os_synchro.cpp @@ -10,7 +10,6 @@ #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"); @@ -32,7 +31,7 @@ int xbt_mutex_try_acquire(xbt_mutex_t mutex) void xbt_mutex_release(xbt_mutex_t mutex) { - ((smx_mutex_t)mutex)->unlock(SIMIX_process_self()); + simcall_mutex_unlock((smx_mutex_t)mutex); } void xbt_mutex_destroy(xbt_mutex_t mutex)