X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d13c76fb79f0ea6de163197084f9422f340b7262..773e09f91e02cdd7e30e221f2bd6f39e97896b16:/src/smpi/smpi_bench.c diff --git a/src/smpi/smpi_bench.c b/src/smpi/smpi_bench.c index 8f43a5828d..b64c2f7a3a 100644 --- a/src/smpi/smpi_bench.c +++ b/src/smpi/smpi_bench.c @@ -1,58 +1,49 @@ -#include #include "private.h" -// FIXME: could cause trouble with multithreaded procs on same host... -// FIXME: add benchmarking flag? +void smpi_execute(double duration) { + smx_host_t host = SIMIX_host_self(); + smx_action_t action; + + SIMIX_mutex_lock(smpi_global->execute_mutex); + + action = SIMIX_action_execute(host, "computation", duration * SMPI_DEFAULT_SPEED); + + SIMIX_register_action_to_condition(action, smpi_global->execute_cond); + SIMIX_cond_wait(smpi_global->execute_cond, smpi_global->execute_mutex); + SIMIX_unregister_action_to_condition(action, smpi_global->execute_cond); + SIMIX_action_destroy(action); + + SIMIX_mutex_unlock(smpi_global->execute_mutex); + + return; +} void smpi_bench_begin() { SIMIX_mutex_lock(smpi_global->timer_mutex); - xbt_os_timer_start(smpi_global->timer); - return; } double smpi_bench_end() { double duration; - smx_host_t host; - smx_action_t action; xbt_os_timer_stop(smpi_global->timer); duration = xbt_os_timer_elapsed(smpi_global->timer); - host = SIMIX_host_self(); - action = SIMIX_action_execute(host, "computation", duration * SMPI_DEFAULT_SPEED); - - SIMIX_register_action_to_condition(action, smpi_global->timer_cond); - SIMIX_cond_wait(smpi_global->timer_cond, smpi_global->timer_mutex); - SIMIX_unregister_action_to_condition(action, smpi_global->timer_cond); - SIMIX_action_destroy(action); - SIMIX_mutex_unlock(smpi_global->timer_mutex); + smpi_execute(duration); + return duration; } + void smpi_bench_skip() { - smx_host_t host; - smx_action_t action; double duration = smpi_global->times[0]; - - SIMIX_mutex_lock(smpi_global->timer_mutex); - - host = SIMIX_host_self(); - action = SIMIX_action_execute(host, "computation", duration * SMPI_DEFAULT_SPEED); - - SIMIX_register_action_to_condition(action, smpi_global->timer_cond); - SIMIX_cond_wait(smpi_global->timer_cond, smpi_global->timer_mutex); - SIMIX_unregister_action_to_condition(action, smpi_global->timer_cond); - SIMIX_action_destroy(action); - - SIMIX_mutex_unlock(smpi_global->timer_mutex); - + smpi_execute(duration); return; }