X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8e70d54a095cd7779a53c7a164f775f7a37b29e5..5843ccab4e336d47ca34f54e68760ac78d242f36:/src/kernel/xml/sg_platf.cpp diff --git a/src/kernel/xml/sg_platf.cpp b/src/kernel/xml/sg_platf.cpp index 95a9638bc7..d953e005ab 100644 --- a/src/kernel/xml/sg_platf.cpp +++ b/src/kernel/xml/sg_platf.cpp @@ -3,6 +3,8 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +/* This file implements the public API to platform parsing */ + #include #include #include @@ -18,20 +20,32 @@ #include #include -#include "simgrid/sg_config.hpp" #include "src/kernel/EngineImpl.hpp" #include "src/kernel/resource/DiskImpl.hpp" #include "src/kernel/resource/HostImpl.hpp" +#include "src/kernel/resource/StandardLinkImpl.hpp" #include "src/kernel/resource/profile/Profile.hpp" #include "src/kernel/xml/platf.hpp" #include "src/kernel/xml/platf_private.hpp" -#include "src/surf/surf_interface.hpp" +#include "src/simgrid/sg_config.hpp" #include #include XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(platf_parse); +/* This function acts as a main in the parsing area. */ +void parse_platform_file(const std::string& file) +{ + /* init the flex parser */ + simgrid_parse_open(file); + + /* Do the actual parsing */ + simgrid_parse(true); + + simgrid_parse_close(); +} + namespace simgrid::kernel::routing { xbt::signal on_cluster_creation; } // namespace simgrid::kernel::routing @@ -135,7 +149,7 @@ void sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk) /*************************************************************************************************/ /** @brief Auxiliary function to create hosts */ -static std::pair +static simgrid::s4u::Host* sg_platf_cluster_create_host(const simgrid::kernel::routing::ClusterCreationArgs* cluster, simgrid::s4u::NetZone* zone, const std::vector& /*coord*/, unsigned long id) { @@ -146,11 +160,10 @@ sg_platf_cluster_create_host(const simgrid::kernel::routing::ClusterCreationArgs std::string host_id = cluster->prefix + std::to_string(cluster->radicals[id]) + cluster->suffix; XBT_DEBUG("Cluster: creating host=%s speed=%f", host_id.c_str(), cluster->speeds.front()); - const simgrid::s4u::Host* host = zone->create_host(host_id, cluster->speeds) - ->set_core_count(cluster->core_amount) - ->set_properties(cluster->properties) - ->seal(); - return std::make_pair(host->get_netpoint(), nullptr); + simgrid::s4u::Host* host = zone->create_host(host_id, cluster->speeds) + ->set_core_count(cluster->core_amount) + ->set_properties(cluster->properties); + return host; } /** @brief Auxiliary function to create loopback links */ @@ -196,7 +209,8 @@ static void sg_platf_new_cluster_hierarchical(const simgrid::kernel::routing::Cl using simgrid::kernel::routing::FatTreeZone; using simgrid::kernel::routing::TorusZone; - auto set_host = std::bind(sg_platf_cluster_create_host, cluster, _1, _2, _3); + std::function set_host = + std::bind(sg_platf_cluster_create_host, cluster, _1, _2, _3); std::function set_loopback{}; std::function set_limiter{}; @@ -279,8 +293,7 @@ static void sg_platf_new_cluster_flat(simgrid::kernel::routing::ClusterCreationA ->set_latency(cluster->loopback_lat) ->seal(); - zone->add_route(host->get_netpoint(), host->get_netpoint(), nullptr, nullptr, - {simgrid::s4u::LinkInRoute(loopback)}); + zone->add_route(host, host, {simgrid::s4u::LinkInRoute(loopback)}); } // add a limiter link (shared link to account for maximal bandwidth of the node) @@ -308,7 +321,7 @@ static void sg_platf_new_cluster_flat(simgrid::kernel::routing::ClusterCreationA if (backbone) links.emplace_back(backbone); - zone->add_route(host->get_netpoint(), nullptr, nullptr, nullptr, links, true); + zone->add_route(host, nullptr, links, true); } // Add a router. @@ -316,8 +329,7 @@ static void sg_platf_new_cluster_flat(simgrid::kernel::routing::ClusterCreationA XBT_DEBUG("", cluster->router_id.c_str()); if (cluster->router_id.empty()) cluster->router_id = cluster->prefix + cluster->id + "_router" + cluster->suffix; - auto* router = zone->create_router(cluster->router_id); - zone->add_route(router, nullptr, nullptr, nullptr, {}); + zone->create_router(cluster->router_id); simgrid::kernel::routing::on_cluster_creation(*cluster); } @@ -360,12 +372,12 @@ static void sg_platf_build_hostlink(simgrid::kernel::routing::StarZone* zone, const simgrid::kernel::routing::HostLinkCreationArgs* hostlink, const simgrid::s4u::Link* backbone) { - const auto engine = simgrid::s4u::Engine::get_instance(); - auto netpoint = engine->host_by_name(hostlink->id)->get_netpoint(); + const auto* engine = simgrid::s4u::Engine::get_instance(); + auto* netpoint = engine->host_by_name(hostlink->id)->get_netpoint(); xbt_assert(netpoint, "Host '%s' not found!", hostlink->id.c_str()); - const auto linkUp = engine->link_by_name_or_null(hostlink->link_up); - const auto linkDown = engine->link_by_name_or_null(hostlink->link_down); + const auto* linkUp = engine->link_by_name_or_null(hostlink->link_up); + const auto* linkDown = engine->link_by_name_or_null(hostlink->link_down); xbt_assert(linkUp, "Link '%s' not found!", hostlink->link_up.c_str()); xbt_assert(linkDown, "Link '%s' not found!", hostlink->link_down.c_str());