Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
b43a1280f7b3e85bf6eae3f1c061e476a38fb17f
[simgrid.git] / src / smpi / smpi_bench.c
1 #include "private.h"
2
3 // FIXME: could cause trouble with multithreaded procs on same host...
4 // FIXME: add benchmarking flag?
5
6 void smpi_bench_begin()
7 {
8         SIMIX_mutex_lock(smpi_global->timer_mutex);
9         xbt_os_timer_start(smpi_global->timer);
10         return;
11 }
12
13 void smpi_bench_end()
14 {
15         double duration;
16         smx_host_t host;
17         char computation[] = "computation";
18         smx_action_t action;
19
20         xbt_os_timer_stop(smpi_global->timer);
21         duration = xbt_os_timer_elapsed(smpi_global->timer);
22         host     = SIMIX_host_self();
23         action   = SIMIX_action_execute(host, computation, duration * SMPI_DEFAULT_SPEED);
24
25         SIMIX_register_action_to_condition(action, smpi_global->timer_cond);
26         SIMIX_cond_wait(smpi_global->timer_cond, smpi_global->timer_mutex);
27         SIMIX_unregister_action_to_condition(action, smpi_global->timer_cond);
28
29         SIMIX_mutex_unlock(smpi_global->timer_mutex);
30
31         return;
32 }