static int monitor() { simgrid::s4u::Host* host1 = simgrid::s4u::Host::by_name("MyHost1"); XBT_INFO("Initial pstate: %d; Energy dissipated so far:%.0E J", host1->get_pstate(), sg_host_get_consumed_energy(host1)); XBT_INFO("Sleep for 10 seconds"); simgrid::s4u::this_actor::sleep_for(10); XBT_INFO("Done sleeping. Current pstate: %d; Energy dissipated so far: %.2f J", host1->get_pstate(), sg_host_get_consumed_energy(host1)); simulate_shutdown(host1); XBT_INFO("Host1 is now OFF. Current pstate: %d; Energy dissipated so far: %.2f J", host1->get_pstate(), sg_host_get_consumed_energy(host1)); XBT_INFO("Sleep for 10 seconds"); simgrid::s4u::this_actor::sleep_for(10); XBT_INFO("Done sleeping. Current pstate: %d; Energy dissipated so far: %.2f J", host1->get_pstate(), sg_host_get_consumed_energy(host1)); simulate_bootup(host1); XBT_INFO("Host1 is now ON again. Current pstate: %d; Energy dissipated so far: %.2f J", host1->get_pstate(), sg_host_get_consumed_energy(host1)); return 0; }
static int onoff(int argc, char *argv[]) { msg_host_t host1 = MSG_host_by_name("MyHost1"); XBT_INFO("Energetic profile: %s", MSG_host_get_property_value(host1,"watt_per_state")); XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J", MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1)); XBT_INFO("Sleep for 10 seconds"); MSG_process_sleep(10); XBT_INFO("Done sleeping. Current peak speed=%.0E; Energy dissipated=%.2f J", MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1)); simulate_shutdown(host1); XBT_INFO("Host1 is now OFF. Current peak speed=%.0E flop/s; Energy dissipated=%.0f J", MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1)); XBT_INFO("Sleep for 10 seconds"); MSG_process_sleep(10); XBT_INFO("Done sleeping. Current peak speed=%.0E; Energy dissipated=%.2f J", MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1)); simulate_bootup(host1); XBT_INFO("Host1 is now ON again. Current peak speed=%.0E flop/s; Energy dissipated=%.0f J", MSG_host_get_current_power_peak(host1), sg_host_get_consumed_energy(host1)); return 0; }
/** * \brief Return the total energy consumed by a host (in Joules) * * \return Returns the consumed energy */ double smpi_get_host_consumed_energy() { return sg_host_get_consumed_energy(SIMIX_host_self()); }