protected:
friend simgrid::kernel::routing::NetZoneImpl;
- explicit NetZone(NetZone * father, const char* name);
+ explicit NetZone(NetZone * father, std::string name);
virtual ~NetZone();
public:
/** @brief Seal your netzone once you're done adding content, and before routing stuff through it */
virtual void seal();
- char* getCname();
+ const char* getCname();
NetZone* getFather();
std::vector<NetZone*>* getChildren(); // Sub netzones
std::unordered_map<std::string, std::string> properties_;
NetZone* father_ = nullptr;
- char* name_ = nullptr;
+ std::string name_;
bool sealed_ = false; // We cannot add more content when sealed
}
int console_AS_seal(lua_State *L) {
XBT_DEBUG("Sealing AS");
- sg_platf_new_AS_seal();
+ sg_platf_new_Zone_seal();
return 0;
}
namespace simgrid {
namespace kernel {
namespace routing {
-ClusterZone::ClusterZone(NetZone* father, const char* name) : NetZoneImpl(father, name)
+ClusterZone::ClusterZone(NetZone* father, std::string name) : NetZoneImpl(father, name)
{
}
class XBT_PRIVATE ClusterZone : public NetZoneImpl {
public:
- explicit ClusterZone(NetZone* father, const char* name);
+ explicit ClusterZone(NetZone* father, std::string name);
void getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_t into, double* latency) override;
void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) override;
/* Creation routing model functions */
-DijkstraZone::DijkstraZone(NetZone* father, const char* name, bool cached) : RoutedZone(father, name)
+DijkstraZone::DijkstraZone(NetZone* father, std::string name, bool cached) : RoutedZone(father, name)
{
if (cached)
routeCache_ = xbt_dict_new_homogeneous(&route_cache_elem_free);
*/
class XBT_PRIVATE DijkstraZone : public RoutedZone {
public:
- DijkstraZone(NetZone* father, const char* name, bool cached);
+ DijkstraZone(NetZone* father, std::string name, bool cached);
void seal() override;
~DijkstraZone() override;
namespace kernel {
namespace routing {
-DragonflyZone::DragonflyZone(NetZone* father, const char* name) : ClusterZone(father, name)
+DragonflyZone::DragonflyZone(NetZone* father, std::string name) : ClusterZone(father, name)
{
}
*/
class XBT_PRIVATE DragonflyZone : public ClusterZone {
public:
- explicit DragonflyZone(NetZone* father, const char* name);
+ explicit DragonflyZone(NetZone* father, std::string name);
~DragonflyZone() override;
// void create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position) override;
void getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_t into, double* latency) override;
namespace kernel {
namespace routing {
-EmptyZone::EmptyZone(NetZone* father, const char* name) : NetZoneImpl(father, name)
+EmptyZone::EmptyZone(NetZone* father, std::string name) : NetZoneImpl(father, name)
{
}
class XBT_PRIVATE EmptyZone : public NetZoneImpl {
public:
- explicit EmptyZone(NetZone* father, const char* name);
+ explicit EmptyZone(NetZone* father, std::string name);
~EmptyZone() override;
void getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_t into, double* latency) override
namespace kernel {
namespace routing {
-FatTreeZone::FatTreeZone(NetZone* father, const char* name) : ClusterZone(father, name)
+FatTreeZone::FatTreeZone(NetZone* father, std::string name) : ClusterZone(father, name)
{
XBT_DEBUG("Creating a new fat tree.");
}
*/
class XBT_PRIVATE FatTreeZone : public ClusterZone {
public:
- explicit FatTreeZone(NetZone* father, const char* name);
+ explicit FatTreeZone(NetZone* father, std::string name);
~FatTreeZone() override;
void getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_t into, double* latency) override;
namespace kernel {
namespace routing {
-FloydZone::FloydZone(NetZone* father, const char* name) : RoutedZone(father, name)
+FloydZone::FloydZone(NetZone* father, std::string name) : RoutedZone(father, name)
{
predecessorTable_ = nullptr;
costTable_ = nullptr;
*/
class XBT_PRIVATE FloydZone : public RoutedZone {
public:
- explicit FloydZone(NetZone* father, const char* name);
+ explicit FloydZone(NetZone* father, std::string name);
~FloydZone() override;
void getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_t into, double* latency) override;
namespace simgrid {
namespace kernel {
namespace routing {
-FullZone::FullZone(NetZone* father, const char* name) : RoutedZone(father, name)
+FullZone::FullZone(NetZone* father, std::string name) : RoutedZone(father, name)
{
}
/** @ingroup ROUTING_API
* @brief NetZone with an explicit routing provided by the user
*
- * The full communication matrix is provided at creation, so this model
- * has the highest expressive power and the lowest computational requirements,
- * but also the highest memory requirements (both in platform file and in memory).
+ * The full communication matrix is provided at creation, so this model has the highest expressive power and the lowest
+ * computational requirements, but also the highest memory requirements (both in platform file and in memory).
*/
class XBT_PRIVATE FullZone : public RoutedZone {
public:
- explicit FullZone(NetZone* father, const char* name);
+ explicit FullZone(NetZone* father, std::string name);
void seal() override;
~FullZone() override;
std::vector<surf::LinkImpl*> links;
};
-NetZoneImpl::NetZoneImpl(NetZone* father, const char* name) : NetZone(father, name)
+NetZoneImpl::NetZoneImpl(NetZone* father, std::string name) : NetZone(father, name)
{
- xbt_assert(nullptr == simgrid::s4u::Engine::getInstance()->getNetpointByNameOrNull(name),
- "Refusing to create a second NetZone called '%s'.", name);
+ xbt_assert(nullptr == simgrid::s4u::Engine::getInstance()->getNetpointByNameOrNull(name.c_str()),
+ "Refusing to create a second NetZone called '%s'.", name.c_str());
netpoint_ = new NetPoint(name, NetPoint::Type::NetZone, static_cast<NetZoneImpl*>(father));
- XBT_DEBUG("NetZone '%s' created with the id '%u'", name, netpoint_->id());
+ XBT_DEBUG("NetZone '%s' created with the id '%u'", name.c_str(), netpoint_->id());
}
+
NetZoneImpl::~NetZoneImpl()
{
for (auto& kv : bypassRoutes_)
friend simgrid::kernel::EngineImpl; // it destroys netRoot_
protected:
- explicit NetZoneImpl(NetZone * father, const char* name);
+ explicit NetZoneImpl(NetZone * father, std::string name);
virtual ~NetZoneImpl();
public:
namespace kernel {
namespace routing {
-RoutedZone::RoutedZone(NetZone* father, const char* name) : NetZoneImpl(father, name)
+RoutedZone::RoutedZone(NetZone* father, std::string name) : NetZoneImpl(father, name)
{
}
class XBT_PRIVATE RoutedZone : public NetZoneImpl {
public:
- explicit RoutedZone(NetZone* father, const char* name);
+ explicit RoutedZone(NetZone* father, std::string name);
void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) override;
virtual sg_platf_route_cbarg_t newExtendedRoute(RoutingMode hierarchy, sg_platf_route_cbarg_t routearg,
namespace simgrid {
namespace kernel {
namespace routing {
-TorusZone::TorusZone(NetZone* father, const char* name) : ClusterZone(father, name)
+TorusZone::TorusZone(NetZone* father, std::string name) : ClusterZone(father, name)
{
}
class XBT_PRIVATE TorusZone : public ClusterZone {
public:
- explicit TorusZone(NetZone* father, const char* name);
+ explicit TorusZone(NetZone* father, std::string name);
void create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position) override;
void getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_t into, double* latency) override;
void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster) override;
(np->isNetZone() ? "Netzone" : (np->isHost() ? "Host" : "Router")), np->cname(), np);
return &coords->coords;
}
-VivaldiZone::VivaldiZone(NetZone* father, const char* name) : ClusterZone(father, name)
+
+VivaldiZone::VivaldiZone(NetZone* father, std::string name) : ClusterZone(father, name)
{
}
class XBT_PRIVATE VivaldiZone : public ClusterZone {
public:
- explicit VivaldiZone(NetZone* father, const char* name);
+ explicit VivaldiZone(NetZone* father, std::string name);
void setPeerLink(NetPoint* netpoint, double bw_in, double bw_out, std::string coord);
void getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_t into, double* latency) override;
simgrid::xbt::signal<void(NetZone&)> NetZone::onCreation;
simgrid::xbt::signal<void(NetZone&)> NetZone::onSeal;
-NetZone::NetZone(NetZone* father, const char* name) : father_(father), name_(xbt_strdup(name))
+NetZone::NetZone(NetZone* father, std::string name) : father_(father), name_(name)
{
children_ = new std::vector<NetZone*>();
}
for (auto nz : *children_)
delete nz;
delete children_;
- xbt_free(name_);
}
std::unordered_map<std::string, std::string>* NetZone::getProperties()
{
return children_;
}
-char* NetZone::getCname()
+const char* NetZone::getCname()
{
- return name_;
+ return name_.c_str();
}
NetZone* NetZone::getFather()
{
void NetZone::addRoute(sg_platf_route_cbarg_t /*route*/)
{
- xbt_die("NetZone '%s' does not accept new routes (wrong class).", name_);
+ xbt_die("NetZone '%s' does not accept new routes (wrong class).", name_.c_str());
}
}
}; // namespace simgrid::s4u
int rankId=0;
// What an inventive way of initializing the AS that I have as ancestor :-(
- s_sg_platf_AS_cbarg_t AS;
- AS.id = cluster->id;
+ ZoneCreationArgs zone;
+ zone.id = cluster->id;
switch (cluster->topology) {
case SURF_CLUSTER_TORUS:
- AS.routing = A_surfxml_AS_routing_ClusterTorus;
+ zone.routing = A_surfxml_AS_routing_ClusterTorus;
break;
case SURF_CLUSTER_DRAGONFLY:
- AS.routing = A_surfxml_AS_routing_ClusterDragonfly;
+ zone.routing = A_surfxml_AS_routing_ClusterDragonfly;
break;
case SURF_CLUSTER_FAT_TREE:
- AS.routing = A_surfxml_AS_routing_ClusterFatTree;
+ zone.routing = A_surfxml_AS_routing_ClusterFatTree;
break;
default:
- AS.routing = A_surfxml_AS_routing_Cluster;
+ zone.routing = A_surfxml_AS_routing_Cluster;
break;
}
- sg_platf_new_AS_begin(&AS);
+ sg_platf_new_Zone_begin(&zone);
simgrid::kernel::routing::ClusterZone* current_as = static_cast<ClusterZone*>(routing_get_current());
current_as->parse_specific_arguments(cluster);
}
XBT_DEBUG("</AS>");
- sg_platf_new_AS_seal();
+ sg_platf_new_Zone_seal();
simgrid::surf::on_cluster(cluster);
delete cluster->radicals;
}
/**
- * \brief Add an AS to the platform
+ * \brief Add a Zone to the platform
*
- * Add a new autonomous system to the platform. Any elements (such as host,
- * router or sub-AS) added after this call and before the corresponding call
- * to sg_platf_new_AS_seal() will be added to this AS.
+ * Add a new autonomous system to the platform. Any elements (such as host, router or sub-Zone) added after this call
+ * and before the corresponding call to sg_platf_new_Zone_seal() will be added to this Zone.
*
- * Once this function was called, the configuration concerning the used
- * models cannot be changed anymore.
+ * Once this function was called, the configuration concerning the used models cannot be changed anymore.
*
- * @param AS the parameters defining the AS to build.
+ * @param zone the parameters defining the Zone to build.
*/
-simgrid::s4u::NetZone* sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS)
+simgrid::s4u::NetZone* sg_platf_new_Zone_begin(ZoneCreationArgs* zone)
{
if (not surf_parse_models_setup_already_called) {
/* Initialize the surf models. That must be done after we got all config, and before we need the models.
* any further config now that we created some real content */
/* search the routing model */
- simgrid::kernel::routing::NetZoneImpl* new_as = nullptr;
- switch(AS->routing){
+ simgrid::kernel::routing::NetZoneImpl* new_zone = nullptr;
+ switch (zone->routing) {
case A_surfxml_AS_routing_Cluster:
- new_as = new simgrid::kernel::routing::ClusterZone(current_routing, AS->id);
+ new_zone = new simgrid::kernel::routing::ClusterZone(current_routing, zone->id);
break;
case A_surfxml_AS_routing_ClusterDragonfly:
- new_as = new simgrid::kernel::routing::DragonflyZone(current_routing, AS->id);
+ new_zone = new simgrid::kernel::routing::DragonflyZone(current_routing, zone->id);
break;
case A_surfxml_AS_routing_ClusterTorus:
- new_as = new simgrid::kernel::routing::TorusZone(current_routing, AS->id);
+ new_zone = new simgrid::kernel::routing::TorusZone(current_routing, zone->id);
break;
case A_surfxml_AS_routing_ClusterFatTree:
- new_as = new simgrid::kernel::routing::FatTreeZone(current_routing, AS->id);
+ new_zone = new simgrid::kernel::routing::FatTreeZone(current_routing, zone->id);
break;
case A_surfxml_AS_routing_Dijkstra:
- new_as = new simgrid::kernel::routing::DijkstraZone(current_routing, AS->id, 0);
+ new_zone = new simgrid::kernel::routing::DijkstraZone(current_routing, zone->id, 0);
break;
case A_surfxml_AS_routing_DijkstraCache:
- new_as = new simgrid::kernel::routing::DijkstraZone(current_routing, AS->id, 1);
+ new_zone = new simgrid::kernel::routing::DijkstraZone(current_routing, zone->id, 1);
break;
case A_surfxml_AS_routing_Floyd:
- new_as = new simgrid::kernel::routing::FloydZone(current_routing, AS->id);
+ new_zone = new simgrid::kernel::routing::FloydZone(current_routing, zone->id);
break;
case A_surfxml_AS_routing_Full:
- new_as = new simgrid::kernel::routing::FullZone(current_routing, AS->id);
+ new_zone = new simgrid::kernel::routing::FullZone(current_routing, zone->id);
break;
case A_surfxml_AS_routing_None:
- new_as = new simgrid::kernel::routing::EmptyZone(current_routing, AS->id);
+ new_zone = new simgrid::kernel::routing::EmptyZone(current_routing, zone->id);
break;
case A_surfxml_AS_routing_Vivaldi:
- new_as = new simgrid::kernel::routing::VivaldiZone(current_routing, AS->id);
+ new_zone = new simgrid::kernel::routing::VivaldiZone(current_routing, zone->id);
break;
default:
xbt_die("Not a valid model!");
if (current_routing == nullptr) { /* it is the first one */
xbt_assert(simgrid::s4u::Engine::getInstance()->pimpl->netRoot_ == nullptr,
"All defined components must belong to a networking zone.");
- simgrid::s4u::Engine::getInstance()->pimpl->netRoot_ = new_as;
+ simgrid::s4u::Engine::getInstance()->pimpl->netRoot_ = new_zone;
} else {
/* set the father behavior */
if (current_routing->hierarchy_ == simgrid::kernel::routing::NetZoneImpl::RoutingMode::unset)
current_routing->hierarchy_ = simgrid::kernel::routing::NetZoneImpl::RoutingMode::recursive;
/* add to the sons dictionary */
- current_routing->getChildren()->push_back(static_cast<simgrid::s4u::NetZone*>(new_as));
+ current_routing->getChildren()->push_back(static_cast<simgrid::s4u::NetZone*>(new_zone));
}
/* set the new current component of the tree */
- current_routing = new_as;
+ current_routing = new_zone;
- simgrid::s4u::NetZone::onCreation(*new_as); // notify the signal
+ simgrid::s4u::NetZone::onCreation(*new_zone); // notify the signal
- return new_as;
+ return new_zone;
}
/**
* Once you've declared all the content of your AS, you have to seal
* it with this call. Your AS is not usable until you call this function.
*/
-void sg_platf_new_AS_seal()
+void sg_platf_new_Zone_seal()
{
xbt_assert(current_routing, "Cannot seal the current AS: none under construction");
current_routing->seal();
e_surf_process_on_failure_t on_failure;
} s_sg_platf_process_cbarg_t;
-typedef struct s_sg_platf_AS_cbarg *sg_platf_AS_cbarg_t;
-typedef struct s_sg_platf_AS_cbarg {
- const char *id;
+class ZoneCreationArgs {
+public:
+ std::string id;
int routing;
-} s_sg_platf_AS_cbarg_t;
+};
#define SG_PLATF_AS_INITIALIZER {nullptr,0}
/* The default current property receiver. Setup in the corresponding opening callbacks. */
XBT_PUBLIC(void) sg_platf_begin(); // Start a new platform
XBT_PUBLIC(void) sg_platf_end(); // Finish the creation of the platform
-XBT_PUBLIC(simgrid::s4u::NetZone*) sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS); // Begin description of new AS
-XBT_PUBLIC(void) sg_platf_new_AS_seal(); // That AS is fully described
+XBT_PUBLIC(simgrid::s4u::NetZone*) sg_platf_new_Zone_begin(ZoneCreationArgs* zone); // Begin description of new Zone
+XBT_PUBLIC(void) sg_platf_new_Zone_seal(); // That Zone is fully described
XBT_PUBLIC(void) sg_platf_new_host (sg_platf_host_cbarg_t host); // Add an host to the currently described AS
XBT_PUBLIC(void) sg_platf_new_hostlink(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
{
parse_after_config();
ZONE_TAG = 1;
- s_sg_platf_AS_cbarg_t AS = {A_surfxml_zone_id, (int)A_surfxml_zone_routing};
+ ZoneCreationArgs zone;
+ zone.id = A_surfxml_zone_id;
+ zone.routing = static_cast<int>(A_surfxml_zone_routing);
- sg_platf_new_AS_begin(&AS);
+ sg_platf_new_Zone_begin(&zone);
}
void ETag_surfxml_zone()
{
- sg_platf_new_AS_seal();
+ sg_platf_new_Zone_seal();
}
void STag_surfxml_config()