+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_bench, smpi,
+ "Logging specific to SMPI (benchmarking)");
+
+void smpi_execute(double duration)
+{
+ smx_host_t host = SIMIX_host_self();
+ smx_mutex_t mutex = smpi_process_mutex();
+ smx_cond_t cond = smpi_process_cond();
+ smx_action_t action;
+ e_surf_action_state_t state;
+
+ if (duration < 0.001)
+ return;
+ DEBUG1("Sleep for %f to handle real computation time",duration);
+ SIMIX_mutex_lock(mutex);
+
+ action =
+ SIMIX_action_execute(host, "execute",
+ duration * smpi_global->reference_speed);
+
+ SIMIX_register_action_to_condition(action, cond);
+ for (state = SIMIX_action_get_state(action);
+ state == SURF_ACTION_READY ||
+ state == SURF_ACTION_RUNNING; state = SIMIX_action_get_state(action)
+ ) {
+ SIMIX_cond_wait(cond, mutex);
+ }
+ SIMIX_unregister_action_to_condition(action, cond);
+ SIMIX_action_destroy(action);
+
+ SIMIX_mutex_unlock(mutex);
+
+ return;
+}
+
+void smpi_start_timer()
+{
+ xbt_os_timer_start(smpi_global->timer);
+}
+
+double smpi_stop_timer()
+{
+ double duration;
+ xbt_os_timer_stop(smpi_global->timer);
+ duration = xbt_os_timer_elapsed(smpi_global->timer);
+ return duration;
+}