NetZoneImpl* get_englobing_zone() { return englobing_zone_; }
/** @brief Set the NetZone in which this NetPoint is included */
NetPoint* set_englobing_zone(NetZoneImpl* netzone_p);
+ NetPoint* set_coordinates(const std::string& coords);
bool is_netzone() const { return component_type_ == Type::NetZone; }
bool is_host() const { return component_type_ == Type::Host; }
class XBT_PRIVATE VivaldiZone : public ClusterZone {
public:
using ClusterZone::ClusterZone;
- void set_peer_link(NetPoint* netpoint, double bw_in, double bw_out, const std::string& coord);
+ void set_peer_link(NetPoint* netpoint, double bw_in, double bw_out);
void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override;
};
int get_pstate() const;
double get_pstate_speed(int pstate_index) const;
Host* set_pstate(int pstate_index);
+ Host* set_coordinates(const std::string& coords);
std::vector<Disk*> get_disks() const;
/**
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "simgrid/kernel/routing/NetPoint.hpp"
+#include "simgrid/kernel/routing/VivaldiZone.hpp"
#include "simgrid/s4u/Engine.hpp"
#include "simgrid/s4u/Host.hpp"
#include "xbt/log.h"
return this;
}
+NetPoint* NetPoint::set_coordinates(const std::string& coords)
+{
+ new vivaldi::Coords(this, coords);
+ return this;
+}
} // namespace routing
} // namespace kernel
} // namespace simgrid
return &coords->coords;
}
-void VivaldiZone::set_peer_link(NetPoint* netpoint, double bw_in, double bw_out, const std::string& coord)
+void VivaldiZone::set_peer_link(NetPoint* netpoint, double bw_in, double bw_out)
{
xbt_assert(netpoint->get_englobing_zone() == this,
"Cannot add a peer link to a netpoint that is not in this netzone");
- new vivaldi::Coords(netpoint, coord);
-
std::string link_up = "link_" + netpoint->get_name() + "_UP";
std::string link_down = "link_" + netpoint->get_name() + "_DOWN";
resource::LinkImpl* linkUp = get_network_model()->create_link(link_up, std::vector<double>(1, bw_out));
return this->pimpl_cpu->get_pstate();
}
+Host* Host::set_coordinates(const std::string& coords)
+{
+ if (not coords.empty())
+ kernel::actor::simcall([this, coords] { this->pimpl_netpoint_->set_coordinates(coords); });
+ return this;
+}
std::vector<Disk*> Host::get_disks() const
{
return this->pimpl_->get_disks();
/** @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);
-
- if (not args->coord.empty())
- new simgrid::kernel::routing::vivaldi::Coords(host->get_netpoint(), args->coord);
+ simgrid::s4u::Host* host =
+ routing_get_current()->create_host(args->id, args->speed_per_pstate)->set_coordinates(args->coord);
if (args->properties) {
host->set_properties(*args->properties);
}
/** @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());
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;
}
XBT_DEBUG("<router id=\"%s\"/>", 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)) {
simgrid::s4u::Host* host = zone->create_host(peer->id, std::vector<double>{peer->speed})
->set_state_profile(peer->state_trace)
- ->set_speed_profile(peer->speed_trace);
-
- zone->set_peer_link(host->get_netpoint(), peer->bw_in, peer->bw_out, peer->coord);
+ ->set_speed_profile(peer->speed_trace)
+ ->set_coordinates(peer->coord)
+ ->seal();
- host->seal();
+ zone->set_peer_link(host->get_netpoint(), peer->bw_in, peer->bw_out);
}
-
/**
* @brief Auxiliary function to build the object NetZoneImpl
*
XBT_PUBLIC void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* clust); // Add a cluster to the current Zone
XBT_PUBLIC void
sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet); // Add a cabinet 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 char* coords);
+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_route(simgrid::kernel::routing::RouteCreationArgs* route); // Add a route
XBT_PUBLIC void sg_platf_new_bypassRoute(simgrid::kernel::routing::RouteCreationArgs* bypassroute); // Add a bypassRoute