return true;
}
-void FatTreeZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency)
+void FatTreeZone::get_local_route(NetPoint* src, NetPoint* dst, Route* into, double* latency)
{
if (dst->is_router() || src->is_router())
return;
/* In case destination is the source, and there is a loopback, let's use it instead of going up to a switch */
if (source->id == destination->id && has_loopback()) {
- into->link_list.push_back(source->loopback_);
+ into->link_list_.push_back(source->loopback_);
if (latency)
*latency += source->loopback_->get_latency();
return;
int k = this->num_parents_per_node_[currentNode->level];
d = d % k;
- into->link_list.push_back(currentNode->parents[d]->up_link_);
+ into->link_list_.push_back(currentNode->parents[d]->up_link_);
if (latency)
*latency += currentNode->parents[d]->up_link_->get_latency();
if (currentNode->limiter_link_)
- into->link_list.push_back(currentNode->limiter_link_);
+ into->link_list_.push_back(currentNode->limiter_link_);
currentNode = currentNode->parents[d]->up_node_;
}
while (currentNode != destination) {
for (unsigned int i = 0; i < currentNode->children.size(); i++) {
if (i % this->num_children_per_node_[currentNode->level - 1] == destination->label[currentNode->level - 1]) {
- into->link_list.push_back(currentNode->children[i]->down_link_);
+ into->link_list_.push_back(currentNode->children[i]->down_link_);
if (latency)
*latency += currentNode->children[i]->down_link_->get_latency();
currentNode = currentNode->children[i]->down_node_;
if (currentNode->limiter_link_)
- into->link_list.push_back(currentNode->limiter_link_);
+ into->link_list_.push_back(currentNode->limiter_link_);
XBT_DEBUG("%d(%u,%u) is accessible through %d(%u,%u)", destination->id, destination->level,
destination->position, currentNode->id, currentNode->level, currentNode->position);
}
}
}
// set gateways (if any)
- into->gw_src = get_gateway(src->id());
- into->gw_dst = get_gateway(dst->id());
+ into->gw_src_ = get_gateway(src->id());
+ into->gw_dst_ = get_gateway(dst->id());
}
/* This function makes the assumption that parse_specific_arguments() and
std::string id =
"link_from_" + std::to_string(child->id) + "_" + std::to_string(parent->id) + "_" + std::to_string(uniqueId);
- if (link_sharing_policy_ == s4u::Link::SharingPolicy::SPLITDUPLEX) {
- linkup = create_link(id + "_UP", std::vector<double>{link_bw_})->set_latency(link_lat_)->seal();
- linkdown = create_link(id + "_DOWN", std::vector<double>{link_bw_})->set_latency(link_lat_)->seal();
+ if (get_link_sharing_policy() == s4u::Link::SharingPolicy::SPLITDUPLEX) {
+ linkup =
+ create_link(id + "_UP", std::vector<double>{get_link_bandwidth()})->set_latency(get_link_latency())->seal();
+ linkdown =
+ create_link(id + "_DOWN", std::vector<double>{get_link_bandwidth()})->set_latency(get_link_latency())->seal();
} else {
- linkup = create_link(id, std::vector<double>{link_bw_})->set_latency(link_lat_)->seal();
+ linkup = create_link(id, std::vector<double>{get_link_bandwidth()})->set_latency(get_link_latency())->seal();
linkdown = linkup;
}
uniqueId++;
{
/* check number of levels */
- if (n_levels <= 0)
+ if (n_levels == 0)
throw std::invalid_argument("FatTreeZone: invalid number of levels, must be > 0");
auto check_vector = [&n_levels](const std::vector<unsigned int>& vector, const std::string& var_name) {
check_vector(link_count, "link count");
}
-void FatTreeZone::set_link_characteristics(double bw, double lat, s4u::Link::SharingPolicy sharing_policy)
-{
- link_sharing_policy_ = sharing_policy;
- link_bw_ = bw;
- link_lat_ = lat;
-}
-
void FatTreeZone::set_topology(unsigned int n_levels, const std::vector<unsigned int>& down_links,
const std::vector<unsigned int>& up_links, const std::vector<unsigned int>& link_count)
{
num_port_lower_level_ = link_count;
}
-void FatTreeZone::parse_specific_arguments(ClusterCreationArgs* cluster)
+s4u::FatTreeParams FatTreeZone::parse_topo_parameters(const std::string& topo_parameters)
{
std::vector<std::string> parameters;
std::vector<std::string> tmp;
std::vector<unsigned int> down;
std::vector<unsigned int> up;
std::vector<unsigned int> count;
- boost::split(parameters, cluster->topo_parameters, boost::is_any_of(";"));
+ boost::split(parameters, topo_parameters, boost::is_any_of(";"));
surf_parse_assert(
parameters.size() == 4,
throw std::invalid_argument(std::string("Invalid lower level port number:") + port);
}
}
-
- /* set topology */
- FatTreeZone::check_topology(n_lev, down, up, count);
- set_topology(n_lev, down, up, count);
- /* saving internal links properties */
- set_link_characteristics(cluster->bw, cluster->lat, cluster->sharing_policy);
+ return s4u::FatTreeParams(n_lev, down, up, count);
}
void FatTreeZone::generate_dot_file(const std::string& filename) const
} // namespace kernel
namespace s4u {
+FatTreeParams::FatTreeParams(unsigned int n_levels, const std::vector<unsigned int>& down_links,
+ const std::vector<unsigned int>& up_links, const std::vector<unsigned int>& links_number)
+ : levels(n_levels), down(down_links), up(up_links), number(links_number)
+{
+ kernel::routing::FatTreeZone::check_topology(levels, down, up, number);
+}
+
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)
if (latency < 0)
throw std::invalid_argument("FatTreeZone: incorrect latency for internode communication, lat=" +
std::to_string(latency));
- kernel::routing::FatTreeZone::check_topology(params.levels, params.down, params.up, params.number);
/* creating zone */
auto* zone = new kernel::routing::FatTreeZone(name);
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);
}