4 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_bench, smpi,
5 "Logging specific to SMPI (benchmarking)");
7 void smpi_execute(double duration)
9 smx_host_t host = SIMIX_host_self();
10 smx_mutex_t mutex = smpi_host_mutex();
11 smx_cond_t cond = smpi_host_cond();
13 e_surf_action_state_t state;
15 SIMIX_mutex_lock(mutex);
18 SIMIX_action_execute(host, "execute", duration * SMPI_DEFAULT_SPEED);
20 SIMIX_register_action_to_condition(action, cond);
21 for (state = SIMIX_action_get_state(action);
22 state == SURF_ACTION_READY ||
23 state == SURF_ACTION_RUNNING; state = SIMIX_action_get_state(action)
25 SIMIX_cond_wait(cond, mutex);
27 SIMIX_unregister_action_to_condition(action, cond);
28 SIMIX_action_destroy(action);
30 SIMIX_mutex_unlock(mutex);
35 void smpi_start_timer()
37 SIMIX_mutex_lock(smpi_global->timer_mutex);
38 xbt_os_timer_start(smpi_global->timer);
41 double smpi_stop_timer()
44 xbt_os_timer_stop(smpi_global->timer);
45 duration = xbt_os_timer_elapsed(smpi_global->timer);
46 SIMIX_mutex_unlock(smpi_global->timer_mutex);
50 void smpi_bench_begin()
57 smpi_execute(smpi_stop_timer());
60 void smpi_do_once_1(const char *file, int line)
62 smpi_do_once_duration_node_t curr, prev;
64 SIMIX_mutex_lock(smpi_global->do_once_mutex);
66 for (curr = smpi_global->do_once_duration_nodes;
67 NULL != curr && (strcmp(curr->file, file) || curr->line != line);
72 curr = xbt_new(s_smpi_do_once_duration_node_t, 1);
73 curr->file = xbt_strdup(file);
78 smpi_global->do_once_duration_nodes = curr;
83 smpi_global->do_once_duration = &curr->duration;
88 double duration = *(smpi_global->do_once_duration);
93 SIMIX_mutex_unlock(smpi_global->do_once_mutex);
94 smpi_execute(duration);
101 *(smpi_global->do_once_duration) = smpi_stop_timer();