From eaa222acd330e2c3e2c517c5eaab82c8fcb8a4c1 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Fri, 9 Mar 2018 17:23:51 +0100 Subject: [PATCH] cosmetics: rename a function, deprecate old name --- .../s4u/actor-suspend/s4u-actor-suspend.cpp | 2 +- examples/s4u/app-bittorrent/s4u-bittorrent.cpp | 2 +- .../s4u/app-token-ring/s4u-app-token-ring.cpp | 2 +- examples/s4u/dht-chord/s4u-dht-chord.cpp | 2 +- examples/s4u/exec-ptask/s4u-exec-ptask.cpp | 2 +- .../s4u-platform-properties.cpp | 2 +- include/simgrid/s4u/Engine.hpp | 4 ++-- src/s4u/s4u_engine.cpp | 18 ++++++++++++------ src/simdag/sd_dotloader.cpp | 2 +- src/simgrid/host.cpp | 4 ++-- src/smpi/internals/smpi_deployment.cpp | 2 +- src/surf/plugins/host_energy.cpp | 4 ++-- src/surf/plugins/link_energy.cpp | 2 +- src/surf/sg_platf.cpp | 2 +- teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp | 2 +- 15 files changed, 29 insertions(+), 23 deletions(-) diff --git a/examples/s4u/actor-suspend/s4u-actor-suspend.cpp b/examples/s4u/actor-suspend/s4u-actor-suspend.cpp index 967e8034c8..60aa8efd91 100644 --- a/examples/s4u/actor-suspend/s4u-actor-suspend.cpp +++ b/examples/s4u/actor-suspend/s4u-actor-suspend.cpp @@ -70,7 +70,7 @@ int main(int argc, char* argv[]) xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]); e.loadPlatform(argv[1]); /* - Load the platform description */ - std::vector list = e.getHostList(); + std::vector list = e.getAllHosts(); simgrid::s4u::Actor::createActor("dream_master", list.front(), dream_master); e.run(); /* - Run the simulation */ diff --git a/examples/s4u/app-bittorrent/s4u-bittorrent.cpp b/examples/s4u/app-bittorrent/s4u-bittorrent.cpp index 9307ba0031..0ce2b97cf2 100644 --- a/examples/s4u/app-bittorrent/s4u-bittorrent.cpp +++ b/examples/s4u/app-bittorrent/s4u-bittorrent.cpp @@ -21,7 +21,7 @@ int main(int argc, char* argv[]) HostBittorrent::EXTENSION_ID = simgrid::s4u::Host::extension_create(); - std::vector list = simgrid::s4u::Engine::getInstance()->getHostList(); + std::vector list = simgrid::s4u::Engine::getInstance()->getAllHosts(); for (auto const& host : list) host->extension_set(new HostBittorrent(host)); diff --git a/examples/s4u/app-token-ring/s4u-app-token-ring.cpp b/examples/s4u/app-token-ring/s4u-app-token-ring.cpp index 893e6df539..f9535065c1 100644 --- a/examples/s4u/app-token-ring/s4u-app-token-ring.cpp +++ b/examples/s4u/app-token-ring/s4u-app-token-ring.cpp @@ -60,7 +60,7 @@ int main(int argc, char** argv) XBT_INFO("Number of hosts '%zu'", e.getHostCount()); int id = 0; - std::vector list = e.getHostList(); + std::vector list = e.getAllHosts(); for (auto const& host : list) { /* - Give a unique rank to each host and create a @ref relay_runner process on each */ simgrid::s4u::Actor::createActor((std::to_string(id)).c_str(), host, RelayRunner()); diff --git a/examples/s4u/dht-chord/s4u-dht-chord.cpp b/examples/s4u/dht-chord/s4u-dht-chord.cpp index f18cf54d6e..86cdfbf808 100644 --- a/examples/s4u/dht-chord/s4u-dht-chord.cpp +++ b/examples/s4u/dht-chord/s4u-dht-chord.cpp @@ -28,7 +28,7 @@ static void chord_init() HostChord::EXTENSION_ID = simgrid::s4u::Host::extension_create(); - std::vector list = simgrid::s4u::Engine::getInstance()->getHostList(); + std::vector list = simgrid::s4u::Engine::getInstance()->getAllHosts(); for (auto const& host : list) host->extension_set(new HostChord(host)); } diff --git a/examples/s4u/exec-ptask/s4u-exec-ptask.cpp b/examples/s4u/exec-ptask/s4u-exec-ptask.cpp index 4de50c26ad..4f9b81ab07 100644 --- a/examples/s4u/exec-ptask/s4u-exec-ptask.cpp +++ b/examples/s4u/exec-ptask/s4u-exec-ptask.cpp @@ -28,7 +28,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_energyptask, "Messages specific for this s4u ex static void runner() { /* Retrieve the list of all hosts as an array of hosts */ - std::vector hosts = simgrid::s4u::Engine::getInstance()->getHostList(); + std::vector hosts = simgrid::s4u::Engine::getInstance()->getAllHosts(); int hosts_count = hosts.size(); XBT_INFO("First, build a classical parallel task, with 1 Gflop to execute on each node, " diff --git a/examples/s4u/platform-properties/s4u-platform-properties.cpp b/examples/s4u/platform-properties/s4u-platform-properties.cpp index 2d9f388494..f2a948da4e 100644 --- a/examples/s4u/platform-properties/s4u-platform-properties.cpp +++ b/examples/s4u/platform-properties/s4u-platform-properties.cpp @@ -106,7 +106,7 @@ int main(int argc, char* argv[]) size_t totalHosts = sg_host_count(); XBT_INFO("There are %zu hosts in the environment", totalHosts); - std::vector hosts = e.getHostList(); + std::vector hosts = e.getAllHosts(); for (unsigned int i = 0; i < hosts.size(); i++) XBT_INFO("Host '%s' runs at %.0f flops/s", hosts[i]->getCname(), hosts[i]->getSpeed()); diff --git a/include/simgrid/s4u/Engine.hpp b/include/simgrid/s4u/Engine.hpp index 8b2f0cdc93..cd42aec895 100644 --- a/include/simgrid/s4u/Engine.hpp +++ b/include/simgrid/s4u/Engine.hpp @@ -65,11 +65,11 @@ public: size_t getHostCount(); void getHostList(std::vector * whereTo); - std::vector getHostList(); + std::vector getAllHosts(); size_t getLinkCount(); void getLinkList(std::vector * list); - std::vector getLinkList(); + std::vector getAllLinks(); /** @brief Run the simulation */ void run(); diff --git a/src/s4u/s4u_engine.cpp b/src/s4u/s4u_engine.cpp index 5a231d6b1a..e49b59db09 100644 --- a/src/s4u/s4u_engine.cpp +++ b/src/s4u/s4u_engine.cpp @@ -85,14 +85,17 @@ size_t Engine::getHostCount() { return pimpl->hosts_.size(); } -/** @brief Fills the passed list with all hosts found in the platform */ -void Engine::getHostList(std::vector* list) +/** @brief Fills the passed list with all hosts found in the platform + * @deprecated Please prefer Engine::getAllHosts() + */ +void XBT_ATTRIB_DEPRECATED_v322("Engine::getHostList() is deprecated in favor of Engine::getAllHosts(). Please switch before v3.22") +Engine::getHostList(std::vector* list) { for (auto const& kv : pimpl->hosts_) list->push_back(kv.second); } /** @brief Returns the list of all hosts found in the platform */ -std::vector Engine::getHostList() +std::vector Engine::getAllHosts() { std::vector res; for (auto const& kv : pimpl->hosts_) @@ -122,13 +125,16 @@ size_t Engine::getLinkCount() { return simgrid::surf::LinkImpl::linksCount(); } -/** @brief Fills the passed list with all links found in the platform */ -void Engine::getLinkList(std::vector* list) +/** @brief Fills the passed list with all links found in the platform + * + * @deprecated. Prefer Engine::getAllLinks() */ +void XBT_ATTRIB_DEPRECATED_v322("Engine::getLinkList() is deprecated in favor of Engine::getAllLinks(). Please switch before v3.22") +Engine::getLinkList(std::vector* list) { simgrid::surf::LinkImpl::linksList(list); } /** @brief Returns the list of all links found in the platform */ -std::vector Engine::getLinkList() +std::vector Engine::getAllLinks() { std::vector res; simgrid::surf::LinkImpl::linksList(&res); diff --git a/src/simdag/sd_dotloader.cpp b/src/simdag/sd_dotloader.cpp index 10bb4ad5d0..db121d754a 100644 --- a/src/simdag/sd_dotloader.cpp +++ b/src/simdag/sd_dotloader.cpp @@ -213,7 +213,7 @@ xbt_dynar_t SD_dotload_generic(const char* filename, bool sequential, bool sched if(schedule){ if (schedule_success) { - std::vector hosts = simgrid::s4u::Engine::getInstance()->getHostList(); + std::vector hosts = simgrid::s4u::Engine::getInstance()->getAllHosts(); for (auto const& elm : computers) { SD_task_t previous_task = nullptr; diff --git a/src/simgrid/host.cpp b/src/simgrid/host.cpp index faf160f219..e8ea892a41 100644 --- a/src/simgrid/host.cpp +++ b/src/simgrid/host.cpp @@ -37,7 +37,7 @@ size_t sg_host_count() */ sg_host_t *sg_host_list() { xbt_assert(sg_host_count() > 0, "There is no host!"); - std::vector hosts = simgrid::s4u::Engine::getInstance()->getHostList(); + std::vector hosts = simgrid::s4u::Engine::getInstance()->getAllHosts(); sg_host_t* res = (sg_host_t*)malloc(sizeof(sg_host_t) * hosts.size()); memcpy(res, hosts.data(), sizeof(sg_host_t) * hosts.size()); @@ -75,7 +75,7 @@ xbt_dynar_t sg_hosts_as_dynar() { xbt_dynar_t res = xbt_dynar_new(sizeof(sg_host_t),nullptr); - std::vector list = simgrid::s4u::Engine::getInstance()->getHostList(); + std::vector list = simgrid::s4u::Engine::getInstance()->getAllHosts(); for (auto const& host : list) { if (host && host->pimpl_netpoint && host->pimpl_netpoint->isHost()) diff --git a/src/smpi/internals/smpi_deployment.cpp b/src/smpi/internals/smpi_deployment.cpp index 174447a972..ad05eae729 100644 --- a/src/smpi/internals/smpi_deployment.cpp +++ b/src/smpi/internals/smpi_deployment.cpp @@ -57,7 +57,7 @@ void SMPI_app_instance_register(const char *name, xbt_main_func_t code, int num_ static int already_called = 0; if (not already_called) { already_called = 1; - std::vector list = simgrid::s4u::Engine::getInstance()->getHostList(); + std::vector list = simgrid::s4u::Engine::getInstance()->getAllHosts(); for (auto const& host : list) { host->extension_set(new simgrid::smpi::SmpiHost(host)); } diff --git a/src/surf/plugins/host_energy.cpp b/src/surf/plugins/host_energy.cpp index f999bd1e9b..55236368e7 100644 --- a/src/surf/plugins/host_energy.cpp +++ b/src/surf/plugins/host_energy.cpp @@ -432,7 +432,7 @@ static void onHostDestruction(simgrid::s4u::Host& host) static void onSimulationEnd() { - std::vector hosts = simgrid::s4u::Engine::getInstance()->getHostList(); + std::vector hosts = simgrid::s4u::Engine::getInstance()->getAllHosts(); double total_energy = 0.0; // Total energy consumption (whole platform) double used_hosts_energy = 0.0; // Energy consumed by hosts that computed something @@ -483,7 +483,7 @@ void sg_host_energy_plugin_init() void sg_host_energy_update_all() { simgrid::simix::kernelImmediate([]() { - std::vector list = simgrid::s4u::Engine::getInstance()->getHostList(); + std::vector list = simgrid::s4u::Engine::getInstance()->getAllHosts(); for (auto const& host : list) if (dynamic_cast(host) == nullptr) // Ignore virtual machines host->extension()->update(); diff --git a/src/surf/plugins/link_energy.cpp b/src/surf/plugins/link_energy.cpp index cee5ad2bcf..d4a9f3780c 100644 --- a/src/surf/plugins/link_energy.cpp +++ b/src/surf/plugins/link_energy.cpp @@ -164,7 +164,7 @@ static void onCommunicate(simgrid::surf::NetworkAction* action, simgrid::s4u::Ho static void onSimulationEnd() { - std::vector links = simgrid::s4u::Engine::getInstance()->getLinkList(); + std::vector links = simgrid::s4u::Engine::getInstance()->getAllLinks(); double total_energy = 0.0; // Total dissipated energy (whole platform) for (const auto link : links) { diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index f372ea8058..c54247675f 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -417,7 +417,7 @@ void sg_platf_new_actor(ActorCreationArgs* actor) std::string msg = std::string("Cannot create actor '") + actor->function + "': host '" + actor->host + "' does not exist\nExisting hosts: '"; - std::vector list = simgrid::s4u::Engine::getInstance()->getHostList(); + std::vector list = simgrid::s4u::Engine::getInstance()->getAllHosts(); for (auto const& host : list) { msg += host->getName(); diff --git a/teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp b/teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp index 8dce7585af..c28714e19a 100644 --- a/teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp +++ b/teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp @@ -182,7 +182,7 @@ int main(int argc, char* argv[]) } xbt_assert(argSend.front().size() == argRecv.front().size(), "Sender and receiver spec must be of the same size"); - std::vector hosts = e.getHostList(); + std::vector hosts = e.getAllHosts(); simgrid::s4u::Actor::createActor("sender", hosts[0], sender, argSend); simgrid::s4u::Actor::createActor("recver", hosts[1], receiver, argRecv); -- 2.20.1