X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/13bf12b18f191192a6ba4f0ef5452b88986aa88f..445e892abe9e2f84dc82d712f9d5f97081530d59:/src/surf/sg_platf.cpp diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 2cc3b1744f..fa37309f1d 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -96,28 +96,26 @@ void sg_platf_new_host(sg_platf_host_cbarg_t args) } /** @brief Add a "router" to the network element list */ -void sg_platf_new_router(sg_platf_router_cbarg_t router) +simgrid::kernel::routing::NetCard* sg_platf_new_router(const char* name, const char* coords) { simgrid::kernel::routing::NetZoneImpl* current_routing = routing_get_current(); 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::instance()->netcardByNameOrNull(router->id), - "Refusing to create a router named '%s': this name already describes a node.", router->id); + xbt_assert(nullptr == simgrid::s4u::Engine::instance()->netcardByNameOrNull(name), + "Refusing to create a router named '%s': this name already describes a node.", name); simgrid::kernel::routing::NetCard* netcard = - new simgrid::kernel::routing::NetCard(router->id, simgrid::kernel::routing::NetCard::Type::Router, current_routing); - XBT_DEBUG("Router '%s' has the id %d", router->id, netcard->id()); + new simgrid::kernel::routing::NetCard(name, simgrid::kernel::routing::NetCard::Type::Router, current_routing); + XBT_DEBUG("Router '%s' has the id %d", name, netcard->id()); - if (router->coord && strcmp(router->coord, "")) - new simgrid::kernel::routing::vivaldi::Coords(netcard, router->coord); - - auto cluster = dynamic_cast(current_routing); - if(cluster != nullptr) - cluster->router_ = simgrid::s4u::Engine::instance()->netcardByNameOrNull(router->id); + if (coords && strcmp(coords, "")) + new simgrid::kernel::routing::vivaldi::Coords(netcard, coords); if (TRACE_is_enabled() && TRACE_needs_platform()) - sg_instr_new_router(router); + sg_instr_new_router(name, coords); + + return netcard; } void sg_platf_new_link(sg_platf_link_cbarg_t link){ @@ -280,19 +278,16 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster) rankId++; } - // Add a router. It is magically used thanks to the way in which surf_routing_cluster is written, - // and it's very useful to connect clusters together + // Add a router. XBT_DEBUG(" "); XBT_DEBUG("", cluster->router_id); - char *newid = nullptr; - s_sg_platf_router_cbarg_t router; - memset(&router, 0, sizeof(router)); - router.id = cluster->router_id; - if (!router.id || !strcmp(router.id, "")) - router.id = newid = bprintf("%s%s_router%s", cluster->prefix, cluster->id, cluster->suffix); - sg_platf_new_router(&router); - current_as->router_ = simgrid::s4u::Engine::instance()->netcardByNameOrNull(router.id); - free(newid); + if (!cluster->router_id || !strcmp(cluster->router_id, "")) { + char* newid = bprintf("%s%s_router%s", cluster->prefix, cluster->id, cluster->suffix); + current_as->router_ = sg_platf_new_router(newid, NULL); + free(newid); + } else { + current_as->router_ = sg_platf_new_router(cluster->router_id, NULL); + } //Make the backbone if ((cluster->bb_bw != 0) || (cluster->bb_lat != 0)) { @@ -557,7 +552,7 @@ void sg_platf_new_process(sg_platf_process_cbarg_t process) void sg_platf_new_peer(sg_platf_peer_cbarg_t peer) { simgrid::kernel::routing::VivaldiZone* as = dynamic_cast(current_routing); - xbt_assert(as, " tag can only be used in Vivaldi ASes"); + xbt_assert(as, " tag can only be used in Vivaldi netzones."); std::vector speedPerPstate; speedPerPstate.push_back(peer->speed);