static int src_id = -1;
static int dst_id = -1;
-/* Free memory for a network link */
-static void link_free(void *nw_link)
-{
- xbt_dict_free(&(((network_link_GTNETS_t) nw_link)->properties));
- surf_resource_free(nw_link);
-}
-
/* Instantiate a new network link */
/* name: some name for the link, from the XML */
/* bw: The bandwidth value */
/* KF: Insert entry in the dictionary */
gtnets_link = xbt_new0(s_network_link_GTNETS_t, 1);
gtnets_link->generic_resource.name = name;
+ gtnets_link->generic_resource.properties = props;
gtnets_link->bw_current = bw;
gtnets_link->lat_current = lat;
gtnets_link->id = link_count;
- /* Add the properties */
- gtnets_link->properties = props;
- xbt_dict_set(surf_network_model->resource_set, name, gtnets_link, link_free);
+ xbt_dict_set(surf_network_model->resource_set, name, gtnets_link, surf_resource_free);
return;
}
/* KF: just use the dictionary to map link names to link indices */
card = xbt_new0(s_network_card_GTNETS_t, 1);
- card->generic_resource.name = xbt_strdup(name);
+ card->name = xbt_strdup(name);
card->id = card_count;
xbt_dict_set(surf_model_resource_set(surf_network_model), name, card,
surf_resource_free);
char *name;
double bw;
double lat;
- e_surf_link_state_t state;
+ e_surf_resource_state_t state;
name = xbt_strdup(A_surfxml_link_id);
surf_parse_get_double(&bw, A_surfxml_link_bandwidth);
surf_parse_get_double(&lat, A_surfxml_link_latency);
- state = SURF_LINK_ON;
+ state = SURF_RESOURCE_ON;
tmgr_trace_t bw_trace;
tmgr_trace_t state_trace;
tmgr_trace_t lat_trace;
- surf_parse_get_trace(&bw_trace, A_surfxml_link_bandwidth_file);
- surf_parse_get_trace(&lat_trace, A_surfxml_link_latency_file);
- surf_parse_get_trace(&state_trace, A_surfxml_link_state_file);
+ bw_trace = tmgr_trace_new(A_surfxml_link_bandwidth_file);
+ lat_trace = tmgr_trace_new(A_surfxml_link_latency_file);
+ state_trace = tmgr_trace_new(A_surfxml_link_state_file);
if (bw_trace)
INFO0("The GTNetS network model doesn't support bandwidth state traces");
surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_route);
}
-static xbt_dict_t get_properties(void *link)
-{
- return ((network_card_GTNETS_t) link)->properties;
-}
-
-
/* We do not care about this: only used for traces */
static int resource_used(void *resource_id)
{
return;
}
-static void action_change_state(surf_action_t action,
+static void action_state_set(surf_action_t action,
e_surf_action_state_t state)
{
/* if((state==SURF_ACTION_DONE) || (state==SURF_ACTION_FAILED)) */
static double share_resources(double now)
{
xbt_swag_t running_actions =
- surf_network_model->common_public.states.running_action_set;
+ surf_network_model->states.running_action_set;
//get the first relevant value from the running_actions list
if (!xbt_swag_size(running_actions))
surf_action_network_GTNETS_t action = NULL;
// surf_action_network_GTNETS_t next_action = NULL;
xbt_swag_t running_actions =
- surf_network_model->common_public.states.running_action_set;
+ surf_network_model->states.running_action_set;
/* If there are no renning flows, just return */
if (time_to_next_flow_completion < 0.0) {
action = (surf_action_network_GTNETS_t) (metadata[i]);
action->generic_action.finish = now + time_to_next_flow_completion;
- action_change_state((surf_action_t) action, SURF_ACTION_DONE);
+ action_state_set((surf_action_t) action, SURF_ACTION_DONE);
DEBUG1("----> Action (%p) just terminated", action);
}
}
/* KF: Rate not supported */
-static surf_action_t communicate(void *src, void *dst, double size,
+/* Max durations are not supported */
+static surf_action_t communicate(const char *src_name, const char *dst_name,int src, int dst, double size,
double rate)
{
surf_action_network_GTNETS_t action = NULL;
- network_card_GTNETS_t card_src = src;
- network_card_GTNETS_t card_dst = dst;
-/*
- int route_size = ROUTE_SIZE(card_src->id, card_dst->id);
- network_link_GTNETS_t *route = ROUTE(card_src->id, card_dst->id);
-*/
-/*
- xbt_assert2(route_size,"You're trying to send data from %s to %s but there is no connexion between these two cards.", card_src->name, card_dst->name);
-*/
-
- action = xbt_new0(s_surf_action_network_GTNETS_t, 1);
-
- action->generic_action.refcount = 1;
- action->generic_action.cost = size;
- action->generic_action.remains = size;
- /* Max durations are not supported */
- action->generic_action.max_duration = NO_MAX_DURATION;
- action->generic_action.start = surf_get_clock();
- action->generic_action.finish = -1.0;
- action->generic_action.model_type = surf_network_model;
-
- action->generic_action.state_set =
- surf_network_model->common_public.states.running_action_set;
-
- xbt_swag_insert(action, action->generic_action.state_set);
+ action = surf_action_new(sizeof(s_surf_action_network_GTNETS_t),size,surf_network_model,0);
/* KF: Add a flow to the GTNets Simulation, associated to this action */
- if (gtnets_create_flow(card_src->id, card_dst->id, size, (void *) action)
- < 0) {
- xbt_assert2(0, "Not route between host %s and host %s", card_src->generic_resource.name,
- card_dst->generic_resource.name);
+ if (gtnets_create_flow(src, dst, size, (void *) action) < 0) {
+ xbt_assert2(0, "Not route between host %s and host %s", src_name,
+ dst_name);
}
return (surf_action_t) action;
static void surf_network_model_init_internal(void)
{
- s_surf_action_t action;
-
surf_network_model = surf_model_init();
surf_network_model->name = "network GTNetS";
surf_network_model->action_unref = action_unref;
surf_network_model->action_cancel = action_cancel;
surf_network_model->action_recycle = action_recycle;
- surf_network_model->action_change_state = action_change_state;
+ surf_network_model->action_state_set = action_state_set;
surf_network_model->model_private->resource_used = resource_used;
surf_network_model->model_private->share_resources = share_resources;
surf_network_model->extension.network.communicate = communicate;
- /*for the props of the link */
- surf_network_model->get_properties = get_properties;
-
/* KF: Added the initialization for GTNetS interface */
if (gtnets_initialize()) {
xbt_assert0(0, "impossible to initialize GTNetS interface");