Put set callbacks in an object.
Less (or encapsulated) arguments for create_zones.
Remove create_cluster_zone (create_star_zone does its job for C++
interfaces).
static void create_torus_cluster()
{
/* create the torus cluster, 10Gbs link between elements in the cluster */
- sg4::create_torus_zone("cluster", nullptr, {2, 2, 2}, 10e9, 10e-6, sg4::Link::SharingPolicy::SPLITDUPLEX,
- create_hostzone, {}, create_limiter)
+ sg4::create_torus_zone("cluster", nullptr, {2, 2, 2}, {create_hostzone, {}, create_limiter}, 10e9, 10e-6,
+ sg4::Link::SharingPolicy::SPLITDUPLEX)
->seal();
}
static void create_fatTree_cluster()
{
/* create the fat tree cluster, 10Gbs link between elements in the cluster */
- sg4::create_fatTree_zone("cluster", nullptr, {2, {2, 3}, {1, 2}, {1, 1}}, 10e9, 10e-6,
- sg4::Link::SharingPolicy::SPLITDUPLEX, create_hostzone, {}, create_limiter)
+ sg4::create_fatTree_zone("cluster", nullptr, {2, {2, 3}, {1, 2}, {1, 1}}, {create_hostzone, {}, create_limiter}, 10e9,
+ 10e-6, sg4::Link::SharingPolicy::SPLITDUPLEX)
->seal();
}
static void create_dragonfly_cluster()
{
/* create the dragonfly cluster, 10Gbs link between elements in the cluster */
- sg4::create_dragonfly_zone("cluster", nullptr, {{2, 2}, {2, 1}, {2, 2}, 2}, 10e9, 10e-6,
- sg4::Link::SharingPolicy::SPLITDUPLEX, create_hostzone, {}, create_limiter)
+ sg4::create_dragonfly_zone("cluster", nullptr, {{2, 2}, {2, 1}, {2, 2}, 2}, {create_hostzone, {}, create_limiter},
+ 10e9, 10e-6, sg4::Link::SharingPolicy::SPLITDUPLEX)
->seal();
}
}
/** Fill the leaf retriving netpoint from a user's callback */
void fill_leaf_from_cb(unsigned int position, const std::vector<unsigned int>& dimensions,
- const std::function<s4u::ClusterNetPointCb>& set_netpoint_cb,
- const std::function<s4u::ClusterLinkCb>& set_loopback_cb,
- const std::function<s4u::ClusterLinkCb>& set_limiter_cb, NetPoint** node_netpoint,
- s4u::Link** lb_link, s4u::Link** limiter_link);
+ const s4u::ClusterCallbacks& set_callbacks, NetPoint** node_netpoint, s4u::Link** lb_link,
+ s4u::Link** limiter_link);
};
} // namespace routing
} // namespace kernel
public:
using ClusterZone::ClusterZone;
- void create_links_for_node(int id, int rank, unsigned int position);
+ void create_links(int id, int rank, unsigned int position);
void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override;
void set_topology(const std::vector<unsigned int>& dimensions);
// External constructors so that the types (and the types of their content) remain hidden
XBT_PUBLIC NetZone* create_full_zone(const std::string& name);
-XBT_PUBLIC NetZone* create_cluster_zone(const std::string& name);
XBT_PUBLIC NetZone* create_star_zone(const std::string& name);
XBT_PUBLIC NetZone* create_dijkstra_zone(const std::string& name, bool cache);
XBT_PUBLIC NetZone* create_empty_zone(const std::string& name);
XBT_PUBLIC NetZone* create_floyd_zone(const std::string& name);
XBT_PUBLIC NetZone* create_vivaldi_zone(const std::string& name);
XBT_PUBLIC NetZone* create_wifi_zone(const std::string& name);
-/**
- * @brief Callback used to set the netpoint and gateway located at some leaf of clusters (Torus, FatTree, etc)
- *
- * The netpoint can be either a host, router or another netzone.
- * Gateway must be non-null if netpoint is a netzone
- *
- * @param zone: The newly create zone, needed for creating new resources (hosts, links)
- * @param coord: the coordinates of the element
- * @param id: Internal identifier of the element
- * @return pair<NetPoint*, NetPoint*>: returns a pair of netpoint and gateway.
- */
-using ClusterNetPointCb = std::pair<kernel::routing::NetPoint*, kernel::routing::NetPoint*>(
- NetZone* zone, const std::vector<unsigned int>& coord, int id);
-/**
- * @brief Callback used to set the links for some leaf of the cluster (Torus, FatTree, etc)
- *
- * @param zone: The newly create zone, needed for creating new resources (hosts, links)
- * @param coord: the coordinates of the element
- * @param id: Internal identifier of the element
- * @return Pointer to the Link
- */
-using ClusterLinkCb = Link*(NetZone* zone, const std::vector<unsigned int>& coord, int id);
+
+// Extra data structure for complex constructors
+
+/** @brief Aggregates the callbacks used to build clusters netzones (Torus/Dragronfly/Fat-Tree) */
+struct ClusterCallbacks {
+ /**
+ * @brief Callback used to set the netpoint and gateway located at some leaf of clusters (Torus, FatTree, etc)
+ *
+ * The netpoint can be either a host, router or another netzone.
+ * Gateway must be non-null if netpoint is a netzone
+ *
+ * @param zone: The newly create zone, needed for creating new resources (hosts, links)
+ * @param coord: the coordinates of the element
+ * @param id: Internal identifier of the element
+ * @return pair<NetPoint*, NetPoint*>: returns a pair of netpoint and gateway.
+ */
+ using ClusterNetPointCb = std::pair<kernel::routing::NetPoint*, kernel::routing::NetPoint*>(
+ NetZone* zone, const std::vector<unsigned int>& coord, int id);
+ /**
+ * @brief Callback used to set the links for some leaf of the cluster (Torus, FatTree, etc)
+ *
+ * @param zone: The newly create zone, needed for creating new resources (hosts, links)
+ * @param coord: the coordinates of the element
+ * @param id: Internal identifier of the element
+ * @return Pointer to the Link
+ */
+ using ClusterLinkCb = Link*(NetZone* zone, const std::vector<unsigned int>& coord, int id);
+
+ std::function<ClusterNetPointCb> netpoint;
+ std::function<ClusterLinkCb> loopback = {};
+ std::function<ClusterLinkCb> limiter = {};
+ explicit ClusterCallbacks(std::function<ClusterNetPointCb> set_netpoint) : netpoint(set_netpoint){/*nothing to do */};
+ ClusterCallbacks(std::function<ClusterNetPointCb> set_netpoint, std::function<ClusterLinkCb> set_loopback,
+ std::function<ClusterLinkCb> set_limiter)
+ : netpoint(set_netpoint), loopback(set_loopback), limiter(set_limiter){/*nothing to do */};
+};
/**
* @brief Create a torus zone
*
* @param parent Pointer to parent's netzone (nullptr if root netzone). Needed to be able to create the resources inside
* the netzone
* @param dimensions List of positive integers (> 0) which determines the torus' dimensions
+ * @param set_callbacks Callbacks to set properties from cluster elements (netpoint, loopback and limiter)
* @param bandwidth Characteristics of the inter-nodes link
* @param latency Characteristics of the inter-nodes link
* @param sharing_policy Characteristics of the inter-nodes link
- * @param set_netpoint Callback to set the netpoint of an element in the torus
- * @param set_loopback Callback to set the loopback
- * @param set_limiter Callback to set the limiter
* @return Pointer to new netzone
*/
XBT_PUBLIC NetZone* create_torus_zone(const std::string& name, const NetZone* parent,
- const std::vector<unsigned int>& dimensions, double bandwidth, double latency,
- Link::SharingPolicy sharing_policy,
- const std::function<ClusterNetPointCb>& set_netpoint,
- const std::function<ClusterLinkCb>& set_loopback = {},
- const std::function<ClusterLinkCb>& set_limiter = {});
+ const std::vector<unsigned int>& dimensions,
+ const ClusterCallbacks& set_callbacks, double bandwidth, double latency,
+ Link::SharingPolicy sharing_policy);
/** @brief Aggregates the parameters necessary to build a Fat-tree zone */
struct FatTreeParams {
* @param parent Pointer to parent's netzone (nullptr if root netzone). Needed to be able to create the resources inside
* the netzone
* @param parameters Characteristics of this Fat-Tree
+ * @param set_callbacks Callbacks to set properties from cluster elements (netpoint, loopback and limiter)
* @param bandwidth Characteristics of the inter-nodes link
* @param latency Characteristics of the inter-nodes link
* @param sharing_policy Characteristics of the inter-nodes link
- * @param set_netpoint Callback to set the netpoint of an element in the torus
- * @param set_loopback Callback to set the loopback
- * @param set_limiter Callback to set the limiter
* @return Pointer to new netzone
*/
XBT_PUBLIC NetZone* create_fatTree_zone(const std::string& name, const NetZone* parent, const FatTreeParams& parameters,
- double bandwidth, double latency, Link::SharingPolicy sharing_policy,
- const std::function<ClusterNetPointCb>& set_netpoint,
- const std::function<ClusterLinkCb>& set_loopback = {},
- const std::function<ClusterLinkCb>& set_limiter = {});
+ const ClusterCallbacks& set_callbacks, double bandwidth, double latency,
+ Link::SharingPolicy sharing_policy);
/** @brief Aggregates the parameters necessary to build a Dragonfly zone */
struct DragonflyParams {
* @param parent Pointer to parent's netzone (nullptr if root netzone). Needed to be able to create the resources inside
* the netzone
* @param parameters Characteristics of this Dragonfly
+ * @param set_callbacks Callbacks to set properties from cluster elements (netpoint, loopback and limiter)
* @param bandwidth Characteristics of the inter-nodes link
* @param latency Characteristics of the inter-nodes link
* @param sharing_policy Characteristics of the inter-nodes link
- * @param set_netpoint Callback to set the netpoint of an element in the torus
- * @param set_loopback Callback to set the loopback
- * @param set_limiter Callback to set the limiter
* @return Pointer to new netzone
*/
XBT_PUBLIC NetZone* create_dragonfly_zone(const std::string& name, const NetZone* parent,
- const DragonflyParams& parameters, double bandwidth, double latency,
- Link::SharingPolicy sharing_policy,
- const std::function<ClusterNetPointCb>& set_netpoint,
- const std::function<ClusterLinkCb>& set_loopback = {},
- const std::function<ClusterLinkCb>& set_limiter = {});
+ const DragonflyParams& parameters, const ClusterCallbacks& set_callbacks,
+ double bandwidth, double latency, Link::SharingPolicy sharing_policy);
} // namespace s4u
} // namespace simgrid
}
void ClusterZone::fill_leaf_from_cb(unsigned int position, const std::vector<unsigned int>& dimensions,
- const std::function<s4u::ClusterNetPointCb>& set_netpoint_cb,
- const std::function<s4u::ClusterLinkCb>& set_loopback_cb,
- const std::function<s4u::ClusterLinkCb>& set_limiter_cb, NetPoint** node_netpoint,
+ const s4u::ClusterCallbacks& set_callbacks, NetPoint** node_netpoint,
s4u::Link** lb_link, s4u::Link** limiter_link)
{
xbt_assert(node_netpoint, "Invalid node_netpoint parameter");
kernel::routing::NetPoint* netpoint = nullptr;
kernel::routing::NetPoint* gw = nullptr;
auto dims = index_to_dims(position);
- std::tie(netpoint, gw) = set_netpoint_cb(get_iface(), dims, position);
+ std::tie(netpoint, gw) = set_callbacks.netpoint(get_iface(), dims, position);
xbt_assert(netpoint, "set_netpoint(elem=%u): Invalid netpoint (nullptr)", position);
if (netpoint->is_netzone()) {
xbt_assert(gw && not gw->is_netzone(),
// setting gateway
set_gateway(position, gw);
- if (set_loopback_cb) {
- s4u::Link* loopback = set_loopback_cb(get_iface(), dims, position);
+ if (set_callbacks.loopback) {
+ s4u::Link* loopback = set_callbacks.loopback(get_iface(), dims, position);
xbt_assert(loopback, "set_loopback: Invalid loopback link (nullptr) for element %u", position);
set_loopback();
add_private_link_at(node_pos(netpoint->id()), {loopback->get_impl(), loopback->get_impl()});
*lb_link = loopback;
}
- if (set_limiter_cb) {
- s4u::Link* limiter = set_limiter_cb(get_iface(), dims, position);
+ if (set_callbacks.limiter) {
+ s4u::Link* limiter = set_callbacks.limiter(get_iface(), dims, position);
xbt_assert(limiter, "set_limiter: Invalid limiter link (nullptr) for element %u", position);
set_limiter();
add_private_link_at(node_pos_with_loopback(netpoint->id()), {limiter->get_impl(), limiter->get_impl()});
} // namespace routing
} // namespace kernel
-
-namespace s4u {
-NetZone* create_cluster_zone(const std::string& name)
-{
- return (new kernel::routing::ClusterZone(name))->get_iface();
-}
-} // namespace s4u
-
} // namespace simgrid
}
NetZone* create_dragonfly_zone(const std::string& name, const NetZone* parent, const DragonflyParams& params,
- double bandwidth, double latency, Link::SharingPolicy sharing_policy,
- const std::function<ClusterNetPointCb>& set_netpoint,
- const std::function<ClusterLinkCb>& set_loopback,
- const std::function<ClusterLinkCb>& set_limiter)
+ const ClusterCallbacks& set_callbacks, double bandwidth, double latency,
+ Link::SharingPolicy sharing_policy)
{
/* initial checks */
if (bandwidth <= 0)
kernel::routing::NetPoint* netpoint;
Link* limiter;
Link* loopback;
- zone->fill_leaf_from_cb(i, dimensions, set_netpoint, set_loopback, set_limiter, &netpoint, &loopback, &limiter);
+ zone->fill_leaf_from_cb(i, dimensions, set_callbacks, &netpoint, &loopback, &limiter);
}
return zone->get_iface();
{
using namespace simgrid::s4u;
EngineWrapper e("test");
- REQUIRE(create_dragonfly_zone("test", e.e.get_netzone_root(), {{3, 4}, {4, 3}, {5, 1}, 2}, 1e9, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host));
+ ClusterCallbacks callbacks(create_host);
+ REQUIRE(create_dragonfly_zone("test", e.e.get_netzone_root(), {{3, 4}, {4, 3}, {5, 1}, 2}, callbacks, 1e9, 10,
+ simgrid::s4u::Link::SharingPolicy::SHARED));
}
TEST_CASE("kernel::routing::DragonflyZone: Invalid params", "")
{
using namespace simgrid::s4u;
EngineWrapper e("test");
+ ClusterCallbacks callbacks(create_host);
SECTION("0 nodes")
{
- REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.e.get_netzone_root(), {{3, 4}, {4, 3}, {5, 1}, 0}, 1e9, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.e.get_netzone_root(), {{3, 4}, {4, 3}, {5, 1}, 0}, callbacks, 1e9,
+ 10, simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
SECTION("0 groups")
{
- REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.e.get_netzone_root(), {{0, 4}, {4, 3}, {5, 1}, 2}, 1e9, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.e.get_netzone_root(), {{0, 4}, {4, 3}, {5, 1}, 2}, callbacks, 1e9,
+ 10, simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
SECTION("0 groups links")
{
- REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.e.get_netzone_root(), {{3, 0}, {4, 3}, {5, 1}, 2}, 1e9, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.e.get_netzone_root(), {{3, 0}, {4, 3}, {5, 1}, 2}, callbacks, 1e9,
+ 10, simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
SECTION("0 chassis")
{
- REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.e.get_netzone_root(), {{3, 4}, {0, 3}, {5, 1}, 2}, 1e9, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.e.get_netzone_root(), {{3, 4}, {0, 3}, {5, 1}, 2}, callbacks, 1e9,
+ 10, simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
SECTION("0 chassis links")
{
- REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.e.get_netzone_root(), {{3, 4}, {4, 0}, {5, 1}, 2}, 1e9, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.e.get_netzone_root(), {{3, 4}, {4, 0}, {5, 1}, 2}, callbacks, 1e9,
+ 10, simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
SECTION("0 routers")
{
- REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.e.get_netzone_root(), {{3, 4}, {4, 3}, {0, 1}, 2}, 1e9, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.e.get_netzone_root(), {{3, 4}, {4, 3}, {0, 1}, 2}, callbacks, 1e9,
+ 10, simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
SECTION("0 routers links")
{
- REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.e.get_netzone_root(), {{3, 4}, {4, 3}, {5, 0}, 2}, 1e9, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.e.get_netzone_root(), {{3, 4}, {4, 3}, {5, 0}, 2}, callbacks, 1e9,
+ 10, simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
SECTION("0 bandwidth")
{
- REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.e.get_netzone_root(), {{3, 4}, {4, 3}, {5, 1}, 2}, 0, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.e.get_netzone_root(), {{3, 4}, {4, 3}, {5, 1}, 2}, callbacks, 0,
+ 10, simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
SECTION("Negative latency")
{
- REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.e.get_netzone_root(), {{3, 4}, {4, 3}, {5, 1}, 2}, 1e9, -10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.e.get_netzone_root(), {{3, 4}, {4, 3}, {5, 1}, 2}, callbacks, 1e9,
+ -10, simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
}
\ No newline at end of file
}
NetZone* create_fatTree_zone(const std::string& name, const NetZone* parent, const FatTreeParams& params,
- double bandwidth, double latency, Link::SharingPolicy sharing_policy,
- const std::function<ClusterNetPointCb>& set_netpoint,
- const std::function<ClusterLinkCb>& set_loopback,
- const std::function<ClusterLinkCb>& set_limiter)
+ const ClusterCallbacks& set_callbacks, double bandwidth, double latency,
+ Link::SharingPolicy sharing_policy)
{
/* initial checks */
if (bandwidth <= 0)
kernel::routing::NetPoint* netpoint;
Link* limiter;
Link* loopback;
- zone->fill_leaf_from_cb(i, params.down, set_netpoint, set_loopback, set_limiter, &netpoint, &loopback, &limiter);
+ zone->fill_leaf_from_cb(i, params.down, set_callbacks, &netpoint, &loopback, &limiter);
zone->add_processing_node(i, limiter ? limiter->get_impl() : nullptr, loopback ? loopback->get_impl() : nullptr);
}
{
using namespace simgrid::s4u;
EngineWrapper e("test");
- REQUIRE(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 4}, {1, 2}, {1, 2}}, 1e9, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host));
+ ClusterCallbacks callbacks(create_host);
+ REQUIRE(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 4}, {1, 2}, {1, 2}}, callbacks, 1e9, 10,
+ simgrid::s4u::Link::SharingPolicy::SHARED));
}
TEST_CASE("kernel::routing::FatTreeZone: Invalid params", "")
{
using namespace simgrid::s4u;
EngineWrapper e("test");
+ ClusterCallbacks callbacks(create_host);
SECTION("0 levels")
{
- REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {0, {4, 4}, {1, 2}, {1, 2}}, 1e9, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {0, {4, 4}, {1, 2}, {1, 2}}, callbacks, 1e9,
+ 10, simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
SECTION("Invalid down links")
{
- REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4}, {1, 2}, {1, 2}}, 1e9, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4}, {1, 2}, {1, 2}}, callbacks, 1e9, 10,
+ simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
SECTION("Invalid up links")
{
- REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 4}, {1}, {1, 2}}, 1e9, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 4}, {1}, {1, 2}}, callbacks, 1e9, 10,
+ simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
SECTION("Invalid link count")
{
- REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 4}, {1, 2}, {1}}, 1e9, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 4}, {1, 2}, {1}}, callbacks, 1e9, 10,
+ simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
SECTION("Down links with zeroes")
{
- REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 0}, {1, 2}, {1, 2}}, 1e9, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 0}, {1, 2}, {1, 2}}, callbacks, 1e9,
+ 10, simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
SECTION("Up links with zeroes")
{
- REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 4}, {0, 2}, {1, 2}}, 1e9, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 4}, {0, 2}, {1, 2}}, callbacks, 1e9,
+ 10, simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
SECTION("Link count with zeroes")
{
- REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 4}, {1, 2}, {1, 0}}, 1e9, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 4}, {1, 2}, {1, 0}}, callbacks, 1e9,
+ 10, simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
SECTION("0 bandwidth")
{
- REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 4}, {1, 2}, {1, 2}}, 0, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 4}, {1, 2}, {1, 2}}, callbacks, 0, 10,
+ simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
SECTION("Negative latency")
{
- REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 4}, {1, 2}, {1, 2}}, 1e9, -10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 4}, {1, 2}, {1, 2}}, callbacks, 1e9,
+ -10, simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
}
\ No newline at end of file
namespace kernel {
namespace routing {
-void TorusZone::create_links_for_node(int id, int rank, unsigned int position)
+void TorusZone::create_links(int id, int rank, unsigned 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
namespace s4u {
NetZone* create_torus_zone(const std::string& name, const NetZone* parent, const std::vector<unsigned int>& dimensions,
- double bandwidth, double latency, Link::SharingPolicy sharing_policy,
- const std::function<ClusterNetPointCb>& set_netpoint,
- const std::function<ClusterLinkCb>& set_loopback,
- const std::function<ClusterLinkCb>& set_limiter)
+ const ClusterCallbacks& set_callbacks, double bandwidth, double latency,
+ Link::SharingPolicy sharing_policy)
{
int tot_elements = std::accumulate(dimensions.begin(), dimensions.end(), 1, std::multiplies<>());
if (dimensions.empty() || tot_elements <= 0)
kernel::routing::NetPoint* netpoint;
Link* limiter;
Link* loopback;
- zone->fill_leaf_from_cb(i, dimensions, set_netpoint, set_loopback, set_limiter, &netpoint, &loopback, &limiter);
+ zone->fill_leaf_from_cb(i, dimensions, set_callbacks, &netpoint, &loopback, &limiter);
- zone->create_links_for_node(netpoint->id(), i, zone->node_pos_with_loopback_limiter(netpoint->id()));
+ zone->create_links(netpoint->id(), i, zone->node_pos_with_loopback_limiter(netpoint->id()));
}
return zone->get_iface();
{
using namespace simgrid::s4u;
EngineWrapper e("test");
- REQUIRE(create_torus_zone("test", e.e.get_netzone_root(), {3, 3, 3}, 1e9, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host));
+ ClusterCallbacks callbacks(create_host);
+ REQUIRE(create_torus_zone("test", e.e.get_netzone_root(), {3, 3, 3}, callbacks, 1e9, 10,
+ simgrid::s4u::Link::SharingPolicy::SHARED));
}
TEST_CASE("kernel::routing::TorusZone: Invalid params", "")
{
using namespace simgrid::s4u;
EngineWrapper e("test");
+ ClusterCallbacks callbacks(create_host);
SECTION("Empty dimensions")
{
- REQUIRE_THROWS_AS(create_torus_zone("test", e.e.get_netzone_root(), {}, 1e9, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_torus_zone("test", e.e.get_netzone_root(), {}, callbacks, 1e9, 10,
+ simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
SECTION("One 0 dimension")
{
- REQUIRE_THROWS_AS(create_torus_zone("test", e.e.get_netzone_root(), {3, 0, 2}, 1e9, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_torus_zone("test", e.e.get_netzone_root(), {3, 0, 2}, callbacks, 1e9, 10,
+ simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
SECTION("Invalid bandwidth")
{
- REQUIRE_THROWS_AS(create_torus_zone("test", e.e.get_netzone_root(), {3, 2, 2}, 0, 10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_torus_zone("test", e.e.get_netzone_root(), {3, 2, 2}, callbacks, 0, 10,
+ simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
SECTION("Invalid latency")
{
- REQUIRE_THROWS_AS(create_torus_zone("test", e.e.get_netzone_root(), {3, 2, 2}, 1e9, -10,
- simgrid::s4u::Link::SharingPolicy::SHARED, create_host),
+ REQUIRE_THROWS_AS(create_torus_zone("test", e.e.get_netzone_root(), {3, 2, 2}, callbacks, 1e9, -10,
+ simgrid::s4u::Link::SharingPolicy::SHARED),
std::invalid_argument);
}
}
\ No newline at end of file
using simgrid::kernel::routing::TorusZone;
auto set_host = std::bind(sg_platf_cluster_create_host, cluster, _1, _2, _3);
- std::function<simgrid::s4u::ClusterLinkCb> set_loopback{};
- std::function<simgrid::s4u::ClusterLinkCb> set_limiter{};
+ std::function<simgrid::s4u::ClusterCallbacks::ClusterLinkCb> set_loopback{};
+ std::function<simgrid::s4u::ClusterCallbacks::ClusterLinkCb> set_limiter{};
if (cluster->loopback_bw > 0 || cluster->loopback_lat > 0) {
set_loopback = std::bind(sg_platf_cluster_create_loopback, cluster, _1, _2, _3);
switch (cluster->topology) {
case simgrid::kernel::routing::ClusterTopology::TORUS:
zone = simgrid::s4u::create_torus_zone(
- cluster->id, parent, TorusZone::parse_topo_parameters(cluster->topo_parameters), cluster->bw, cluster->lat,
- cluster->sharing_policy, set_host, set_loopback, set_limiter);
+ cluster->id, parent, TorusZone::parse_topo_parameters(cluster->topo_parameters),
+ {set_host, set_loopback, set_limiter}, cluster->bw, cluster->lat, cluster->sharing_policy);
break;
case simgrid::kernel::routing::ClusterTopology::DRAGONFLY:
zone = simgrid::s4u::create_dragonfly_zone(
- cluster->id, parent, DragonflyZone::parse_topo_parameters(cluster->topo_parameters), cluster->bw,
- cluster->lat, cluster->sharing_policy, set_host, set_loopback, set_limiter);
+ cluster->id, parent, DragonflyZone::parse_topo_parameters(cluster->topo_parameters),
+ {set_host, set_loopback, set_limiter}, cluster->bw, cluster->lat, cluster->sharing_policy);
break;
case simgrid::kernel::routing::ClusterTopology::FAT_TREE:
zone = simgrid::s4u::create_fatTree_zone(
- cluster->id, parent, FatTreeZone::parse_topo_parameters(cluster->topo_parameters), cluster->bw, cluster->lat,
- cluster->sharing_policy, set_host, set_loopback, set_limiter);
+ cluster->id, parent, FatTreeZone::parse_topo_parameters(cluster->topo_parameters),
+ {set_host, set_loopback, set_limiter}, cluster->bw, cluster->lat, cluster->sharing_policy);
break;
default:
THROW_IMPOSSIBLE;