From 3b8917255c91e66f504810102478f14dd5b73b64 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Fri, 12 Jan 2018 10:18:55 +0100 Subject: [PATCH] use enum class for cluster topology --- src/surf/sg_platf.cpp | 26 +++++++++++++------------- src/surf/xml/platf_private.hpp | 11 +++-------- src/surf/xml/surfxml_sax_cb.cpp | 8 ++++---- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index f451fad71d..c6fd8563ff 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -154,18 +154,18 @@ void sg_platf_new_cluster(ClusterCreationArgs* cluster) ZoneCreationArgs zone; zone.id = cluster->id; switch (cluster->topology) { - case SURF_CLUSTER_TORUS: - zone.routing = A_surfxml_AS_routing_ClusterTorus; - break; - case SURF_CLUSTER_DRAGONFLY: - zone.routing = A_surfxml_AS_routing_ClusterDragonfly; - break; - case SURF_CLUSTER_FAT_TREE: - zone.routing = A_surfxml_AS_routing_ClusterFatTree; - break; - default: - zone.routing = A_surfxml_AS_routing_Cluster; - break; + case ClusterTopology::TORUS: + zone.routing = A_surfxml_AS_routing_ClusterTorus; + break; + case ClusterTopology::DRAGONFLY: + zone.routing = A_surfxml_AS_routing_ClusterDragonfly; + break; + case ClusterTopology::FAT_TREE: + zone.routing = A_surfxml_AS_routing_ClusterFatTree; + break; + default: + zone.routing = A_surfxml_AS_routing_Cluster; + break; } sg_platf_new_Zone_begin(&zone); simgrid::kernel::routing::ClusterZone* current_as = static_cast(routing_get_current()); @@ -250,7 +250,7 @@ void sg_platf_new_cluster(ClusterCreationArgs* cluster) } //call the cluster function that adds the others links - if (cluster->topology == SURF_CLUSTER_FAT_TREE) { + if (cluster->topology == ClusterTopology::FAT_TREE) { static_cast(current_as)->addProcessingNode(i); } else { current_as->create_links_for_node(cluster, i, rankId, current_as->nodePositionWithLimiter(rankId)); diff --git a/src/surf/xml/platf_private.hpp b/src/surf/xml/platf_private.hpp index 48ed8498d3..2a62c6db05 100644 --- a/src/surf/xml/platf_private.hpp +++ b/src/surf/xml/platf_private.hpp @@ -23,13 +23,6 @@ extern "C" { typedef size_t yy_size_t; #endif -enum e_surf_cluster_topology_t { - SURF_CLUSTER_DRAGONFLY = 3, - SURF_CLUSTER_FAT_TREE = 2, - SURF_CLUSTER_FLAT = 1, - SURF_CLUSTER_TORUS = 0 -}; - /* ***************************************** */ /* * Platform creation functions. Instead of passing 123 arguments to the creation functions @@ -93,6 +86,8 @@ public: std::vector link_list; }; +enum class ClusterTopology { DRAGONFLY = 3, FAT_TREE = 2, FLAT = 1, TORUS = 0 }; + class ClusterCreationArgs { public: std::string id; @@ -108,7 +103,7 @@ public: double loopback_bw = 0; double loopback_lat = 0; double limiter_link = 0; - e_surf_cluster_topology_t topology; + ClusterTopology topology; std::string topo_parameters; std::map* properties; std::string router_id; diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index fdb04ed447..f41d907c16 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -485,16 +485,16 @@ void ETag_surfxml_cluster(){ switch(AX_surfxml_cluster_topology){ case A_surfxml_cluster_topology_FLAT: - cluster.topology= SURF_CLUSTER_FLAT ; + cluster.topology = ClusterTopology::FLAT; break; case A_surfxml_cluster_topology_TORUS: - cluster.topology= SURF_CLUSTER_TORUS ; + cluster.topology = ClusterTopology::TORUS; break; case A_surfxml_cluster_topology_FAT___TREE: - cluster.topology = SURF_CLUSTER_FAT_TREE; + cluster.topology = ClusterTopology::FAT_TREE; break; case A_surfxml_cluster_topology_DRAGONFLY: - cluster.topology= SURF_CLUSTER_DRAGONFLY ; + cluster.topology = ClusterTopology::DRAGONFLY; break; default: surf_parse_error(std::string("Invalid cluster topology for cluster ") + cluster.id); -- 2.20.1