simgrid::s4u::NetZone* getNetzoneByNameOrNull(const char* name);
/** @brief Retrieve the netcard of the given name (or nullptr if not found) */
- simgrid::kernel::routing::NetPoint* getNetpointByNameOrNull(const char* name);
+ simgrid::kernel::routing::NetPoint* getNetpointByNameOrNull(std::string name);
void getNetpointList(std::vector<simgrid::kernel::routing::NetPoint*> * list);
void netpointRegister(simgrid::kernel::routing::NetPoint * card);
void netpointUnregister(simgrid::kernel::routing::NetPoint * card);
}
}
-void ClusterZone::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int /*rank*/, int position)
+void ClusterZone::create_links_for_node(ClusterCreationArgs* cluster, int id, int /*rank*/, int position)
{
- std::string link_id = std::string(cluster->id) + "_link_" + std::to_string(id);
+ std::string link_id = cluster->id + "_link_" + std::to_string(id);
LinkCreationArgs link;
link.id = link_id;
surf::LinkImpl *linkUp;
surf::LinkImpl *linkDown;
if (link.policy == SURF_LINK_FULLDUPLEX) {
- std::string tmp_link = std::string(link_id) + "_UP";
- linkUp = surf::LinkImpl::byName(tmp_link);
- tmp_link = std::string(link_id) + "_DOWN";
- linkDown = surf::LinkImpl::byName(tmp_link);
+ linkUp = surf::LinkImpl::byName(link_id + "_UP");
+ linkDown = surf::LinkImpl::byName(link_id + "_DOWN");
} else {
linkUp = surf::LinkImpl::byName(link_id);
linkDown = linkUp;
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;
- virtual void create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position);
- virtual void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster)
+ virtual void create_links_for_node(ClusterCreationArgs* cluster, int id, int rank, int position);
+ virtual void parse_specific_arguments(ClusterCreationArgs* cluster)
{
/* this routing method does not require any specific argument */
}
(*coords)[3] = rankId % numNodesPerBlade_;
}
-void DragonflyZone::parse_specific_arguments(sg_platf_cluster_cbarg_t cluster)
+void DragonflyZone::parse_specific_arguments(ClusterCreationArgs* cluster)
{
std::vector<std::string> parameters;
std::vector<std::string> tmp;
~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;
- void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster) override;
+ void parse_specific_arguments(ClusterCreationArgs* cluster) override;
void seal() override;
void generateRouters();
void generateLinks();
private:
void rankId_to_coords(int rankId, unsigned int (*coords)[4]);
- sg_platf_cluster_cbarg_t cluster_;
+ ClusterCreationArgs* cluster_;
unsigned int numNodesPerBlade_ = 0;
unsigned int numBladesPerChassis_ = 0;
unsigned int numChassisPerGroup_ = 0;
this->links_.push_back(newLink);
}
-void FatTreeZone::parse_specific_arguments(sg_platf_cluster_cbarg_t cluster)
+void FatTreeZone::parse_specific_arguments(ClusterCreationArgs* cluster)
{
std::vector<std::string> parameters;
std::vector<std::string> tmp;
file.close();
}
-FatTreeNode::FatTreeNode(sg_platf_cluster_cbarg_t cluster, int id, int level, int position)
+FatTreeNode::FatTreeNode(ClusterCreationArgs* cluster, int id, int level, int position)
: id(id), level(level), position(position)
{
LinkCreationArgs linkTemplate;
}
}
-FatTreeLink::FatTreeLink(sg_platf_cluster_cbarg_t cluster, FatTreeNode* downNode, FatTreeNode* upNode)
+FatTreeLink::FatTreeLink(ClusterCreationArgs* cluster, FatTreeNode* downNode, FatTreeNode* upNode)
: upNode(upNode), downNode(downNode)
{
static int uniqueId = 0;
* instead of passing by an upper level switch.
*/
surf::LinkImpl* loopback;
- FatTreeNode(sg_platf_cluster_cbarg_t cluster, int id, int level, int position);
+ FatTreeNode(ClusterCreationArgs* cluster, int id, int level, int position);
};
/** \brief Link in a fat tree (@ref FatTreeZone).
*/
class FatTreeLink {
public:
- FatTreeLink(sg_platf_cluster_cbarg_t cluster, FatTreeNode* source, FatTreeNode* destination);
+ FatTreeLink(ClusterCreationArgs* cluster, FatTreeNode* source, FatTreeNode* destination);
/** Link going up in the tree */
surf::LinkImpl* upLink;
/** Link going down in the tree */
*
* It will also store the cluster for future use.
*/
- void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster) override;
+ void parse_specific_arguments(ClusterCreationArgs* cluster) override;
void addProcessingNode(int id);
void generateDotFile(const std::string& filename = "fatTree.dot") const;
std::vector<FatTreeLink*> links_;
std::vector<unsigned int> nodesByLevel_;
- sg_platf_cluster_cbarg_t cluster_ = nullptr;
+ ClusterCreationArgs* cluster_ = nullptr;
void addLink(FatTreeNode* parent, unsigned int parentPort, FatTreeNode* child, unsigned int childPort);
int getLevelPosition(const unsigned int level);
{
}
-void TorusZone::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position)
+void TorusZone::create_links_for_node(ClusterCreationArgs* cluster, int id, int rank, int position)
{
/* Create all links that exist in the torus. Each rank creates @a dimensions-1 links */
int dim_product = 1; // Needed to calculate the next neighbor_id
rank++;
}
-void TorusZone::parse_specific_arguments(sg_platf_cluster_cbarg_t cluster)
+void TorusZone::parse_specific_arguments(ClusterCreationArgs* cluster)
{
std::vector<std::string> dimensions;
boost::split(dimensions, cluster->topo_parameters, boost::is_any_of(","));
class XBT_PRIVATE TorusZone : public ClusterZone {
public:
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 create_links_for_node(ClusterCreationArgs* 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;
+ void parse_specific_arguments(ClusterCreationArgs* cluster) override;
private:
std::vector<unsigned int> dimensions_;
}
/** @brief Retrieve the netpoint of the given name (or nullptr if not found) */
-simgrid::kernel::routing::NetPoint* Engine::getNetpointByNameOrNull(const char* name)
+simgrid::kernel::routing::NetPoint* Engine::getNetpointByNameOrNull(std::string name)
{
auto netp = pimpl->netpoints_.find(name);
return netp == pimpl->netpoints_.end() ? nullptr : netp->second;
}
+
/** @brief Fill the provided vector with all existing netpoints */
void Engine::getNetpointList(std::vector<simgrid::kernel::routing::NetPoint*>* list)
{
* Callbacks *
*************/
-static void clusterCreation_cb(sg_platf_cluster_cbarg_t cluster)
+static void clusterCreation_cb(ClusterCreationArgs* cluster)
{
for (int i : *cluster->radicals) {
// Routers don't create a router on the other end of the private link by themselves.
namespace simgrid {
namespace surf {
-simgrid::xbt::signal<void(sg_platf_cluster_cbarg_t)> on_cluster;
-
+simgrid::xbt::signal<void(ClusterCreationArgs*)> on_cluster;
}
}
}
/** @brief Add a "router" to the network element list */
-simgrid::kernel::routing::NetPoint* sg_platf_new_router(const char* name, const char* coords)
+simgrid::kernel::routing::NetPoint* sg_platf_new_router(std::string 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::getInstance()->getNetpointByNameOrNull(name),
- "Refusing to create a router named '%s': this name already describes a node.", name);
+ "Refusing to create a router named '%s': this name already describes a node.", name.c_str());
simgrid::kernel::routing::NetPoint* netpoint =
new simgrid::kernel::routing::NetPoint(name, simgrid::kernel::routing::NetPoint::Type::Router, current_routing);
- XBT_DEBUG("Router '%s' has the id %u", name, netpoint->id());
+ XBT_DEBUG("Router '%s' has the id %u", name.c_str(), netpoint->id());
if (coords && strcmp(coords, ""))
new simgrid::kernel::routing::vivaldi::Coords(netpoint, coords);
}
}
-void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster)
+void sg_platf_new_cluster(ClusterCreationArgs* cluster)
{
using simgrid::kernel::routing::ClusterZone;
using simgrid::kernel::routing::DragonflyZone;
// Add a router.
XBT_DEBUG(" ");
- XBT_DEBUG("<router id=\"%s\"/>", cluster->router_id);
- if (not cluster->router_id || not strcmp(cluster->router_id, "")) {
+ XBT_DEBUG("<router id=\"%s\"/>", cluster->router_id.c_str());
+ if (cluster->router_id.empty()) {
std::string newid = std::string(cluster->prefix) + cluster->id + "_router" + cluster->suffix;
current_as->router_ = sg_platf_new_router(newid.c_str(), NULL);
} else {
XBT_PUBLIC(double) surf_parse_get_double(std::string s);
XBT_PUBLIC(int) surf_parse_get_int(std::string s);
-XBT_PUBLIC(double) surf_parse_get_time(const char *string, const char *entity_kind, const char *name);
-XBT_PUBLIC(double) surf_parse_get_size(const char *string, const char *entity_kind, const char *name);
-XBT_PUBLIC(double) surf_parse_get_bandwidth(const char *string, const char *entity_kind, const char *name);
-XBT_PUBLIC(double) surf_parse_get_speed(const char *string, const char *entity_kind, const char *name);
+XBT_PUBLIC(double) surf_parse_get_time(const char* string, const char* entity_kind, std::string name);
+XBT_PUBLIC(double) surf_parse_get_size(const char* string, const char* entity_kind, std::string name);
+XBT_PUBLIC(double) surf_parse_get_bandwidth(const char* string, const char* entity_kind, std::string name);
+XBT_PUBLIC(double) surf_parse_get_speed(const char* string, const char* entity_kind, std::string name);
XBT_PUBLIC(int) surf_parse(); /* Entry-point to the parser */
std::vector<simgrid::surf::LinkImpl*>* link_list;
} s_sg_platf_route_cbarg_t;
-typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
-typedef struct s_sg_platf_cluster_cbarg {
- const char* id;
- const char* prefix;
- const char* suffix;
- std::vector<int>* radicals;
+class ClusterCreationArgs {
+public:
+ std::string id;
+ std::string prefix;
+ std::string suffix;
+ std::vector<int>* radicals = nullptr;
std::vector<double> speeds;
- int core_amount;
- double bw;
- double lat;
- double bb_bw;
- double bb_lat;
- double loopback_bw;
- double loopback_lat;
- double limiter_link;
+ int core_amount = 0;
+ double bw = 0;
+ double lat = 0;
+ double bb_bw = 0;
+ double bb_lat = 0;
+ double loopback_bw = 0;
+ double loopback_lat = 0;
+ double limiter_link = 0;
e_surf_cluster_topology_t topology;
- const char* topo_parameters;
+ std::string topo_parameters;
std::map<std::string, std::string>* properties;
- const char* router_id;
+ std::string router_id;
e_surf_link_sharing_policy_t sharing_policy;
e_surf_link_sharing_policy_t bb_sharing_policy;
-} s_sg_platf_cluster_cbarg_t;
+};
class CabinetCreationArgs {
public:
XBT_PUBLIC(void) sg_platf_new_hostlink(HostLinkCreationArgs* h); // Add a host_link to the current Zone
XBT_PUBLIC(void) sg_platf_new_link(LinkCreationArgs* link); // Add a link to the current Zone
XBT_PUBLIC(void) sg_platf_new_peer(PeerCreationArgs* peer); // Add a peer to the current Zone
-XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the current Zone
+XBT_PUBLIC(void) sg_platf_new_cluster(ClusterCreationArgs* clust); // Add a cluster to the current Zone
XBT_PUBLIC(void) sg_platf_new_cabinet(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 char* name, const char* coords);
+sg_platf_new_router(std::string, const char* coords);
XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route
XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_route_cbarg_t bypassroute); // Add a bypassRoute
namespace simgrid {
namespace surf {
-extern XBT_PRIVATE simgrid::xbt::signal<void(sg_platf_cluster_cbarg_t)> on_cluster;
-
+extern XBT_PRIVATE simgrid::xbt::signal<void(ClusterCreationArgs*)> on_cluster;
}
}
};
/* Note: field `unit' for the last element of parameter `units' should be nullptr. */
-static double surf_parse_get_value_with_unit(const char *string, const struct unit_scale *units,
- const char *entity_kind, const char *name, const char *error_msg, const char *default_unit)
+static double surf_parse_get_value_with_unit(const char* string, const struct unit_scale* units,
+ const char* entity_kind, std::string name, const char* error_msg,
+ const char* default_unit)
{
char* ptr;
int i;
if (res == 0)
return res; // Ok, 0 can be unit-less
- XBT_WARN("Deprecated unit-less value '%s' for %s %s. %s",string, entity_kind, name, error_msg);
+ XBT_WARN("Deprecated unit-less value '%s' for %s %s. %s", string, entity_kind, name.c_str(), error_msg);
ptr = (char*)default_unit;
}
for (i = 0; units[i].unit != nullptr && strcmp(ptr, units[i].unit) != 0; i++);
return res;
}
-double surf_parse_get_time(const char *string, const char *entity_kind, const char *name)
+double surf_parse_get_time(const char* string, const char* entity_kind, std::string name)
{
const struct unit_scale units[] = {
{ "w", 7 * 24 * 60 * 60 },
"Append 's' to your time to get seconds", "s");
}
-double surf_parse_get_size(const char *string, const char *entity_kind, const char *name)
+double surf_parse_get_size(const char* string, const char* entity_kind, std::string name)
{
const struct unit_scale units[] = {
{ "EiB", pow(1024, 6) },
"Append 'B' to get bytes (or 'b' for bits but 1B = 8b).", "B");
}
-double surf_parse_get_bandwidth(const char *string, const char *entity_kind, const char *name)
+double surf_parse_get_bandwidth(const char* string, const char* entity_kind, std::string name)
{
const struct unit_scale units[] = {
{ "EiBps", pow(1024, 6) },
"Append 'Bps' to get bytes per second (or 'bps' for bits but 1Bps = 8bps)", "Bps");
}
-double surf_parse_get_speed(const char *string, const char *entity_kind, const char *name)
+double surf_parse_get_speed(const char* string, const char* entity_kind, std::string name)
{
const struct unit_scale units[] = {
{ "yottaflops", 1e24 },
"Append 'f' or 'flops' to your speed to get flop per second", "f");
}
-static std::vector<double> surf_parse_get_all_speeds(char* speeds, const char* entity_kind, const char* id){
+static std::vector<double> surf_parse_get_all_speeds(char* speeds, const char* entity_kind, std::string id)
+{
std::vector<double> speed_per_pstate;
}
void ETag_surfxml_cluster(){
- s_sg_platf_cluster_cbarg_t cluster;
- memset(&cluster,0,sizeof(cluster));
- cluster.properties = current_property_set;
+ ClusterCreationArgs cluster;
+ cluster.properties = current_property_set;
current_property_set = nullptr;
cluster.id = A_surfxml_cluster_id;