|
1 | 1 | #include "incast_topology_parser.hpp" |
2 | 2 |
|
| 3 | +#include "common.hpp" |
3 | 4 | #include "host/host_parser.hpp" |
4 | | -#include "link/link_parser.hpp" |
5 | 5 | #include "switch/switch_parser.hpp" |
6 | 6 |
|
7 | 7 | namespace sim { |
@@ -43,32 +43,16 @@ Topology parse_incast_topology(const ConfigNode& node) { |
43 | 43 | node_with_preset["links"].value_or_throw(); |
44 | 44 |
|
45 | 45 | utils::IdTable<ILink> links; |
46 | | - auto add_two_way_link = [&links](const ConfigNodeWithPreset& preset, |
47 | | - std::shared_ptr<IDevice> from, |
48 | | - std::shared_ptr<IDevice> to) { |
49 | | - auto add_directed_link = [&preset, &links]( |
50 | | - std::shared_ptr<IDevice> from, |
51 | | - std::shared_ptr<IDevice> to) { |
52 | | - std::shared_ptr<ILink> link = parse_i_link(from, to, preset); |
53 | | - if (!links.emplace(link->get_id(), link).second) { |
54 | | - throw std::runtime_error(fmt::format( |
55 | | - "Duplicate of link with name {} ", link->get_id())); |
56 | | - } |
57 | | - }; |
58 | | - |
59 | | - add_directed_link(from, to); |
60 | | - add_directed_link(to, from); |
61 | | - }; |
62 | 46 |
|
63 | 47 | // create links from between senders and switch |
64 | 48 | for (const auto& [_, sender] : senders) { |
65 | | - add_two_way_link(links_preset, sender, swtch); |
| 49 | + add_links_between(sender, swtch, links_preset, links); |
66 | 50 | } |
67 | 51 |
|
68 | 52 | const ConfigNodeWithPreset& bottleneck_link_preset = |
69 | 53 | ConfigNodeWithPreset(node)["bottleneck-link"].value_or(links_preset); |
70 | 54 |
|
71 | | - add_two_way_link(bottleneck_link_preset, swtch, receiver); |
| 55 | + add_links_between(swtch, receiver, bottleneck_link_preset, links); |
72 | 56 |
|
73 | 57 | TopologyContext ctx; |
74 | 58 |
|
|
0 commit comments