From cf6a1d5f1eddea2b377415ab57c5185058488269 Mon Sep 17 00:00:00 2001 From: Bruno Donassolo Date: Mon, 10 May 2021 18:17:22 +0200 Subject: [PATCH] Fix lua compilation Get code back to sg_platf since it's used by lua_platf.cpp --- src/bindings/lua/lua_platf.cpp | 17 ++++++------- src/surf/sg_platf.cpp | 45 +++++++++++++++++++++++++++------ src/surf/xml/platf_private.hpp | 8 +++++- src/surf/xml/surfxml_sax_cb.cpp | 17 +++---------- 4 files changed, 55 insertions(+), 32 deletions(-) diff --git a/src/bindings/lua/lua_platf.cpp b/src/bindings/lua/lua_platf.cpp index d569454e88..48dface9c1 100644 --- a/src/bindings/lua/lua_platf.cpp +++ b/src/bindings/lua/lua_platf.cpp @@ -79,7 +79,7 @@ int console_close(lua_State*) } int console_add_backbone(lua_State *L) { - simgrid::kernel::routing::LinkCreationArgs link; + auto link = std::make_unique(); lua_Debug ar; lua_getstack(L, 1, &ar); lua_getinfo(L, "Sl", &ar); @@ -89,33 +89,32 @@ int console_add_backbone(lua_State *L) { lua_pushstring(L, "id"); int type = lua_gettable(L, -2); lua_ensure(type == LUA_TSTRING, "Attribute 'id' must be specified for backbone and must be a string."); - link.id = lua_tostring(L, -1); + link->id = lua_tostring(L, -1); lua_pop(L, 1); lua_pushstring(L, "bandwidth"); type = lua_gettable(L, -2); lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER, "Attribute 'bandwidth' must be specified for backbone and must either be a string (in the right format; see docs) or a number."); - link.bandwidths.push_back(xbt_parse_get_bandwidth(ar.short_src, ar.currentline, lua_tostring(L, -1), - "bandwidth of backbone", link.id.c_str())); + link->bandwidths.push_back(xbt_parse_get_bandwidth(ar.short_src, ar.currentline, lua_tostring(L, -1), + "bandwidth of backbone", link->id.c_str())); lua_pop(L, 1); lua_pushstring(L, "lat"); type = lua_gettable(L, -2); lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER, "Attribute 'lat' must be specified for backbone and must either be a string (in the right format; see docs) or a number."); - link.latency = - xbt_parse_get_time(ar.short_src, ar.currentline, lua_tostring(L, -1), "latency of backbone", link.id.c_str()); + link->latency = + xbt_parse_get_time(ar.short_src, ar.currentline, lua_tostring(L, -1), "latency of backbone", link->id.c_str()); lua_pop(L, 1); lua_pushstring(L, "sharing_policy"); lua_gettable(L, -2); const char* policy = lua_tostring(L, -1); lua_pop(L, 1); - link.policy = link_policy_get_by_name(policy); + link->policy = link_policy_get_by_name(policy); - sg_platf_new_link(&link); - routing_cluster_add_backbone(simgrid::s4u::Link::by_name(link.id)->get_impl()); + routing_cluster_add_backbone(std::move(link)); return 0; } diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 021a989fdb..7b72b44ea9 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -38,6 +38,9 @@ xbt::signal on_cluster_creation; } // namespace kernel } // namespace simgrid +simgrid::kernel::routing::ClusterZoneCreationArgs + zone_cluster; /* temporary store data for irregular clusters, created with */ + /** The current NetZone in the parsing */ static simgrid::kernel::routing::NetZoneImpl* current_routing = nullptr; static simgrid::kernel::routing::NetZoneImpl* routing_get_current() @@ -374,9 +377,9 @@ static void sg_platf_cluster_set_hostlink(simgrid::kernel::routing::StarZone* zo } /** @brief Add a link connecting a host to the rest of its StarZone */ -static void sg_platf_new_hostlink(simgrid::kernel::routing::StarZone* zone, - const simgrid::kernel::routing::HostLinkCreationArgs* hostlink, - simgrid::kernel::resource::LinkImpl* backbone) +static void sg_platf_build_hostlink(simgrid::kernel::routing::StarZone* zone, + const simgrid::kernel::routing::HostLinkCreationArgs* hostlink, + simgrid::kernel::resource::LinkImpl* backbone) { simgrid::kernel::routing::NetPoint* netpoint = simgrid::s4u::Host::by_name(hostlink->id)->get_netpoint(); xbt_assert(netpoint, "Host '%s' not found!", hostlink->id.c_str()); @@ -390,9 +393,9 @@ static void sg_platf_new_hostlink(simgrid::kernel::routing::StarZone* zone, } /** @brief Create a cabinet (set of hosts) inside a Cluster(StarZone) */ -static void sg_platf_new_cabinet(simgrid::kernel::routing::StarZone* zone, - const simgrid::kernel::routing::CabinetCreationArgs* args, - simgrid::kernel::resource::LinkImpl* backbone) +static void sg_platf_build_cabinet(simgrid::kernel::routing::StarZone* zone, + const simgrid::kernel::routing::CabinetCreationArgs* args, + simgrid::kernel::resource::LinkImpl* backbone) { for (int const& radical : args->radicals) { std::string id = args->prefix + std::to_string(radical) + args->suffix; @@ -421,15 +424,26 @@ void sg_platf_zone_cluster_populate(simgrid::kernel::routing::ClusterZoneCreatio /* create host_links for hosts */ for (auto const& hostlink : cluster->host_links) { - sg_platf_new_hostlink(zone, &hostlink, backbone); + sg_platf_build_hostlink(zone, &hostlink, backbone); } /* create cabinets */ for (auto const& cabinet : cluster->cabinets) { - sg_platf_new_cabinet(zone, &cabinet, backbone); + sg_platf_build_cabinet(zone, &cabinet, backbone); } } +void routing_cluster_add_backbone(std::unique_ptr link) +{ + zone_cluster.backbone = std::move(link); +} + +void sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* args) +{ + xbt_assert(args, "Invalid nullptr argument"); + zone_cluster.cabinets.emplace_back(*args); +} + /*************************************************************************************************/ void sg_platf_new_route(simgrid::kernel::routing::RouteCreationArgs* route) { @@ -562,6 +576,7 @@ sg_platf_create_zone(const simgrid::kernel::routing::ZoneCreationArgs* zone) */ simgrid::kernel::routing::NetZoneImpl* sg_platf_new_Zone_begin(const simgrid::kernel::routing::ZoneCreationArgs* zone) { + zone_cluster.routing = zone->routing; current_routing = sg_platf_create_zone(zone); return current_routing; @@ -583,10 +598,24 @@ void sg_platf_new_Zone_set_properties(const std::unordered_mapseal(); current_routing = current_routing->get_parent(); } +/** @brief Add a link connecting a host to the rest of its Zone (which must be cluster or vivaldi) */ +void sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* hostlink) +{ + xbt_assert(hostlink, "Invalid nullptr parameter"); + zone_cluster.host_links.emplace_back(*hostlink); +} + void sg_platf_new_trace(simgrid::kernel::routing::ProfileCreationArgs* args) { simgrid::kernel::profile::Profile* profile; diff --git a/src/surf/xml/platf_private.hpp b/src/surf/xml/platf_private.hpp index fbe530cb4b..6c0c475a4c 100644 --- a/src/surf/xml/platf_private.hpp +++ b/src/surf/xml/platf_private.hpp @@ -121,6 +121,7 @@ public: class ClusterZoneCreationArgs { public: + std::string routing; std::vector host_links; std::vector cabinets; std::unique_ptr backbone; @@ -174,6 +175,8 @@ extern XBT_PRIVATE xbt::signal on_cluster_crea } // namespace kernel } // namespace simgrid +/********** Routing **********/ +void routing_cluster_add_backbone(std::unique_ptr link); /*** END of the parsing cruft ***/ XBT_PUBLIC simgrid::kernel::routing::NetZoneImpl* @@ -186,6 +189,8 @@ sg_platf_new_host_begin(const simgrid::kernel::routing::HostCreationArgs* host); XBT_PUBLIC void sg_platf_new_host_set_properties(const std::unordered_map& props); XBT_PUBLIC void sg_platf_new_host_seal(int pstate); // That Host is fully described +XBT_PUBLIC void +sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* h); // Add a host_link to the current Zone XBT_PUBLIC void sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link); // Add a link to the current Zone XBT_PUBLIC void @@ -198,7 +203,8 @@ XBT_PUBLIC void sg_platf_zone_cluster_populate( simgrid::kernel::routing::ClusterZoneCreationArgs* clust); // Add a routing cluster to the current Zone XBT_PUBLIC simgrid::kernel::routing::NetPoint* // Add a router to the current Zone sg_platf_new_router(const std::string&, const std::string& coords); - +XBT_PUBLIC void +sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet); // Add a cabinet to the current Zone XBT_PUBLIC void sg_platf_new_route(simgrid::kernel::routing::RouteCreationArgs* route); // Add a route XBT_PUBLIC void sg_platf_new_bypassRoute(simgrid::kernel::routing::RouteCreationArgs* bypassroute); // Add a bypassRoute diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index 1f66a8acad..fc31b33291 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -30,8 +30,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_parse, surf, "Logging specific to the SURF std::string surf_parsed_filename; // Currently parsed file (for the error messages) std::vector parsed_link_list; /* temporary store of current link list of a route */ -simgrid::kernel::routing::ClusterZoneCreationArgs - zone_cluster; /* temporary store data for irregular clusters, created with */ /* Helping functions */ void surf_parse_assert(bool cond, const std::string& msg) @@ -292,7 +290,7 @@ void STag_surfxml_host___link(){ host_link.id = A_surfxml_host___link_id; host_link.link_up = A_surfxml_host___link_up; host_link.link_down = A_surfxml_host___link_down; - zone_cluster.host_links.emplace_back(host_link); + sg_platf_new_hostlink(&host_link); } void STag_surfxml_router(){ @@ -400,7 +398,7 @@ void STag_surfxml_cabinet(){ cabinet.id.c_str()); explodesRadical(A_surfxml_cabinet_radical, &cabinet.radicals); - zone_cluster.cabinets.emplace_back(cabinet); + sg_platf_new_cabinet(&cabinet); } void STag_surfxml_peer(){ @@ -526,7 +524,7 @@ void ETag_surfxml_backbone() "latency of backbone", link->id.c_str()); link->policy = simgrid::s4u::Link::SharingPolicy::SHARED; - zone_cluster.backbone = std::move(link); + routing_cluster_add_backbone(std::move(link)); } void STag_surfxml_route(){ @@ -704,21 +702,12 @@ void STag_surfxml_zone() zone.id = A_surfxml_zone_id; zone.routing = A_surfxml_zone_routing; sg_platf_new_Zone_begin(&zone); - /* new cluster zone, clear temp structures */ - if (strcasecmp(A_surfxml_zone_routing, "Cluster") == 0) { - zone_cluster.host_links.clear(); - zone_cluster.cabinets.clear(); - zone_cluster.backbone.reset(); - } } void ETag_surfxml_zone() { sg_platf_new_Zone_set_properties(property_sets.back()); property_sets.pop_back(); - if (strcasecmp(A_surfxml_zone_routing, "Cluster") == 0) { - sg_platf_zone_cluster_populate(&zone_cluster); - } sg_platf_new_Zone_seal(); } -- 2.20.1