message(FATAL_ERROR "Could not figure out the stack direction. Test prog returned: ${stack}; CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}.")
endif()
endif()
+# If the test ran well, remove the test binary
+execute_process(COMMAND ${CMAKE_COMMAND} -E remove test_stackgrowth)
###############
## System checks
if (current_routing->hierarchy_ == SURF_ROUTING_NULL)
current_routing->hierarchy_ = SURF_ROUTING_RECURSIVE;
/* add to the sons dictionary */
- xbt_dict_set(current_routing->sons_, AS->id,
- (void *) new_as, NULL);
+ xbt_dict_set(current_routing->sons_, AS->id, (void *) new_as, NULL);
/* add to the father element list */
netcard->setId(current_routing->addComponent(netcard));
} else {
*
* Once you've declared all the content of your AS, you have to close
* it with this call. Your AS is not usable until you call this function.
- *
- * @fixme: this call is not as robust as wanted: bad things WILL happen
- * if you call it twice for the same AS, or if you forget calling it, or
- * even if you add stuff to a closed AS
- *
*/
void routing_AS_end()
{
current_routing = current_routing->father_;
}
-/* Aux Business methods */
-
/**
* \brief Get the AS father and the first elements of the chain
*
* father in the chain
*/
static void elements_father(sg_netcard_t src, sg_netcard_t dst,
- AS_t * res_father,
- AS_t * res_src,
- AS_t * res_dst)
+ AS_t * res_father, AS_t * res_src, AS_t * res_dst)
{
xbt_assert(src && dst, "bad parameters for \"elements_father\" method");
#define ROUTING_HIERARCHY_MAXDEPTH 16 /* increase if it is not enough */
free(link_down);
}
-// static void routing_parse_Srandom(void)
-// {
-// double mean, std, min, max, seed;
-// char *random_id = A_surfxml_random_id;
-// char *random_radical = A_surfxml_random_radical;
-// char *rd_name = NULL;
-// char *rd_value;
-// mean = surf_parse_get_double(A_surfxml_random_mean);
-// std = surf_parse_get_double(A_surfxml_random_std___deviation);
-// min = surf_parse_get_double(A_surfxml_random_min);
-// max = surf_parse_get_double(A_surfxml_random_max);
-// seed = surf_parse_get_double(A_surfxml_random_seed);
-
-// double res = 0;
-// int i = 0;
-// random_data_t random = xbt_new0(s_random_data_t, 1);
-// char *tmpbuf;
-
-// xbt_dynar_t radical_elements;
-// unsigned int iter;
-// char *groups;
-// int start, end;
-// xbt_dynar_t radical_ends;
-
-// switch (A_surfxml_random_generator) {
-// case AU_surfxml_random_generator:
-// case A_surfxml_random_generator_NONE:
-// random->generator = NONE;
-// break;
-// case A_surfxml_random_generator_DRAND48:
-// random->generator = DRAND48;
-// break;
-// case A_surfxml_random_generator_RAND:
-// random->generator = RAND;
-// break;
-// case A_surfxml_random_generator_RNGSTREAM:
-// random->generator = RNGSTREAM;
-// break;
-// default:
-// surf_parse_error("Invalid random generator");
-// break;
-// }
-// random->seed = seed;
-// random->min = min;
-// random->max = max;
-
-// /* Check user stupidities */
-// if (max < min)
-// THROWF(arg_error, 0, "random->max < random->min (%f < %f)", max, min);
-// if (mean < min)
-// THROWF(arg_error, 0, "random->mean < random->min (%f < %f)", mean, min);
-// if (mean > max)
-// THROWF(arg_error, 0, "random->mean > random->max (%f > %f)", mean, max);
-
-// /* normalize the mean and standard deviation before storing */
-// random->mean = (mean - min) / (max - min);
-// random->std = std / (max - min);
-
-// if (random->mean * (1 - random->mean) < random->std * random->std)
-// THROWF(arg_error, 0, "Invalid mean and standard deviation (%f and %f)",
-// random->mean, random->std);
-
-// XBT_DEBUG
-// ("id = '%s' min = '%f' max = '%f' mean = '%f' std_deviatinon = '%f' generator = '%d' seed = '%ld' radical = '%s'",
-// random_id, random->min, random->max, random->mean, random->std,
-// (int)random->generator, random->seed, random_radical);
-
-// if (!random_value)
-// random_value = xbt_dict_new_homogeneous(free);
-
-// if (!strcmp(random_radical, "")) {
-// res = random_generate(random);
-// rd_value = bprintf("%f", res);
-// xbt_dict_set(random_value, random_id, rd_value, NULL);
-// } else {
-// radical_elements = xbt_str_split(random_radical, ",");
-// xbt_dynar_foreach(radical_elements, iter, groups) {
-// radical_ends = xbt_str_split(groups, "-");
-// switch (xbt_dynar_length(radical_ends)) {
-// case 1:
-// xbt_assert(!xbt_dict_get_or_null(random_value, random_id),
-// "Custom Random '%s' already exists !", random_id);
-// res = random_generate(random);
-// tmpbuf =
-// bprintf("%s%d", random_id,
-// atoi(xbt_dynar_getfirst_as(radical_ends, char *)));
-// xbt_dict_set(random_value, tmpbuf, bprintf("%f", res), NULL);
-// xbt_free(tmpbuf);
-// break;
-
-// case 2:
-// start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *));
-// end = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 1, char *));
-// for (i = start; i <= end; i++) {
-// xbt_assert(!xbt_dict_get_or_null(random_value, random_id),
-// "Custom Random '%s' already exists !", bprintf("%s%d",
-// random_id,
-// i));
-// res = random_generate(random);
-// tmpbuf = bprintf("%s%d", random_id, i);
-// xbt_dict_set(random_value, tmpbuf, bprintf("%f", res), NULL);
-// xbt_free(tmpbuf);
-// }
-// break;
-// default:
-// XBT_CRITICAL("Malformed radical");
-// break;
-// }
-// res = random_generate(random);
-// rd_name = bprintf("%s_router", random_id);
-// rd_value = bprintf("%f", res);
-// xbt_dict_set(random_value, rd_name, rd_value, NULL);
-
-// xbt_dynar_free(&radical_ends);
-// }
-// free(rd_name);
-// xbt_dynar_free(&radical_elements);
-// }
-// }
-
static void check_disk_attachment()
{
xbt_lib_cursor_t cursor;
}
RoutingPlatf::~RoutingPlatf()
{
- xbt_dynar_free(&lastRoute_);
finalize_rec(root_);
}
return as->name_;
}
-static simgrid::surf::As *surf_AS_recursive_get_by_name(
- simgrid::surf::As *current, const char * name)
+static simgrid::surf::As *surf_AS_recursive_get_by_name(simgrid::surf::As *current, const char * name)
{
xbt_dict_cursor_t cursor = NULL;
char *key;
};
/** @ingroup SURF_routing_interface
- * @brief Link of lenght 1, alongside with its source and destination. This is mainly usefull in the ns3 bindings
+ * @brief Link of length 1, alongside with its source and destination. This is mainly useful in the ns3 bindings
*/
class Onelink {
public:
~RoutingPlatf();
As *root_ = nullptr;
Link *loopback_;
- xbt_dynar_t lastRoute_ = xbt_dynar_new(sizeof(Link*),NULL);
xbt_dynar_t getOneLinkRoutes(void);
void getRouteAndLatency(NetCard *src, NetCard *dst, std::vector<Link*> * links, double *latency);
};
namespace simgrid {
namespace surf {
+ xbt_dynar_t AsRoutedGraph::getOneLinkRoutes()
+ {
+ xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
+ sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1);
+ route->link_list = new std::vector<Link*>();
+
+ int table_size = (int)xbt_dynar_length(vertices_);
+ for(int src=0; src < table_size; src++) {
+ for(int dst=0; dst< table_size; dst++) {
+ route->link_list->clear();
+ NetCard *src_elm = xbt_dynar_get_as(vertices_, src, NetCard*);
+ NetCard *dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*);
+ this->getRouteAndLatency(src_elm, dst_elm,route, NULL);
+
+ if (route->link_list->size() == 1) {
+ Link *link = route->link_list->at(0);
+ Onelink *onelink;
+ if (hierarchy_ == SURF_ROUTING_BASE)
+ onelink = new Onelink(link, src_elm, dst_elm);
+ else if (hierarchy_ == SURF_ROUTING_RECURSIVE)
+ onelink = new Onelink(link, route->gw_src, route->gw_dst);
+ else
+ onelink = new Onelink(link, NULL, NULL);
+ xbt_dynar_push(ret, &onelink);
+ }
+ }
+ }
+ return ret;
+ }
+
void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
{
int src, dst;
AsRoutedGraph(const char*name);
~AsRoutedGraph();
+ xbt_dynar_t getOneLinkRoutes() override;
+
virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) override;
virtual sg_platf_route_cbarg_t newExtendedRoute(e_surf_routing_hierarchy_t hierarchy, sg_platf_route_cbarg_t routearg, int change_order);
protected:
xbt_graph_new_edge(routeGraph_, src, dst, e_route);
}
-xbt_dynar_t AsDijkstra::getOneLinkRoutes()
-{
- xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
- sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1);
- route->link_list = new std::vector<Link*>();
-
- int table_size = (int)xbt_dynar_length(vertices_);
- for(int src=0; src < table_size; src++) {
- for(int dst=0; dst< table_size; dst++) {
- route->link_list->clear();
- NetCard *src_elm = xbt_dynar_get_as(vertices_, src, NetCard*);
- NetCard *dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*);
- this->getRouteAndLatency(src_elm, dst_elm,route, NULL);
-
- if (route->link_list->size() == 1) {
- Link *link = route->link_list->at(0);
- Onelink *onelink;
- if (hierarchy_ == SURF_ROUTING_BASE)
- onelink = new Onelink(link, src_elm, dst_elm);
- else if (hierarchy_ == SURF_ROUTING_RECURSIVE)
- onelink = new Onelink(link, route->gw_src, route->gw_dst);
- else
- onelink = new Onelink(link, NULL, NULL);
- xbt_dynar_push(ret, &onelink);
- }
- }
- }
- return ret;
-}
-
void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat)
{
getRouteCheckParams(src, dst);
* will have a loopback attached to it.
*/
void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat) override;
- void getRouteAndLatency(sg_platf_route_cbarg_t route, double *lat); // FIXME: this function is dangerously not overriding because of diverging prototype
- xbt_dynar_t getOneLinkRoutes() override;
void addRoute(sg_platf_route_cbarg_t route) override;
xbt_graph_t routeGraph_ = nullptr; /* xbt_graph */
xbt_free(costTable_);
}
-/* Business methods */
-xbt_dynar_t AsFloyd::getOneLinkRoutes()
-{
- xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
- sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
- route->link_list = new std::vector<Link*>();
-
- int table_size = xbt_dynar_length(vertices_);
- for(int src=0; src < table_size; src++) {
- for(int dst=0; dst< table_size; dst++) {
- route->link_list->clear();
- NetCard *src_elm = xbt_dynar_get_as(vertices_, src, NetCard*);
- NetCard *dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*);
- this->getRouteAndLatency(src_elm, dst_elm, route, NULL);
-
- if (route->link_list->size() == 1) {
- void *link = route->link_list->at(0);
- Onelink *onelink;
- if (hierarchy_ == SURF_ROUTING_BASE)
- onelink = new Onelink(link, src_elm, dst_elm);
- else if (hierarchy_ == SURF_ROUTING_RECURSIVE)
- onelink = new Onelink(link, route->gw_src, route->gw_dst);
- else
- onelink = new Onelink(link, NULL, NULL);
- xbt_dynar_push(ret, &onelink);
- }
- }
- }
-
- return ret;
-}
-
void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat)
{
-
size_t table_size = xbt_dynar_length(vertices_);
getRouteCheckParams(src, dst);
~AsFloyd();
void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
- xbt_dynar_t getOneLinkRoutes() override;
void addRoute(sg_platf_route_cbarg_t route) override;
void Seal() override;
}
}
-xbt_dynar_t AsFull::getOneLinkRoutes()
-{
- xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
-
- int src, dst;
- int table_size = xbt_dynar_length(vertices_);
-
- for(src=0; src < table_size; src++) {
- for(dst=0; dst< table_size; dst++) {
- sg_platf_route_cbarg_t route = TO_ROUTE_FULL(src,dst);
- if (route) {
- if (route->link_list->size() == 1) {
- Link *link = route->link_list->at(0);
- Onelink *onelink;
- if (hierarchy_ == SURF_ROUTING_BASE) {
- NetCard *tmp_src = xbt_dynar_get_as(vertices_, src, sg_netcard_t);
- tmp_src->setId(src);
- NetCard *tmp_dst = xbt_dynar_get_as(vertices_, dst, sg_netcard_t);
- tmp_dst->setId(dst);
- onelink = new Onelink(link, tmp_src, tmp_dst);
- } else if (hierarchy_ == SURF_ROUTING_RECURSIVE)
- onelink = new Onelink(link, route->gw_src, route->gw_dst);
- else
- onelink = new Onelink(link, NULL, NULL);
- xbt_dynar_push(ret, &onelink);
- XBT_DEBUG("Push route from '%d' to '%d'",
- src,
- dst);
- }
- }
- }
- }
- return ret;
-}
-
void AsFull::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t res, double *lat)
{
XBT_DEBUG("full_get_route_and_latency from %s[%d] to %s[%d]",
- src->name(),
- src->id(),
- dst->name(),
- dst->id());
+ src->name(), src->id(), dst->name(), dst->id());
/* set utils vars */
size_t table_size = xbt_dynar_length(vertices_);
~AsFull();
void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
- xbt_dynar_t getOneLinkRoutes() override;
void addRoute(sg_platf_route_cbarg_t route) override;
sg_platf_route_cbarg_t *routingTable_ = nullptr;
AsVivaldi(const char *name);
~AsVivaldi() {};
+ xbt_dynar_t getOneLinkRoutes() override {return NULL;};
void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
};