/** @brief Retrieve the root AS, containing all others */
simgrid::s4u::As *rootAs();
+
/** @brief Retrieve the AS of the given name (or nullptr if not found) */
simgrid::s4u::As *asByNameOrNull(const char *name);
*/
boost::unordered_map<std::string, Storage*> const &mountedStorages();
+ void routeTo(Host * dest, std::vector<Link*> * links, double* latency);
+
private:
simgrid::xbt::string name_ = "noname";
boost::unordered_map<std::string, Storage*> *mounts = nullptr; // caching
if(!dst_elm)
xbt_die("Element '%s' not found!",dst);
- std::vector<Link*> *route = new std::vector<Link*>();
- routing_platf->getRouteAndLatency (src_elm, dst_elm, route,nullptr);
- for (auto link : *route)
+ std::vector<Link*> route;
+ simgrid::kernel::routing::AsImpl::getGlobalRoute(src_elm, dst_elm, &route, nullptr);
+ for (auto link : route)
instr_user_variable (time, link->getName(), variable, father_type, value, what, nullptr, user_link_variables);
- delete route;
}
/** \ingroup TRACE_API
strcmp(gw_dst->name().c_str(), prev_gw_src->name().c_str())) {
std::vector<Link*> *e_route_as_to_as = new std::vector<Link*>();
- routing_platf->getRouteAndLatency(gw_dst_net_elm, prev_gw_src_net_elm, e_route_as_to_as, nullptr);
+ getGlobalRoute(gw_dst_net_elm, prev_gw_src_net_elm, e_route_as_to_as, nullptr);
auto pos = route->link_list->begin();
for (auto link : *e_route_as_to_as) {
route->link_list->insert(pos, link);
route_stack.pop_back();
if (hierarchy_ == RoutingMode::recursive && prev_dst_gw != nullptr &&
strcmp(prev_dst_gw->name().c_str(), e_route->gw_src->name().c_str())) {
- routing_platf->getRouteAndLatency(prev_dst_gw, e_route->gw_src, route->link_list, lat);
+ getGlobalRoute(prev_dst_gw, e_route->gw_src, route->link_list, lat);
}
for (auto link: *e_route->link_list) {
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "instr/instr_interface.h"
-#include "simgrid/simix.h"
#include "mc/mc.h"
#include "simgrid/s4u/As.hpp"
-#include "simgrid/s4u/engine.hpp"
#include "simgrid/s4u/Mailbox.hpp"
+#include "simgrid/s4u/engine.hpp"
+#include "simgrid/s4u/host.hpp"
#include "simgrid/s4u/storage.hpp"
#include "simgrid/simix.h"
+#include "simgrid/simix.h"
#include "src/kernel/EngineImpl.hpp"
+#include "src/kernel/routing/AsImpl.hpp"
-#include "surf/surf.h" // routing_platf. FIXME:KILLME. SOON
+#include "src/surf/network_interface.hpp"
#include "src/surf/surf_routing.hpp" // routing_platf. FIXME:KILLME. SOON
+#include "surf/surf.h" // routing_platf. FIXME:KILLME. SOON
XBT_LOG_NEW_CATEGORY(s4u,"Log channels of the S4U (Simgrid for you) interface");
#include "simgrid/s4u/host.hpp"
#include "simgrid/s4u/storage.hpp"
+XBT_LOG_EXTERNAL_CATEGORY(surf_route);
+
std::unordered_map<std::string, simgrid::s4u::Host*> host_list; // FIXME: move it to Engine
int MSG_HOST_LEVEL = -1;
return this->pimpl_cpu->getNbPStates();
}
+/**
+ * \brief Find a route toward another host
+ *
+ * \param dest [IN] where to
+ * \param route [OUT] where to store the list of links (must exist, cannot be nullptr).
+ * \param latency [OUT] where to store the latency experienced on the path (or nullptr if not interested)
+ * It is the caller responsibility to initialize latency to 0 (we add to provided route)
+ * \pre route!=nullptr
+ *
+ * walk through the routing components tree and find a route between hosts
+ * by calling each "get_route" function in each routing component.
+ */
+void Host::routeTo(Host* dest, std::vector<Link*>* links, double* latency)
+{
+ simgrid::kernel::routing::AsImpl::getGlobalRoute(pimpl_netcard, dest->pimpl_netcard, links, latency);
+ if (XBT_LOG_ISENABLED(surf_route, xbt_log_priority_debug)) {
+ XBT_CDEBUG(surf_route, "Route from '%s' to '%s' (latency: %f):", cname(), dest->cname(),
+ (latency == nullptr ? -1 : *latency));
+ for (auto link : *links)
+ XBT_CDEBUG(surf_route, "Link %s", link->getName());
+ }
+}
+
boost::unordered_map<std::string, Storage*> const& Host::mountedStorages() {
if (mounts == nullptr) {
mounts = new boost::unordered_map<std::string, Storage*> ();
*/
SD_link_t *SD_route_get_list(sg_host_t src, sg_host_t dst)
{
- std::vector<Link*> *route = new std::vector<Link*>();
- routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, route, nullptr);
+ std::vector<Link*> route;
+ src->routeTo(dst, &route, nullptr);
int cpt=0;
- SD_link_t *list = xbt_new(SD_link_t, route->size());
- for (auto link : *route){
+ SD_link_t* list = xbt_new(SD_link_t, route.size());
+ for (auto link : route) {
list[cpt] = link;
cpt++;
}
- delete route;
return list;
}
*/
int SD_route_get_size(sg_host_t src, sg_host_t dst)
{
- std::vector<Link*> *route = new std::vector<Link*>();
- routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, route, nullptr);
- int size = route->size();
- delete route;
+ std::vector<Link*> route;
+ src->routeTo(dst, &route, nullptr);
+ int size = route.size();
return size;
}
double SD_route_get_latency(sg_host_t src, sg_host_t dst)
{
double latency = 0;
- std::vector<Link*> *route = new std::vector<Link*>();
- routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, route, &latency);
- delete route;
+ std::vector<Link*> route;
+ src->routeTo(dst, &route, &latency);
return latency;
}
{
double min_bandwidth = -1.0;
- std::vector<Link*> *route = new std::vector<Link*>();
- routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, route, nullptr);
+ std::vector<Link*> route;
+ src->routeTo(dst, &route, nullptr);
- for (auto link : *route) {
+ for (auto link : route) {
double bandwidth = sg_link_bandwidth(link);
if (bandwidth < min_bandwidth || min_bandwidth < 0.0)
min_bandwidth = bandwidth;
}
- delete route;
return min_bandwidth;
}
XBT_IN("(%s,%s,%g,%g)", src->name().c_str(), dst->name().c_str(), size, rate);
- routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, route, &latency);
+ src->routeTo(dst, route, &latency);
xbt_assert(!route->empty() || latency,
"You're trying to send data from %s to %s but there is no connecting path between these two hosts.",
src->name().c_str(), dst->name().c_str());
if (sg_network_crosstraffic == 1) {
back_route = new std::vector<Link*>();
- routing_platf->getRouteAndLatency(dst->pimpl_netcard, src->pimpl_netcard, back_route, nullptr);
+ dst->routeTo(src, back_route, nullptr);
for (auto link: *back_route)
if (link->isOff())
failed = 1;
std::vector<Link*> route = std::vector<Link*>();
- routing_platf->getRouteAndLatency(action->src_->pimpl_netcard, action->dst_->pimpl_netcard, &route, nullptr);
+ action->src_->routeTo(action->dst_, &route, nullptr);
for (auto link : route)
TRACE_surf_link_set_utilization (link->getName(), action->getCategory(), (data_delta_sent)/delta, now-delta, delta);
if (bytes_amount[i * host_nb + j] > 0) {
double lat=0.0;
- std::vector<Link*> route;
- routing_platf->getRouteAndLatency(hostList_->at(i)->pimpl_netcard, hostList_->at(j)->pimpl_netcard, &route,
- &lat);
+ std::vector<Link*> route;
+ hostList_->at(i)->routeTo(hostList_->at(j), &route, &lat);
latency = MAX(latency, lat);
for (auto link : route)
if (bytes_amount[i * host_nb + j] == 0.0)
continue;
- std::vector<Link*> route;
- routing_platf->getRouteAndLatency(hostList_->at(i)->pimpl_netcard, hostList_->at(j)->pimpl_netcard, &route,
- nullptr);
+ std::vector<Link*> route;
+ hostList_->at(i)->routeTo(hostList_->at(j), &route, nullptr);
for (auto link : route)
lmm_expand_add(model->getMaxminSystem(), link->getConstraint(), this->getVariable(), bytes_amount[i * host_nb + j]);
if (communicationAmount_[i * hostNb + j] > 0) {
double lat = 0.0;
std::vector<Link*> route;
- routing_platf->getRouteAndLatency(hostList_->at(i)->pimpl_netcard, hostList_->at(j)->pimpl_netcard, &route,
- &lat);
+ hostList_->at(i)->routeTo(hostList_->at(j), &route, &lat);
lat_current = MAX(lat_current, lat * communicationAmount_[i * hostNb + j]);
}
xbt_dict_set(traces_set_list, trace->id, (void *) tmgr_trace, nullptr);
}
-namespace simgrid {
-namespace kernel {
-namespace routing {
-
-/**
- * \brief Find a route between hosts
- *
- * \param src the network_element_t for src host
- * \param dst the network_element_t for dst host
- * \param route where to store the list of links.
- * If *route=nullptr, create a short lived dynar. Else, fill the provided dynar
- * \param latency where to store the latency experienced on the path (or nullptr if not interested)
- * It is the caller responsibility to initialize latency to 0 (we add to provided route)
- * \pre route!=nullptr
- *
- * walk through the routing components tree and find a route between hosts
- * by calling each "get_route" function in each routing component.
- */
-void RoutingPlatf::getRouteAndLatency(NetCard *src, NetCard *dst, std::vector<Link*> * route, double *latency)
-{
- AsImpl::getGlobalRoute(src, dst, route, latency);
- if (XBT_LOG_ISENABLED(surf_route, xbt_log_priority_debug)) {
- XBT_DEBUG("Route from '%s' to '%s' (latency: %f):", src->cname(), dst->cname(),
- (latency == nullptr ? -1 : *latency));
- for (auto link : *route)
- XBT_DEBUG("Link %s", link->getName());
- }
-}
-
-}}}
-
/* ************************************************************************** */
/* ************************* GENERIC PARSE FUNCTIONS ************************ */
explicit RoutingPlatf();
~RoutingPlatf();
AsImpl *root_ = nullptr;
- void getRouteAndLatency(NetCard *src, NetCard *dst, std::vector<Link*> * links, double *latency);
};
}}}