Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add debug + incredibly stupid bug fix.
[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
8         SIMIX_mutex_lock(smpi_global->timers_mutexes[rank]);
9
10         xbt_os_timer_start(smpi_global->timers[rank]);
11
12         return;
13 }
14
15 void smpi_bench_end()
16 {
17         int rank = smpi_mpi_comm_rank_self(smpi_mpi_global->mpi_comm_world);
18         double duration;
19         smx_host_t host;
20         char compute[] = "compute";
21         smx_action_t action;
22         smx_mutex_t mutex;
23         smx_cond_t cond;
24
25         xbt_os_timer_stop(smpi_global->timers[rank]);
26
27         duration = xbt_os_timer_elapsed(smpi_global->timers[rank]);
28
29         SIMIX_mutex_unlock(smpi_global->timers_mutexes[rank]);
30
31         host   = smpi_mpi_global->mpi_comm_world->hosts[rank];
32         action = SIMIX_action_execute(host, compute, duration * SMPI_DEFAULT_SPEED);
33         mutex  = SIMIX_mutex_init();
34         cond   = SIMIX_cond_init();
35
36         SIMIX_mutex_lock(mutex);
37         SIMIX_register_action_to_condition(action, cond);
38         SIMIX_cond_wait(cond, mutex);
39         SIMIX_unregister_action_to_condition(action, cond);
40         SIMIX_mutex_unlock(mutex);
41
42         SIMIX_mutex_destroy(mutex);
43         SIMIX_cond_destroy(cond);
44         SIMIX_action_destroy(action);
45
46         // FIXME: check for success/failure?
47
48         return;
49 }