From 262c0777ed16cb8e15eaadd3785c6fec87039b26 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Wed, 25 Apr 2018 09:34:05 +0200 Subject: [PATCH] snake_case and cleanup some more methods of s4u::Engine --- .../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 | 53 ++++++++++++------- src/instr/instr_paje_containers.cpp | 4 +- src/kernel/EngineImpl.cpp | 2 +- src/kernel/EngineImpl.hpp | 2 +- src/kernel/routing/NetPoint.cpp | 4 +- src/kernel/routing/NetZoneImpl.cpp | 4 +- src/kernel/routing/VivaldiZone.cpp | 4 +- src/s4u/s4u_Engine.cpp | 23 +++++--- src/s4u/s4u_Host.cpp | 14 ++--- src/s4u/s4u_Netzone.cpp | 4 +- src/s4u/s4u_Storage.cpp | 8 +-- src/simdag/sd_dotloader.cpp | 2 +- src/simdag/sd_global.cpp | 2 +- src/simgrid/host.cpp | 6 +-- src/smpi/bindings/smpi_pmpi.cpp | 2 +- src/smpi/internals/smpi_deployment.cpp | 2 +- src/surf/instr_routing.cpp | 4 +- src/surf/plugins/host_energy.cpp | 4 +- src/surf/plugins/link_energy.cpp | 2 +- src/surf/sg_platf.cpp | 10 ++-- src/surf/storage_n11.cpp | 2 +- src/surf/xml/surfxml_sax_cb.cpp | 15 +++--- .../storage_client_server.cpp | 2 +- teshsuite/simdag/flatifier/flatifier.cpp | 38 ++++++------- teshsuite/simdag/is-router/is-router.cpp | 10 ++-- 30 files changed, 128 insertions(+), 105 deletions(-) diff --git a/examples/s4u/app-bittorrent/s4u-bittorrent.cpp b/examples/s4u/app-bittorrent/s4u-bittorrent.cpp index 2ef35e10b7..0f45f82b06 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[]) /* Install our extension on all existing hosts */ HostBittorrent::EXTENSION_ID = simgrid::s4u::Host::extension_create(); - std::vector list = simgrid::s4u::Engine::getInstance()->get_all_hosts(); + std::vector list = simgrid::s4u::Engine::get_instance()->get_all_hosts(); 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 7dfba65ffc..8e76889a5f 100644 --- a/examples/s4u/app-token-ring/s4u-app-token-ring.cpp +++ b/examples/s4u/app-token-ring/s4u-app-token-ring.cpp @@ -29,7 +29,7 @@ public: ia.what()); } my_mailbox = simgrid::s4u::Mailbox::byName(std::to_string(rank)); - if (rank + 1 == simgrid::s4u::Engine::getInstance()->get_host_count()) + if (rank + 1 == simgrid::s4u::Engine::get_instance()->get_host_count()) /* The last process, which sends the token back to rank 0 */ neighbor_mailbox = simgrid::s4u::Mailbox::byName("0"); else diff --git a/examples/s4u/dht-chord/s4u-dht-chord.cpp b/examples/s4u/dht-chord/s4u-dht-chord.cpp index d7613fb87b..2fc2877c34 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()->get_all_hosts(); + std::vector list = simgrid::s4u::Engine::get_instance()->get_all_hosts(); 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 37fe2e2df0..d2ffff9688 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()->get_all_hosts(); + std::vector hosts = simgrid::s4u::Engine::get_instance()->get_all_hosts(); 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 a5c6c53a6c..c4d57e00e2 100644 --- a/examples/s4u/platform-properties/s4u-platform-properties.cpp +++ b/examples/s4u/platform-properties/s4u-platform-properties.cpp @@ -71,7 +71,7 @@ static int david(int argc, char* argv[]) static int bob(int argc, char* argv[]) { /* this host also tests the properties of the AS*/ - simgrid::s4u::NetZone* root = simgrid::s4u::Engine::getInstance()->getNetRoot(); + simgrid::s4u::NetZone* root = simgrid::s4u::Engine::get_instance()->getNetRoot(); XBT_INFO("== Print the properties of the zone"); XBT_INFO(" Zone property: filename -> %s", root->getProperty("filename")); XBT_INFO(" Zone property: date -> %s", root->getProperty("date")); diff --git a/include/simgrid/s4u/Engine.hpp b/include/simgrid/s4u/Engine.hpp index 52f96c5d13..c55e376661 100644 --- a/include/simgrid/s4u/Engine.hpp +++ b/include/simgrid/s4u/Engine.hpp @@ -33,6 +33,14 @@ public: /** Finalize the default engine and all its dependencies */ static void shutdown(); + /** @brief Run the simulation */ + void run(); + + /** @brief Retrieve the simulation time */ + static double get_clock(); + /** @brief Retrieve the engine singleton */ + static s4u::Engine* get_instance(); + /** @brief Load a platform file describing the environment * * The environment is either a XML file following the simgrid.dtd formalism, or a lua file. @@ -98,39 +106,38 @@ public: simgrid::s4u::Storage* storage_by_name(std::string name); simgrid::s4u::Storage* storage_by_name_or_null(std::string name); - /** @brief Run the simulation */ - void run(); - - /** @brief Retrieve the simulation time */ - static double get_clock(); - - /** @brief Retrieve the engine singleton */ - static s4u::Engine* getInstance(); + std::vector get_all_netpoints(); /** @brief Retrieve the root netzone, containing all others */ simgrid::s4u::NetZone* getNetRoot(); - /** @brief Retrieve the netzone of the given name (or nullptr if not found) */ simgrid::s4u::NetZone* getNetzoneByNameOrNull(const char* name); /** @brief Retrieves all netzones of the same type than the subtype of the whereto vector */ template void getNetzoneByType(std::vector * whereto) { netzoneByTypeRecursive(getNetRoot(), whereto); } + /** @brief Retrieve the netcard of the given name (or nullptr if not found) */ simgrid::kernel::routing::NetPoint* getNetpointByNameOrNull(std::string name); - void getNetpointList(std::vector * list); /** Returns whether SimGrid was initialized yet -- mostly for internal use */ - static bool isInitialized(); - + static bool is_initialized(); /** @brief set a configuration variable * - * Do --help on any simgrid binary to see the list of currently existing configuration variables (see @ref options). + * Do --help on any simgrid binary to see the list of currently existing configuration variables (see also @ref + * options). * * Example: - * e->setConfig("host/model","ptask_L07"); + * e->set_config("host/model:ptask_L07"); */ - void setConfig(std::string str); + void set_config(std::string str); + simgrid::kernel::EngineImpl* pimpl; + +private: + static s4u::Engine* instance_; + + //////////////// Deprecated functions +public: XBT_ATTRIB_DEPRECATED_v323("Please use Engine::load_platform()") void loadPlatform(const char* platf) { load_platform(platf); @@ -199,11 +206,17 @@ public: return get_all_storages(); } XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_clock()") static double getClock() { return get_clock(); } - - simgrid::kernel::EngineImpl* pimpl; - -private: - static s4u::Engine* instance_; + XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_all_netpoints()") void getNetpointList( + std::vector* list); + XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_instance()") static s4u::Engine* getInstance() + { + return get_instance(); + } + XBT_ATTRIB_DEPRECATED_v323("Please use Engine::is_initialized()") static bool isInitialized() + { + return is_initialized(); + } + XBT_ATTRIB_DEPRECATED_v323("Please use Engine::set_config()") void setConfig(std::string str) { set_config(str); } }; /** Callback fired when the platform is created (ie, the xml file parsed), diff --git a/src/instr/instr_paje_containers.cpp b/src/instr/instr_paje_containers.cpp index 8b29f80e8e..2b901348ea 100644 --- a/src/instr/instr_paje_containers.cpp +++ b/src/instr/instr_paje_containers.cpp @@ -35,7 +35,7 @@ container_t Container::getRoot() NetZoneContainer::NetZoneContainer(std::string name, unsigned int level, NetZoneContainer* father) : Container::Container(name, "", father) { - netpoint_ = simgrid::s4u::Engine::getInstance()->getNetpointByNameOrNull(name); + netpoint_ = simgrid::s4u::Engine::get_instance()->getNetpointByNameOrNull(name); xbt_assert(netpoint_, "Element '%s' not found", name.c_str()); if (father_) { type_ = father_->type_->getOrCreateContainerType(std::string("L") + std::to_string(level)); @@ -51,7 +51,7 @@ RouterContainer::RouterContainer(std::string name, Container* father) : Containe { xbt_assert(father, "Only the Root container has no father"); - netpoint_ = simgrid::s4u::Engine::getInstance()->getNetpointByNameOrNull(name); + netpoint_ = simgrid::s4u::Engine::get_instance()->getNetpointByNameOrNull(name); xbt_assert(netpoint_, "Element '%s' not found", name.c_str()); trivaNodeTypes.insert(type_->get_name()); diff --git a/src/kernel/EngineImpl.cpp b/src/kernel/EngineImpl.cpp index 12979fa570..dcda57deda 100644 --- a/src/kernel/EngineImpl.cpp +++ b/src/kernel/EngineImpl.cpp @@ -34,7 +34,7 @@ EngineImpl::~EngineImpl() hosts_.at(name)->destroy(); /* Also delete the other data */ - delete netRoot_; + delete netzone_root_; for (auto const& kv : netpoints_) delete kv.second; diff --git a/src/kernel/EngineImpl.hpp b/src/kernel/EngineImpl.hpp index 313ba4e046..43f8b676dd 100644 --- a/src/kernel/EngineImpl.hpp +++ b/src/kernel/EngineImpl.hpp @@ -16,7 +16,7 @@ class EngineImpl { public: EngineImpl(); virtual ~EngineImpl(); - kernel::routing::NetZoneImpl* netRoot_ = nullptr; + kernel::routing::NetZoneImpl* netzone_root_ = nullptr; private: std::map hosts_; diff --git a/src/kernel/routing/NetPoint.cpp b/src/kernel/routing/NetPoint.cpp index e1b0510aee..9246108db2 100644 --- a/src/kernel/routing/NetPoint.cpp +++ b/src/kernel/routing/NetPoint.cpp @@ -22,7 +22,7 @@ NetPoint::NetPoint(std::string name, NetPoint::Type componentType, NetZoneImpl* id_ = netzone_p->addComponent(this); else id_ = static_cast(-1); - simgrid::s4u::Engine::getInstance()->netpoint_register(this); + simgrid::s4u::Engine::get_instance()->netpoint_register(this); simgrid::kernel::routing::NetPoint::onCreation(this); } } @@ -35,5 +35,5 @@ NetPoint::NetPoint(std::string name, NetPoint::Type componentType, NetZoneImpl* */ simgrid::kernel::routing::NetPoint* sg_netpoint_by_name_or_null(const char* name) { - return simgrid::s4u::Engine::getInstance()->getNetpointByNameOrNull(name); + return simgrid::s4u::Engine::get_instance()->getNetpointByNameOrNull(name); } diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index 94603ef8be..8c4f453d3c 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -28,7 +28,7 @@ public: NetZoneImpl::NetZoneImpl(NetZone* father, std::string name) : NetZone(father, name) { - xbt_assert(nullptr == simgrid::s4u::Engine::getInstance()->getNetpointByNameOrNull(name.c_str()), + xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->getNetpointByNameOrNull(name.c_str()), "Refusing to create a second NetZone called '%s'.", name.c_str()); netpoint_ = new NetPoint(name, NetPoint::Type::NetZone, static_cast(father)); @@ -40,7 +40,7 @@ NetZoneImpl::~NetZoneImpl() for (auto const& kv : bypass_routes_) delete kv.second; - simgrid::s4u::Engine::getInstance()->netpoint_unregister(netpoint_); + simgrid::s4u::Engine::get_instance()->netpoint_unregister(netpoint_); } simgrid::s4u::Host* NetZoneImpl::create_host(const char* name, std::vector* speedPerPstate, int coreAmount, diff --git a/src/kernel/routing/VivaldiZone.cpp b/src/kernel/routing/VivaldiZone.cpp index b424a4738a..3364f033c7 100644 --- a/src/kernel/routing/VivaldiZone.cpp +++ b/src/kernel/routing/VivaldiZone.cpp @@ -84,8 +84,8 @@ void VivaldiZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg if (src->is_netzone()) { std::string srcName = "router_" + src->get_name(); std::string dstName = "router_" + dst->get_name(); - route->gw_src = simgrid::s4u::Engine::getInstance()->getNetpointByNameOrNull(srcName.c_str()); - route->gw_dst = simgrid::s4u::Engine::getInstance()->getNetpointByNameOrNull(dstName.c_str()); + route->gw_src = simgrid::s4u::Engine::get_instance()->getNetpointByNameOrNull(srcName.c_str()); + route->gw_dst = simgrid::s4u::Engine::get_instance()->getNetpointByNameOrNull(dstName.c_str()); } /* Retrieve the private links */ diff --git a/src/s4u/s4u_Engine.cpp b/src/s4u/s4u_Engine.cpp index 6b174d58f5..49c4b034ed 100644 --- a/src/s4u/s4u_Engine.cpp +++ b/src/s4u/s4u_Engine.cpp @@ -47,7 +47,8 @@ Engine::~Engine() s4u::Engine::instance_ = nullptr; } -Engine* Engine::getInstance() +/** @brief Retrieve the engine singleton */ +Engine* Engine::get_instance() { if (s4u::Engine::instance_ == nullptr) return new Engine(0, nullptr); @@ -188,16 +189,16 @@ void Engine::run() s4u::NetZone* Engine::getNetRoot() { - return pimpl->netRoot_; + return pimpl->netzone_root_; } -static s4u::NetZone* netzoneByNameRecursive(s4u::NetZone* current, const char* name) +static s4u::NetZone* netzone_by_name_recursive(s4u::NetZone* current, const char* name) { if (not strcmp(current->get_cname(), name)) return current; for (auto const& elem : *(current->getChildren())) { - simgrid::s4u::NetZone* tmp = netzoneByNameRecursive(elem, name); + simgrid::s4u::NetZone* tmp = netzone_by_name_recursive(elem, name); if (tmp != nullptr) { return tmp; } @@ -208,7 +209,7 @@ static s4u::NetZone* netzoneByNameRecursive(s4u::NetZone* current, const char* n /** @brief Retrieve the NetZone of the given name (or nullptr if not found) */ NetZone* Engine::getNetzoneByNameOrNull(const char* name) { - return netzoneByNameRecursive(getNetRoot(), name); + return netzone_by_name_recursive(getNetRoot(), name); } /** @brief Retrieve the netpoint of the given name (or nullptr if not found) */ @@ -224,6 +225,14 @@ void Engine::getNetpointList(std::vector* l for (auto const& kv : pimpl->netpoints_) list->push_back(kv.second); } +std::vector Engine::get_all_netpoints() +{ + std::vector res; + for (auto const& kv : pimpl->netpoints_) + res.push_back(kv.second); + return res; +} + /** @brief Register a new netpoint to the system */ void Engine::netpoint_register(simgrid::kernel::routing::NetPoint* point) { @@ -240,11 +249,11 @@ void Engine::netpoint_unregister(simgrid::kernel::routing::NetPoint* point) }); } -bool Engine::isInitialized() +bool Engine::is_initialized() { return Engine::instance_ != nullptr; } -void Engine::setConfig(std::string str) +void Engine::set_config(std::string str) { simgrid::config::set_parse(std::move(str)); } diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index 8c448a8811..efc4cc3864 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -30,7 +30,7 @@ simgrid::xbt::signal Host::onSpeedChange; Host::Host(const char* name) : name_(name) { xbt_assert(Host::by_name_or_null(name) == nullptr, "Refusing to create a second host named '%s'.", name); - Engine::getInstance()->host_register(std::string(name_), this); + Engine::get_instance()->host_register(std::string(name_), this); new simgrid::surf::HostImpl(this); } @@ -40,7 +40,7 @@ Host::~Host() delete pimpl_; if (pimpl_netpoint != nullptr) // not removed yet by a children class - simgrid::s4u::Engine::getInstance()->netpoint_unregister(pimpl_netpoint); + simgrid::s4u::Engine::get_instance()->netpoint_unregister(pimpl_netpoint); delete pimpl_cpu; delete mounts; } @@ -58,26 +58,26 @@ void Host::destroy() if (not currentlyDestroying_) { currentlyDestroying_ = true; onDestruction(*this); - Engine::getInstance()->host_unregister(std::string(name_)); + Engine::get_instance()->host_unregister(std::string(name_)); delete this; } } Host* Host::by_name(std::string name) { - return Engine::getInstance()->host_by_name(name); + return Engine::get_instance()->host_by_name(name); } Host* Host::by_name(const char* name) { - return Engine::getInstance()->host_by_name(std::string(name)); + return Engine::get_instance()->host_by_name(std::string(name)); } Host* Host::by_name_or_null(const char* name) { - return Engine::getInstance()->host_by_name_or_null(std::string(name)); + return Engine::get_instance()->host_by_name_or_null(std::string(name)); } Host* Host::by_name_or_null(std::string name) { - return Engine::getInstance()->host_by_name_or_null(name); + return Engine::get_instance()->host_by_name_or_null(name); } Host* Host::current() diff --git a/src/s4u/s4u_Netzone.cpp b/src/s4u/s4u_Netzone.cpp index e62b0afcde..d805c8c828 100644 --- a/src/s4u/s4u_Netzone.cpp +++ b/src/s4u/s4u_Netzone.cpp @@ -111,7 +111,7 @@ void NetZone::add_route(kernel::routing::NetPoint* /*src*/, kernel::routing::Net sg_netzone_t sg_zone_get_root() { - return simgrid::s4u::Engine::getInstance()->getNetRoot(); + return simgrid::s4u::Engine::get_instance()->getNetRoot(); } const char* sg_zone_get_name(sg_netzone_t netzone) @@ -121,7 +121,7 @@ const char* sg_zone_get_name(sg_netzone_t netzone) sg_netzone_t sg_zone_get_by_name(const char* name) { - return simgrid::s4u::Engine::getInstance()->getNetzoneByNameOrNull(name); + return simgrid::s4u::Engine::get_instance()->getNetzoneByNameOrNull(name); } void sg_zone_get_sons(sg_netzone_t netzone, xbt_dict_t whereto) diff --git a/src/s4u/s4u_Storage.cpp b/src/s4u/s4u_Storage.cpp index a4e08df8fc..2e5d37d57f 100644 --- a/src/s4u/s4u_Storage.cpp +++ b/src/s4u/s4u_Storage.cpp @@ -23,18 +23,18 @@ void XBT_ATTRIB_DEPRECATED_v322( "simgrid::s4u::getStorageList() is deprecated in favor of Engine::getAllStorages(). Please switch before v3.22") getStorageList(std::map* whereTo) { - for (auto const& s : simgrid::s4u::Engine::getInstance()->get_all_storages()) + for (auto const& s : simgrid::s4u::Engine::get_instance()->get_all_storages()) whereTo->insert({s->get_name(), s}); } Storage::Storage(std::string name, surf::StorageImpl* pimpl) : pimpl_(pimpl), name_(name) { - simgrid::s4u::Engine::getInstance()->storage_register(name, this); + simgrid::s4u::Engine::get_instance()->storage_register(name, this); } Storage* Storage::byName(std::string name) { - return Engine::getInstance()->storage_by_name_or_null(name); + return Engine::get_instance()->storage_by_name_or_null(name); } const std::string& Storage::get_name() const @@ -172,7 +172,7 @@ sg_storage_t sg_storage_get_by_name(const char* name) */ xbt_dynar_t sg_storages_as_dynar() { - std::vector storage_list = simgrid::s4u::Engine::getInstance()->get_all_storages(); + std::vector storage_list = simgrid::s4u::Engine::get_instance()->get_all_storages(); xbt_dynar_t res = xbt_dynar_new(sizeof(sg_storage_t), nullptr); for (auto const& s : storage_list) xbt_dynar_push(res, &s); diff --git a/src/simdag/sd_dotloader.cpp b/src/simdag/sd_dotloader.cpp index ddea1a77d0..29c5294248 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()->get_all_hosts(); + std::vector hosts = simgrid::s4u::Engine::get_instance()->get_all_hosts(); for (auto const& elm : computers) { SD_task_t previous_task = nullptr; diff --git a/src/simdag/sd_global.cpp b/src/simdag/sd_global.cpp index 81682d44d5..81c70e1b9c 100644 --- a/src/simdag/sd_global.cpp +++ b/src/simdag/sd_global.cpp @@ -200,7 +200,7 @@ void SD_config(const char *key, const char *value){ */ void SD_create_environment(const char *platform_file) { - simgrid::s4u::Engine::getInstance()->load_platform(platform_file); + simgrid::s4u::Engine::get_instance()->load_platform(platform_file); XBT_DEBUG("Host number: %zu, link number: %d", sg_host_count(), sg_link_count()); #if SIMGRID_HAVE_JEDULE diff --git a/src/simgrid/host.cpp b/src/simgrid/host.cpp index ad422c6b7a..c4e6ee1c85 100644 --- a/src/simgrid/host.cpp +++ b/src/simgrid/host.cpp @@ -21,7 +21,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sg_host, sd, "Logging specific to sg_hosts"); size_t sg_host_count() { - return simgrid::s4u::Engine::getInstance()->get_host_count(); + return simgrid::s4u::Engine::get_instance()->get_host_count(); } /** @brief Returns the host list * @@ -35,7 +35,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()->get_all_hosts(); + std::vector hosts = simgrid::s4u::Engine::get_instance()->get_all_hosts(); sg_host_t* res = (sg_host_t*)malloc(sizeof(sg_host_t) * hosts.size()); memcpy(res, hosts.data(), sizeof(sg_host_t) * hosts.size()); @@ -73,7 +73,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()->get_all_hosts(); + std::vector list = simgrid::s4u::Engine::get_instance()->get_all_hosts(); for (auto const& host : list) { if (host && host->pimpl_netpoint && host->pimpl_netpoint->is_host()) diff --git a/src/smpi/bindings/smpi_pmpi.cpp b/src/smpi/bindings/smpi_pmpi.cpp index 1409885a85..9028c78d38 100644 --- a/src/smpi/bindings/smpi_pmpi.cpp +++ b/src/smpi/bindings/smpi_pmpi.cpp @@ -28,7 +28,7 @@ void TRACE_smpi_set_category(const char *category) int PMPI_Init(int *argc, char ***argv) { - xbt_assert(simgrid::s4u::Engine::isInitialized(), + xbt_assert(simgrid::s4u::Engine::is_initialized(), "Your MPI program was not properly initialized. The easiest is to use smpirun to start it."); // PMPI_Init is called only once per SMPI process int already_init; diff --git a/src/smpi/internals/smpi_deployment.cpp b/src/smpi/internals/smpi_deployment.cpp index a3dbcef96e..4d800c374d 100644 --- a/src/smpi/internals/smpi_deployment.cpp +++ b/src/smpi/internals/smpi_deployment.cpp @@ -58,7 +58,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()->get_all_hosts(); + std::vector list = simgrid::s4u::Engine::get_instance()->get_all_hosts(); for (auto const& host : list) { host->extension_set(new simgrid::smpi::SmpiHost(host)); } diff --git a/src/surf/instr_routing.cpp b/src/surf/instr_routing.cpp index 835aee20f9..cfee5747b1 100644 --- a/src/surf/instr_routing.cpp +++ b/src/surf/instr_routing.cpp @@ -266,7 +266,7 @@ static void instr_routing_parse_end_platform () currentContainer.clear(); std::set* filter = new std::set; XBT_DEBUG ("Starting graph extraction."); - recursiveGraphExtraction(simgrid::s4u::Engine::getInstance()->getNetRoot(), simgrid::instr::Container::getRoot(), + recursiveGraphExtraction(simgrid::s4u::Engine::get_instance()->getNetRoot(), simgrid::instr::Container::getRoot(), filter); XBT_DEBUG ("Graph extraction finished."); delete filter; @@ -374,7 +374,7 @@ xbt_graph_t instr_routing_platform_graph () xbt_graph_t ret = xbt_graph_new_graph (0, nullptr); std::map* nodes = new std::map; std::map* edges = new std::map; - recursiveXBTGraphExtraction(ret, nodes, edges, simgrid::s4u::Engine::getInstance()->getNetRoot(), + recursiveXBTGraphExtraction(ret, nodes, edges, simgrid::s4u::Engine::get_instance()->getNetRoot(), simgrid::instr::Container::getRoot()); delete nodes; delete edges; diff --git a/src/surf/plugins/host_energy.cpp b/src/surf/plugins/host_energy.cpp index 7bf554eee9..b35157c4a4 100644 --- a/src/surf/plugins/host_energy.cpp +++ b/src/surf/plugins/host_energy.cpp @@ -424,7 +424,7 @@ static void onHostDestruction(simgrid::s4u::Host& host) static void onSimulationEnd() { - std::vector hosts = simgrid::s4u::Engine::getInstance()->get_all_hosts(); + std::vector hosts = simgrid::s4u::Engine::get_instance()->get_all_hosts(); double total_energy = 0.0; // Total energy consumption (whole platform) double used_hosts_energy = 0.0; // Energy consumed by hosts that computed something @@ -474,7 +474,7 @@ void sg_host_energy_plugin_init() void sg_host_energy_update_all() { simgrid::simix::kernelImmediate([]() { - std::vector list = simgrid::s4u::Engine::getInstance()->get_all_hosts(); + std::vector list = simgrid::s4u::Engine::get_instance()->get_all_hosts(); 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 dd39c53a05..e7eb0c64bb 100644 --- a/src/surf/plugins/link_energy.cpp +++ b/src/surf/plugins/link_energy.cpp @@ -162,7 +162,7 @@ static void onCommunicate(simgrid::kernel::resource::NetworkAction* action, simg static void onSimulationEnd() { - std::vector links = simgrid::s4u::Engine::getInstance()->get_all_links(); + std::vector links = simgrid::s4u::Engine::get_instance()->get_all_links(); 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 fae502ce36..2af42b8869 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -95,7 +95,7 @@ simgrid::kernel::routing::NetPoint* sg_platf_new_router(std::string name, const if (current_routing->hierarchy_ == simgrid::kernel::routing::NetZoneImpl::RoutingMode::unset) current_routing->hierarchy_ = simgrid::kernel::routing::NetZoneImpl::RoutingMode::base; - xbt_assert(nullptr == simgrid::s4u::Engine::getInstance()->getNetpointByNameOrNull(name), + xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->getNetpointByNameOrNull(name), "Refusing to create a router named '%s': this name already describes a node.", name.c_str()); simgrid::kernel::routing::NetPoint* netpoint = @@ -391,7 +391,7 @@ void sg_platf_new_mount(simgrid::kernel::routing::MountCreationArgs* mount) if (mount_list.empty()) XBT_DEBUG("Create a Mount list for %s", A_surfxml_host_id); - mount_list.insert({mount->name, simgrid::s4u::Engine::getInstance()->storage_by_name(mount->storageId)->getImpl()}); + mount_list.insert({mount->name, simgrid::s4u::Engine::get_instance()->storage_by_name(mount->storageId)->getImpl()}); } void sg_platf_new_route(simgrid::kernel::routing::RouteCreationArgs* route) @@ -414,7 +414,7 @@ void sg_platf_new_actor(simgrid::kernel::routing::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()->get_all_hosts(); + std::vector list = simgrid::s4u::Engine::get_instance()->get_all_hosts(); for (auto const& host : list) { msg += host->get_name(); @@ -602,9 +602,9 @@ simgrid::s4u::NetZone* sg_platf_new_Zone_begin(simgrid::kernel::routing::ZoneCre } if (current_routing == nullptr) { /* it is the first one */ - xbt_assert(simgrid::s4u::Engine::getInstance()->pimpl->netRoot_ == nullptr, + xbt_assert(simgrid::s4u::Engine::get_instance()->pimpl->netzone_root_ == nullptr, "All defined components must belong to a networking zone."); - simgrid::s4u::Engine::getInstance()->pimpl->netRoot_ = new_zone; + simgrid::s4u::Engine::get_instance()->pimpl->netzone_root_ = new_zone; } else { /* set the father behavior */ diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 6a709c7ad6..237c72d570 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -19,7 +19,7 @@ extern std::map storage_types; static void check_disk_attachment() { - for (auto const& s : simgrid::s4u::Engine::getInstance()->get_all_storages()) { + for (auto const& s : simgrid::s4u::Engine::get_instance()->get_all_storages()) { simgrid::kernel::routing::NetPoint* host_elm = sg_netpoint_by_name_or_null(s->getImpl()->getHost().c_str()); if (not host_elm) surf_parse_error(std::string("Unable to attach storage ") + s->get_cname() + ": host " + diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index 91c0d5a1ca..339cf0ac2c 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -58,13 +58,14 @@ void surf_parse_assert_netpoint(std::string hostname, std::string pre, std::stri std::string msg = pre + hostname + post + " Existing netpoints: \n"; - std::vector list; - simgrid::s4u::Engine::getInstance()->getNetpointList(&list); - std::sort(list.begin(), list.end(), [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) { - return a->get_name() < b->get_name(); - }); + std::vector netpoints = + simgrid::s4u::Engine::get_instance()->get_all_netpoints(); + std::sort(netpoints.begin(), netpoints.end(), + [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) { + return a->get_name() < b->get_name(); + }); bool first = true; - for (auto const& np : list) { + for (auto const& np : netpoints) { if (np->is_netzone()) continue; @@ -405,7 +406,7 @@ void STag_surfxml_prop() { if (ZONE_TAG) { // We need to retrieve the most recently opened zone XBT_DEBUG("Set zone property %s -> %s", A_surfxml_prop_id, A_surfxml_prop_value); - simgrid::s4u::NetZone* netzone = simgrid::s4u::Engine::getInstance()->getNetzoneByNameOrNull(A_surfxml_zone_id); + simgrid::s4u::NetZone* netzone = simgrid::s4u::Engine::get_instance()->getNetzoneByNameOrNull(A_surfxml_zone_id); netzone->setProperty(A_surfxml_prop_id, A_surfxml_prop_value); } else { diff --git a/teshsuite/s4u/storage_client_server/storage_client_server.cpp b/teshsuite/s4u/storage_client_server/storage_client_server.cpp index d02157f4a3..166d1341ec 100644 --- a/teshsuite/s4u/storage_client_server/storage_client_server.cpp +++ b/teshsuite/s4u/storage_client_server/storage_client_server.cpp @@ -91,7 +91,7 @@ static void get_set_storage_data(const std::string& storage_name) static void dump_platform_storages() { - std::vector storages = simgrid::s4u::Engine::getInstance()->get_all_storages(); + std::vector storages = simgrid::s4u::Engine::get_instance()->get_all_storages(); for (auto const& s : storages) { XBT_INFO("Storage %s is attached to %s", s->get_cname(), s->getHost()->get_cname()); diff --git a/teshsuite/simdag/flatifier/flatifier.cpp b/teshsuite/simdag/flatifier/flatifier.cpp index d21cf4d8cd..11e6ce78da 100644 --- a/teshsuite/simdag/flatifier/flatifier.cpp +++ b/teshsuite/simdag/flatifier/flatifier.cpp @@ -97,16 +97,16 @@ static void dump_links() static void dump_routers() { - std::vector netcardList; - simgrid::s4u::Engine::getInstance()->getNetpointList(&netcardList); - std::sort(netcardList.begin(), netcardList.end(), + std::vector netpoints = + simgrid::s4u::Engine::get_instance()->get_all_netpoints(); + std::sort(netpoints.begin(), netpoints.end(), [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) { return a->get_name() < b->get_name(); }); - for (auto const& srcCard : netcardList) - if (srcCard->is_router()) - std::printf(" \n", srcCard->get_cname()); + for (auto const& src : netpoints) + if (src->is_router()) + std::printf(" \n", src->get_cname()); } static void dump_routes() @@ -115,21 +115,21 @@ static void dump_routes() sg_host_t* hosts = sg_host_list(); std::sort(hosts, hosts + totalHosts, [](sg_host_t a, sg_host_t b) { return strcmp(sg_host_get_name(a), sg_host_get_name(b)) < 0; }); - std::vector netcardList; - simgrid::s4u::Engine::getInstance()->getNetpointList(&netcardList); - std::sort(netcardList.begin(), netcardList.end(), + std::vector netpoints = + simgrid::s4u::Engine::get_instance()->get_all_netpoints(); + std::sort(netpoints.begin(), netpoints.end(), [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) { return a->get_name() < b->get_name(); }); for (unsigned int it_src = 0; it_src < totalHosts; it_src++) { // Routes from host - simgrid::s4u::Host* host1 = hosts[it_src]; - simgrid::kernel::routing::NetPoint* netcardSrc = host1->pimpl_netpoint; + simgrid::s4u::Host* host1 = hosts[it_src]; + simgrid::kernel::routing::NetPoint* src = host1->pimpl_netpoint; for (unsigned int it_dst = 0; it_dst < totalHosts; it_dst++) { // Routes to host simgrid::s4u::Host* host2 = hosts[it_dst]; std::vector route; - simgrid::kernel::routing::NetPoint* netcardDst = host2->pimpl_netpoint; - simgrid::kernel::routing::NetZoneImpl::get_global_route(netcardSrc, netcardDst, route, nullptr); + simgrid::kernel::routing::NetPoint* dst = host2->pimpl_netpoint; + simgrid::kernel::routing::NetZoneImpl::get_global_route(src, dst, route, nullptr); if (not route.empty()) { std::printf(" \n ", host1->get_cname(), host2->get_cname()); for (auto const& link : route) @@ -138,11 +138,11 @@ static void dump_routes() } } - for (auto const& netcardDst : netcardList) { // to router - if (netcardDst->is_router()) { - std::printf(" \n ", host1->get_cname(), netcardDst->get_cname()); + for (auto const& dst : netpoints) { // to router + if (dst->is_router()) { + std::printf(" \n ", host1->get_cname(), dst->get_cname()); std::vector route; - simgrid::kernel::routing::NetZoneImpl::get_global_route(netcardSrc, netcardDst, route, nullptr); + simgrid::kernel::routing::NetZoneImpl::get_global_route(src, dst, route, nullptr); for (auto const& link : route) std::printf("", link->get_cname()); std::printf("\n \n"); @@ -150,9 +150,9 @@ static void dump_routes() } } - for (auto const& value1 : netcardList) { // Routes from router + for (auto const& value1 : netpoints) { // Routes from router if (value1->is_router()) { - for (auto const& value2 : netcardList) { // to router + for (auto const& value2 : netpoints) { // to router if (value2->is_router()) { std::printf(" \n ", value1->get_cname(), value2->get_cname()); std::vector route; diff --git a/teshsuite/simdag/is-router/is-router.cpp b/teshsuite/simdag/is-router/is-router.cpp index fbfd1dcd4d..8666fe792c 100644 --- a/teshsuite/simdag/is-router/is-router.cpp +++ b/teshsuite/simdag/is-router/is-router.cpp @@ -19,9 +19,9 @@ int main(int argc, char **argv) xbt_dynar_t hosts = sg_hosts_as_dynar(); std::printf("Host count: %zu, link number: %d\n", sg_host_count(), sg_link_count()); - std::vector netcardList; - simgrid::s4u::Engine::getInstance()->getNetpointList(&netcardList); - std::sort(netcardList.begin(), netcardList.end(), + std::vector netpoints = + simgrid::s4u::Engine::get_instance()->get_all_netpoints(); + std::sort(netpoints.begin(), netpoints.end(), [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) { return a->get_name() < b->get_name(); }); @@ -41,8 +41,8 @@ int main(int argc, char **argv) } xbt_dynar_free(&hosts); - std::printf("NetCards count: %zu\n", netcardList.size()); - for (auto const& nc : netcardList) + std::printf("NetCards count: %zu\n", netpoints.size()); + for (auto const& nc : netpoints) std::printf(" - Seen: \"%s\". Type: %s\n", nc->get_cname(), nc->is_router() ? "router" : (nc->is_netzone() ? "netzone" : (nc->is_host() ? "host" : "buggy"))); -- 2.20.1