4 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_bench, smpi,
5 "Logging specific to SMPI (benchmarking)");
7 void smpi_execute(double duration)
13 e_surf_action_state_t state;
16 if(duration > 0.001) {
17 host = SIMIX_host_self();
18 mutex = SIMIX_mutex_init();
19 cond = SIMIX_cond_init();
20 DEBUG1("Sleep for %f to handle real computation time", duration);
21 duration *= xbt_cfg_get_double(_surf_cfg_set, "reference_speed");
22 action = SIMIX_action_sleep(host, duration);
23 SIMIX_mutex_lock(mutex);
24 SIMIX_register_action_to_condition(action, cond);
25 for (state = SIMIX_action_get_state(action);
26 state == SURF_ACTION_READY ||
27 state == SURF_ACTION_RUNNING; state = SIMIX_action_get_state(action)) {
28 SIMIX_cond_wait(cond, mutex);
30 SIMIX_unregister_action_to_condition(action, cond);
31 SIMIX_mutex_unlock(mutex);
32 SIMIX_action_destroy(action);
33 SIMIX_cond_destroy(cond);
34 SIMIX_mutex_destroy(mutex);
38 void smpi_bench_begin()
40 xbt_os_timer_start(smpi_process_timer());
45 xbt_os_timer_t timer = smpi_process_timer();
47 xbt_os_timer_stop(timer);
48 smpi_execute(xbt_os_timer_elapsed(timer));
53 void smpi_do_once_1(const char *file, int line)
55 smpi_do_once_duration_node_t curr, prev;
58 SIMIX_mutex_lock(smpi_global->do_once_mutex);
60 for(curr = smpi_global->do_once_duration_nodes;
61 NULL != curr && (strcmp(curr->file, file) || curr->line != line);
66 curr = xbt_new(s_smpi_do_once_duration_node_t, 1);
67 curr->file = xbt_strdup(file);
72 smpi_global->do_once_duration_nodes = curr;
77 smpi_global->do_once_duration = &curr->duration;
82 double duration = *(smpi_global->do_once_duration);
88 SIMIX_mutex_unlock(smpi_global->do_once_mutex);
89 smpi_execute(duration);
96 *(smpi_global->do_once_duration) = smpi_stop_timer();