From 49edceb9509566727606fd091e79ef201d7a0863 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Baptiste=20Herv=C3=A9?= Date: Wed, 8 Aug 2012 16:49:00 +0200 Subject: [PATCH] Platform generation: Make link labeling work Also check if the link is labeled when the callbacks have been called. --- src/surf/platf_generator.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/surf/platf_generator.c b/src/surf/platf_generator.c index 0e5031650e..5b536e9c2e 100644 --- a/src/surf/platf_generator.c +++ b/src/surf/platf_generator.c @@ -8,6 +8,8 @@ #include "surf_private.h" #include +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(platf_generator, surf, "Platform Generator"); + static xbt_graph_t platform_graph = NULL; static xbt_dynar_t promoter_dynar = NULL; static xbt_dynar_t labeler_dynar = NULL; @@ -466,6 +468,7 @@ void platf_graph_promote_to_cluster(context_node_t node, sg_platf_cluster_cbarg_ */ void platf_graph_link_label(context_edge_t edge, sg_platf_link_cbarg_t parameters) { memcpy(&(edge->link_parameters), parameters, sizeof(s_sg_platf_link_cbarg_t)); + edge->labeled = TRUE; } /** @@ -496,7 +499,8 @@ void platf_graph_promoter(platf_promoter_cb_t promoter_callback) { * it, and call platf_graph_link_label if needed. * You can register several callbacks: the first registered function will be * called first. If the link have not been labeled yet, the second function - * will be called, and so on... + * will be called, and so on... All the links must have been labeled after + * all the calls. * * \param labeler_callback The callback function */ @@ -542,11 +546,15 @@ void platf_do_label(void) { dynar_edges = xbt_graph_get_edges(platform_graph); xbt_dynar_foreach(dynar_edges, i, graph_edge) { edge = (context_edge_t) xbt_graph_edge_get_data(graph_edge); - xbt_dynar_foreach(promoter_dynar, j, labeler_callback) { - if(edge->labeled == TRUE) + xbt_dynar_foreach(labeler_dynar, j, labeler_callback) { + if(edge->labeled) break; labeler_callback(edge); } + if(!edge->labeled) { + XBT_ERROR("All links of the generated platform are not labeled."); + xbt_die("Please check your generation parameters."); + } } } -- 2.20.1