* It will also store the cluster for future use.
*/
void parse_specific_arguments(ClusterCreationArgs* cluster) override;
- void addProcessingNode(int id);
- void generateDotFile(const std::string& filename = "fatTree.dot") const;
+ void add_processing_node(int id);
+ void generate_dot_file(const std::string& filename = "fatTree.dot") const;
private:
// description of a PGFT (TODO : better doc)
unsigned long levels_ = 0;
- std::vector<unsigned int> lowerLevelNodesNumber_; // number of children by node
- std::vector<unsigned int> upperLevelNodesNumber_; // number of parents by node
- std::vector<unsigned int> lowerLevelPortsNumber_; // ports between each level l and l-1
+ std::vector<unsigned int> num_children_per_node_; // number of children by node
+ std::vector<unsigned int> num_parents_per_node_; // number of parents by node
+ std::vector<unsigned int> num_port_lower_level_; // ports between each level l and l-1
std::map<int, FatTreeNode*> compute_nodes_;
std::vector<FatTreeNode*> nodes_;
std::vector<FatTreeLink*> links_;
- std::vector<unsigned int> nodesByLevel_;
+ std::vector<unsigned int> nodes_by_level_;
ClusterCreationArgs* cluster_ = nullptr;
- void addLink(FatTreeNode* parent, unsigned int parentPort, FatTreeNode* child, unsigned int childPort);
+ void addLink(FatTreeNode* parent, unsigned int parent_port, FatTreeNode* child, unsigned int child_port);
int getLevelPosition(const unsigned int level);
void generateLabels();
void generateSwitches();
private:
/* vars to compute the Floyd algorithm. */
- int* predecessorTable_;
- double* costTable_;
- RouteCreationArgs** linkTable_;
+ int* predecessor_table_;
+ double* cost_table_;
+ RouteCreationArgs** link_table_;
};
} // namespace routing
} // namespace kernel
kernel::routing::NetPoint* gw_dst, std::vector<simgrid::surf::LinkImpl*>& link_list,
bool symmetrical) override;
- RouteCreationArgs** routingTable_ = nullptr;
+private:
+ RouteCreationArgs** routing_table_ = nullptr;
};
} // namespace routing
} // namespace kernel
/** @brief the NetZone in which this NetPoint is included */
NetZoneImpl* netzone() { return netzone_; }
- bool isNetZone() { return componentType_ == Type::NetZone; }
- bool isHost() { return componentType_ == Type::Host; }
- bool isRouter() { return componentType_ == Type::Router; }
+ bool isNetZone() { return component_type_ == Type::NetZone; }
+ bool isHost() { return component_type_ == Type::Host; }
+ bool isRouter() { return component_type_ == Type::Router; }
static simgrid::xbt::signal<void(NetPoint*)> onCreation;
private:
unsigned int id_;
std::string name_;
- NetPoint::Type componentType_;
+ NetPoint::Type component_type_;
NetZoneImpl* netzone_;
};
} // namespace routing
RoutingMode hierarchy_ = RoutingMode::unset;
private:
- std::map<std::pair<NetPoint*, NetPoint*>, BypassRoute*> bypassRoutes_; // src x dst -> route
+ std::map<std::pair<NetPoint*, NetPoint*>, BypassRoute*> bypass_routes_; // src x dst -> route
routing::NetPoint* netpoint_ = nullptr; // Our representative in the father NetZone
};
} // namespace routing
/** Put some user data onto the Activity */
Activity* setUserData(void* data)
{
- userData_ = data;
+ user_data_ = data;
return this;
}
/** Retrieve the user data of the Activity */
- void *getUserData() { return userData_; }
+ void* getUserData() { return user_data_; }
private:
simgrid::kernel::activity::ActivityImplPtr pimpl_ = nullptr;
e_s4u_activity_state_t state_ = inited;
double remains_ = 0;
- void *userData_ = nullptr;
+ void* user_data_ = nullptr;
}; // class
}}; // Namespace simgrid::s4u
int d = destination->position; // as in d-mod-k
for (unsigned int i = 0; i < currentNode->level; i++)
- d /= this->upperLevelNodesNumber_[i];
+ d /= this->num_parents_per_node_[i];
- int k = this->upperLevelNodesNumber_[currentNode->level];
+ int k = this->num_parents_per_node_[currentNode->level];
d = d % k;
into->link_list.push_back(currentNode->parents[d]->up_link_);
// Down part
while (currentNode != destination) {
for (unsigned int i = 0; i < currentNode->children.size(); i++) {
- if (i % this->lowerLevelNodesNumber_[currentNode->level - 1] == destination->label[currentNode->level - 1]) {
+ 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_);
if (latency)
*latency += currentNode->children[i]->down_link_->latency();
std::stringstream msgBuffer;
msgBuffer << "We are creating a fat tree of " << this->levels_ << " levels "
- << "with " << this->nodesByLevel_[0] << " processing nodes";
+ << "with " << this->nodes_by_level_[0] << " processing nodes";
for (unsigned int i = 1; i <= this->levels_; i++) {
- msgBuffer << ", " << this->nodesByLevel_[i] << " switches at level " << i;
+ msgBuffer << ", " << this->nodes_by_level_[i] << " switches at level " << i;
}
XBT_DEBUG("%s", msgBuffer.str().c_str());
msgBuffer.str("");
unsigned int k = 0;
// Nodes are totally ordered, by level and then by position, in this->nodes
for (unsigned int i = 0; i < this->levels_; i++) {
- for (unsigned int j = 0; j < this->nodesByLevel_[i]; j++) {
+ for (unsigned int j = 0; j < this->nodes_by_level_[i]; j++) {
this->connectNodeToParents(this->nodes_[k]);
k++;
}
const int level = node->level;
XBT_DEBUG("We are connecting node %d(%u,%u) to his parents.", node->id, node->level, node->position);
currentParentNode += this->getLevelPosition(level + 1);
- for (unsigned int i = 0; i < this->nodesByLevel_[level + 1]; i++) {
+ for (unsigned int i = 0; i < this->nodes_by_level_[level + 1]; i++) {
if (this->areRelated(*currentParentNode, node)) {
XBT_DEBUG("%d(%u,%u) and %d(%u,%u) are related,"
" with %u links between them.",
node->id, node->level, node->position, (*currentParentNode)->id, (*currentParentNode)->level,
- (*currentParentNode)->position, this->lowerLevelPortsNumber_[level]);
- for (unsigned int j = 0; j < this->lowerLevelPortsNumber_[level]; j++) {
- this->addLink(*currentParentNode, node->label[level] + j * this->lowerLevelNodesNumber_[level], node,
- (*currentParentNode)->label[level] + j * this->upperLevelNodesNumber_[level]);
+ (*currentParentNode)->position, this->num_port_lower_level_[level]);
+ for (unsigned int j = 0; j < this->num_port_lower_level_[level]; j++) {
+ this->addLink(*currentParentNode, node->label[level] + j * this->num_children_per_node_[level], node,
+ (*currentParentNode)->label[level] + j * this->num_parents_per_node_[level]);
}
connectionsNumber++;
}
void FatTreeZone::generateSwitches()
{
XBT_DEBUG("Generating switches.");
- this->nodesByLevel_.resize(this->levels_ + 1, 0);
+ this->nodes_by_level_.resize(this->levels_ + 1, 0);
// Take care of the number of nodes by level
- this->nodesByLevel_[0] = 1;
+ this->nodes_by_level_[0] = 1;
for (unsigned int i = 0; i < this->levels_; i++)
- this->nodesByLevel_[0] *= this->lowerLevelNodesNumber_[i];
+ this->nodes_by_level_[0] *= this->num_children_per_node_[i];
- if (this->nodesByLevel_[0] != this->nodes_.size()) {
+ if (this->nodes_by_level_[0] != this->nodes_.size()) {
surf_parse_error(std::string("The number of provided nodes does not fit with the wanted topology.") +
- " Please check your platform description (We need " + std::to_string(this->nodesByLevel_[0]) +
+ " Please check your platform description (We need " + std::to_string(this->nodes_by_level_[0]) +
"nodes, we got " + std::to_string(this->nodes_.size()));
return;
}
int nodesInThisLevel = 1;
for (unsigned int j = 0; j <= i; j++)
- nodesInThisLevel *= this->upperLevelNodesNumber_[j];
+ nodesInThisLevel *= this->num_parents_per_node_[j];
for (unsigned int j = i + 1; j < this->levels_; j++)
- nodesInThisLevel *= this->lowerLevelNodesNumber_[j];
+ nodesInThisLevel *= this->num_children_per_node_[j];
- this->nodesByLevel_[i + 1] = nodesInThisLevel;
+ this->nodes_by_level_[i + 1] = nodesInThisLevel;
}
// Create the switches
int k = 0;
for (unsigned int i = 0; i < this->levels_; i++) {
- for (unsigned int j = 0; j < this->nodesByLevel_[i + 1]; j++) {
+ for (unsigned int j = 0; j < this->nodes_by_level_[i + 1]; j++) {
FatTreeNode* newNode = new FatTreeNode(this->cluster_, --k, i + 1, j);
XBT_DEBUG("We create the switch %d(%u,%u)", newNode->id, newNode->level, newNode->position);
- newNode->children.resize(this->lowerLevelNodesNumber_[i] * this->lowerLevelPortsNumber_[i]);
+ newNode->children.resize(this->num_children_per_node_[i] * this->num_port_lower_level_[i]);
if (i != this->levels_ - 1) {
- newNode->parents.resize(this->upperLevelNodesNumber_[i + 1] * this->lowerLevelPortsNumber_[i + 1]);
+ newNode->parents.resize(this->num_parents_per_node_[i + 1] * this->num_port_lower_level_[i + 1]);
}
newNode->label.resize(this->levels_);
this->nodes_.push_back(newNode);
for (unsigned int i = 0; i <= this->levels_; i++) {
currentLabel.assign(this->levels_, 0);
for (unsigned int j = 0; j < this->levels_; j++) {
- maxLabel[j] = j + 1 > i ? this->lowerLevelNodesNumber_[j] : this->upperLevelNodesNumber_[j];
+ maxLabel[j] = j + 1 > i ? this->num_children_per_node_[j] : this->num_parents_per_node_[j];
}
- for (unsigned int j = 0; j < this->nodesByLevel_[i]; j++) {
+ for (unsigned int j = 0; j < this->nodes_by_level_[i]; j++) {
if (XBT_LOG_ISENABLED(surf_route_fat_tree, xbt_log_priority_debug)) {
std::stringstream msgBuffer;
int tempPosition = 0;
for (unsigned int i = 0; i < level; i++)
- tempPosition += this->nodesByLevel_[i];
+ tempPosition += this->nodes_by_level_[i];
return tempPosition;
}
-void FatTreeZone::addProcessingNode(int id)
+void FatTreeZone::add_processing_node(int id)
{
using std::make_pair;
static int position = 0;
FatTreeNode* newNode;
newNode = new FatTreeNode(this->cluster_, id, 0, position++);
- newNode->parents.resize(this->upperLevelNodesNumber_[0] * this->lowerLevelPortsNumber_[0]);
+ newNode->parents.resize(this->num_parents_per_node_[0] * this->num_port_lower_level_[0]);
newNode->label.resize(this->levels_);
this->compute_nodes_.insert(make_pair(id, newNode));
this->nodes_.push_back(newNode);
}
for (size_t i = 0; i < tmp.size(); i++) {
try {
- this->lowerLevelNodesNumber_.push_back(std::stoi(tmp[i]));
+ this->num_children_per_node_.push_back(std::stoi(tmp[i]));
} catch (std::invalid_argument& ia) {
throw std::invalid_argument(std::string("Invalid lower level node number:") + tmp[i]);
}
}
for (size_t i = 0; i < tmp.size(); i++) {
try {
- this->upperLevelNodesNumber_.push_back(std::stoi(tmp[i]));
+ this->num_parents_per_node_.push_back(std::stoi(tmp[i]));
} catch (std::invalid_argument& ia) {
throw std::invalid_argument(std::string("Invalid upper level node number:") + tmp[i]);
}
}
for (size_t i = 0; i < tmp.size(); i++) {
try {
- this->lowerLevelPortsNumber_.push_back(std::stoi(tmp[i]));
+ this->num_port_lower_level_.push_back(std::stoi(tmp[i]));
} catch (std::invalid_argument& ia) {
throw std::invalid_argument(std::string("Invalid lower level port number:") + tmp[i]);
}
this->cluster_ = cluster;
}
-void FatTreeZone::generateDotFile(const std::string& filename) const
+void FatTreeZone::generate_dot_file(const std::string& filename) const
{
std::ofstream file;
file.open(filename, std::ios::out | std::ios::trunc);
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_floyd, surf, "Routing part of surf");
-#define TO_FLOYD_COST(i, j) (costTable_)[(i) + (j)*table_size]
-#define TO_FLOYD_PRED(i, j) (predecessorTable_)[(i) + (j)*table_size]
-#define TO_FLOYD_LINK(i, j) (linkTable_)[(i) + (j)*table_size]
+#define TO_FLOYD_COST(i, j) (cost_table_)[(i) + (j)*table_size]
+#define TO_FLOYD_PRED(i, j) (predecessor_table_)[(i) + (j)*table_size]
+#define TO_FLOYD_LINK(i, j) (link_table_)[(i) + (j)*table_size]
namespace simgrid {
namespace kernel {
FloydZone::FloydZone(NetZone* father, std::string name) : RoutedZone(father, name)
{
- predecessorTable_ = nullptr;
- costTable_ = nullptr;
- linkTable_ = nullptr;
+ predecessor_table_ = nullptr;
+ cost_table_ = nullptr;
+ link_table_ = nullptr;
}
FloydZone::~FloydZone()
{
- if (linkTable_ == nullptr) // Dealing with a parse error in the file?
+ if (link_table_ == nullptr) // Dealing with a parse error in the file?
return;
unsigned int table_size = getTableSize();
/* Delete link_table */
for (unsigned int i = 0; i < table_size; i++)
for (unsigned int j = 0; j < table_size; j++)
delete TO_FLOYD_LINK(i, j);
- delete[] linkTable_;
+ delete[] link_table_;
- delete[] predecessorTable_;
- delete[] costTable_;
+ delete[] predecessor_table_;
+ delete[] cost_table_;
}
void FloydZone::getLocalRoute(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat)
addRouteCheckParams(src, dst, gw_src, gw_dst, link_list, symmetrical);
- if (not linkTable_) {
+ if (not link_table_) {
/* Create Cost, Predecessor and Link tables */
- costTable_ = new double[table_size * table_size]; /* link cost from host to host */
- predecessorTable_ = new int[table_size * table_size]; /* predecessor host numbers */
- linkTable_ = new RouteCreationArgs*[table_size * table_size]; /* actual link between src and dst */
+ cost_table_ = new double[table_size * table_size]; /* link cost from host to host */
+ predecessor_table_ = new int[table_size * table_size]; /* predecessor host numbers */
+ link_table_ = new RouteCreationArgs*[table_size * table_size]; /* actual link between src and dst */
/* Initialize costs and predecessors */
for (unsigned int i = 0; i < table_size; i++)
/* set the size of table routing */
unsigned int table_size = getTableSize();
- if (not linkTable_) {
+ if (not link_table_) {
/* Create Cost, Predecessor and Link tables */
- costTable_ = new double[table_size * table_size]; /* link cost from host to host */
- predecessorTable_ = new int[table_size * table_size]; /* predecessor host numbers */
- linkTable_ = new RouteCreationArgs*[table_size * table_size]; /* actual link between src and dst */
+ cost_table_ = new double[table_size * table_size]; /* link cost from host to host */
+ predecessor_table_ = new int[table_size * table_size]; /* predecessor host numbers */
+ link_table_ = new RouteCreationArgs*[table_size * table_size]; /* actual link between src and dst */
/* Initialize costs and predecessors */
for (unsigned int i = 0; i < table_size; i++)
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_full, surf, "Routing part of surf");
-#define TO_ROUTE_FULL(i, j) routingTable_[(i) + (j)*table_size]
+#define TO_ROUTE_FULL(i, j) routing_table_[(i) + (j)*table_size]
namespace simgrid {
namespace kernel {
unsigned int table_size = getTableSize();
/* Create table if needed */
- if (not routingTable_)
- routingTable_ = new RouteCreationArgs*[table_size * table_size]();
+ if (not routing_table_)
+ routing_table_ = new RouteCreationArgs*[table_size * table_size]();
/* Add the loopback if needed */
if (surf_network_model->loopback_ && hierarchy_ == RoutingMode::base) {
FullZone::~FullZone()
{
- if (routingTable_) {
+ if (routing_table_) {
unsigned int table_size = getTableSize();
/* Delete routing table */
for (unsigned int i = 0; i < table_size; i++)
for (unsigned int j = 0; j < table_size; j++)
delete TO_ROUTE_FULL(i, j);
- delete[] routingTable_;
+ delete[] routing_table_;
}
}
unsigned int table_size = getTableSize();
- if (not routingTable_)
- routingTable_ = new RouteCreationArgs*[table_size * table_size]();
+ if (not routing_table_)
+ routing_table_ = new RouteCreationArgs*[table_size * table_size]();
/* Check that the route does not already exist */
if (gw_dst) // inter-zone route (to adapt the error message, if any)
simgrid::xbt::signal<void(NetPoint*)> NetPoint::onCreation;
NetPoint::NetPoint(std::string name, NetPoint::Type componentType, NetZoneImpl* netzone_p)
- : name_(name), componentType_(componentType), netzone_(netzone_p)
+ : name_(name), component_type_(componentType), netzone_(netzone_p)
{
if (netzone_p != nullptr)
id_ = netzone_p->addComponent(this);
NetZoneImpl::~NetZoneImpl()
{
- for (auto const& kv : bypassRoutes_)
+ for (auto const& kv : bypass_routes_)
delete kv.second;
simgrid::s4u::Engine::getInstance()->netpointUnregister(netpoint_);
gw_dst->getCname());
xbt_assert(not link_list.empty(), "Bypass route between %s@%s and %s@%s cannot be empty.", src->getCname(),
gw_src->getCname(), dst->getCname(), gw_dst->getCname());
- xbt_assert(bypassRoutes_.find({src, dst}) == bypassRoutes_.end(),
+ xbt_assert(bypass_routes_.find({src, dst}) == bypass_routes_.end(),
"The bypass route between %s@%s and %s@%s already exists.", src->getCname(), gw_src->getCname(),
dst->getCname(), gw_dst->getCname());
} else {
XBT_DEBUG("Load bypassRoute from %s to %s", src->getCname(), dst->getCname());
xbt_assert(not link_list.empty(), "Bypass route between %s and %s cannot be empty.", src->getCname(),
dst->getCname());
- xbt_assert(bypassRoutes_.find({src, dst}) == bypassRoutes_.end(),
+ xbt_assert(bypass_routes_.find({src, dst}) == bypass_routes_.end(),
"The bypass route between %s and %s already exists.", src->getCname(), dst->getCname());
}
newRoute->links.push_back(link);
/* Store it */
- bypassRoutes_.insert({{src, dst}, newRoute});
+ bypass_routes_.insert({{src, dst}, newRoute});
}
/** @brief Get the common ancestor and its first children in each line leading to src and dst
/* OUT */ std::vector<surf::LinkImpl*>& links, double* latency)
{
// If never set a bypass route return nullptr without any further computations
- if (bypassRoutes_.empty())
+ if (bypass_routes_.empty())
return false;
/* Base case, no recursion is needed */
if (dst->netzone() == this && src->netzone() == this) {
- if (bypassRoutes_.find({src, dst}) != bypassRoutes_.end()) {
- BypassRoute* bypassedRoute = bypassRoutes_.at({src, dst});
+ if (bypass_routes_.find({src, dst}) != bypass_routes_.end()) {
+ BypassRoute* bypassedRoute = bypass_routes_.at({src, dst});
for (surf::LinkImpl* const& link : bypassedRoute->links) {
links.push_back(link);
if (latency)
for (int i = 0; i < max; i++) {
if (i <= max_index_src && max <= max_index_dst) {
key = {path_src.at(i)->netpoint_, path_dst.at(max)->netpoint_};
- auto bpr = bypassRoutes_.find(key);
- if (bpr != bypassRoutes_.end()) {
+ auto bpr = bypass_routes_.find(key);
+ if (bpr != bypass_routes_.end()) {
bypassedRoute = bpr->second;
break;
}
}
if (max <= max_index_src && i <= max_index_dst) {
key = {path_src.at(max)->netpoint_, path_dst.at(i)->netpoint_};
- auto bpr = bypassRoutes_.find(key);
- if (bpr != bypassRoutes_.end()) {
+ auto bpr = bypass_routes_.find(key);
+ if (bpr != bypass_routes_.end()) {
bypassedRoute = bpr->second;
break;
}
if (max <= max_index_src && max <= max_index_dst) {
key = {path_src.at(max)->netpoint_, path_dst.at(max)->netpoint_};
- auto bpr = bypassRoutes_.find(key);
- if (bpr != bypassRoutes_.end()) {
+ auto bpr = bypass_routes_.find(key);
+ if (bpr != bypass_routes_.end()) {
bypassedRoute = bpr->second;
break;
}
xbt_assert(state_ == inited);
if (srcBuff_ != nullptr) { // Sender side
- pimpl_ = simcall_comm_isend(sender_, mailbox_->getImpl(), remains_, rate_,
- srcBuff_, srcBuffSize_,
- matchFunction_, cleanFunction_, copyDataFunction_,
- userData_, detached_);
+ pimpl_ = simcall_comm_isend(sender_, mailbox_->getImpl(), remains_, rate_, srcBuff_, srcBuffSize_, matchFunction_,
+ cleanFunction_, copyDataFunction_, user_data_, detached_);
} else if (dstBuff_ != nullptr) { // Receiver side
xbt_assert(not detached_, "Receive cannot be detached");
- pimpl_ = simcall_comm_irecv(receiver_, mailbox_->getImpl(), dstBuff_, &dstBuffSize_,
- matchFunction_, copyDataFunction_,
- userData_, rate_);
+ pimpl_ = simcall_comm_irecv(receiver_, mailbox_->getImpl(), dstBuff_, &dstBuffSize_, matchFunction_,
+ copyDataFunction_, user_data_, rate_);
} else {
xbt_die("Cannot start a communication before specifying whether we are the sender or the receiver");
case inited: // It's not started yet. Do it in one simcall
if (srcBuff_ != nullptr) {
simcall_comm_send(sender_, mailbox_->getImpl(), remains_, rate_, srcBuff_, srcBuffSize_, matchFunction_,
- copyDataFunction_, userData_, timeout);
+ copyDataFunction_, user_data_, timeout);
} else { // Receiver
simcall_comm_recv(receiver_, mailbox_->getImpl(), dstBuff_, &dstBuffSize_, matchFunction_, copyDataFunction_,
- userData_, timeout, rate_);
+ user_data_, timeout, rate_);
}
state_ = finished;
return this;
//call the cluster function that adds the others links
if (cluster->topology == simgrid::kernel::routing::ClusterTopology::FAT_TREE) {
- static_cast<FatTreeZone*>(current_as)->addProcessingNode(i);
+ static_cast<FatTreeZone*>(current_as)->add_processing_node(i);
} else {
current_as->create_links_for_node(cluster, i, rankId, current_as->nodePositionWithLimiter(rankId));
}