S4U:
- New class ActivitySet to ease wait_any()/test_any()/wait_all()
- New function NetZone::add_route(host1, host2, links) when you don't need gateways
+ Also add a variant with s4u::Link, when you don't want to specify the directions
+ on symmetric routes.
Python:
- Make the host_load plugin available from Python. See examples/python/plugin-host-load
auto* host1 = zone->create_host("Host1", "1f");
auto* host2 = zone->create_host("Host2", "1f");
auto* host3 = zone->create_host("Host3", "1f");
+ auto* link2 = zone->create_link("linkto2", "1bps")->seal();
+ auto* link3 = zone->create_link("linkto3", "1bps")->seal();
- sg4::LinkInRoute linkto2{zone->create_link("linkto2", "1bps")->seal()};
- sg4::LinkInRoute linkto3{zone->create_link("linkto3", "1bps")->seal()};
-
- zone->add_route(host1, host2, {linkto2}, false);
- zone->add_route(host1, host3, {linkto3}, false);
+ zone->add_route(host1, host2, {link2});
+ zone->add_route(host1, host3, {link3});
zone->seal();
sg4::Actor::create("Sender", host1, Sender("mailbox2", "mailbox3"));
> [ 10.000000] (1:Sender@Host1) Comm to mailbox3 has state: STARTED
> [ 10.000000] (1:Sender@Host1) Waiting on a FAILED comm raises an exception: 'Cannot wait for a failed communication'
> [ 10.000000] (1:Sender@Host1) Wait for remaining comm, just to be nice
-> [ 16.494845] (3:Receiver@Host3) Receiver has received successfully!
+> [ 17.319588] (3:Receiver@Host3) Receiver has received successfully!
/* add link UP/DOWN for communications from the host */
root->add_route(host->get_netpoint(), nullptr, nullptr, nullptr, {{l, sg4::LinkInRoute::Direction::UP}}, true);
- const sg4::Link* loopback = root->create_link(hostname + "_loopback", BW_LOCAL)->set_latency(LATENCY)->seal();
- root->add_route(host, host, {sg4::LinkInRoute(loopback)});
+ sg4::Link* loopback = root->create_link(hostname + "_loopback", BW_LOCAL)->set_latency(LATENCY)->seal();
+ root->add_route(host, host, {loopback});
}
root->seal();
link->set_latency(10e-6)->seal();
/* create routes between nodes */
- zone->add_route(sender, receiver, {{link, sg4::LinkInRoute::Direction::UP}}, true);
+ zone->add_route(sender, receiver, {link});
zone->seal();
/* create actors Sender/Receiver */
zone->create_split_duplex_link("link1", 10e9)->set_latency(10e-6)->set_concurrency_limit(2)->seal();
/* create routes between nodes */
- zone->add_route(sender, receiver, {{link, sg4::LinkInRoute::Direction::UP}}, true);
+ zone->add_route(sender, receiver, {link});
zone->seal();
/* create actors Sender/Receiver */
// Add a new host programatically, and attach a state profile to it
auto* root = e.get_netzone_root();
auto* lilibeth = root->create_host("Lilibeth", 1e15);
- auto link = sg4::LinkInRoute(e.link_by_name("10"));
- root->add_route(e.host_by_name("Tremblay"), lilibeth, {link}, true);
+ auto link = e.link_by_name("10");
+ root->add_route(e.host_by_name("Tremblay"), lilibeth, {link});
lilibeth->set_state_profile(simgrid::kernel::profile::ProfileBuilder::from_string("lilibeth_profile", R"(
4 0
5 1
}
auto* router = cluster->create_router("cluster_router");
- cluster->add_route(router, nullptr, nullptr, nullptr, {});
+ std::vector<sg4::LinkInRoute> links; // empty
+ cluster->add_route(router, nullptr, nullptr, nullptr, links);
simgrid::plugin::ProducerConsumerPtr<int> pc = simgrid::plugin::ProducerConsumer<int>::create(2);
host2 = zone.create_host("Host2", "1f")
host3 = zone.create_host("Host3", "1f")
- link_to_2 = LinkInRoute(zone.create_link("link_to_2", "1bps").seal())
- link_to_3 = LinkInRoute(zone.create_link("link_to_3", "1bps").seal())
+ link_to_2 = zone.create_link("link_to_2", "1bps").seal()
+ link_to_3 = zone.create_link("link_to_3", "1bps").seal()
- zone.add_route(host1, host2, [link_to_2], False)
- zone.add_route(host1, host3, [link_to_3], False)
+ zone.add_route(host1, host2, [link_to_2])
+ zone.add_route(host1, host3, [link_to_3])
zone.seal()
Actor.create("Sender", host1, sender, "mailbox2", "mailbox3")
> [ 10.000000] (1:Sender@Host1) Comm to mailbox3 has state: STARTED
> [ 10.000000] (1:Sender@Host1) Waiting on a FAILED comm raises an exception: 'Cannot wait for a failed communication'
> [ 10.000000] (1:Sender@Host1) Wait for remaining comm, just to be nice
-> [ 16.494845] (3:Receiver-2@Host3) Receiver has received successfully (mailbox3)!
+> [ 17.319588] (3:Receiver-2@Host3) Receiver has received successfully (mailbox3)!
link.set_latency(10e-6).seal()
# create routes between nodes
- zone.add_route(sender.netpoint, receiver.netpoint, None, None,
- [LinkInRoute(link, LinkInRoute.Direction.UP)], True)
+ zone.add_route(sender, receiver, [link])
zone.seal()
# create actors Sender/Receiver
link = zone.create_split_duplex_link("link1", 10e9).set_latency(10e-6).set_concurrency_limit(2).seal()
# create routes between nodes
- zone.add_route(
- sender_host.netpoint,
- receiver_host.netpoint,
- None,
- None,
- [LinkInRoute(link, LinkInRoute.UP)],
- True
- )
+ zone.add_route(sender_host, receiver_host, [link])
zone.seal()
# create actors Sender/Receiver
const sg4::Link* link9 = root->create_split_duplex_link("9", "7.20975MBps")->set_latency("1.461517ms")->seal();
- root->add_route(tremblay->get_netpoint(), jupiter->get_netpoint(), nullptr, nullptr,
- {{link9, sg4::LinkInRoute::Direction::UP}}, true);
+ root->add_route(tremblay, jupiter, {link9});
root->seal();
/* set cost callback for MPI_Send and MPI_Recv */
*/
void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, kernel::routing::NetPoint* gw_src,
kernel::routing::NetPoint* gw_dst, const std::vector<LinkInRoute>& link_list, bool symmetrical = true);
+ /**
+ * @brief Add a route between 2 netpoints, and same in other direction
+ *
+ * Create a route:
+ * - route between 2 hosts/routers in same netzone, no gateway is needed
+ * - route between 2 netzones, connecting 2 gateways.
+ *
+ * @param src Source netzone's netpoint
+ * @param dst Destination netzone' netpoint
+ * @param gw_src Netpoint of the gateway in the source netzone
+ * @param gw_dst Netpoint of the gateway in the destination netzone
+ * @param link_list List of links
+ */
+ void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, kernel::routing::NetPoint* gw_src,
+ kernel::routing::NetPoint* gw_dst, const std::vector<const Link*>& links);
+
/**
* @brief Add a route between 2 hosts
*
* @param symmetrical Bi-directional communication
*/
void add_route(const Host* src, const Host* dst, const std::vector<LinkInRoute>& link_list, bool symmetrical = true);
+ /**
+ * @brief Add a route between 2 hosts
+ *
+ * @param src Source host
+ * @param dst Destination host
+ * @param link_list List of links. The UP direction will be used on src->dst and DOWN direction on dst->src
+ */
+ void add_route(const Host* src, const Host* dst, const std::vector<const Link*>& links);
void add_bypass_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
py::overload_cast<const simgrid::s4u::Host*, const simgrid::s4u::Host*,
const std::vector<simgrid::s4u::LinkInRoute>&, bool>(&simgrid::s4u::NetZone::add_route),
"Add a route between 2 netpoints")
+ .def("add_route",
+ py::overload_cast<const simgrid::s4u::Host*, const simgrid::s4u::Host*,
+ const std::vector<const simgrid::s4u::Link*>&>(&simgrid::s4u::NetZone::add_route),
+ "Add a route between 2 netpoints")
.def("create_host", py::overload_cast<const std::string&, double>(&simgrid::s4u::NetZone::create_host),
"Creates a host")
.def("create_host",
if (cluster->router_id.empty())
cluster->router_id = cluster->prefix + cluster->id + "_router" + cluster->suffix;
auto* router = zone->create_router(cluster->router_id);
- zone->add_route(router, nullptr, nullptr, nullptr, {});
+ std::vector<simgrid::s4u::LinkInRoute> links;
+ zone->add_route(router, nullptr, nullptr, nullptr, links);
simgrid::kernel::routing::on_cluster_creation(*cluster);
}
{
pimpl_->add_route(src, dst, gw_src, gw_dst, link_list, symmetrical);
}
+void NetZone::add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
+ kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
+ const std::vector<const Link*>& links)
+{
+ std::vector<LinkInRoute> links_direct;
+ std::vector<LinkInRoute> links_reverse;
+ for (auto* l : links) {
+ links_direct.emplace_back(LinkInRoute(l, LinkInRoute::Direction::UP));
+ links_reverse.emplace_back(LinkInRoute(l, LinkInRoute::Direction::DOWN));
+ }
+ pimpl_->add_route(src, dst, gw_src, gw_dst, links_direct, false);
+ pimpl_->add_route(dst, src, gw_dst, gw_src, links_reverse, false);
+}
void NetZone::add_route(const Host* src, const Host* dst, const std::vector<LinkInRoute>& link_list, bool symmetrical)
{
pimpl_->add_route(src->get_netpoint(), dst->get_netpoint(), nullptr, nullptr, link_list, symmetrical);
}
+void NetZone::add_route(const Host* src, const Host* dst, const std::vector<const Link*>& links)
+{
+ std::vector<LinkInRoute> links_direct;
+ std::vector<LinkInRoute> links_reverse;
+ for (auto* l : links) {
+ links_direct.emplace_back(LinkInRoute(l, LinkInRoute::Direction::UP));
+ links_reverse.emplace_back(LinkInRoute(l, LinkInRoute::Direction::DOWN));
+ }
+ pimpl_->add_route(src->get_netpoint(), dst->get_netpoint(), nullptr, nullptr, links_direct, false);
+ pimpl_->add_route(dst->get_netpoint(), src->get_netpoint(), nullptr, nullptr, links_reverse, false);
+}
void NetZone::add_bypass_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
links[name] = zone->create_link(name, 1e9)->set_latency(1e-9)->seal();
}
links["L0"] = zone->create_link("L0", 1e3)->seal();
- zone->add_route(hosts["S1"]->get_netpoint(), hosts["C1"]->get_netpoint(), nullptr, nullptr,
- {sg4::LinkInRoute(links["L1"]), sg4::LinkInRoute(links["L0"]), sg4::LinkInRoute(links["L2"])});
- zone->add_route(hosts["S2"]->get_netpoint(), hosts["C2"]->get_netpoint(), nullptr, nullptr,
- {sg4::LinkInRoute(links["L3"]), sg4::LinkInRoute(links["L0"]), sg4::LinkInRoute(links["L4"])});
-
+ zone->add_route(hosts["S1"], hosts["C1"], {links["L1"], links["L0"], links["L2"]});
+ zone->add_route(hosts["S2"], hosts["C2"], {links["L3"], links["L0"], links["L4"]});
zone->seal();
sg4::Actor::create("", hosts["S1"], sender, "C1", nullptr);
auto const* host1 = zone->create_host("host1", 1e6)->seal();
auto const* host2 = zone->create_host("host2", 1e6)->seal();
auto* testlink = zone->create_link("L1", 1e10)->seal();
- zone->add_route(host1->get_netpoint(), host2->get_netpoint(), nullptr, nullptr, {sg4::LinkInRoute(testlink)});
+ zone->add_route(host1, host2, {testlink});
simgrid::s4u::Actor::create("dispatcher", engine.host_by_name("host1"), main_dispatcher, testlink);
engine.run();
->set_bandwidth_profile(linkSaBandwidthProfile)
->seal();
- world->add_route(hostGl01->get_netpoint(), hostSa01->get_netpoint(), nullptr, nullptr,
- {{linkSa, sg4::LinkInRoute::Direction::NONE}}, true);
+ world->add_route(hostGl01, hostSa01, {{linkSa, sg4::LinkInRoute::Direction::NONE}}, true);
world->seal();
sg4::Mailbox* mb1 = e.mailbox_by_name_or_create("Mailbox 1");
auto* rootzone = sg4::create_full_zone("root");
auto* hostA = rootzone->create_host("hostA", 1e9);
auto* hostB = rootzone->create_host("hostB", 1e9);
- sg4::LinkInRoute link(rootzone->create_link("backbone", "1")->set_latency("1s")->seal());
- rootzone->add_route(hostA->get_netpoint(), hostB->get_netpoint(), nullptr, nullptr, {link}, true);
+ auto* backb = rootzone->create_link("backbone", "1")->set_latency("1s")->seal();
+ rootzone->add_route(hostA, hostB, {backb});
rootzone->seal();
sg4::Actor::create("ptask", hostA, ptask, hostA, hostB);
hosts.append(host2)
link1 = dijkstra.create_link("link1_up", [1e9]).set_latency(1e-3).set_concurrency_limit(10).seal()
link2 = dijkstra.create_link("link1_down", ["1GBps"]).set_latency("1ms").seal()
- dijkstra.add_route(host1.netpoint, host2.netpoint, None, None, [LinkInRoute(link1)], False)
- dijkstra.add_route(host2.netpoint, host1.netpoint, None, None, [LinkInRoute(link2)], False)
+ dijkstra.add_route(host1, host2, [LinkInRoute(link1)], False)
+ dijkstra.add_route(host2, host1, [LinkInRoute(link2)], False)
dijkstra.seal()
# vivaldi
pr::Profile* profile_link = pr::ProfileBuilder::from_string("link_profile", ctx.link_profile.str(), 0);
sg4::Link const* link =
zone->create_link("link", LinkBandwidth)->set_latency(LinkLatency)->set_state_profile(profile_link)->seal();
- zone->add_route(sender_host->get_netpoint(), receiver_host->get_netpoint(), nullptr, nullptr,
- {sg4::LinkInRoute{link}}, false);
+ zone->add_route(sender_host, receiver_host, {link});
zone->seal();
sg4::Host::on_onoff_cb([mbox](sg4::Host const& host) {
for (int i = 1; i < cfg_host_count; i++) {
auto hostname = "lilibeth " + std::to_string(i);
auto* host = rootzone->create_host(hostname, 1e9);
- sg4::LinkInRoute link(rootzone->create_link(hostname, "1MBps")->set_latency("24us")->seal());
- rootzone->add_route(master_host->get_netpoint(), host->get_netpoint(), nullptr, nullptr, {link}, true);
+ auto* link = rootzone->create_link(hostname, "1MBps")->set_latency("24us")->seal();
+ rootzone->add_route(master_host, host, {link});
worker_hosts.push_back(host);
}
rootzone->seal();
for i in range(1, host_count):
link = rootzone.create_split_duplex_link(f"link {i}", "1MBps").set_latency("24us")
host = rootzone.create_host(f"lilibeth {i}", 1e9)
- rootzone.add_route(main.netpoint, host.netpoint, None, None, [LinkInRoute(link, LinkInRoute.Direction.UP)], True)
+ rootzone.add_route(main, host, [link])
Actor.create("worker", host, worker, i).set_auto_restart(True)
e.netzone_root.seal()
auto* rootzone = sg4::create_full_zone("root");
auto* paul = rootzone->create_host("Paul", 1e9);
auto* carol = rootzone->create_host("Carol", 1e9);
- sg4::LinkInRoute link(rootzone->create_link("link", "1MBps")->set_latency("24us")->seal());
- rootzone->add_route(paul->get_netpoint(), carol->get_netpoint(), nullptr, nullptr, {link}, true);
+ auto* link = rootzone->create_link("link", "1MBps")->set_latency("24us")->seal();
+ rootzone->add_route(paul, carol, {link});
SharedBuffer buffer;
sg4::Actor::create("producer", paul, producer, std::ref(buffer))->set_auto_restart();
auto* host = zone->create_host(hostname, 1e9);
host->create_disk("disk-" + hostname, 1e9, 1e6);
const auto* link = zone->create_link("link-" + hostname, 1e9);
- zone->add_route(host->get_netpoint(), router, nullptr, nullptr, {sg4::LinkInRoute(link)});
+ zone->add_route(host->get_netpoint(), router, nullptr, nullptr, {link});
}
return zone;
}