X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8d9b5170925fd2a7873c619c5d6cdff8616f9bfc..62983a196bc73bd07ce7b780297fa51528822860:/src/surf/sg_platf.cpp diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index eef11b53d6..a0853f368e 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -63,15 +63,11 @@ void sg_platf_exit() /** @brief Add a host to the current NetZone */ void sg_platf_new_host(const simgrid::kernel::routing::HostCreationArgs* args) { - simgrid::s4u::Host* host = routing_get_current()->create_host(args->id, args->speed_per_pstate); + simgrid::s4u::Host* host = routing_get_current() + ->create_host(args->id, args->speed_per_pstate) + ->set_coordinates(args->coord) + ->set_properties(args->properties); - if (not args->coord.empty()) - new simgrid::kernel::routing::vivaldi::Coords(host->get_netpoint(), args->coord); - - if (args->properties) { - host->set_properties(*args->properties); - delete args->properties; - } host->get_impl()->set_disks(args->disks); host->pimpl_cpu->set_core_count(args->core_amount) @@ -87,7 +83,7 @@ void sg_platf_new_host(const simgrid::kernel::routing::HostCreationArgs* args) } /** @brief Add a "router" to the network element list */ -simgrid::kernel::routing::NetPoint* sg_platf_new_router(const std::string& name, const char* coords) +simgrid::kernel::routing::NetPoint* sg_platf_new_router(const std::string& name, const std::string& coords) { xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name), "Refusing to create a router named '%s': this name already describes a node.", name.c_str()); @@ -96,19 +92,18 @@ simgrid::kernel::routing::NetPoint* sg_platf_new_router(const std::string& name, netpoint->set_englobing_zone(current_routing); XBT_DEBUG("Router '%s' has the id %u", netpoint->get_cname(), netpoint->id()); - if (coords && strcmp(coords, "")) - new simgrid::kernel::routing::vivaldi::Coords(netpoint, coords); + if (not coords.empty()) + netpoint->set_coordinates(coords); return netpoint; } static void sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* args, const std::string& link_name) { - simgrid::s4u::Link* link = routing_get_current()->create_link(link_name, args->bandwidths); - if (args->properties) - link->set_properties(*args->properties); - - link->get_impl() // this call to get_impl saves some simcalls but can be removed + routing_get_current() + ->create_link(link_name, args->bandwidths) + ->set_properties(args->properties) + ->get_impl() // this call to get_impl saves some simcalls but can be removed ->set_sharing_policy(args->policy) ->set_state_profile(args->state_trace) ->set_latency_profile(args->latency_trace) @@ -125,7 +120,6 @@ void sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link) } else { sg_platf_new_link(link, link->id); } - delete link->properties; } void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster) @@ -157,9 +151,8 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster sg_platf_new_Zone_begin(&zone); auto* current_zone = static_cast(routing_get_current()); current_zone->parse_specific_arguments(cluster); - if (cluster->properties != nullptr) - for (auto const& elm : *cluster->properties) - current_zone->get_iface()->set_property(elm.first, elm.second); + for (auto const& elm : cluster->properties) + current_zone->get_iface()->set_property(elm.first, elm.second); if (cluster->loopback_bw > 0 || cluster->loopback_lat > 0) { current_zone->set_loopback(); @@ -169,16 +162,14 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster current_zone->set_limiter(); } - for (int const& i : *cluster->radicals) { + for (int const& i : cluster->radicals) { std::string host_id = std::string(cluster->prefix) + std::to_string(i) + cluster->suffix; XBT_DEBUG("", host_id.c_str(), cluster->speeds.front()); - simgrid::s4u::Host* host = - current_zone->create_host(host_id, cluster->speeds)->set_core_count(cluster->core_amount); - - if ((cluster->properties != nullptr) && (not cluster->properties->empty())) - host->set_properties(*cluster->properties); - host->seal(); + current_zone->create_host(host_id, cluster->speeds) + ->set_core_count(cluster->core_amount) + ->set_properties(cluster->properties) + ->seal(); XBT_DEBUG(""); @@ -196,12 +187,13 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster std::string loopback_name = link_id + "_loopback"; XBT_DEBUG("", loopback_name.c_str(), cluster->loopback_bw); - simgrid::s4u::Link* loopback = current_zone->create_link(loopback_name, std::vector{cluster->loopback_bw}) - ->set_sharing_policy(simgrid::s4u::Link::SharingPolicy::FATPIPE) - ->set_latency(cluster->loopback_lat) - ->seal(); + auto* loopback = current_zone->create_link(loopback_name, std::vector{cluster->loopback_bw}) + ->set_sharing_policy(simgrid::s4u::Link::SharingPolicy::FATPIPE) + ->set_latency(cluster->loopback_lat) + ->seal() + ->get_impl(); - current_zone->add_private_link_at(current_zone->node_pos(rankId), {loopback->get_impl(), loopback->get_impl()}); + current_zone->add_private_link_at(current_zone->node_pos(rankId), {loopback, loopback}); } // add a limiter link (shared link to account for maximal bandwidth of the node) @@ -209,11 +201,10 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster std::string limiter_name = std::string(link_id) + "_limiter"; XBT_DEBUG("", limiter_name.c_str(), cluster->limiter_link); - simgrid::s4u::Link* limiter = - current_zone->create_link(limiter_name, std::vector{cluster->limiter_link})->seal(); + auto* limiter = + current_zone->create_link(limiter_name, std::vector{cluster->limiter_link})->seal()->get_impl(); - current_zone->add_private_link_at(current_zone->node_pos_with_loopback(rankId), - {limiter->get_impl(), limiter->get_impl()}); + current_zone->add_private_link_at(current_zone->node_pos_with_loopback(rankId), {limiter, limiter}); } // call the cluster function that adds the others links @@ -224,33 +215,31 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster } rankId++; } - delete cluster->properties; // Add a router. XBT_DEBUG(" "); XBT_DEBUG("", cluster->router_id.c_str()); if (cluster->router_id.empty()) cluster->router_id = std::string(cluster->prefix) + cluster->id + "_router" + cluster->suffix; - current_zone->set_router(sg_platf_new_router(cluster->router_id, nullptr)); + current_zone->set_router(sg_platf_new_router(cluster->router_id, "")); // Make the backbone if ((cluster->bb_bw > 0) || (cluster->bb_lat > 0)) { - std::string backbone_name = std::string(cluster->id) + "_backbone"; - XBT_DEBUG("", backbone_name.c_str(), cluster->bb_bw, cluster->bb_lat); - - simgrid::s4u::Link* backbone = current_zone->create_link(backbone_name, std::vector{cluster->bb_bw}) - ->set_sharing_policy(cluster->bb_sharing_policy) - ->set_latency(cluster->bb_lat) - ->seal(); - - routing_cluster_add_backbone(backbone->get_impl()); + std::string bb_name = std::string(cluster->id) + "_backbone"; + XBT_DEBUG(" ", bb_name.c_str(), cluster->bb_bw, + cluster->bb_lat); + + auto* backbone = current_zone->create_link(bb_name, std::vector{cluster->bb_bw}) + ->set_sharing_policy(cluster->bb_sharing_policy) + ->set_latency(cluster->bb_lat) + ->seal(); + current_zone->set_backbone(backbone->get_impl()); } XBT_DEBUG(""); sg_platf_new_Zone_seal(); simgrid::kernel::routing::on_cluster_creation(*cluster); - delete cluster->radicals; } void routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl* bb) @@ -266,40 +255,26 @@ void routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl* bb) void sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet) { - for (int const& radical : *cabinet->radicals) { - std::string hostname = cabinet->prefix + std::to_string(radical) + cabinet->suffix; - simgrid::kernel::routing::HostCreationArgs host; - host.pstate = 0; - host.core_amount = 1; - host.id = hostname; - host.speed_per_pstate.push_back(cabinet->speed); - sg_platf_new_host(&host); - - simgrid::kernel::routing::LinkCreationArgs link; - link.policy = simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX; - link.latency = cabinet->lat; - link.bandwidths.push_back(cabinet->bw); - link.id = "link_" + hostname; - sg_platf_new_link(&link); - - simgrid::kernel::routing::HostLinkCreationArgs host_link; - host_link.id = hostname; - host_link.link_up = std::string("link_") + hostname + "_UP"; - host_link.link_down = std::string("link_") + hostname + "_DOWN"; - sg_platf_new_hostlink(&host_link); + auto* zone = static_cast(routing_get_current()); + for (int const& radical : cabinet->radicals) { + std::string id = cabinet->prefix + std::to_string(radical) + cabinet->suffix; + simgrid::s4u::Host* host = zone->create_host(id, std::vector{cabinet->speed})->seal(); + + simgrid::s4u::Link* link_up = + zone->create_link("link_" + id + "_UP", std::vector{cabinet->bw})->set_latency(cabinet->lat)->seal(); + simgrid::s4u::Link* link_down = + zone->create_link("link_" + id + "_DOWN", std::vector{cabinet->bw})->set_latency(cabinet->lat)->seal(); + + zone->add_private_link_at(host->get_netpoint()->id(), {link_up->get_impl(), link_down->get_impl()}); } - delete cabinet->radicals; } simgrid::kernel::resource::DiskImpl* sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk) { - simgrid::kernel::resource::DiskImpl* pimpl = - routing_get_current()->create_disk(disk->id, disk->read_bw, disk->write_bw)->get_impl(); - - if (disk->properties) { - pimpl->set_properties(*disk->properties); - delete disk->properties; - } + simgrid::kernel::resource::DiskImpl* pimpl = routing_get_current() + ->create_disk(disk->id, disk->read_bw, disk->write_bw) + ->set_properties(disk->properties) + ->get_impl(); pimpl->seal(); simgrid::s4u::Disk::on_creation(*pimpl->get_iface()); @@ -349,20 +324,21 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor) std::string actor_name = actor->args[0]; simgrid::kernel::actor::ActorCode code = factory(std::move(actor->args)); - std::shared_ptr> properties(actor->properties); - auto* arg = - new simgrid::kernel::actor::ProcessArg(actor_name, code, nullptr, host, kill_time, properties, auto_restart); + auto* arg = new simgrid::kernel::actor::ProcessArg(actor_name, code, nullptr, host, kill_time, actor->properties, + auto_restart); host->get_impl()->add_actor_at_boot(arg); if (start_time > SIMIX_get_clock()) { - arg = new simgrid::kernel::actor::ProcessArg(actor_name, code, nullptr, host, kill_time, properties, auto_restart); + arg = new simgrid::kernel::actor::ProcessArg(actor_name, code, nullptr, host, kill_time, actor->properties, + auto_restart); XBT_DEBUG("Process %s@%s will be started at time %f", arg->name.c_str(), arg->host->get_cname(), start_time); simgrid::simix::Timer::set(start_time, [arg, auto_restart]() { - simgrid::kernel::actor::ActorImplPtr new_actor = simgrid::kernel::actor::ActorImpl::create( - arg->name.c_str(), arg->code, arg->data, arg->host, arg->properties.get(), nullptr); + simgrid::kernel::actor::ActorImplPtr new_actor = + simgrid::kernel::actor::ActorImpl::create(arg->name.c_str(), arg->code, arg->data, arg->host, nullptr); + new_actor->set_properties(arg->properties); if (arg->kill_time >= 0) new_actor->set_kill_time(arg->kill_time); if (auto_restart) @@ -374,8 +350,8 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor) try { simgrid::kernel::actor::ActorImplPtr new_actor = nullptr; - new_actor = simgrid::kernel::actor::ActorImpl::create(arg->name.c_str(), code, nullptr, host, - arg->properties.get(), nullptr); + new_actor = simgrid::kernel::actor::ActorImpl::create(arg->name.c_str(), code, nullptr, host, nullptr); + new_actor->set_properties(arg->properties); /* The actor creation will fail if the host is currently dead, but that's fine */ if (arg->kill_time >= 0) new_actor->set_kill_time(arg->kill_time); @@ -394,13 +370,12 @@ void sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer) simgrid::s4u::Host* host = zone->create_host(peer->id, std::vector{peer->speed}) ->set_state_profile(peer->state_trace) - ->set_speed_profile(peer->speed_trace); + ->set_speed_profile(peer->speed_trace) + ->set_coordinates(peer->coord) + ->seal(); - zone->set_peer_link(host->get_netpoint(), peer->bw_in, peer->bw_out, peer->coord); - - host->seal(); + zone->set_peer_link(host->get_netpoint(), peer->bw_in, peer->bw_out); } - /** * @brief Auxiliary function to build the object NetZoneImpl * @@ -472,12 +447,11 @@ simgrid::kernel::routing::NetZoneImpl* sg_platf_new_Zone_begin(const simgrid::ke return new_zone; } -void sg_platf_new_Zone_set_properties(const std::unordered_map* props) +void sg_platf_new_Zone_set_properties(const std::unordered_map& props) { xbt_assert(current_routing, "Cannot set properties of the current Zone: none under construction"); - if (props) - current_routing->set_properties(*props); + current_routing->set_properties(props); } /**