-/* Copyright (c) 2009-2011, 2013-2014. The SimGrid Team.
+/* Copyright (c) 2009-2011, 2013-2015. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* Global vars */
RoutingPlatf *routing_platf = NULL;
-As *current_routing = NULL;
/* global parse functions */
extern xbt_dynar_t mount_list;
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route, surf, "Routing part of surf");
+/** The current AS in the parsing */
+static As *current_routing = NULL;
+As* routing_get_current()
+{
+ return current_routing;
+}
+
static void routing_parse_peer(sg_platf_peer_cbarg_t peer); /* peer bypass */
// static void routing_parse_Srandom(void); /* random bypass */
/**
* \brief Add a "host_link" to the network element list
*/
-static void parse_S_host_link(sg_platf_host_link_cbarg_t host)
+static void parse_S_host(sg_platf_host_link_cbarg_t host)
{
RoutingEdge *info = sg_host_edge(sg_host_by_name(host->id));
xbt_assert(info, "Host '%s' not found!", host->id);
/**
* \brief Add a "host" to the network element list
*/
-static void parse_S_host(sg_platf_host_cbarg_t host)
+RoutingEdge *routing_add_host(As* current_routing, sg_platf_host_cbarg_t host)
{
if (current_routing->p_hierarchy == SURF_ROUTING_NULL)
current_routing->p_hierarchy = SURF_ROUTING_BASE;
xbt_assert(!sg_host_by_name(host->id),
"Reading a host, processing unit \"%s\" already exists", host->id);
- RoutingEdge *info = new RoutingEdgeImpl(xbt_strdup(host->id),
+ RoutingEdge *routingEdge = new RoutingEdgeImpl(xbt_strdup(host->id),
-1,
SURF_NETWORK_ELEMENT_HOST,
current_routing);
- info->setId(current_routing->parsePU(info));
- sg_host_edge_set(sg_host_by_name_or_create(host->id), info);
- XBT_DEBUG("Having set name '%s' id '%d'", host->id, info->getId());
+ routingEdge->setId(current_routing->parsePU(routingEdge));
+ sg_host_edge_set(sg_host_by_name_or_create(host->id), routingEdge);
+ XBT_DEBUG("Having set name '%s' id '%d'", host->id, routingEdge->getId());
if(mount_list){
xbt_lib_set(storage_lib, host->id, ROUTING_STORAGE_HOST_LEVEL, (void *) mount_list);
xbt_lib_set(host_lib, host->id, COORD_HOST_LEVEL, (void *) ctn);
XBT_DEBUG("Having set host coordinates for '%s'",host->id);
}
+
+ return routingEdge;
}
/**
void routing_cluster_add_backbone(void* bb) {
xbt_assert(current_routing->p_modelDesc == &routing_models[SURF_MODEL_CLUSTER],
"You have to be in model Cluster to use tag backbone!");
- xbt_assert(!surf_as_cluster_get_backbone(current_routing), "The backbone link is already defined!");
- surf_as_cluster_set_backbone(current_routing, bb);
+ xbt_assert(!static_cast<AsCluster*>(current_routing)->p_backbone, "The backbone link is already defined!");
+ static_cast<AsCluster*>(current_routing)->p_backbone = static_cast<Link*>(bb);
XBT_DEBUG("Add a backbone to AS '%s'", current_routing->p_name);
}
link_id = bprintf("link_%s%d%s",cabinet->prefix,i,cabinet->suffix);
host.id = host_id;
link.id = link_id;
- xbt_dynar_t power_state_list = xbt_dynar_new(sizeof(double), NULL);
- xbt_dynar_push(power_state_list,&cabinet->power);
- host.power_peak = power_state_list;
+ host.power_peak = xbt_dynar_new(sizeof(double), NULL);
+ xbt_dynar_push(host.power_peak,&cabinet->power);
sg_platf_new_host(&host);
+ xbt_dynar_free(&host.power_peak);
sg_platf_new_link(&link);
char* link_up = bprintf("%s_UP",link_id);
XBT_DEBUG("\tstate_file=\"\"");
}
- xbt_dynar_t power_state_list = xbt_dynar_new(sizeof(double), NULL);
- xbt_dynar_push(power_state_list,&cluster->power);
- host.power_peak = power_state_list;
+ host.power_peak = xbt_dynar_new(sizeof(double), NULL);
+ xbt_dynar_push(host.power_peak,&cluster->power);
host.pstate = 0;
//host.power_peak = cluster->power;
host.initial_state = SURF_RESOURCE_ON;
host.coord = "";
sg_platf_new_host(&host);
+ xbt_dynar_free(&host.power_peak);
XBT_DEBUG("</host>");
XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_id,
host.initial_state = SURF_RESOURCE_ON;
host.id = host_id;
- xbt_dynar_t power_state_list = xbt_dynar_new(sizeof(double), NULL);
- xbt_dynar_push(power_state_list,&peer->power);
- host.power_peak = power_state_list;
+ host.power_peak = xbt_dynar_new(sizeof(double), NULL);
+ xbt_dynar_push(host.power_peak,&peer->power);
host.pstate = 0;
//host.power_peak = peer->power;
host.power_scale = 1.0;
host.state_trace = peer->state_trace;
host.core_amount = 1;
sg_platf_new_host(&host);
+ xbt_dynar_free(&host.power_peak);
s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
memset(&link, 0, sizeof(link));
void routing_register_callbacks()
{
- sg_platf_host_add_cb(parse_S_host);
sg_platf_router_add_cb(parse_S_router);
- sg_platf_host_link_add_cb(parse_S_host_link);
+ sg_platf_host_link_add_cb(parse_S_host);
sg_platf_route_add_cb(parse_E_route);
sg_platf_ASroute_add_cb(parse_E_ASroute);
sg_platf_bypassRoute_add_cb(parse_E_bypassRoute);