X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d6ce3162b34f0a964b8844368b9d86df4f1cf89b..c086caac4026d0bbd54508d51ce4738157d15238:/src/smpi/smpi_bench.c diff --git a/src/smpi/smpi_bench.c b/src/smpi/smpi_bench.c index b3e5f9c245..374ff9725b 100644 --- a/src/smpi/smpi_bench.c +++ b/src/smpi/smpi_bench.c @@ -1,41 +1,49 @@ #include "private.h" // FIXME: could cause trouble with multithreaded procs on same host... +// FIXME: add benchmarking flag? + void smpi_bench_begin() { - int rank = smpi_mpi_comm_rank_self(smpi_mpi_global->mpi_comm_world); - SIMIX_mutex_lock(smpi_global->timers_mutexes[rank]); - xbt_os_timer_start(smpi_global->timers[rank]); + int index = smpi_host_index(); + + SIMIX_mutex_lock(smpi_global->timers_mutexes[index]); + + xbt_os_timer_start(smpi_global->timers[index]); + return; } void smpi_bench_end() { - int rank = smpi_mpi_comm_rank_self(smpi_mpi_global->mpi_comm_world); + int index = smpi_host_index(); double duration; smx_host_t host; - smx_action_t compute_action; + char computation[] = "computation"; + smx_action_t action; smx_mutex_t mutex; smx_cond_t cond; - xbt_os_timer_stop(smpi_global->timers[rank]); + xbt_os_timer_stop(smpi_global->timers[index]); + + duration = xbt_os_timer_elapsed(smpi_global->timers[index]); - duration = xbt_os_timer_elapsed(smpi_global->timers[rank]); - SIMIX_mutex_unlock(smpi_global->timers_mutexes[rank]); + SIMIX_mutex_unlock(smpi_global->timers_mutexes[index]); - host = smpi_mpi_global->mpi_comm_world->simdata->hosts[rank]; - compute_action = SIMIX_action_execute(host, NULL, duration * SMPI_DEFAULT_SPEED); - mutex = SIMIX_mutex_init(); - cond = SIMIX_cond_init(); + host = smpi_global->hosts[index]; + action = SIMIX_action_execute(host, computation, duration * SMPI_DEFAULT_SPEED); + mutex = SIMIX_mutex_init(); + cond = SIMIX_cond_init(); SIMIX_mutex_lock(mutex); - SIMIX_register_action_to_condition(compute_action, cond); + SIMIX_register_action_to_condition(action, cond); SIMIX_cond_wait(cond, mutex); - SIMIX_unregister_action_to_condition(compute_action, cond); + SIMIX_unregister_action_to_condition(action, cond); SIMIX_mutex_unlock(mutex); SIMIX_mutex_destroy(mutex); SIMIX_cond_destroy(cond); + //SIMIX_action_destroy(action); // FIXME: check for success/failure?