#include "gtnets/gtnets_interface.h"
#include "xbt/str.h"
+
+static double time_to_next_flow_completion=-1;
+
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network_gtnets, surf,
"Logging specific to the SURF network module");
{
static int card_count = -1;
+ XBT_IN1("(%s)",name);
/* KF: Check that we haven't seen the network card before */
network_card_GTNETS_t card =
xbt_dict_get_or_null(network_card_set, name);
card->id = card_count;
xbt_dict_set(network_card_set, name, card, network_card_free);
}
-
+
+ LOG1(xbt_log_priority_trace, " return %d",card->id);
+ XBT_OUT;
/* KF: just return the GTNetS ID as the SURF ID */
return card->id;
}
{
int i;
int *gtnets_links;
+ XBT_IN4("(src_id=%d, dst_id=%d, links=%p, nb_link=%d)",
+ src_id,dst_id,links,nb_link);
/* KF: Build the list of gtnets link IDs */
gtnets_links = (int *) calloc(nb_link, sizeof(int));
if (gtnets_add_route(src_id, dst_id, gtnets_links, nb_link)) {
xbt_assert0(0, "Cannot create GTNetS route");
}
+ XBT_OUT;
}
/* Instantiate a new route: MODIFY BY KF */
static network_link_GTNETS_t *link_list = NULL;
- DEBUG0("Entering add_route()");
+ XBT_IN;
xbt_dict_foreach(route_table, cursor, key, data) {
char *link = NULL;
nb_link = 0;
RETHROW1("Link %s not found (dict raised this exception: %s)", link);
}
}
- if (nb_link > 1)
- route_new(src_id, dst_id, link_list, nb_link);
if (nb_link == 1)
route_onehop_new(src_id, dst_id, link_list, nb_link);
}
+ xbt_dict_foreach(route_table, cursor, key, data) {
+ char *link = NULL;
+ nb_link = 0;
+ links = (xbt_dynar_t)data;
+ keys = xbt_str_split_str(key, sep);
+
+ link_list_capacity = xbt_dynar_length(links);
+ link_list = xbt_new(network_link_GTNETS_t, link_list_capacity);
+
+ src_id = strtol(xbt_dynar_get_as(keys, 0, char*), &end, 16);
+ dst_id = strtol(xbt_dynar_get_as(keys, 1, char*), &end, 16);
+ xbt_dynar_free(&keys);
+
+ xbt_dynar_foreach (links, cpt, link) {
+ TRY {
+ link_list[nb_link++] = xbt_dict_get(link_set, link);
+ }
+ CATCH(e) {
+ RETHROW1("Link %s not found (dict raised this exception: %s)", link);
+ }
+ }
+ if (nb_link >= 1)
+ route_new(src_id, dst_id, link_list, nb_link);
+ }
+
xbt_dict_free(&route_table);
- DEBUG0("Bailling add_route()");
+ gtnets_print_topology();
+ XBT_OUT;
}
/* Main XML parsing */
static int action_free(surf_action_t action)
{
- action->using--;
- if (!action->using) {
+ action->refcount--;
+ if (!action->refcount) {
xbt_swag_remove(action, action->state_set);
/* KF: No explicit freeing needed for GTNeTS here */
free(action);
static void action_use(surf_action_t action)
{
- action->using++;
+ action->refcount++;
}
static void action_cancel(surf_action_t action)
if (!xbt_swag_size(running_actions))
return -1.0;
- return gtnets_get_time_to_next_flow_completion();
+ xbt_assert0(time_to_next_flow_completion, "Time to next flow completion not initialized!\n");
+
+ time_to_next_flow_completion = gtnets_get_time_to_next_flow_completion();
+
+ return time_to_next_flow_completion;
}
/* delta: by how many time units the simulation must advance */
xbt_swag_t running_actions =
surf_network_model->common_public->states.running_action_set;
- double time_to_next_flow_completion =
- gtnets_get_time_to_next_flow_completion();
-
/* If there are no renning flows, just return */
if (time_to_next_flow_completion < 0.0) {
return;
"GTNetS simulation couldn't find a flow that would complete");
}
-
-
xbt_swag_foreach(action, running_actions) {
- DEBUG1("]]]]]]]]] Action remains old value: %f", action->generic_action.remains);
+ DEBUG2("Action (%p) remains old value: %f", action, action->generic_action.remains);
double remain = gtnets_get_flow_rx(action);
+ DEBUG1("Remain value returned by GTNetS : %f", remain);
//need to trust this remain value
if(remain == 0){
action->generic_action.remains=0;
}else {
- action->generic_action.remains-=remain;
+ action->generic_action.remains=action->generic_action.cost-remain;
}
- DEBUG1("[[[[[[[[[ Action remains new value: %f", action->generic_action.remains);
+ DEBUG2("Action (%p) remains new value: %f", action, action->generic_action.remains);
}
for (i = 0; i < num_flows; i++) {
action->generic_action.finish = now + time_to_next_flow_completion;
action_change_state((surf_action_t) action, SURF_ACTION_DONE);
- /* TODO: Anything else here? */
-
- //need to map this action to the gtnets engine
- DEBUG1("]]]]]]]]] Action remains old value: %f", action->generic_action.remains);
- action->generic_action.remains -= gtnets_get_flow_rx(metadata[i]);
- DEBUG1("[[[[[[[[[ Action remains new value: %f", action->generic_action.remains);
+ DEBUG1("----> Action (%p) just terminated",action);
}
action = xbt_new0(s_surf_action_network_GTNETS_t, 1);
- action->generic_action.using = 1;
+ action->generic_action.refcount = 1;
action->generic_action.cost = size;
action->generic_action.remains = size;
/* Max durations are not supported */