X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9a94db9ebea7a49f58308560099411d4ab59b183..cd5185ae774cc99650b6cae2dca17b6062accea3:/examples/c/energy-exec/energy-exec.c diff --git a/examples/c/energy-exec/energy-exec.c b/examples/c/energy-exec/energy-exec.c index e2232187eb..7820d77bc7 100644 --- a/examples/c/energy-exec/energy-exec.c +++ b/examples/c/energy-exec/energy-exec.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2007-2020. The SimGrid Team. +/* Copyright (c) 2007-2023. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -14,19 +14,19 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(energy_exec, "Messages specific for this example"); -static void dvfs(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[]) +static void dvfs(int argc, char* argv[]) { sg_host_t host = sg_host_by_name("MyHost1"); XBT_INFO("Energetic profile: %s", sg_host_get_property_value(host, "wattage_per_state")); - XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J", sg_host_speed(host), + XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J", sg_host_get_speed(host), sg_host_get_consumed_energy(host)); double start = simgrid_get_clock(); XBT_INFO("Sleep for 10 seconds"); sg_actor_sleep_for(10); XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E; Energy dissipated=%.2f J", - simgrid_get_clock() - start, sg_host_speed(host), sg_host_get_consumed_energy(host)); + simgrid_get_clock() - start, sg_host_get_speed(host), sg_host_get_consumed_energy(host)); // Run a task start = simgrid_get_clock(); @@ -34,27 +34,27 @@ static void dvfs(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[]) sg_actor_execute(100E6); XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Current consumption: from %.0fW to %.0fW" " depending on load; Energy dissipated=%.0f J", - simgrid_get_clock() - start, sg_host_speed(host), sg_host_get_wattmin_at(host, sg_host_get_pstate(host)), + simgrid_get_clock() - start, sg_host_get_speed(host), sg_host_get_wattmin_at(host, sg_host_get_pstate(host)), sg_host_get_wattmax_at(host, sg_host_get_pstate(host)), sg_host_get_consumed_energy(host)); // ========= Change power peak ========= int pstate = 2; sg_host_set_pstate(host, pstate); XBT_INFO("========= Requesting pstate %d (speed should be of %.0E flop/s and is of %.0E flop/s)", pstate, - sg_host_get_pstate_speed(host, pstate), sg_host_speed(host)); + sg_host_get_pstate_speed(host, pstate), sg_host_get_speed(host)); // Run a second task start = simgrid_get_clock(); XBT_INFO("Run a task of %.0E flops", 100E6); sg_actor_execute(100E6); XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J", - simgrid_get_clock() - start, sg_host_speed(host), sg_host_get_consumed_energy(host)); + simgrid_get_clock() - start, sg_host_get_speed(host), sg_host_get_consumed_energy(host)); start = simgrid_get_clock(); XBT_INFO("Sleep for 4 seconds"); sg_actor_sleep_for(4); XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J", - simgrid_get_clock() - start, sg_host_speed(host), sg_host_get_consumed_energy(host)); + simgrid_get_clock() - start, sg_host_get_speed(host), sg_host_get_consumed_energy(host)); // =========== Turn the other host off ========== XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 dissipated %.0f J so far.", @@ -63,7 +63,7 @@ static void dvfs(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[]) start = simgrid_get_clock(); sg_actor_sleep_for(10); XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J", - simgrid_get_clock() - start, sg_host_speed(host), sg_host_get_consumed_energy(host)); + simgrid_get_clock() - start, sg_host_get_speed(host), sg_host_get_consumed_energy(host)); } int main(int argc, char* argv[]) @@ -71,11 +71,10 @@ int main(int argc, char* argv[]) simgrid_init(&argc, argv); sg_cfg_set_string("plugin", "host_energy"); - xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]); + xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s platform.xml\n", argv[0], argv[0]); simgrid_load_platform(argv[1]); - sg_actor_t actor = sg_actor_init("dvfs_test", sg_host_by_name("MyHost1")); - sg_actor_start(actor, dvfs, 0, NULL); + sg_actor_create("dvfs_test", sg_host_by_name("MyHost1"), dvfs, 0, NULL); simgrid_run();