Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
removed some unnecessary waiting
[simgrid.git] / src / smpi / smpi_bench.c
1 #include "private.h"
2
3 // FIXME: could cause trouble with multithreaded procs on same host...
4 void smpi_bench_begin()
5 {
6         int rank = smpi_mpi_comm_rank_self(smpi_mpi_global->mpi_comm_world);
7         SIMIX_mutex_lock(smpi_global->timers_mutexes[rank]);
8         xbt_os_timer_start(smpi_global->timers[rank]);
9         return;
10 }
11
12 void smpi_bench_end()
13 {
14         int rank = smpi_mpi_comm_rank_self(smpi_mpi_global->mpi_comm_world);
15         double duration;
16         smx_host_t host;
17         smx_action_t compute_action;
18         smx_mutex_t mutex;
19         smx_cond_t cond;
20
21         xbt_os_timer_stop(smpi_global->timers[rank]);
22
23         duration       = xbt_os_timer_elapsed(smpi_global->timers[rank]);
24         SIMIX_mutex_unlock(smpi_global->timers_mutexes[rank]);
25
26         host           = smpi_mpi_global->mpi_comm_world->simdata->hosts[rank];
27         compute_action = SIMIX_action_execute(host, NULL, duration * SMPI_DEFAULT_SPEED);
28         mutex          = SIMIX_mutex_init();
29         cond           = SIMIX_cond_init();
30
31         SIMIX_mutex_lock(mutex);
32         SIMIX_register_action_to_condition(compute_action, cond);
33         SIMIX_cond_wait(cond, mutex);
34         SIMIX_unregister_action_to_condition(compute_action, cond);
35         SIMIX_mutex_unlock(mutex);
36
37         SIMIX_mutex_destroy(mutex);
38         SIMIX_cond_destroy(cond);
39
40         // FIXME: check for success/failure?
41
42         return;
43 }