XBT_PUBLIC(void) sg_platf_cluster_add_cb(sg_platf_cluster_cb_t fct);
XBT_PUBLIC(void) sg_platf_cabinet_add_cb(sg_platf_cabinet_cb_t fct);
XBT_PUBLIC(void) sg_platf_postparse_add_cb(void_f_void_t fct);
-XBT_PUBLIC(void) sg_platf_AS_begin_add_cb(sg_platf_AS_cb_t fct);
-XBT_PUBLIC(void) sg_platf_AS_end_add_cb(sg_platf_AS_cb_t fct);
XBT_PUBLIC(void) sg_platf_prop_add_cb(sg_platf_prop_cb_t fct);
XBT_PUBLIC(void) sg_platf_route_add_cb(sg_platf_route_cb_t);
xbt_graph_t instr_routing_platform_graph (void);
void instr_routing_platform_graph_export_graphviz (xbt_graph_t g, const char *filename);
-XBT_PRIVATE void sg_instr_new_router(sg_platf_router_cbarg_t router);
-
/********** Routing **********/
void routing_AS_begin(sg_platf_AS_cbarg_t AS);
-void routing_AS_end(sg_platf_AS_cbarg_t AS);
+void routing_AS_end(void);
RoutingEdge *routing_add_host(As* as, sg_platf_host_cbarg_t host);
void routing_cluster_add_backbone(void* bb);
As* routing_get_current();
/*
* Callbacks
*/
-static void instr_routing_parse_start_AS (sg_platf_AS_cbarg_t AS)
+void sg_instr_AS_begin(sg_platf_AS_cbarg_t AS)
{
const char*id = AS->id;
}
}
-static void instr_routing_parse_end_AS (sg_platf_AS_cbarg_t)
+void sg_instr_AS_end()
{
if (TRACE_needs_platform()){
xbt_dynar_pop_ptr (currentContainer);
if (!TRACE_is_enabled()) return;
//always need the call backs to ASes (we need only the root AS),
//to create the rootContainer and the rootType properly
- sg_platf_AS_begin_add_cb(instr_routing_parse_start_AS);
- sg_platf_AS_end_add_cb(instr_routing_parse_end_AS);
if (!TRACE_needs_platform()) return;
sg_platf_link_add_cb(instr_routing_parse_start_link);
sg_platf_host_add_cb(instr_routing_parse_start_host);
);
}
-static void parse_ns3_add_AS(sg_platf_AS_cbarg_t AS)
+static void parse_ns3_add_AS(As* as)
{
- XBT_DEBUG("NS3_ADD_AS '%s'",AS->id);
- xbt_lib_set(as_router_lib,
- AS->id,
- NS3_ASR_LEVEL,
- ns3_add_AS(AS->id)
- );
+ const char* as_id = as->p_name;
+ XBT_DEBUG("NS3_ADD_AS '%s'", as_id);
+ xbt_lib_set(as_router_lib, as_id, NS3_ASR_LEVEL, ns3_add_AS(as_id) );
}
static void parse_ns3_add_cluster(sg_platf_cluster_cbarg_t cluster)
routingEdgeCreatedCallbacks.connect(simgrid_ns3_add_router);
sg_platf_link_add_cb (&parse_ns3_add_link);
sg_platf_cluster_add_cb (&parse_ns3_add_cluster);
- sg_platf_AS_begin_add_cb (&parse_ns3_add_AS);
+
+ asCreatedCallbacks.connect(parse_ns3_add_AS);
+
sg_platf_postparse_add_cb(&create_ns3_topology); //get_one_link_routes
sg_platf_postparse_add_cb(&parse_ns3_end_platform); //InitializeRoutes
}
#include "xbt/RngStream.h"
#include "simgrid/platf_interface.h"
#include "surf/surf_routing.h"
+#include "surf/surf.h"
#include "src/simix/smx_private.h"
xbt_dynar_t sg_platf_peer_cb_list = NULL; // of sg_platf_peer_cb_t
xbt_dynar_t sg_platf_cluster_cb_list = NULL; // of sg_platf_cluster_cb_t
xbt_dynar_t sg_platf_cabinet_cb_list = NULL; // of sg_platf_cluster_cb_t
-xbt_dynar_t sg_platf_AS_begin_cb_list = NULL; //of sg_platf_AS_begin_cb_t
-xbt_dynar_t sg_platf_AS_end_cb_list = NULL; //of void_f_void_t
xbt_dynar_t sg_platf_postparse_cb_list = NULL; // of void_f_void_t
xbt_dynar_t sg_platf_prop_cb_list = NULL; // of sg_platf_prop_cb_t
sg_platf_cluster_cb_list = xbt_dynar_new(sizeof(sg_platf_cluster_cb_t), NULL);
sg_platf_cabinet_cb_list = xbt_dynar_new(sizeof(sg_platf_cabinet_cb_t), NULL);
sg_platf_postparse_cb_list = xbt_dynar_new(sizeof(sg_platf_link_cb_t),NULL);
- sg_platf_AS_begin_cb_list = xbt_dynar_new(sizeof(sg_platf_AS_cb_t),NULL);
- sg_platf_AS_end_cb_list = xbt_dynar_new(sizeof(sg_platf_AS_cb_t),NULL);
sg_platf_prop_cb_list = xbt_dynar_new(sizeof(sg_platf_prop_cb_t),NULL);
sg_platf_route_cb_list = xbt_dynar_new(sizeof(sg_platf_route_cb_t), NULL);
xbt_dynar_free(&sg_platf_peer_cb_list);
xbt_dynar_free(&sg_platf_cluster_cb_list);
xbt_dynar_free(&sg_platf_cabinet_cb_list);
- xbt_dynar_free(&sg_platf_AS_begin_cb_list);
- xbt_dynar_free(&sg_platf_AS_end_cb_list);
xbt_dynar_free(&sg_platf_prop_cb_list);
xbt_dynar_free(&sg_platf_trace_cb_list);
}
}
-void sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS) {
- unsigned int iterator;
- sg_platf_AS_cb_t fun;
-
- if (!surf_parse_models_setup_already_called && !xbt_dynar_is_empty(sg_platf_AS_begin_cb_list)) {
+void sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS)
+{
+ if (!surf_parse_models_setup_already_called) {
/* Initialize the surf models. That must be done after we got all config, and before we need the models.
* That is, after the last <config> tag, if any, and before the first of cluster|peer|AS|trace|trace_connect
*
* (FIXME: check it out by creating a file beginning with one of these tags)
* but cluster and peer create ASes internally, so putting the code in there is ok.
*
- * We are also guarding against xbt_dynar_length(sg_platf_AS_begin_cb_list) because we don't
- * want to initialize the models if we are parsing the file to get the deployment. That could happen if
- * the same file would be used for platf and deploy: it'd contain AS tags even during the deploy parsing.
- * Removing that guard would result of the models to get re-inited when parsing for deploy.
+ * TODO, There used to be a guard protecting here against
+ * xbt_dynar_length(sg_platf_AS_begin_cb_list) because we don't want to
+ * initialize the models if we are parsing the file to get the deployment.
+ * That could happen if the same file would be used for platf and deploy:
+ * it'd contain AS tags even during the deploy parsing. Removing that guard
+ * would result of the models to get re-inited when parsing for deploy.
+ * Currently using the same file for platform and deployment is broken
+ * however. This guard will have to ba adapted in order to make this feature
+ * work again.
*/
surf_parse_models_setup_already_called = 1;
surf_config_models_setup();
}
- xbt_dynar_foreach(sg_platf_AS_begin_cb_list, iterator, fun) {
- fun(AS);
- }
+ routing_AS_begin(AS);
+ if (TRACE_is_enabled())
+ sg_instr_AS_begin(AS);
}
-void sg_platf_new_AS_end() {
- unsigned int iterator;
- void_f_void_t fun;
- xbt_dynar_foreach(sg_platf_AS_end_cb_list, iterator, fun) {
- fun();
- }
+void sg_platf_new_AS_end()
+{
+ routing_AS_end();
+ if (TRACE_is_enabled())
+ sg_instr_AS_end();
}
/* ***************************************** */
void sg_platf_postparse_add_cb(void_f_void_t fct) {
xbt_dynar_push(sg_platf_postparse_cb_list, &fct);
}
-void sg_platf_AS_begin_add_cb(sg_platf_AS_cb_t fct) {
- xbt_dynar_push(sg_platf_AS_begin_cb_list, &fct);
-}
-void sg_platf_AS_end_add_cb(sg_platf_AS_cb_t fct) {
- xbt_dynar_push(sg_platf_AS_end_cb_list, &fct);
-}
void sg_platf_route_add_cb(sg_platf_route_cb_t fct) {
xbt_dynar_push(sg_platf_route_cb_list, &fct);
}
void TRACE_surf_host_set_power(double date, const char *resource, double power);
void TRACE_surf_link_set_bandwidth(double date, const char *resource, double bandwidth);
+/********** Instr. **********/
+
+XBT_PRIVATE void sg_instr_AS_begin(sg_platf_AS_cbarg_t AS);
+XBT_PRIVATE void sg_instr_new_router(sg_platf_router_cbarg_t router);
+XBT_PRIVATE void sg_instr_AS_end(void);
+
SG_END_DECL()
#endif /* _SURF_SURF_PRIVATE_H */
*************/
surf_callback(void, RoutingEdge*) routingEdgeCreatedCallbacks;
+surf_callback(void, As*) asCreatedCallbacks;
/**
* @ingroup SURF_build_api
(void *) info);
XBT_DEBUG("Having set name '%s' id '%d'", new_as->p_name, info->getId());
- routingEdgeCreatedCallbacks(info);
-
/* set the new current component of the tree */
current_routing = new_as;
current_routing->p_netElem = info;
+
+ routingEdgeCreatedCallbacks(info);
+ asCreatedCallbacks(new_as);
}
/**
* even if you add stuff to a closed AS
*
*/
-void routing_AS_end(sg_platf_AS_cbarg_t /*AS*/)
+void routing_AS_end()
{
if (current_routing == NULL) {
sg_platf_postparse_add_cb(routing_parse_postparse);
sg_platf_postparse_add_cb(check_disk_attachment);
- /* we care about the ASes while parsing the platf. Incredible, isnt it? */
- sg_platf_AS_end_add_cb(routing_AS_end);
- sg_platf_AS_begin_add_cb(routing_AS_begin);
-
sg_platf_trace_add_cb(routing_parse_trace);
sg_platf_trace_connect_add_cb(routing_parse_trace_connect);
*************/
XBT_PUBLIC_DATA(surf_callback(void, RoutingEdge*)) routingEdgeCreatedCallbacks;
+XBT_PUBLIC_DATA(surf_callback(void, As*)) asCreatedCallbacks;
#endif /* NETWORK_ROUTING_HPP_ */