4 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_bench, smpi,
5 "Logging specific to SMPI (benchmarking)");
7 static void smpi_execute(double duration) {
12 e_surf_action_state_t state;
14 if(duration > 0.001) {
15 host = SIMIX_host_self();
16 mutex = SIMIX_mutex_init();
17 cond = SIMIX_cond_init();
18 DEBUG1("Sleep for %f to handle real computation time", duration);
19 duration *= xbt_cfg_get_double(_surf_cfg_set, "reference_speed");
20 action = SIMIX_action_execute(host, "computation", duration);
21 SIMIX_mutex_lock(mutex);
22 SIMIX_register_action_to_condition(action, cond);
23 for(state = SIMIX_action_get_state(action);
24 state == SURF_ACTION_READY ||
25 state == SURF_ACTION_RUNNING; state = SIMIX_action_get_state(action)) {
26 SIMIX_cond_wait(cond, mutex);
28 SIMIX_unregister_action_to_condition(action, cond);
29 SIMIX_mutex_unlock(mutex);
30 SIMIX_action_destroy(action);
31 SIMIX_cond_destroy(cond);
32 SIMIX_mutex_destroy(mutex);
36 void smpi_bench_begin(const char* mpi_call) {
37 double simulated = smpi_process_simulated_elapsed();
39 if(mpi_call && xbt_cfg_get_int(_surf_cfg_set, "SMPE")) {
40 INFO2("SMPE: %s in %fs", mpi_call, simulated);
42 xbt_os_timer_start(smpi_process_timer());
45 void smpi_bench_end() {
46 xbt_os_timer_t timer = smpi_process_timer();
48 xbt_os_timer_stop(timer);
49 smpi_execute(xbt_os_timer_elapsed(timer));
50 smpi_process_simulated_reset();
55 void smpi_do_once_1(const char *file, int line)
57 smpi_do_once_duration_node_t curr, prev;
60 SIMIX_mutex_lock(smpi_global->do_once_mutex);
62 for(curr = smpi_global->do_once_duration_nodes;
63 NULL != curr && (strcmp(curr->file, file) || curr->line != line);
68 curr = xbt_new(s_smpi_do_once_duration_node_t, 1);
69 curr->file = xbt_strdup(file);
74 smpi_global->do_once_duration_nodes = curr;
79 smpi_global->do_once_duration = &curr->duration;
84 double duration = *(smpi_global->do_once_duration);
90 SIMIX_mutex_unlock(smpi_global->do_once_mutex);
91 smpi_execute(duration);
98 *(smpi_global->do_once_duration) = smpi_stop_timer();