From 3d42ca4a7357664a08b737ac461f53ee2933d4c2 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 23 Jun 2018 21:58:50 +0200 Subject: [PATCH] snake_case s4u::Host and improve doc --- .../actor-migration/s4u-actor-migration.cpp | 2 +- .../s4u/cloud-capping/s4u-cloud-capping.cpp | 12 +++--- examples/s4u/energy-exec/s4u-energy-exec.cpp | 14 +++---- .../engine-filtering/s4u-engine-filtering.cpp | 5 ++- examples/s4u/exec-dvfs/s4u-exec-dvfs.cpp | 8 ++-- examples/s4u/exec-remote/s4u-exec-remote.cpp | 12 +++--- .../s4u/io-file-system/s4u-io-file-system.cpp | 2 +- .../s4u/io-storage-raw/s4u-io-storage-raw.cpp | 2 +- .../s4u-platform-properties.cpp | 2 +- .../plugin-hostload/s4u-plugin-hostload.cpp | 26 ++++++------ examples/simdag/test/sd_test.cpp | 4 +- include/simgrid/s4u/Host.hpp | 24 ++++++----- src/bindings/java/jmsg_host.cpp | 2 +- src/instr/instr_platform.cpp | 2 +- src/kernel/lmm/maxmin.cpp | 8 ++-- src/plugins/file_system/s4u_FileSystem.cpp | 6 +-- src/plugins/host_energy.cpp | 2 +- src/plugins/host_load.cpp | 8 ++-- src/plugins/vm/VmLiveMigration.cpp | 2 +- src/plugins/vm/s4u_VirtualMachine.cpp | 2 +- src/s4u/s4u_Host.cpp | 40 ++++++++++++------- src/simdag/sd_task.cpp | 2 +- src/smpi/internals/smpi_dvfs.cpp | 4 +- src/smpi/mpi/smpi_request.cpp | 2 +- .../storage_client_server.cpp | 2 +- 25 files changed, 107 insertions(+), 88 deletions(-) diff --git a/examples/s4u/actor-migration/s4u-actor-migration.cpp b/examples/s4u/actor-migration/s4u-actor-migration.cpp index d6fb4c5fda..788bf0f864 100644 --- a/examples/s4u/actor-migration/s4u-actor-migration.cpp +++ b/examples/s4u/actor-migration/s4u-actor-migration.cpp @@ -23,7 +23,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_actor_migration, "Messages specific for this s4 static void worker(simgrid::s4u::Host* first, simgrid::s4u::Host* second) { - double flopAmount = first->getSpeed() * 5 + second->getSpeed() * 5; + double flopAmount = first->get_speed() * 5 + second->get_speed() * 5; XBT_INFO("Let's move to %s to execute %.2f Mflops (5sec on %s and 5sec on %s)", first->get_cname(), flopAmount / 1e6, first->get_cname(), second->get_cname()); diff --git a/examples/s4u/cloud-capping/s4u-cloud-capping.cpp b/examples/s4u/cloud-capping/s4u-cloud-capping.cpp index 42c2984003..fbdef2a05e 100644 --- a/examples/s4u/cloud-capping/s4u-cloud-capping.cpp +++ b/examples/s4u/cloud-capping/s4u-cloud-capping.cpp @@ -63,7 +63,7 @@ static void test_dynamic_change() vm1->start(); simgrid::s4u::Actor::create("worker0", vm0, worker_busy_loop, "Task0", -1); - simgrid::s4u::Actor::create("worker1", vm1, worker_busy_loop, "Task1", pm0->getSpeed()); + simgrid::s4u::Actor::create("worker1", vm1, worker_busy_loop, "Task1", pm0->get_speed()); simgrid::s4u::this_actor::sleep_for(3000); // let the tasks end vm0->destroy(); @@ -72,7 +72,7 @@ static void test_dynamic_change() static void test_one_task(simgrid::s4u::Host* host) { - const double cpu_speed = host->getSpeed(); + const double cpu_speed = host->get_speed(); const double computation_amount = cpu_speed * 10; XBT_INFO("### Test: with/without task set_bound"); @@ -105,8 +105,8 @@ static void test_one_task(simgrid::s4u::Host* host) static void test_two_tasks(simgrid::s4u::Host* hostA, simgrid::s4u::Host* hostB) { - const double cpu_speed = hostA->getSpeed(); - xbt_assert(cpu_speed == hostB->getSpeed()); + const double cpu_speed = hostA->get_speed(); + xbt_assert(cpu_speed == hostB->get_speed()); const double computation_amount = cpu_speed * 10; const char* hostA_name = hostA->get_cname(); const char* hostB_name = hostB->get_cname(); @@ -189,7 +189,7 @@ static void master_main() vm0->destroy(); vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1); - vm0->set_bound(pm0->getSpeed() / 10); + vm0->set_bound(pm0->get_speed() / 10); vm0->start(); XBT_INFO("# 7. Put a single task on the VM capped by 10%%."); @@ -210,7 +210,7 @@ static void master_main() vm0->set_ramsize(1e9); // 1GB vm0->start(); - double cpu_speed = pm0->getSpeed(); + double cpu_speed = pm0->get_speed(); XBT_INFO("# 10. Test migration"); const double computation_amount = cpu_speed * 10; diff --git a/examples/s4u/energy-exec/s4u-energy-exec.cpp b/examples/s4u/energy-exec/s4u-energy-exec.cpp index 1a30be2076..62d0f6c530 100644 --- a/examples/s4u/energy-exec/s4u-energy-exec.cpp +++ b/examples/s4u/energy-exec/s4u-energy-exec.cpp @@ -14,14 +14,14 @@ static void dvfs() simgrid::s4u::Host* host2 = simgrid::s4u::Host::by_name("MyHost2"); XBT_INFO("Energetic profile: %s", host1->get_property("watt_per_state")); - XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J", host1->getSpeed(), + XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J", host1->get_speed(), sg_host_get_consumed_energy(host1)); double start = simgrid::s4u::Engine::get_clock(); XBT_INFO("Sleep for 10 seconds"); simgrid::s4u::this_actor::sleep_for(10); XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E; Energy dissipated=%.2f J", - simgrid::s4u::Engine::get_clock() - start, host1->getSpeed(), sg_host_get_consumed_energy(host1)); + simgrid::s4u::Engine::get_clock() - start, host1->get_speed(), sg_host_get_consumed_energy(host1)); // Execute something start = simgrid::s4u::Engine::get_clock(); @@ -30,7 +30,7 @@ static void dvfs() simgrid::s4u::this_actor::execute(flopAmount); 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::s4u::Engine::get_clock() - start, host1->getSpeed(), + simgrid::s4u::Engine::get_clock() - start, host1->get_speed(), sg_host_get_wattmin_at(host1, host1->get_pstate()), sg_host_get_wattmax_at(host1, host1->get_pstate()), sg_host_get_consumed_energy(host1)); @@ -38,20 +38,20 @@ static void dvfs() int pstate = 2; host1->set_pstate(pstate); XBT_INFO("========= Requesting pstate %d (speed should be of %.0E flop/s and is of %.0E flop/s)", pstate, - host1->getPstateSpeed(pstate), host1->getSpeed()); + host1->get_pstate_speed(pstate), host1->get_speed()); // Run another task start = simgrid::s4u::Engine::get_clock(); XBT_INFO("Run a task of %.0E flops", flopAmount); simgrid::s4u::this_actor::execute(flopAmount); XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J", - simgrid::s4u::Engine::get_clock() - start, host1->getSpeed(), sg_host_get_consumed_energy(host1)); + simgrid::s4u::Engine::get_clock() - start, host1->get_speed(), sg_host_get_consumed_energy(host1)); start = simgrid::s4u::Engine::get_clock(); XBT_INFO("Sleep for 4 seconds"); simgrid::s4u::this_actor::sleep_for(4); XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J", - simgrid::s4u::Engine::get_clock() - start, host1->getSpeed(), sg_host_get_consumed_energy(host1)); + simgrid::s4u::Engine::get_clock() - start, host1->get_speed(), sg_host_get_consumed_energy(host1)); // =========== Turn the other host off ========== XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 dissipated %.0f J so far.", @@ -60,7 +60,7 @@ static void dvfs() start = simgrid::s4u::Engine::get_clock(); simgrid::s4u::this_actor::sleep_for(10); XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J", - simgrid::s4u::Engine::get_clock() - start, host1->getSpeed(), sg_host_get_consumed_energy(host1)); + simgrid::s4u::Engine::get_clock() - start, host1->get_speed(), sg_host_get_consumed_energy(host1)); } int main(int argc, char* argv[]) diff --git a/examples/s4u/engine-filtering/s4u-engine-filtering.cpp b/examples/s4u/engine-filtering/s4u-engine-filtering.cpp index c3e0e7eabd..acc939126c 100644 --- a/examples/s4u/engine-filtering/s4u-engine-filtering.cpp +++ b/examples/s4u/engine-filtering/s4u-engine-filtering.cpp @@ -21,7 +21,7 @@ namespace filter { /* First example of thing that we can use as a filtering criteria: a simple boolean function */ static bool filter_speed_more_than_50Mf(simgrid::s4u::Host* host) { - return host->getSpeed() > 50E6; + return host->get_speed() > 50E6; } /* Second kind of thing that we can use as a filtering criteria: a functor (=function object). @@ -80,7 +80,8 @@ int main(int argc, char* argv[]) list = e.get_filtered_hosts(filter); for (auto& host : list) - XBT_INFO("The following hosts changed their frequency: %s (from %.1ff to %.1ff)", host->get_cname(), host->getPstateSpeed(filter.get_old_speed(host)), host->getSpeed()); + XBT_INFO("The following hosts changed their frequency: %s (from %.1ff to %.1ff)", host->get_cname(), + host->get_pstate_speed(filter.get_old_speed(host)), host->get_speed()); /* You can also just use any regular function (namespaced on need) to filter */ list = e.get_filtered_hosts(filter::filter_speed_more_than_50Mf); diff --git a/examples/s4u/exec-dvfs/s4u-exec-dvfs.cpp b/examples/s4u/exec-dvfs/s4u-exec-dvfs.cpp index 81abcf61a3..32ef5ddeb5 100644 --- a/examples/s4u/exec-dvfs/s4u-exec-dvfs.cpp +++ b/examples/s4u/exec-dvfs/s4u-exec-dvfs.cpp @@ -15,7 +15,7 @@ static int dvfs() int nb = host->get_pstate_count(); XBT_INFO("Count of Processor states=%d", nb); - XBT_INFO("Current power peak=%f", host->getSpeed()); + XBT_INFO("Current power peak=%f", host->get_speed()); // Run a task simgrid::s4u::this_actor::execute(workload); @@ -26,11 +26,11 @@ static int dvfs() // Change power peak int new_pstate = 2; - XBT_INFO("Changing power peak value to %f (at index %d)", host->getPstateSpeed(new_pstate), new_pstate); + XBT_INFO("Changing power peak value to %f (at index %d)", host->get_pstate_speed(new_pstate), new_pstate); host->set_pstate(new_pstate); - XBT_INFO("Current power peak=%f", host->getSpeed()); + XBT_INFO("Current power peak=%f", host->get_speed()); // Run a second task simgrid::s4u::this_actor::execute(workload); @@ -42,7 +42,7 @@ static int dvfs() host = simgrid::s4u::Host::by_name_or_null("MyHost2"); XBT_INFO("Count of Processor states=%d", host->get_pstate_count()); - XBT_INFO("Current power peak=%f", host->getSpeed()); + XBT_INFO("Current power peak=%f", host->get_speed()); return 0; } diff --git a/examples/s4u/exec-remote/s4u-exec-remote.cpp b/examples/s4u/exec-remote/s4u-exec-remote.cpp index 8044e17ac7..a119a8dc6e 100644 --- a/examples/s4u/exec-remote/s4u-exec-remote.cpp +++ b/examples/s4u/exec-remote/s4u-exec-remote.cpp @@ -20,8 +20,8 @@ static void wizard() XBT_INFO("It started. Running 48.492Mf takes exactly one second on Ginette (but not on Fafard)."); simgrid::s4u::this_actor::sleep_for(0.1); - XBT_INFO("Loads in flops/s: Boivin=%.0f; Fafard=%.0f; Ginette=%.0f", - boivin->getLoad(), fafard->getLoad(), ginette->getLoad()); + XBT_INFO("Loads in flops/s: Boivin=%.0f; Fafard=%.0f; Ginette=%.0f", boivin->get_load(), fafard->get_load(), + ginette->get_load()); exec->wait(); @@ -31,14 +31,14 @@ static void wizard() exec->start(); simgrid::s4u::this_actor::sleep_for(0.5); - XBT_INFO("Loads before the move: Boivin=%.0f; Fafard=%.0f; Ginette=%.0f", - boivin->getLoad(), fafard->getLoad(), ginette->getLoad()); + XBT_INFO("Loads before the move: Boivin=%.0f; Fafard=%.0f; Ginette=%.0f", boivin->get_load(), fafard->get_load(), + ginette->get_load()); exec->set_host(boivin); simgrid::s4u::this_actor::sleep_for(0.1); - XBT_INFO("Loads after the move: Boivin=%.0f; Fafard=%.0f; Ginette=%.0f", - boivin->getLoad(), fafard->getLoad(), ginette->getLoad()); + XBT_INFO("Loads after the move: Boivin=%.0f; Fafard=%.0f; Ginette=%.0f", boivin->get_load(), fafard->get_load(), + ginette->get_load()); exec->wait(); XBT_INFO("Done!"); diff --git a/examples/s4u/io-file-system/s4u-io-file-system.cpp b/examples/s4u/io-file-system/s4u-io-file-system.cpp index 2c34333f94..bce3113fdb 100644 --- a/examples/s4u/io-file-system/s4u-io-file-system.cpp +++ b/examples/s4u/io-file-system/s4u-io-file-system.cpp @@ -30,7 +30,7 @@ public: void operator()() { std::unordered_map const& mounts = - simgrid::s4u::Host::current()->getMountedStorages(); + simgrid::s4u::Host::current()->get_mounted_storages(); show_info(mounts); diff --git a/examples/s4u/io-storage-raw/s4u-io-storage-raw.cpp b/examples/s4u/io-storage-raw/s4u-io-storage-raw.cpp index e594a1e083..feaba5e2ed 100644 --- a/examples/s4u/io-storage-raw/s4u-io-storage-raw.cpp +++ b/examples/s4u/io-storage-raw/s4u-io-storage-raw.cpp @@ -16,7 +16,7 @@ static void host() /* - Retrieve all mount points of current host */ std::unordered_map const& storage_list = - simgrid::s4u::Host::current()->getMountedStorages(); + simgrid::s4u::Host::current()->get_mounted_storages(); /* - For each disk mounted on host, display disk name and mount point */ for (auto const& kv : storage_list) diff --git a/examples/s4u/platform-properties/s4u-platform-properties.cpp b/examples/s4u/platform-properties/s4u-platform-properties.cpp index f125e9d4ab..d35bf9f5b1 100644 --- a/examples/s4u/platform-properties/s4u-platform-properties.cpp +++ b/examples/s4u/platform-properties/s4u-platform-properties.cpp @@ -114,7 +114,7 @@ int main(int argc, char* argv[]) XBT_INFO("There are %zu hosts in the environment", totalHosts); std::vector hosts = e.get_all_hosts(); for (unsigned int i = 0; i < hosts.size(); i++) - XBT_INFO("Host '%s' runs at %.0f flops/s", hosts[i]->get_cname(), hosts[i]->getSpeed()); + XBT_INFO("Host '%s' runs at %.0f flops/s", hosts[i]->get_cname(), hosts[i]->get_speed()); e.load_deployment(argv[2]); e.run(); diff --git a/examples/s4u/plugin-hostload/s4u-plugin-hostload.cpp b/examples/s4u/plugin-hostload/s4u-plugin-hostload.cpp index ac8962a5e1..6ac50d8699 100644 --- a/examples/s4u/plugin-hostload/s4u-plugin-hostload.cpp +++ b/examples/s4u/plugin-hostload/s4u-plugin-hostload.cpp @@ -12,37 +12,39 @@ static void execute_load_test() { s4u_Host* host = simgrid::s4u::Host::by_name("MyHost1"); - XBT_INFO("Initial peak speed: %.0E flop/s; number of flops computed so far: %.0E (should be 0) and current average load: %.5f (should be 0)", host->getSpeed(), - sg_host_get_computed_flops(host), sg_host_get_avg_load(host)); + XBT_INFO("Initial peak speed: %.0E flop/s; number of flops computed so far: %.0E (should be 0) and current average " + "load: %.5f (should be 0)", + host->get_speed(), sg_host_get_computed_flops(host), sg_host_get_avg_load(host)); double start = simgrid::s4u::Engine::get_clock(); XBT_INFO("Sleep for 10 seconds"); simgrid::s4u::this_actor::sleep_for(10); - double speed = host->getSpeed(); + double speed = host->get_speed(); XBT_INFO("Done sleeping %.2fs; peak speed: %.0E flop/s; number of flops computed so far: %.0E (nothing should have " "changed)", - simgrid::s4u::Engine::get_clock() - start, host->getSpeed(), sg_host_get_computed_flops(host)); + simgrid::s4u::Engine::get_clock() - start, host->get_speed(), sg_host_get_computed_flops(host)); // Run a task start = simgrid::s4u::Engine::get_clock(); - XBT_INFO("Run a task of %.0E flops at current speed of %.0E flop/s", 200E6, host->getSpeed()); + XBT_INFO("Run a task of %.0E flops at current speed of %.0E flop/s", 200E6, host->get_speed()); simgrid::s4u::this_actor::execute(200E6); XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s (when I started the computation, " "the speed was set to %.0E flop/s); number of flops computed so " "far: %.2E, average load as reported by the HostLoad plugin: %.5f (should be %.5f)", - simgrid::s4u::Engine::get_clock() - start, host->getSpeed(), speed, sg_host_get_computed_flops(host), + simgrid::s4u::Engine::get_clock() - start, host->get_speed(), speed, sg_host_get_computed_flops(host), sg_host_get_avg_load(host), static_cast(200E6) / (10.5 * speed * host->get_core_count() + - (simgrid::s4u::Engine::get_clock() - start - 0.5) * host->getSpeed() * host->get_core_count())); + (simgrid::s4u::Engine::get_clock() - start - 0.5) * host->get_speed() * host->get_core_count())); // ========= Change power peak ========= int pstate = 1; host->set_pstate(pstate); - XBT_INFO("========= Requesting pstate %d (speed should be of %.0E flop/s and is of %.0E flop/s, average load is %.5f)", pstate, - host->getPstateSpeed(pstate), host->getSpeed(), sg_host_get_avg_load(host)); + XBT_INFO( + "========= Requesting pstate %d (speed should be of %.0E flop/s and is of %.0E flop/s, average load is %.5f)", + pstate, host->get_pstate_speed(pstate), host->get_speed(), sg_host_get_avg_load(host)); // Run a second task start = simgrid::s4u::Engine::get_clock(); @@ -50,7 +52,7 @@ static void execute_load_test() simgrid::s4u::this_actor::execute(100E6); XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s; number of flops computed so " "far: %.2E", - simgrid::s4u::Engine::get_clock() - start, host->getSpeed(), sg_host_get_computed_flops(host)); + simgrid::s4u::Engine::get_clock() - start, host->get_speed(), sg_host_get_computed_flops(host)); start = simgrid::s4u::Engine::get_clock(); XBT_INFO("========= Requesting a reset of the computation and load counters"); @@ -59,7 +61,7 @@ static void execute_load_test() XBT_INFO("Sleep for 4 seconds"); simgrid::s4u::this_actor::sleep_for(4); XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E", - simgrid::s4u::Engine::get_clock() - start, host->getSpeed(), sg_host_get_computed_flops(host)); + simgrid::s4u::Engine::get_clock() - start, host->get_speed(), sg_host_get_computed_flops(host)); // =========== Turn the other host off ========== s4u_Host* host2 = simgrid::s4u::Host::by_name("MyHost2"); @@ -69,7 +71,7 @@ static void execute_load_test() start = simgrid::s4u::Engine::get_clock(); simgrid::s4u::this_actor::sleep_for(10); XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E", - simgrid::s4u::Engine::get_clock() - start, host->getSpeed(), sg_host_get_computed_flops(host)); + simgrid::s4u::Engine::get_clock() - start, host->get_speed(), sg_host_get_computed_flops(host)); } static void change_speed() diff --git a/examples/simdag/test/sd_test.cpp b/examples/simdag/test/sd_test.cpp index 35ce7c0237..3e5822b131 100644 --- a/examples/simdag/test/sd_test.cpp +++ b/examples/simdag/test/sd_test.cpp @@ -33,8 +33,8 @@ int main(int argc, char **argv) double comp_amount2 = 1000000; double comm_amount12 = 2000000; double comm_amount21 = 3000000; - XBT_INFO("Computation time for %f flops on %s: %f", comp_amount1, h1->get_cname(), comp_amount1 / h1->getSpeed()); - XBT_INFO("Computation time for %f flops on %s: %f", comp_amount2, h2->get_cname(), comp_amount2 / h2->getSpeed()); + XBT_INFO("Computation time for %f flops on %s: %f", comp_amount1, h1->get_cname(), comp_amount1 / h1->get_speed()); + XBT_INFO("Computation time for %f flops on %s: %f", comp_amount2, h2->get_cname(), comp_amount2 / h2->get_speed()); XBT_INFO("Route between %s and %s:", h1->get_cname(), h2->get_cname()); std::vector route; diff --git a/include/simgrid/s4u/Host.hpp b/include/simgrid/s4u/Host.hpp index 4d9f6077f0..477bb22515 100644 --- a/include/simgrid/s4u/Host.hpp +++ b/include/simgrid/s4u/Host.hpp @@ -108,15 +108,22 @@ public: return res; } - double getSpeed(); + double get_speed(); double get_available_speed(); int get_core_count(); + double get_load(); - double getPstateSpeed(int pstate_index); + double get_pstate_speed(int pstate_index); int get_pstate_count() const; void set_pstate(int pstate_index); int get_pstate(); + XBT_ATTRIB_DEPRECATED_v323("Please use Host::get_speed() instead.") double getSpeed() { return get_speed(); } + XBT_ATTRIB_DEPRECATED_v323("Please use Host::get_pstate_speed() instead.") double getPstateSpeed(int pstate_index) + { + return get_pstate_speed(pstate_index); + } + std::vector get_attached_storages(); XBT_ATTRIB_DEPRECATED_v323("Please use Host::get_attached_storages() instead.") void getAttachedStorages( std::vector* storages); @@ -125,7 +132,11 @@ public: * * This is defined in the platform file, and cannot be modified programatically (yet). */ - std::unordered_map const& getMountedStorages(); + std::unordered_map const& get_mounted_storages(); + XBT_ATTRIB_DEPRECATED_v323("Please use Host::get_mounted_storages() instead.") std::unordered_map const& getMountedStorages() + { + return get_mounted_storages(); + } void route_to(Host* dest, std::vector& links, double* latency); void route_to(Host* dest, std::vector& links, double* latency); @@ -139,13 +150,6 @@ public: /** Block the calling actor on an execution located on the called host (with explicit priority) */ void execute(double flops, double priority); - /** @brief Returns the current computation load (in flops per second) - * The external load (coming from an availability trace) is not taken in account. - * - * @return The number of activities currently running on a host (an activity at priority 2 is counted twice). - */ - double getLoad(); - // Deprecated functions XBT_ATTRIB_DEPRECATED_v323("Please use Host::get_name()") simgrid::xbt::string const& getName() const { diff --git a/src/bindings/java/jmsg_host.cpp b/src/bindings/java/jmsg_host.cpp index 7076f7a543..32c513fa12 100644 --- a/src/bindings/java/jmsg_host.cpp +++ b/src/bindings/java/jmsg_host.cpp @@ -236,7 +236,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getMountedStorage(JNIEn int index = 0; jobjectArray jtable; - std::unordered_map mounted_storages = host->getMountedStorages(); + std::unordered_map mounted_storages = host->get_mounted_storages(); int count = mounted_storages.size(); jclass cls = env->FindClass("org/simgrid/msg/Storage"); diff --git a/src/instr/instr_platform.cpp b/src/instr/instr_platform.cpp index a9ba36935f..44d2276d17 100644 --- a/src/instr/instr_platform.cpp +++ b/src/instr/instr_platform.cpp @@ -210,7 +210,7 @@ static void instr_host_on_creation(simgrid::s4u::Host& host) if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_speed())) { simgrid::instr::VariableType* power = container->type_->by_name_or_create("power", ""); power->set_calling_container(container); - power->set_event(0, host.getSpeed()); + power->set_event(0, host.get_speed()); } if (TRACE_uncategorized()) diff --git a/src/kernel/lmm/maxmin.cpp b/src/kernel/lmm/maxmin.cpp index 5060a2dac7..6eab5be5ce 100644 --- a/src/kernel/lmm/maxmin.cpp +++ b/src/kernel/lmm/maxmin.cpp @@ -932,11 +932,11 @@ void System::remove_all_modified_set() /** * Returns resource load (in flop per second, or byte per second, or similar) * - * If the resource is shared (the default case), the load is sum of resource usage made by every variables located on - * this resource. + * If the resource is shared (the default case), the load is sum of resource usage made by + * every variables located on this resource. * - * If the resource is not shared (ie in FATPIPE mode), then the load is the max (not the sum) of all resource usages - * located on this resource. + * If the resource is not shared (ie in FATPIPE mode), then the load is the max (not the sum) + * of all resource usages located on this resource. */ double Constraint::get_usage() const { diff --git a/src/plugins/file_system/s4u_FileSystem.cpp b/src/plugins/file_system/s4u_FileSystem.cpp index 0dd328719d..70a7a3b4bd 100644 --- a/src/plugins/file_system/s4u_FileSystem.cpp +++ b/src/plugins/file_system/s4u_FileSystem.cpp @@ -32,7 +32,7 @@ File::File(std::string fullpath, sg_host_t host, void* userdata) : fullpath_(ful size_t longest_prefix_length = 0; XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath.c_str(), host->get_cname()); - for (auto const& mnt : host->getMountedStorages()) { + for (auto const& mnt : host->get_mounted_storages()) { XBT_DEBUG("See '%s'", mnt.first.c_str()); mount_point_ = fullpath.substr(0, mnt.first.length()); @@ -246,7 +246,7 @@ int File::remote_copy(sg_host_t host, const char* fullpath) Host* dst_host; size_t longest_prefix_length = 0; - for (auto const& elm : host->getMountedStorages()) { + for (auto const& elm : host->get_mounted_storages()) { std::string mount_point = std::string(fullpath).substr(0, elm.first.size()); if (mount_point == elm.first && elm.first.length() > longest_prefix_length) { /* The current mount name is found in the full path and is bigger than the previous*/ @@ -492,7 +492,7 @@ xbt_dict_t sg_host_get_storage_content(sg_host_t host) { xbt_assert((host != nullptr), "Invalid parameters"); xbt_dict_t contents = xbt_dict_new_homogeneous(nullptr); - for (auto const& elm : host->getMountedStorages()) + for (auto const& elm : host->get_mounted_storages()) xbt_dict_set(contents, elm.first.c_str(), sg_storage_get_content(elm.second), nullptr); return contents; diff --git a/src/plugins/host_energy.cpp b/src/plugins/host_energy.cpp index 6a8936a30b..579af031d3 100644 --- a/src/plugins/host_energy.cpp +++ b/src/plugins/host_energy.cpp @@ -220,7 +220,7 @@ double HostEnergy::get_current_watts_value() if (this->pstate_ == pstate_off_) // The host is off (or was off at the beginning of this time interval) return this->watts_off_; - double current_speed = host_->getSpeed(); + double current_speed = host_->get_speed(); double cpu_load; // We may have start == finish if the past consumption was updated since the simcall was started diff --git a/src/plugins/host_load.cpp b/src/plugins/host_load.cpp index 54d5fc98a2..dd1d428b93 100644 --- a/src/plugins/host_load.cpp +++ b/src/plugins/host_load.cpp @@ -26,7 +26,7 @@ public: : host_(ptr) , last_updated_(surf_get_clock()) , last_reset_(surf_get_clock()) - , current_speed_(host_->getSpeed()) + , current_speed_(host_->get_speed()) , current_flops_(host_->pimpl_cpu->get_constraint()->get_usage()) , theor_max_flops_(0) , was_prev_idle_(current_flops_ == 0) @@ -81,7 +81,7 @@ void HostLoad::update() } theor_max_flops_ += current_speed_ * host_->get_core_count() * (now - last_updated_); - current_speed_ = host_->getSpeed(); + current_speed_ = host_->get_speed(); last_updated_ = now; was_prev_idle_ = (current_flops_ == 0); } @@ -98,7 +98,7 @@ double HostLoad::get_current_load() { // We don't need to call update() here because it is called every time an action terminates or starts // FIXME: Can this happen at the same time? stop -> call to getCurrentLoad, load = 0 -> next action starts? - return current_flops_ / static_cast(host_->getSpeed() * host_->get_core_count()); + return current_flops_ / static_cast(host_->get_speed() * host_->get_core_count()); } /* @@ -112,7 +112,7 @@ void HostLoad::reset() computed_flops_ = 0; theor_max_flops_ = 0; current_flops_ = host_->pimpl_cpu->get_constraint()->get_usage(); - current_speed_ = host_->getSpeed(); + current_speed_ = host_->get_speed(); was_prev_idle_ = (current_flops_ == 0); } } // namespace plugin diff --git a/src/plugins/vm/VmLiveMigration.cpp b/src/plugins/vm/VmLiveMigration.cpp index e946205445..38741de29a 100644 --- a/src/plugins/vm/VmLiveMigration.cpp +++ b/src/plugins/vm/VmLiveMigration.cpp @@ -134,7 +134,7 @@ void MigrationTx::operator()() { XBT_DEBUG("mig: tx_start"); - double host_speed = vm_->get_pm()->getSpeed(); + double host_speed = vm_->get_pm()->get_speed(); const sg_size_t ramsize = vm_->get_ramsize(); const double dp_rate = host_speed ? (sg_vm_get_migration_speed(vm_) * sg_vm_get_dirty_page_intensity(vm_)) / host_speed : 1; diff --git a/src/plugins/vm/s4u_VirtualMachine.cpp b/src/plugins/vm/s4u_VirtualMachine.cpp index aca373b662..b727465c9f 100644 --- a/src/plugins/vm/s4u_VirtualMachine.cpp +++ b/src/plugins/vm/s4u_VirtualMachine.cpp @@ -37,7 +37,7 @@ VirtualMachine::VirtualMachine(const char* name, s4u::Host* physical_host, int c // Create a VCPU for this VM std::vector speeds; for (int i = 0; i < physical_host->get_pstate_count(); i++) - speeds.push_back(physical_host->getPstateSpeed(i)); + speeds.push_back(physical_host->get_pstate_speed(i)); surf_cpu_model_vm->create_cpu(this, &speeds, physical_host->get_core_count()); if (physical_host->get_pstate() != 0) diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index af81dcb9a0..e321de2074 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -221,19 +221,36 @@ void Host::set_property(std::string key, std::string value) } /** @brief Get the peak processor speed (in flops/s), at the specified pstate */ -double Host::getPstateSpeed(int pstate_index) +double Host::get_pstate_speed(int pstate_index) { return simgrid::simix::simcall([this, pstate_index] { return this->pimpl_cpu->get_pstate_peak_speed(pstate_index); }); } -/** @brief Get the peak processor speed in flops/s, (under full load (=1.0), at the current pstate) +/** @brief Get the peak computing speed in flops/s at the current pstate, taking the external load into account. * - * The result also takes the external load into account. + * The amount of flops per second available for computing depends on several things: + * - The current pstate determines the maximal peak computing speed (use @ref get_pstate_speed() to retrieve the + * computing speed you would get at another pstate) + * - If you declared an external load, then this reduces the available computing speed (see @ref set_speed_trace()) + * + * The remaining speed is then shared between the executions located on this host. + * You can retrieve the amount of tasks currently running on this host with @ref get_load(). + * + * The host may have multiple cores, and your executions may be able to use more than a single core. + * + * Finally, executions of priority 2 get twice the amount of flops than executions of priority 1. */ -double Host::getSpeed() +double Host::get_speed() { return this->pimpl_cpu->get_speed(1.0); } +/** @brief Returns the current computation load (in flops per second) + * The external load (coming from an availability trace) is not taken in account. + */ +double Host::get_load() +{ + return this->pimpl_cpu->get_load(); +} /** @brief Get the available speed ratio, between 0 and 1. * * This accounts for external load (see @ref set_speed_trace()). @@ -278,7 +295,7 @@ void Host::getAttachedStorages(std::vector* storages) storages->push_back(elm); } -std::unordered_map const& Host::getMountedStorages() +std::unordered_map const& Host::get_mounted_storages() { if (mounts_ == nullptr) { mounts_ = new std::unordered_map(); @@ -299,11 +316,6 @@ void Host::execute(double flops, double priority) simcall_execution_wait(s); } -double Host::getLoad() -{ - return this->pimpl_cpu->get_load(); -} - } // namespace s4u } // namespace simgrid @@ -394,7 +406,7 @@ xbt_dict_t sg_host_get_mounted_storage_list(sg_host_t host) { xbt_assert((host != nullptr), "Invalid parameters"); xbt_dict_t res = xbt_dict_new_homogeneous(nullptr); - for (auto const& elm : host->getMountedStorages()) { + for (auto const& elm : host->get_mounted_storages()) { const char* mount_name = elm.first.c_str(); sg_storage_t storage = elm.second; xbt_dict_set(res, mount_name, (void*)storage->get_cname(), nullptr); @@ -417,7 +429,7 @@ xbt_dynar_t sg_host_get_attached_storage_list(sg_host_t host) /** @brief Returns the total speed of a host */ double sg_host_speed(sg_host_t host) { - return host->getSpeed(); + return host->get_speed(); } /** \brief Return the speed of the processor (in flop/s) at a given pstate. See also @ref plugin_energy. @@ -428,7 +440,7 @@ double sg_host_speed(sg_host_t host) */ double sg_host_get_pstate_speed(sg_host_t host, int pstate_index) { - return host->getPstateSpeed(pstate_index); + return host->get_pstate_speed(pstate_index); } /** \ingroup m_host_management @@ -603,7 +615,7 @@ double sg_host_route_bandwidth(sg_host_t from, sg_host_t to) void sg_host_dump(sg_host_t host) { XBT_INFO("Displaying host %s", host->get_cname()); - XBT_INFO(" - speed: %.0f", host->getSpeed()); + XBT_INFO(" - speed: %.0f", host->get_speed()); XBT_INFO(" - available speed: %.2f", sg_host_get_available_speed(host)); std::unordered_map* props = host->get_properties(); diff --git a/src/simdag/sd_task.cpp b/src/simdag/sd_task.cpp index 7fd697eafd..2894ffa96f 100644 --- a/src/simdag/sd_task.cpp +++ b/src/simdag/sd_task.cpp @@ -683,7 +683,7 @@ double SD_task_get_execution_time(SD_task_t /*task*/, int host_count, const sg_h for (int i = 0; i < host_count; i++) { double time = 0.0; if (flops_amount != nullptr) - time = flops_amount[i] / host_list[i]->getSpeed(); + time = flops_amount[i] / host_list[i]->get_speed(); if (bytes_amount != nullptr) for (int j = 0; j < host_count; j++) diff --git a/src/smpi/internals/smpi_dvfs.cpp b/src/smpi/internals/smpi_dvfs.cpp index 8fe3b4e702..a328d2c4ce 100644 --- a/src/smpi/internals/smpi_dvfs.cpp +++ b/src/smpi/internals/smpi_dvfs.cpp @@ -24,7 +24,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_dvfs, smpi, "Logging specific to SMPI (expe */ double smpi_get_host_power_peak_at(int pstate_index) { - return sg_host_self()->getPstateSpeed(pstate_index); + return sg_host_self()->get_pstate_speed(pstate_index); } /** @@ -34,7 +34,7 @@ double smpi_get_host_power_peak_at(int pstate_index) */ double smpi_get_host_current_power_peak() { - return sg_host_self()->getSpeed(); + return sg_host_self()->get_speed(); } /** diff --git a/src/smpi/mpi/smpi_request.cpp b/src/smpi/mpi/smpi_request.cpp index 4732410eb3..f6ffd0bf78 100644 --- a/src/smpi/mpi/smpi_request.cpp +++ b/src/smpi/mpi/smpi_request.cpp @@ -680,7 +680,7 @@ void Request::iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* // nsleeps is a multiplier to the sleeptime, to increase speed of execution, each failed iprobe will increase it // This can speed up the execution of certain applications by an order of magnitude, such as HPL static int nsleeps = 1; - double speed = simgrid::s4u::Actor::self()->get_host()->getSpeed(); + double speed = simgrid::s4u::Actor::self()->get_host()->get_speed(); double maxrate = simgrid::config::get_value("smpi/iprobe-cpu-usage"); MPI_Request request = new Request(nullptr, 0, MPI_CHAR, source == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : comm->group()->actor(source)->get_pid(), diff --git a/teshsuite/s4u/storage_client_server/storage_client_server.cpp b/teshsuite/s4u/storage_client_server/storage_client_server.cpp index d2ed8fe75a..26c340431a 100644 --- a/teshsuite/s4u/storage_client_server/storage_client_server.cpp +++ b/teshsuite/s4u/storage_client_server/storage_client_server.cpp @@ -103,7 +103,7 @@ static void storage_info(simgrid::s4u::Host* host) { XBT_INFO("*** Storage info on %s ***", host->get_cname()); - for (auto const& elm : host->getMountedStorages()) { + for (auto const& elm : host->get_mounted_storages()) { const std::string& mount_name = elm.first; simgrid::s4u::Storage* storage = elm.second; XBT_INFO("\tStorage name: %s, mount name: %s", storage->get_cname(), mount_name.c_str()); -- 2.20.1