Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a89e5516edfcabbc9d50031e5e97504be0489665
[simgrid.git] / src / surf / network.c
1 /*      $Id$     */
2
3 /* Copyright (c) 2004 Arnaud Legrand. All rights reserved.                  */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8 #include "network_private.h"
9 #include "xbt/log.h"
10
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf,
12                                 "Logging specific to the SURF network module");
13
14 surf_network_resource_t surf_network_resource = NULL;
15 static lmm_system_t network_maxmin_system = NULL;
16 static void (*network_solve)(lmm_system_t) = NULL;
17
18 xbt_dict_t network_link_set = NULL;
19 xbt_dict_t network_card_set = NULL;
20
21 int card_number = 0;
22 network_link_CM02_t **routing_table = NULL;
23 int *routing_table_size = NULL;
24 static network_link_CM02_t loopback = NULL;
25
26 static void create_routing_table(void)
27 {
28   routing_table = xbt_new0(network_link_CM02_t *, card_number * card_number);
29   routing_table_size = xbt_new0(int, card_number * card_number);
30 }
31
32 static void network_link_free(void *nw_link)
33 {
34   free(((network_link_CM02_t)nw_link)->name);
35   free(nw_link);
36 }
37
38 static network_link_CM02_t network_link_new(char *name,
39                                        double bw_initial,
40                                        tmgr_trace_t bw_trace,
41                                        double lat_initial,
42                                        tmgr_trace_t lat_trace,
43                                        e_surf_network_link_state_t
44                                        state_initial,
45                                        tmgr_trace_t state_trace,
46                                        e_surf_network_link_sharing_policy_t policy)
47 {
48   network_link_CM02_t nw_link = xbt_new0(s_network_link_CM02_t, 1);
49
50
51   nw_link->resource = (surf_resource_t) surf_network_resource;
52   nw_link->name = name;
53   nw_link->bw_current = bw_initial;
54   if (bw_trace)
55     nw_link->bw_event =
56         tmgr_history_add_trace(history, bw_trace, 0.0, 0, nw_link);
57   nw_link->lat_current = lat_initial;
58   if (lat_trace)
59     nw_link->lat_event =
60         tmgr_history_add_trace(history, lat_trace, 0.0, 0, nw_link);
61   nw_link->state_current = state_initial;
62   if (state_trace)
63     nw_link->state_event =
64         tmgr_history_add_trace(history, state_trace, 0.0, 0, nw_link);
65
66   nw_link->constraint =
67       lmm_constraint_new(network_maxmin_system, nw_link, nw_link->bw_current);
68
69   if(policy == SURF_NETWORK_LINK_FATPIPE)
70     lmm_constraint_shared(nw_link->constraint);
71
72   xbt_dict_set(network_link_set, name, nw_link, network_link_free);
73
74   return nw_link;
75 }
76
77 static void network_card_free(void *nw_card)
78 {
79   free(((network_card_CM02_t)nw_card)->name);
80   free(nw_card);
81 }
82
83 static int network_card_new(const char *card_name)
84 {
85   network_card_CM02_t card = xbt_dict_get_or_null(network_card_set, card_name);
86
87   if (!card) {
88     card = xbt_new0(s_network_card_CM02_t, 1);
89     card->name = xbt_strdup(card_name);
90     card->id = card_number++;
91     xbt_dict_set(network_card_set, card_name, card, network_card_free);
92   }
93   return card->id;
94 }
95
96 static void route_new(int src_id, int dst_id, network_link_CM02_t *link_list, int nb_link)
97 {
98   ROUTE_SIZE(src_id, dst_id) = nb_link;
99   ROUTE(src_id, dst_id) = link_list = xbt_realloc(link_list, sizeof(network_link_CM02_t) * nb_link);
100 }
101
102 static void parse_network_link(void)
103 {
104   char *name;
105   double bw_initial;
106   tmgr_trace_t bw_trace;
107   double lat_initial;
108   tmgr_trace_t lat_trace;
109   e_surf_network_link_state_t state_initial = SURF_NETWORK_LINK_ON;
110   e_surf_network_link_sharing_policy_t policy_initial = SURF_NETWORK_LINK_SHARED;
111   tmgr_trace_t state_trace;
112
113   name = xbt_strdup(A_surfxml_network_link_name);
114   surf_parse_get_double(&bw_initial,A_surfxml_network_link_bandwidth);
115   surf_parse_get_trace(&bw_trace, A_surfxml_network_link_bandwidth_file);
116   surf_parse_get_double(&lat_initial,A_surfxml_network_link_latency);
117   surf_parse_get_trace(&lat_trace, A_surfxml_network_link_latency_file);
118
119   xbt_assert0((A_surfxml_network_link_state==A_surfxml_network_link_state_ON)||
120               (A_surfxml_network_link_state==A_surfxml_network_link_state_OFF),
121               "Invalid state");
122   if (A_surfxml_network_link_state==A_surfxml_network_link_state_ON) 
123     state_initial = SURF_NETWORK_LINK_ON;
124   else if (A_surfxml_network_link_state==A_surfxml_network_link_state_OFF) 
125     state_initial = SURF_NETWORK_LINK_OFF;
126
127   if (A_surfxml_network_link_sharing_policy==A_surfxml_network_link_sharing_policy_SHARED) 
128     policy_initial = SURF_NETWORK_LINK_SHARED;
129   else if (A_surfxml_network_link_sharing_policy==A_surfxml_network_link_sharing_policy_FATPIPE) 
130     policy_initial = SURF_NETWORK_LINK_FATPIPE;
131
132   surf_parse_get_trace(&state_trace,A_surfxml_network_link_state_file);
133
134   network_link_new(name, bw_initial, bw_trace,
135                    lat_initial, lat_trace, state_initial, state_trace,
136                    policy_initial);
137 }
138
139 static int nb_link;
140 static int link_list_capacity;
141 static network_link_CM02_t *link_list = NULL;
142 static int src_id = -1;
143 static int dst_id = -1;
144
145 static void parse_route_set_endpoints(void)
146 {
147   src_id = network_card_new(A_surfxml_route_src);
148   dst_id = network_card_new(A_surfxml_route_dst);
149   nb_link = 0;
150   link_list_capacity = 20;
151   link_list = xbt_new(network_link_CM02_t, link_list_capacity);
152 }
153
154 static void parse_route_elem(void)
155 {
156   if (nb_link == link_list_capacity) {
157     link_list_capacity *= 2;
158     link_list = xbt_realloc(link_list, (link_list_capacity) * sizeof(network_link_CM02_t));
159   }
160   link_list[nb_link++] = xbt_dict_get_or_null(network_link_set, A_surfxml_route_element_name);
161 }
162
163 static void parse_route_set_route(void)
164 {
165   route_new(src_id, dst_id, link_list, nb_link);
166 }
167
168 static void parse_file(const char *file)
169 {
170   int i;
171
172   /* Figuring out the network links */
173   surf_parse_reset_parser();
174   ETag_surfxml_network_link_fun=parse_network_link;
175   surf_parse_open(file);
176   xbt_assert1((!surf_parse()),"Parse error in %s",file);
177   surf_parse_close();
178
179   /* Figuring out the network cards used */
180   surf_parse_reset_parser();
181   STag_surfxml_route_fun=parse_route_set_endpoints;
182   surf_parse_open(file);
183   xbt_assert1((!surf_parse()),"Parse error in %s",file);
184   surf_parse_close();
185
186   create_routing_table();
187
188   /* Building the routes */
189   surf_parse_reset_parser();
190   STag_surfxml_route_fun=parse_route_set_endpoints;
191   ETag_surfxml_route_element_fun=parse_route_elem;
192   ETag_surfxml_route_fun=parse_route_set_route;
193   surf_parse_open(file);
194   xbt_assert1((!surf_parse()),"Parse error in %s",file);
195   surf_parse_close();
196
197   /* Adding loopback if needed */
198     
199   for (i = 0; i < card_number; i++) 
200     if(!ROUTE_SIZE(i,i)) {
201       if(!loopback)
202         loopback = network_link_new(xbt_strdup("__MSG_loopback__"), 
203                                    498000000, NULL, 0.000015, NULL, 
204                                    SURF_NETWORK_LINK_ON, NULL,
205                                    SURF_NETWORK_LINK_FATPIPE);
206       ROUTE_SIZE(i,i)=1;
207       ROUTE(i,i) = xbt_new0(network_link_CM02_t, 1);
208       ROUTE(i,i)[0] = loopback;
209     }
210 }
211
212 static void *name_service(const char *name)
213 {
214   network_card_CM02_t card = xbt_dict_get_or_null(network_card_set, name);
215   return card;
216 }
217
218 static const char *get_resource_name(void *resource_id)
219 {
220   return ((network_card_CM02_t) resource_id)->name;
221 }
222
223 static int resource_used(void *resource_id)
224 {
225   return lmm_constraint_used(network_maxmin_system,
226                              ((network_link_CM02_t) resource_id)->constraint);
227 }
228
229 static int action_free(surf_action_t action)
230 {
231   action->using--;
232   if(!action->using) {
233     xbt_swag_remove(action, action->state_set);
234     if(((surf_action_network_CM02_t)action)->variable)
235       lmm_variable_free(network_maxmin_system, ((surf_action_network_CM02_t)action)->variable);
236     free(action);
237     return 1;
238   }
239   return 0;
240 }
241
242 static void action_use(surf_action_t action)
243 {
244   action->using++;
245 }
246
247 static void action_cancel(surf_action_t action)
248 {
249   return;
250 }
251
252 static void action_recycle(surf_action_t action)
253 {
254   return;
255 }
256
257 static void action_change_state(surf_action_t action,
258                                 e_surf_action_state_t state)
259 {
260 /*   if((state==SURF_ACTION_DONE) || (state==SURF_ACTION_FAILED)) */
261 /*     if(((surf_action_network_CM02_t)action)->variable) { */
262 /*       lmm_variable_disable(network_maxmin_system, ((surf_action_network_CM02_t)action)->variable); */
263 /*       ((surf_action_network_CM02_t)action)->variable = NULL; */
264 /*     } */
265
266   surf_action_change_state(action, state);
267   return;
268 }
269
270 static double share_resources(double now)
271 {
272   s_surf_action_network_CM02_t s_action;
273   surf_action_network_CM02_t action = NULL;
274   xbt_swag_t running_actions = surf_network_resource->common_public->states.running_action_set;
275   double min;
276   
277   min = generic_maxmin_share_resources2(running_actions,
278                                         xbt_swag_offset(s_action, variable),
279                                         network_maxmin_system, network_solve);
280
281   xbt_swag_foreach(action, running_actions) {
282     if(action->latency>0) {
283       if(min<0) min = action->latency;
284       else if (action->latency<min) min = action->latency;
285     }
286   }
287
288   return min;
289 }
290
291 static void update_actions_state(double now, double delta)
292 {
293   double deltap = 0.0;
294   surf_action_network_CM02_t action = NULL;
295   surf_action_network_CM02_t next_action = NULL;
296   xbt_swag_t running_actions =
297       surf_network_resource->common_public->states.running_action_set;
298   /*
299   xbt_swag_t failed_actions =
300       surf_network_resource->common_public->states.failed_action_set;
301   */
302
303   xbt_swag_foreach_safe(action, next_action, running_actions) {
304     deltap = delta;
305     if (action->latency > 0) {
306       if (action->latency > deltap) {
307         double_update(&(action->latency),deltap);
308         deltap = 0.0;
309       } else {
310         double_update(&(deltap), action->latency);
311         action->latency = 0.0;
312       }
313       if ((action->latency == 0.0) && !(action->suspended)) 
314         lmm_update_variable_weight(network_maxmin_system, action->variable, 
315                                    action->lat_current);
316     }
317     double_update(&(action->generic_action.remains),
318         lmm_variable_getvalue(action->variable) * deltap);
319     if (action->generic_action.max_duration != NO_MAX_DURATION)
320       double_update(&(action->generic_action.max_duration), delta);
321
322     /*   if(action->generic_action.remains<.00001) action->generic_action.remains=0; */
323
324     if ((action->generic_action.remains <= 0) && 
325         (lmm_get_variable_weight(action->variable)>0)) {
326       action->generic_action.finish = surf_get_clock();
327       action_change_state((surf_action_t) action, SURF_ACTION_DONE);
328     } else if ((action->generic_action.max_duration != NO_MAX_DURATION) &&
329                (action->generic_action.max_duration <= 0)) {
330       action->generic_action.finish = surf_get_clock();
331       action_change_state((surf_action_t) action, SURF_ACTION_DONE);
332     } else {                    /* Need to check that none of the resource has failed */
333       lmm_constraint_t cnst = NULL;
334       int i = 0;
335       network_link_CM02_t nw_link = NULL;
336
337       while ((cnst =
338               lmm_get_cnst_from_var(network_maxmin_system, action->variable,
339                                     i++))) {
340         nw_link = lmm_constraint_id(cnst);
341         if (nw_link->state_current == SURF_NETWORK_LINK_OFF) {
342           action->generic_action.finish = surf_get_clock();
343           action_change_state((surf_action_t) action, SURF_ACTION_FAILED);
344           break;
345         }
346       }
347     }
348   }
349
350   return;
351 }
352
353 static void update_resource_state(void *id,
354                                   tmgr_trace_event_t event_type,
355                                   double value)
356 {
357   network_link_CM02_t nw_link = id;
358   /*   printf("[" "%lg" "] Asking to update network card \"%s\" with value " */
359   /*     "%lg" " for event %p\n", surf_get_clock(), nw_link->name, */
360   /*     value, event_type); */
361
362   if (event_type == nw_link->bw_event) {
363     nw_link->bw_current = value;
364     lmm_update_constraint_bound(network_maxmin_system, nw_link->constraint,
365                                 nw_link->bw_current);
366   } else if (event_type == nw_link->lat_event) {
367     double delta = value - nw_link->lat_current;
368     lmm_variable_t var = NULL;
369     surf_action_network_CM02_t action = NULL;
370
371     nw_link->lat_current = value;
372     while (lmm_get_var_from_cnst(network_maxmin_system, nw_link->constraint, &var)) {
373       action = lmm_variable_id(var);
374       action->lat_current += delta;
375       if(action->rate<0)
376         lmm_update_variable_bound(network_maxmin_system, action->variable,
377                                   SG_TCP_CTE_GAMMA / (2.0 * action->lat_current));
378       else 
379         lmm_update_variable_bound(network_maxmin_system, action->variable,
380                                   min(action->rate,SG_TCP_CTE_GAMMA / (2.0 * action->lat_current)));
381       if(!(action->suspended))
382         lmm_update_variable_weight(network_maxmin_system, action->variable, 
383                                    action->lat_current);
384         lmm_update_variable_latency(network_maxmin_system, action->variable, delta);      
385     }
386   } else if (event_type == nw_link->state_event) {
387     if (value > 0)
388       nw_link->state_current = SURF_NETWORK_LINK_ON;
389     else
390       nw_link->state_current = SURF_NETWORK_LINK_OFF;
391   } else {
392     CRITICAL0("Unknown event ! \n");
393     xbt_abort();
394   }
395
396   return;
397 }
398
399 static surf_action_t communicate(void *src, void *dst, double size, double rate)
400 {
401   surf_action_network_CM02_t action = NULL;
402   network_card_CM02_t card_src = src;
403   network_card_CM02_t card_dst = dst;
404   int route_size = ROUTE_SIZE(card_src->id, card_dst->id);
405   network_link_CM02_t *route = ROUTE(card_src->id, card_dst->id);
406   int i;
407
408   XBT_IN4("(%s,%s,%g,%g)",card_src->name,card_dst->name,size,rate);
409   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);
410
411   action = xbt_new0(s_surf_action_network_CM02_t, 1);
412
413   action->generic_action.using = 1;
414   action->generic_action.cost = size;
415   action->generic_action.remains = size;
416   action->generic_action.max_duration = NO_MAX_DURATION;
417   action->generic_action.start = surf_get_clock();
418   action->generic_action.finish = -1.0;
419   action->generic_action.resource_type =
420       (surf_resource_t) surf_network_resource;
421   action->suspended = 0;  /* Should be useless because of the 
422                              calloc but it seems to help valgrind... */
423   action->generic_action.state_set =
424       surf_network_resource->common_public->states.running_action_set;
425
426   xbt_swag_insert(action, action->generic_action.state_set);
427   action->rate = rate;
428
429   action->latency = 0.0;
430   for (i = 0; i < route_size; i++)
431     action->latency += route[i]->lat_current;
432   action->lat_current = action->latency;
433
434   if(action->latency>0)
435     action->variable = lmm_variable_new(network_maxmin_system, action, 0.0, -1.0,
436                                         route_size);
437   else 
438     action->variable = lmm_variable_new(network_maxmin_system, action, 1.0, -1.0,
439                                         route_size);
440
441   if(action->rate<0) {
442     if(action->lat_current>0)
443       lmm_update_variable_bound(network_maxmin_system, action->variable,
444                                 SG_TCP_CTE_GAMMA / (2.0 * action->lat_current));
445     else
446       lmm_update_variable_bound(network_maxmin_system, action->variable, -1.0);
447   } else {
448     if(action->lat_current>0)
449       lmm_update_variable_bound(network_maxmin_system, action->variable,
450                                 min(action->rate,SG_TCP_CTE_GAMMA / (2.0 * action->lat_current)));
451     else
452       lmm_update_variable_bound(network_maxmin_system, action->variable, action->rate);
453   }
454   lmm_update_variable_latency(maxmin_system, action->variable, action->latency);
455
456   for (i = 0; i < route_size; i++)
457     lmm_expand(network_maxmin_system, route[i]->constraint, action->variable, 1.0);
458   XBT_OUT;
459
460   return (surf_action_t) action;
461 }
462
463 /* returns an array of network_link_CM02_t */
464 static const void** get_route(void *src, void *dst) {
465   network_card_CM02_t card_src = src;
466   network_card_CM02_t card_dst = dst;
467   return (const void**) ROUTE(card_src->id, card_dst->id);
468 }
469
470 static int get_route_size(void *src, void *dst) {
471   network_card_CM02_t card_src = src;
472   network_card_CM02_t card_dst = dst;
473   return ROUTE_SIZE(card_src->id, card_dst->id);
474 }
475
476 static const char *get_link_name(const void *link) {
477   return ((network_link_CM02_t) link)->name;
478 }
479
480 static double get_link_bandwidth(const void *link) {
481   return ((network_link_CM02_t) link)->bw_current;
482 }
483
484 static double get_link_latency(const void *link) {
485   return ((network_link_CM02_t) link)->lat_current;  
486 }
487
488 static void action_suspend(surf_action_t action)
489 {
490   ((surf_action_network_CM02_t) action)->suspended = 1;
491   lmm_update_variable_weight(network_maxmin_system,
492                              ((surf_action_network_CM02_t) action)->variable, 0.0);
493 }
494
495 static void action_resume(surf_action_t action)
496 {
497   if(((surf_action_network_CM02_t) action)->suspended) {
498     lmm_update_variable_weight(network_maxmin_system,
499                                ((surf_action_network_CM02_t) action)->variable, 
500                                ((surf_action_network_CM02_t) action)->lat_current);
501     ((surf_action_network_CM02_t) action)->suspended = 0;
502   }
503 }
504
505 static int action_is_suspended(surf_action_t action)
506 {
507   return ((surf_action_network_CM02_t) action)->suspended;
508 }
509
510 static void action_set_max_duration(surf_action_t action, double duration)
511 {
512   action->max_duration = duration;
513 }
514
515 static void finalize(void)
516 {
517   int i,j;
518
519   xbt_dict_free(&network_card_set);
520   xbt_dict_free(&network_link_set);
521   xbt_swag_free(surf_network_resource->common_public->states.
522                 ready_action_set);
523   xbt_swag_free(surf_network_resource->common_public->states.
524                 running_action_set);
525   xbt_swag_free(surf_network_resource->common_public->states.
526                 failed_action_set);
527   xbt_swag_free(surf_network_resource->common_public->states.
528                 done_action_set);
529   free(surf_network_resource->common_public);
530   free(surf_network_resource->common_private);
531   free(surf_network_resource->extension_public);
532
533   free(surf_network_resource);
534   surf_network_resource = NULL;
535
536   loopback = NULL;
537   for (i = 0; i < card_number; i++) 
538     for (j = 0; j < card_number; j++) 
539       free(ROUTE(i,j));
540   free(routing_table);
541   routing_table = NULL;
542   free(routing_table_size);
543   routing_table_size = NULL;
544   card_number = 0;
545 }
546
547 static void surf_network_resource_init_internal(void)
548 {
549   s_surf_action_t action;
550
551   surf_network_resource = xbt_new0(s_surf_network_resource_t, 1);
552
553   surf_network_resource->common_private =
554       xbt_new0(s_surf_resource_private_t, 1);
555   surf_network_resource->common_public =
556       xbt_new0(s_surf_resource_public_t, 1);
557   surf_network_resource->extension_public =
558       xbt_new0(s_surf_network_resource_extension_public_t, 1);
559
560   surf_network_resource->common_public->states.ready_action_set =
561       xbt_swag_new(xbt_swag_offset(action, state_hookup));
562   surf_network_resource->common_public->states.running_action_set =
563       xbt_swag_new(xbt_swag_offset(action, state_hookup));
564   surf_network_resource->common_public->states.failed_action_set =
565       xbt_swag_new(xbt_swag_offset(action, state_hookup));
566   surf_network_resource->common_public->states.done_action_set =
567       xbt_swag_new(xbt_swag_offset(action, state_hookup));
568
569   surf_network_resource->common_public->name_service = name_service;
570   surf_network_resource->common_public->get_resource_name =
571       get_resource_name;
572   surf_network_resource->common_public->action_get_state =
573       surf_action_get_state;
574   surf_network_resource->common_public->action_get_start_time =
575       surf_action_get_start_time;
576   surf_network_resource->common_public->action_get_finish_time =
577       surf_action_get_finish_time;
578   surf_network_resource->common_public->action_free = action_free;
579   surf_network_resource->common_public->action_use = action_use;
580   surf_network_resource->common_public->action_cancel = action_cancel;
581   surf_network_resource->common_public->action_recycle = action_recycle;
582   surf_network_resource->common_public->action_change_state =
583       action_change_state;
584   surf_network_resource->common_public->action_set_data = surf_action_set_data;
585   surf_network_resource->common_public->name = "network";
586
587   surf_network_resource->common_private->resource_used = resource_used;
588   surf_network_resource->common_private->share_resources = share_resources;
589   surf_network_resource->common_private->update_actions_state =
590       update_actions_state;
591   surf_network_resource->common_private->update_resource_state =
592       update_resource_state;
593   surf_network_resource->common_private->finalize = finalize;
594
595   surf_network_resource->common_public->suspend = action_suspend;
596   surf_network_resource->common_public->resume = action_resume;
597   surf_network_resource->common_public->is_suspended = action_is_suspended;
598   surf_cpu_resource->common_public->set_max_duration = action_set_max_duration;
599
600   surf_network_resource->extension_public->communicate = communicate;
601   surf_network_resource->extension_public->get_route = get_route;
602   surf_network_resource->extension_public->get_route_size = get_route_size;
603   surf_network_resource->extension_public->get_link_name = get_link_name;
604   surf_network_resource->extension_public->get_link_bandwidth = get_link_bandwidth;
605   surf_network_resource->extension_public->get_link_latency = get_link_latency;
606
607   network_link_set = xbt_dict_new();
608   network_card_set = xbt_dict_new();
609
610   if(!network_maxmin_system)  
611     network_maxmin_system = lmm_system_new();
612 }
613
614 /***************************************************************************/
615 /* The nice TCP sharing model designed by Loris Marchal and Henri Casanova */
616 /***************************************************************************/
617 /* @TechReport{      rr-lip2002-40, */
618 /*   author        = {Henri Casanova and Loris Marchal}, */
619 /*   institution   = {LIP}, */
620 /*   title         = {A Network Model for Simulation of Grid Application}, */
621 /*   number        = {2002-40}, */
622 /*   month         = {oct}, */
623 /*   year          = {2002} */
624 /* } */
625 void surf_network_resource_init_CM02(const char *filename)
626 {
627
628   if (surf_network_resource)
629     return;
630   surf_network_resource_init_internal();
631   parse_file(filename);
632   xbt_dynar_push(resource_list, &surf_network_resource);
633   network_solve = lmm_solve;
634
635   update_resource_description(surf_network_resource_description,
636                               surf_network_resource_description_size,
637                               "CM02",
638                               (surf_resource_t) surf_network_resource);
639 }
640
641 void surf_network_resource_init_Reno(const char *filename)
642 {
643   if (surf_network_resource)
644     return;
645   surf_network_resource_init_internal();
646   parse_file(filename);
647
648   xbt_dynar_push(resource_list, &surf_network_resource);
649   lmm_set_default_protocol_function(func_reno_f, func_reno_fp, func_reno_fpi);
650   network_solve = lagrange_solve;
651
652   update_resource_description(surf_network_resource_description,
653                               surf_network_resource_description_size,
654                               "Reno",
655                               (surf_resource_t) surf_network_resource);
656 }
657
658 void surf_network_resource_init_Vegas(const char *filename)
659 {
660   if (surf_network_resource)
661     return;
662   surf_network_resource_init_internal();
663   parse_file(filename);
664
665   xbt_dynar_push(resource_list, &surf_network_resource);
666   lmm_set_default_protocol_function(func_vegas_f, func_vegas_fp, func_vegas_fpi);
667   network_solve = lagrange_solve;
668
669   update_resource_description(surf_network_resource_description,
670                               surf_network_resource_description_size,
671                               "Vegas",
672                               (surf_resource_t) surf_network_resource);
673 }
674
675 #ifdef HAVE_SDP
676 void surf_network_resource_init_SDP(const char *filename)
677 {
678   if (surf_network_resource)
679     return;
680   surf_network_resource_init_internal();
681   parse_file(filename);
682
683   xbt_dynar_push(resource_list, &surf_network_resource);
684   network_solve = sdp_solve;
685
686   update_resource_description(surf_network_resource_description,
687                               surf_network_resource_description_size,
688                               "SDP",
689                               (surf_resource_t) surf_network_resource);
690 }
691 #endif