3 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_bench, smpi,
4 "Logging specific to SMPI (benchmarking)");
6 static void smpi_execute(double duration) {
11 e_surf_action_state_t state;
13 if(duration >= xbt_cfg_get_double(_surf_cfg_set, "smpi/cpu_threshold")) {
14 host = SIMIX_host_self();
15 mutex = SIMIX_mutex_init();
16 cond = SIMIX_cond_init();
17 DEBUG1("Sleep for %f to handle real computation time", duration);
18 duration *= xbt_cfg_get_double(_surf_cfg_set, "smpi/running_power");
19 action = SIMIX_action_execute(host, "computation", duration);
20 SIMIX_mutex_lock(mutex);
21 SIMIX_register_action_to_condition(action, cond);
22 for(state = SIMIX_action_get_state(action);
23 state == SURF_ACTION_READY ||
24 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_mutex_unlock(mutex);
29 SIMIX_action_destroy(action);
30 SIMIX_cond_destroy(cond);
31 SIMIX_mutex_destroy(mutex);
35 void smpi_bench_begin(int rank, const char* mpi_call) {
36 if(mpi_call && rank >= 0 && xbt_cfg_get_int(_surf_cfg_set, "smpi/log_events")) {
37 INFO3("SMPE: ts=%f rank=%d type=end et=%s", SIMIX_get_clock(), rank, mpi_call);
39 xbt_os_timer_start(smpi_process_timer());
42 void smpi_bench_end(int rank, const char* mpi_call) {
43 xbt_os_timer_t timer = smpi_process_timer();
45 xbt_os_timer_stop(timer);
46 smpi_execute(xbt_os_timer_elapsed(timer));
47 if(mpi_call && rank >= 0 && xbt_cfg_get_int(_surf_cfg_set, "smpi/log_events")) {
48 INFO3("SMPE: ts=%f rank=%d type=begin et=%s", SIMIX_get_clock(), rank, mpi_call);
54 void smpi_do_once_1(const char *file, int line)
56 smpi_do_once_duration_node_t curr, prev;
59 SIMIX_mutex_lock(smpi_global->do_once_mutex);
61 for(curr = smpi_global->do_once_duration_nodes;
62 NULL != curr && (strcmp(curr->file, file) || curr->line != line);
67 curr = xbt_new(s_smpi_do_once_duration_node_t, 1);
68 curr->file = xbt_strdup(file);
73 smpi_global->do_once_duration_nodes = curr;
78 smpi_global->do_once_duration = &curr->duration;
83 double duration = *(smpi_global->do_once_duration);
89 SIMIX_mutex_unlock(smpi_global->do_once_mutex);
90 smpi_execute(duration);
97 *(smpi_global->do_once_duration) = smpi_stop_timer();