3 * Network with improved management of tasks, IM (Improved Management).
4 * Uses a heap to store actions so that the share_resources is faster.
5 * This model automatically sets the selective update flag to 1 and is
6 * highly dependent on the maxmin lmm module.
9 /* Copyright (c) 2009, 2010, 2011. The SimGrid Team.
10 * All rights reserved. */
12 /* This program is free software; you can redistribute it and/or modify it
13 * under the terms of the license (GNU LGPL) which comes with this package. */
17 #include "surf_private.h"
19 #include "maxmin_private.h"
20 #include "surf/surf_resource_lmm.h"
24 #define GENERIC_ACTION(action) action->generic_action
27 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network_im, surf,
28 "Logging specific to the SURF network module");
31 enum heap_action_type{
38 typedef struct surf_action_network_CM02_im {
39 s_surf_action_t generic_action;
40 s_xbt_swag_hookup_t action_list_hookup;
44 lmm_variable_t variable;
46 #ifdef HAVE_LATENCY_BOUND_TRACKING
55 enum heap_action_type hat;
57 } s_surf_action_network_CM02_im_t, *surf_action_network_CM02_im_t;
60 typedef struct network_link_CM02_im {
61 s_surf_resource_lmm_t lmm_resource; /* must remain first to be added to a trace */
63 /* Using this object with the public part of
64 model does not make sense */
66 tmgr_trace_event_t lat_event;
67 } s_link_CM02_im_t, *link_CM02_im_t;
76 extern surf_model_t surf_network_model;
77 static lmm_system_t network_im_maxmin_system = NULL;
78 static void (*network_im_solve) (lmm_system_t) = NULL;
80 extern double sg_latency_factor;
81 extern double sg_bandwidth_factor;
82 extern double sg_weight_S_parameter;
84 extern double sg_tcp_gamma;
85 extern int sg_network_fullduplex;
88 static void im_net_action_recycle(surf_action_t action);
89 static int im_net_get_link_latency_limited(surf_action_t action);
90 static int im_net_action_is_suspended(surf_action_t action);
91 static double im_net_action_get_remains(surf_action_t action);
92 static void im_net_action_set_max_duration(surf_action_t action, double duration);
93 static void surf_network_model_init_CM02_im(const char *filename);
94 static void im_net_update_actions_state(double now, double delta);
95 static void update_action_remaining(double now);
97 static xbt_swag_t im_net_modified_set = NULL;
98 static xbt_heap_t im_net_action_heap = NULL;
99 xbt_swag_t keep_track = NULL;
100 extern int sg_maxmin_selective_update;
102 /* added to manage the communication action's heap */
103 static void im_net_action_update_index_heap(void *action, int i)
105 ((surf_action_network_CM02_im_t) action)->index_heap = i;
108 /* insert action on heap using a given key and a hat (heap_action_type)
109 * a hat can be of three types for communications:
111 * NORMAL = this is a normal heap entry stating the date to finish transmitting
112 * LATENCY = this is a heap entry to warn us when the latency is payed
113 * MAX_DURATION =this is a heap entry to warn us when the max_duration limit is reached
115 static void heap_insert(surf_action_network_CM02_im_t action, double key, enum heap_action_type hat){
117 xbt_heap_push(im_net_action_heap, action, key);
120 static void heap_remove(surf_action_network_CM02_im_t action){
122 if(((surf_action_network_CM02_im_t) action)->index_heap >= 0){
123 xbt_heap_remove(im_net_action_heap,action->index_heap);
127 /******************************************************************************/
128 /* Factors callbacks */
129 /******************************************************************************/
130 static double im_constant_latency_factor(double size)
132 return sg_latency_factor;
135 static double im_constant_bandwidth_factor(double size)
137 return sg_bandwidth_factor;
140 static double im_constant_bandwidth_constraint(double rate, double bound,
147 static double (*im_latency_factor_callback) (double) =
148 &im_constant_latency_factor;
149 static double (*im_bandwidth_factor_callback) (double) =
150 &im_constant_bandwidth_factor;
151 static double (*im_bandwidth_constraint_callback) (double, double, double) =
152 &im_constant_bandwidth_constraint;
155 static void* im_net_create_resource(const char *name,
157 tmgr_trace_t bw_trace,
159 tmgr_trace_t lat_trace,
160 e_surf_resource_state_t
162 tmgr_trace_t state_trace,
163 e_surf_link_sharing_policy_t
164 policy, xbt_dict_t properties)
166 link_CM02_im_t nw_link = (link_CM02_im_t)
167 surf_resource_lmm_new(sizeof(s_link_CM02_im_t),
168 surf_network_model, name, properties,
169 network_im_maxmin_system,
170 sg_bandwidth_factor * bw_initial,
172 state_initial, state_trace,
173 bw_initial, bw_trace);
175 xbt_assert(!xbt_lib_get_or_null(link_lib, name, SURF_LINK_LEVEL),
176 "Link '%s' declared several times in the platform file.",
179 nw_link->lat_current = lat_initial;
182 tmgr_history_add_trace(history, lat_trace, 0.0, 0, nw_link);
184 if (policy == SURF_LINK_FATPIPE)
185 lmm_constraint_shared(nw_link->lmm_resource.constraint);
187 xbt_lib_set(link_lib, name, SURF_LINK_LEVEL, nw_link);
193 static void im_net_parse_link_init(sg_platf_link_cbarg_t link)
195 if(link->policy == SURF_LINK_FULLDUPLEX)
197 im_net_create_resource(bprintf("%s_UP",link->id), link->bandwidth, link->bandwidth_trace,
198 link->latency, link->latency_trace, link->state, link->state_trace,
199 link->policy, link->properties);
200 im_net_create_resource(bprintf("%s_DOWN",link->id), link->bandwidth, link->bandwidth_trace,
201 link->latency, link->latency_trace, link->state, link->state_trace,
202 link->policy, NULL); // FIXME: We need to deep copy the properties or we won't be able to free it
206 im_net_create_resource(xbt_strdup(link->id), link->bandwidth, link->bandwidth_trace,
207 link->latency, link->latency_trace, link->state, link->state_trace,
208 link->policy, link->properties);
212 static void im_net_add_traces(void)
214 xbt_dict_cursor_t cursor = NULL;
215 char *trace_name, *elm;
217 static int called = 0;
222 /* connect all traces relative to network */
223 xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
224 tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
225 link_CM02_im_t link =
226 xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL);
228 xbt_assert(link, "Cannot connect trace %s to link %s: link undefined",
231 "Cannot connect trace %s to link %s: trace undefined",
234 link->lmm_resource.state_event =
235 tmgr_history_add_trace(history, trace, 0.0, 0, link);
238 xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
239 tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
240 link_CM02_im_t link =
241 xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL);
243 xbt_assert(link, "Cannot connect trace %s to link %s: link undefined",
246 "Cannot connect trace %s to link %s: trace undefined",
249 link->lmm_resource.power.event =
250 tmgr_history_add_trace(history, trace, 0.0, 0, link);
253 xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
254 tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
255 link_CM02_im_t link =
256 xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL);
258 xbt_assert(link, "Cannot connect trace %s to link %s: link undefined",
261 "Cannot connect trace %s to link %s: trace undefined",
264 link->lat_event = tmgr_history_add_trace(history, trace, 0.0, 0, link);
268 static void im_net_define_callbacks(void)
270 /* Figuring out the network links */
271 sg_platf_link_add_cb(im_net_parse_link_init);
272 sg_platf_postparse_add_cb(im_net_add_traces);
275 static int im_net_resource_used(void *resource_id)
277 return lmm_constraint_used(network_im_maxmin_system,
278 ((surf_resource_lmm_t)
279 resource_id)->constraint);
282 static int im_net_action_unref(surf_action_t action)
285 if (!action->refcount) {
286 xbt_swag_remove(action, action->state_set);
287 if (((surf_action_network_CM02_im_t) action)->variable){
288 lmm_variable_free(network_im_maxmin_system,
289 ((surf_action_network_CM02_im_t) action)->variable);
291 // remove action from the heap
292 heap_remove((surf_action_network_CM02_im_t) action);
294 xbt_swag_remove(action, im_net_modified_set);
296 xbt_free(((surf_action_network_CM02_im_t) action)->src_name);
297 xbt_free(((surf_action_network_CM02_im_t) action)->dst_name);
298 xbt_free(action->category);
300 surf_action_free(&action);
308 static void im_net_action_cancel(surf_action_t action)
310 surf_network_model->action_state_set(action, SURF_ACTION_FAILED);
312 xbt_swag_remove(action, im_net_modified_set);
313 // remove action from the heap
314 heap_remove((surf_action_network_CM02_im_t) action);
317 void im_net_action_recycle(surf_action_t action)
322 #ifdef HAVE_LATENCY_BOUND_TRACKING
323 int im_net_get_link_latency_limited(surf_action_t action)
325 return action->latency_limited;
329 double im_net_action_get_remains(surf_action_t action)
331 /* update remains before return it */
332 update_action_remaining(surf_get_clock());
333 return action->remains;
336 static void update_action_remaining(double now){
337 surf_action_network_CM02_im_t action = NULL;
340 xbt_swag_foreach(action, im_net_modified_set) {
342 if(action->suspended != 0){
346 delta = now - action->last_update;
348 double_update(&(action->generic_action.remains),
349 lmm_variable_getvalue(action->variable) * delta);
351 if (action->generic_action.max_duration != NO_MAX_DURATION)
352 double_update(&(action->generic_action.max_duration), delta);
354 if ((action->generic_action.remains <= 0) &&
355 (lmm_get_variable_weight(action->variable) > 0)) {
356 action->generic_action.finish = surf_get_clock();
357 surf_network_model->action_state_set((surf_action_t) action,
360 } else if ((action->generic_action.max_duration != NO_MAX_DURATION)
361 && (action->generic_action.max_duration <= 0)) {
362 action->generic_action.finish = surf_get_clock();
363 surf_network_model->action_state_set((surf_action_t) action,
368 action->last_update = now;
372 static double im_net_share_resources(double now)
374 surf_action_network_CM02_im_t action = NULL;
378 XBT_DEBUG("Before share resources, the size of modified actions set is %d", xbt_swag_size(im_net_modified_set));
379 update_action_remaining(now);
381 keep_track = im_net_modified_set;
382 lmm_solve(network_im_maxmin_system);
385 XBT_DEBUG("After share resources, The size of modified actions set is %d", xbt_swag_size(im_net_modified_set));
387 xbt_swag_foreach(action, im_net_modified_set) {
388 if (GENERIC_ACTION(action).state_set != surf_network_model->states.running_action_set){
392 /* bogus priority, skip it */
393 if (GENERIC_ACTION(action).priority <= 0){
398 value = lmm_variable_getvalue(action->variable);
400 if (GENERIC_ACTION(action).remains > 0) {
401 value = GENERIC_ACTION(action).remains / value;
409 if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION)
411 || GENERIC_ACTION(action).start +
412 GENERIC_ACTION(action).max_duration < min)){
413 min = GENERIC_ACTION(action).start +
414 GENERIC_ACTION(action).max_duration;
417 XBT_DEBUG("Action(%p) Start %lf Finish %lf Max_duration %lf", action,
418 GENERIC_ACTION(action).start, now + value,
419 GENERIC_ACTION(action).max_duration);
423 if (action->index_heap >= 0) {
424 heap_remove((surf_action_network_CM02_im_t) action);
428 heap_insert((surf_action_network_CM02_im_t) action, min, NORMAL);
429 XBT_DEBUG("Insert at heap action(%p) min %lf now %lf", action, min, now);
433 //hereafter must have already the min value for this resource model
434 if(xbt_heap_size(im_net_action_heap) > 0 ){
435 min = xbt_heap_maxkey(im_net_action_heap) - now ;
440 XBT_DEBUG("The minimum with the HEAP %lf", min);
446 static void im_net_update_actions_state(double now, double delta)
448 surf_action_network_CM02_im_t action = NULL;
450 while ((xbt_heap_size(im_net_action_heap) > 0)
451 && (double_equals(xbt_heap_maxkey(im_net_action_heap), now))) {
452 action = xbt_heap_pop(im_net_action_heap);
453 XBT_DEBUG("Action %p: finish", action);
454 GENERIC_ACTION(action).finish = surf_get_clock();
456 // if I am wearing a latency heat
457 if( action->hat == LATENCY){
458 lmm_update_variable_weight(network_im_maxmin_system, action->variable,
461 action->last_update = surf_get_clock();
463 XBT_DEBUG("Action (%p) is not limited by latency anymore", action);
464 #ifdef HAVE_LATENCY_BOUND_TRACKING
465 GENERIC_ACTION(action).latency_limited = 0;
468 // if I am wearing a max_duration or normal hat
469 }else if( action->hat == MAX_DURATION || action->hat == NORMAL ){
470 // no need to communicate anymore
471 // assume that flows that reached max_duration have remaining of 0
472 GENERIC_ACTION(action).remains = 0;
473 action->generic_action.finish = surf_get_clock();
474 surf_network_model->action_state_set((surf_action_t) action,
482 static void im_net_update_resource_state(void *id,
483 tmgr_trace_event_t event_type,
484 double value, double date)
486 link_CM02_im_t nw_link = id;
487 /* printf("[" "%lg" "] Asking to update network card \"%s\" with value " */
488 /* "%lg" " for event %p\n", surf_get_clock(), nw_link->name, */
489 /* value, event_type); */
491 if (event_type == nw_link->lmm_resource.power.event) {
493 sg_weight_S_parameter / value - sg_weight_S_parameter /
494 (nw_link->lmm_resource.power.peak *
495 nw_link->lmm_resource.power.scale);
496 lmm_variable_t var = NULL;
497 lmm_element_t elem = NULL;
498 surf_action_network_CM02_im_t action = NULL;
500 nw_link->lmm_resource.power.peak = value;
501 lmm_update_constraint_bound(network_im_maxmin_system,
502 nw_link->lmm_resource.constraint,
503 sg_bandwidth_factor *
504 (nw_link->lmm_resource.power.peak *
505 nw_link->lmm_resource.power.scale));
507 TRACE_surf_link_set_bandwidth(date, (char *)(((nw_link->lmm_resource).generic_resource).name),
508 sg_bandwidth_factor *
509 (nw_link->lmm_resource.power.peak *
510 nw_link->lmm_resource.power.scale));
512 if (sg_weight_S_parameter > 0) {
513 while ((var = lmm_get_var_from_cnst
514 (network_im_maxmin_system, nw_link->lmm_resource.constraint,
516 action = lmm_variable_id(var);
517 action->weight += delta;
518 if (!(action->suspended))
519 lmm_update_variable_weight(network_im_maxmin_system,
520 action->variable, action->weight);
523 if (tmgr_trace_event_free(event_type))
524 nw_link->lmm_resource.power.event = NULL;
525 } else if (event_type == nw_link->lat_event) {
526 double delta = value - nw_link->lat_current;
527 lmm_variable_t var = NULL;
528 lmm_element_t elem = NULL;
529 surf_action_network_CM02_im_t action = NULL;
531 nw_link->lat_current = value;
532 while ((var = lmm_get_var_from_cnst
533 (network_im_maxmin_system, nw_link->lmm_resource.constraint,
535 action = lmm_variable_id(var);
536 action->lat_current += delta;
537 action->weight += delta;
538 if (action->rate < 0)
539 lmm_update_variable_bound(network_im_maxmin_system, action->variable,
540 sg_tcp_gamma / (2.0 *
541 action->lat_current));
543 lmm_update_variable_bound(network_im_maxmin_system, action->variable,
545 sg_tcp_gamma / (2.0 *
546 action->lat_current)));
548 if (action->rate < sg_tcp_gamma / (2.0 * action->lat_current)) {
549 XBT_INFO("Flow is limited BYBANDWIDTH");
551 XBT_INFO("Flow is limited BYLATENCY, latency of flow is %f",
552 action->lat_current);
555 if (!(action->suspended))
556 lmm_update_variable_weight(network_im_maxmin_system, action->variable,
560 if (tmgr_trace_event_free(event_type))
561 nw_link->lat_event = NULL;
562 } else if (event_type == nw_link->lmm_resource.state_event) {
564 nw_link->lmm_resource.state_current = SURF_RESOURCE_ON;
566 lmm_constraint_t cnst = nw_link->lmm_resource.constraint;
567 lmm_variable_t var = NULL;
568 lmm_element_t elem = NULL;
570 nw_link->lmm_resource.state_current = SURF_RESOURCE_OFF;
571 while ((var = lmm_get_var_from_cnst
572 (network_im_maxmin_system, cnst, &elem))) {
573 surf_action_t action = lmm_variable_id(var);
575 if (surf_action_state_get(action) == SURF_ACTION_RUNNING ||
576 surf_action_state_get(action) == SURF_ACTION_READY) {
577 action->finish = date;
578 surf_network_model->action_state_set(action, SURF_ACTION_FAILED);
582 if (tmgr_trace_event_free(event_type))
583 nw_link->lmm_resource.state_event = NULL;
585 XBT_CRITICAL("Unknown event ! \n");
589 XBT_DEBUG("There were a resource state event, need to update actions related to the constraint (%p)", nw_link->lmm_resource.constraint);
594 static surf_action_t im_net_communicate(const char *src_name,
595 const char *dst_name, double size,
601 surf_action_network_CM02_im_t action = NULL;
602 double bandwidth_bound;
603 /* LARGE PLATFORMS HACK:
604 Add a link_CM02_im_t *link and a int link_nb to network_card_CM02_im_t. It will represent local links for this node
605 Use the cluster_id for ->id */
607 xbt_dynar_t back_route = NULL;
608 int constraints_per_variable = 0;
609 // I will need this route for some time so let's call get_route_no_cleanup
610 xbt_dynar_t route = global_routing->get_route_no_cleanup(src_name, dst_name);
613 if (sg_network_fullduplex == 1) {
614 back_route = global_routing->get_route(dst_name, src_name);
617 /* LARGE PLATFORMS HACK:
618 total_route_size = route_size + src->link_nb + dst->nb */
620 XBT_IN("(%s,%s,%g,%g)", src_name, dst_name, size, rate);
621 /* LARGE PLATFORMS HACK:
622 assert on total_route_size */
623 xbt_assert(xbt_dynar_length(route),
624 "You're trying to send data from %s to %s but there is no connection between these two hosts.",
627 xbt_dynar_foreach(route, i, link) {
628 if (link->lmm_resource.state_current == SURF_RESOURCE_OFF) {
634 surf_action_new(sizeof(s_surf_action_network_CM02_im_t), size,
635 surf_network_model, failed);
638 #ifdef HAVE_LATENCY_BOUND_TRACKING
639 (action->generic_action).latency_limited = 0;
642 xbt_swag_insert(action, action->generic_action.state_set);
644 action->index_heap = -1;
645 action->latency = 0.0;
646 action->weight = 0.0;
647 action->last_update = surf_get_clock();
649 bandwidth_bound = -1.0;
650 xbt_dynar_foreach(route, i, link) {
651 action->latency += link->lat_current;
654 sg_weight_S_parameter /
655 (link->lmm_resource.power.peak * link->lmm_resource.power.scale);
656 if (bandwidth_bound < 0.0)
658 (*im_bandwidth_factor_callback) (size) *
659 (link->lmm_resource.power.peak * link->lmm_resource.power.scale);
663 (*im_bandwidth_factor_callback) (size) *
664 (link->lmm_resource.power.peak *
665 link->lmm_resource.power.scale));
667 /* LARGE PLATFORMS HACK:
668 Add src->link and dst->link latencies */
669 action->lat_current = action->latency;
670 action->latency *= (*im_latency_factor_callback) (size);
672 (*im_bandwidth_constraint_callback) (action->rate, bandwidth_bound,
675 /* LARGE PLATFORMS HACK:
676 lmm_variable_new(..., total_route_size) */
677 if (back_route != NULL) {
678 constraints_per_variable =
679 xbt_dynar_length(route) + xbt_dynar_length(back_route);
681 constraints_per_variable = xbt_dynar_length(route);
684 if (action->latency > 0){
686 lmm_variable_new(network_im_maxmin_system, action, 0.0, -1.0,
687 constraints_per_variable);
688 // add to the heap the event when the latency is payed
689 XBT_DEBUG("Added action (%p) one latency event at date %f", action, action->latency + action->last_update);
690 heap_insert(action, action->latency + action->last_update, LATENCY);
691 #ifdef HAVE_LATENCY_BOUND_TRACKING
692 (action->generic_action).latency_limited = 1;
697 lmm_variable_new(network_im_maxmin_system, action, 1.0, -1.0,
698 constraints_per_variable);
700 if (action->rate < 0) {
701 if (action->lat_current > 0)
702 lmm_update_variable_bound(network_im_maxmin_system, action->variable,
703 sg_tcp_gamma / (2.0 *
704 action->lat_current));
706 lmm_update_variable_bound(network_im_maxmin_system, action->variable,
709 if (action->lat_current > 0)
710 lmm_update_variable_bound(network_im_maxmin_system, action->variable,
712 sg_tcp_gamma / (2.0 *
713 action->lat_current)));
715 lmm_update_variable_bound(network_im_maxmin_system, action->variable,
719 xbt_dynar_foreach(route, i, link) {
720 lmm_expand(network_im_maxmin_system, link->lmm_resource.constraint,
721 action->variable, 1.0);
724 if (sg_network_fullduplex == 1) {
725 XBT_DEBUG("Fullduplex active adding backward flow using 5%c", '%');
726 xbt_dynar_foreach(back_route, i, link) {
727 lmm_expand(network_im_maxmin_system, link->lmm_resource.constraint,
728 action->variable, .05);
732 /* LARGE PLATFORMS HACK:
733 expand also with src->link and dst->link */
735 if (TRACE_is_enabled()) {
736 action->src_name = xbt_strdup(src_name);
737 action->dst_name = xbt_strdup(dst_name);
739 action->src_name = action->dst_name = NULL;
743 xbt_dynar_free(&route);
746 return (surf_action_t) action;
749 static xbt_dynar_t im_net_get_route(const char *src, const char *dst)
751 return global_routing->get_route(src, dst);
754 static double im_net_get_link_bandwidth(const void *link)
756 surf_resource_lmm_t lmm = (surf_resource_lmm_t) link;
757 return lmm->power.peak * lmm->power.scale;
760 static double im_net_get_link_latency(const void *link)
762 return ((link_CM02_im_t) link)->lat_current;
765 static int im_net_link_shared(const void *link)
768 lmm_constraint_is_shared(((surf_resource_lmm_t) link)->constraint);
771 static void im_net_action_suspend(surf_action_t action)
773 ((surf_action_network_CM02_im_t) action)->suspended = 1;
774 lmm_update_variable_weight(network_im_maxmin_system,
775 ((surf_action_network_CM02_im_t)
776 action)->variable, 0.0);
778 // remove action from the heap
779 heap_remove((surf_action_network_CM02_im_t) action);
782 static void im_net_action_resume(surf_action_t action)
784 if (((surf_action_network_CM02_im_t) action)->suspended) {
785 lmm_update_variable_weight(network_im_maxmin_system,
786 ((surf_action_network_CM02_im_t)
788 ((surf_action_network_CM02_im_t)
790 ((surf_action_network_CM02_im_t) action)->suspended = 0;
791 // remove action from the heap
792 heap_remove((surf_action_network_CM02_im_t) action);
796 static int im_net_action_is_suspended(surf_action_t action)
798 return ((surf_action_network_CM02_im_t) action)->suspended;
801 void im_net_action_set_max_duration(surf_action_t action, double duration)
803 action->max_duration = duration;
804 // remove action from the heap
805 heap_remove((surf_action_network_CM02_im_t) action);
809 static void im_net_finalize(void)
811 surf_model_exit(surf_network_model);
812 surf_network_model = NULL;
814 global_routing->finalize();
816 lmm_system_free(network_im_maxmin_system);
817 network_im_maxmin_system = NULL;
819 xbt_heap_free(im_net_action_heap);
820 xbt_swag_free(im_net_modified_set);
824 static void im_surf_network_model_init_internal(void)
826 s_surf_action_network_CM02_im_t comm;
828 surf_network_model = surf_model_init();
830 surf_network_model->name = "network";
831 surf_network_model->action_unref = im_net_action_unref;
832 surf_network_model->action_cancel = im_net_action_cancel;
833 surf_network_model->action_recycle = im_net_action_recycle;
834 surf_network_model->get_remains = im_net_action_get_remains;
835 #ifdef HAVE_LATENCY_BOUND_TRACKING
836 surf_network_model->get_latency_limited = im_net_get_link_latency_limited;
839 surf_network_model->model_private->resource_used = im_net_resource_used;
840 surf_network_model->model_private->share_resources = im_net_share_resources;
841 surf_network_model->model_private->update_actions_state =
842 im_net_update_actions_state;
843 surf_network_model->model_private->update_resource_state =
844 im_net_update_resource_state;
845 surf_network_model->model_private->finalize = im_net_finalize;
847 surf_network_model->suspend = im_net_action_suspend;
848 surf_network_model->resume = im_net_action_resume;
849 surf_network_model->is_suspended = im_net_action_is_suspended;
850 surf_cpu_model->set_max_duration = im_net_action_set_max_duration;
852 surf_network_model->extension.network.communicate = im_net_communicate;
853 surf_network_model->extension.network.get_route = im_net_get_route;
854 surf_network_model->extension.network.get_link_bandwidth =
855 im_net_get_link_bandwidth;
856 surf_network_model->extension.network.get_link_latency =
857 im_net_get_link_latency;
858 surf_network_model->extension.network.link_shared = im_net_link_shared;
859 surf_network_model->extension.network.add_traces = im_net_add_traces;
860 surf_network_model->extension.network.create_resource =
861 im_net_create_resource;
864 if (!network_im_maxmin_system){
865 sg_maxmin_selective_update = 1;
866 network_im_maxmin_system = lmm_system_new();
868 im_net_action_heap = xbt_heap_new(8,NULL);
870 xbt_heap_set_update_callback(im_net_action_heap, im_net_action_update_index_heap);
872 routing_model_create(sizeof(link_CM02_im_t),
873 im_net_create_resource(xbt_strdup("__loopback__"),
874 498000000, NULL, 0.000015, NULL,
875 SURF_RESOURCE_ON, NULL,
876 SURF_LINK_FATPIPE, NULL));
877 im_net_modified_set =
878 xbt_swag_new(xbt_swag_offset(comm, action_list_hookup));
883 /************************************************************************/
884 /* New model based on optimizations discussed during this thesis */
885 /************************************************************************/
886 void im_surf_network_model_init_LegrandVelho(void)
889 if (surf_network_model)
891 im_surf_network_model_init_internal();
892 im_net_define_callbacks();
893 xbt_dynar_push(model_list, &surf_network_model);
894 network_im_solve = lmm_solve;
896 xbt_cfg_setdefault_double(_surf_cfg_set, "network/latency_factor", 10.4);
897 xbt_cfg_setdefault_double(_surf_cfg_set, "network/bandwidth_factor",
899 xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 8775);