Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
used host user data to store global index values and remove some clunky
[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         int index = smpi_host_index();
9
10         SIMIX_mutex_lock(smpi_global->timers_mutexes[index]);
11
12         xbt_os_timer_start(smpi_global->timers[index]);
13
14         return;
15 }
16
17 void smpi_bench_end()
18 {
19         int index = smpi_host_index();
20         double duration;
21         smx_host_t host;
22         char computation[] = "computation";
23         smx_action_t action;
24         smx_mutex_t mutex;
25         smx_cond_t cond;
26
27         xbt_os_timer_stop(smpi_global->timers[index]);
28
29         duration = xbt_os_timer_elapsed(smpi_global->timers[index]);
30
31         SIMIX_mutex_unlock(smpi_global->timers_mutexes[index]);
32
33         host   = smpi_global->hosts[index];
34         action = SIMIX_action_execute(host, computation, duration * SMPI_DEFAULT_SPEED);
35         mutex  = SIMIX_mutex_init();
36         cond   = SIMIX_cond_init();
37
38         SIMIX_mutex_lock(mutex);
39         SIMIX_register_action_to_condition(action, cond);
40         SIMIX_cond_wait(cond, mutex);
41         SIMIX_unregister_action_to_condition(action, cond);
42         SIMIX_mutex_unlock(mutex);
43
44         SIMIX_mutex_destroy(mutex);
45         SIMIX_cond_destroy(cond);
46         //SIMIX_action_destroy(action);
47
48         return;
49 }