Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a1b0a465fdc17a4e1f7ff97fac67796dfe22dc2e
[simgrid.git] / src / surf / sg_platf.cpp
1 /* Copyright (c) 2006-2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "xbt/misc.h"
8 #include "xbt/log.h"
9 #include "xbt/str.h"
10 #include "xbt/dict.h"
11 #include "xbt/RngStream.h"
12 #include "simgrid/platf_interface.h"
13 #include "surf/surf_routing.h"
14 #include "surf/surf.h"
15
16 #include "src/simix/smx_private.h"
17
18 #include "cpu_interface.hpp"
19 #include "host_interface.hpp"
20
21 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse);
22 xbt_dynar_t sg_platf_link_cb_list = NULL;   // of sg_platf_link_cb_t
23 xbt_dynar_t sg_platf_cluster_cb_list = NULL; // of sg_platf_cluster_cb_t
24 xbt_dynar_t sg_platf_cabinet_cb_list = NULL; // of sg_platf_cluster_cb_t
25 xbt_dynar_t sg_platf_postparse_cb_list = NULL; // of void_f_void_t
26 xbt_dynar_t sg_platf_prop_cb_list = NULL; // of sg_platf_prop_cb_t
27
28 xbt_dynar_t sg_platf_route_cb_list = NULL; // of sg_platf_route_cb_t
29 xbt_dynar_t sg_platf_ASroute_cb_list = NULL; // of sg_platf_ASroute_cb_t
30 xbt_dynar_t sg_platf_bypassRoute_cb_list = NULL; // of sg_platf_bypassRoute_cb_t
31 xbt_dynar_t sg_platf_bypassASroute_cb_list = NULL; // of sg_platf_bypassASroute_cb_t
32
33 xbt_dynar_t sg_platf_trace_cb_list = NULL;
34 xbt_dynar_t sg_platf_trace_connect_cb_list = NULL;
35
36 /* ***************************************** */
37 /* TUTORIAL: New TAG                         */
38
39 xbt_dynar_t sg_platf_gpu_cb_list = NULL;
40 /* ***************************************** */
41
42
43 static int surf_parse_models_setup_already_called = 0;
44
45 /* one RngStream for the platform, to respect some statistic rules */
46 static RngStream sg_platf_rng_stream = NULL;
47
48 /** Module management function: creates all internal data structures */
49 void sg_platf_init(void) {
50
51   //FIXME : Ugly, but useful...
52   if (sg_platf_gpu_cb_list)
53     return; //Already initialized, so do nothing...
54
55   sg_platf_link_cb_list = xbt_dynar_new(sizeof(sg_platf_link_cb_t), NULL);
56   sg_platf_cluster_cb_list = xbt_dynar_new(sizeof(sg_platf_cluster_cb_t), NULL);
57   sg_platf_cabinet_cb_list = xbt_dynar_new(sizeof(sg_platf_cabinet_cb_t), NULL);
58   sg_platf_postparse_cb_list = xbt_dynar_new(sizeof(sg_platf_link_cb_t),NULL);
59   sg_platf_prop_cb_list = xbt_dynar_new(sizeof(sg_platf_prop_cb_t),NULL);
60
61   sg_platf_route_cb_list = xbt_dynar_new(sizeof(sg_platf_route_cb_t), NULL);
62   sg_platf_ASroute_cb_list = xbt_dynar_new(sizeof(sg_platf_route_cb_t), NULL);
63   sg_platf_bypassRoute_cb_list = xbt_dynar_new(sizeof(sg_platf_route_cb_t), NULL);
64   sg_platf_bypassASroute_cb_list = xbt_dynar_new(sizeof(sg_platf_route_cb_t), NULL);
65
66   sg_platf_trace_cb_list = xbt_dynar_new(sizeof(sg_platf_trace_cb_t), NULL);
67   sg_platf_trace_connect_cb_list = xbt_dynar_new(sizeof(sg_platf_trace_connect_cb_t), NULL);
68
69   /* ***************************************** */
70   /* TUTORIAL: New TAG                         */
71
72   sg_platf_gpu_cb_list = xbt_dynar_new(sizeof(sg_platf_gpu_cb_t), NULL);
73   /* ***************************************** */
74 }
75 /** Module management function: frees all internal data structures */
76 void sg_platf_exit(void) {
77   xbt_dynar_free(&sg_platf_link_cb_list);
78   xbt_dynar_free(&sg_platf_postparse_cb_list);
79   xbt_dynar_free(&sg_platf_cluster_cb_list);
80   xbt_dynar_free(&sg_platf_cabinet_cb_list);
81   xbt_dynar_free(&sg_platf_prop_cb_list);
82
83   xbt_dynar_free(&sg_platf_trace_cb_list);
84   xbt_dynar_free(&sg_platf_trace_connect_cb_list);
85
86   xbt_dynar_free(&sg_platf_route_cb_list);
87   xbt_dynar_free(&sg_platf_ASroute_cb_list);
88   xbt_dynar_free(&sg_platf_bypassRoute_cb_list);
89   xbt_dynar_free(&sg_platf_bypassASroute_cb_list);
90
91   /* ***************************************** */
92   /* TUTORIAL: New TAG                         */
93
94   xbt_dynar_free(&sg_platf_gpu_cb_list);
95
96   /* ***************************************** */
97
98   /* make sure that we will reinit the models while loading the platf once reinited */
99   surf_parse_models_setup_already_called = 0;
100 }
101
102 void sg_platf_new_host(sg_platf_host_cbarg_t host)
103 {
104   xbt_assert(! sg_host_by_name(host->id),
105                      "Refusing to create a second host named '%s'.", host->id);
106
107   RoutingEdge *net = NULL;
108   As* current_routing = routing_get_current();
109   if (current_routing)
110     net = routing_add_host(current_routing, host);
111
112   Cpu *cpu = surf_cpu_model_pm->createCpu(
113         host->id,
114         host->power_peak,
115         host->pstate,
116         host->power_scale,
117         host->power_trace,
118         host->core_amount,
119         host->initial_state,
120         host->state_trace,
121         host->properties);
122   surf_host_model->createHost(host->id, net, cpu);
123
124   if (TRACE_is_enabled() && TRACE_needs_platform())
125     sg_instr_new_host(host);
126 }
127
128 /**
129  * \brief Add a "router" to the network element list
130  */
131 void sg_platf_new_router(sg_platf_router_cbarg_t router)
132 {
133   As* current_routing = routing_get_current();
134
135   if (current_routing->p_hierarchy == SURF_ROUTING_NULL)
136     current_routing->p_hierarchy = SURF_ROUTING_BASE;
137   xbt_assert(!xbt_lib_get_or_null(as_router_lib, router->id, ROUTING_ASR_LEVEL),
138              "Reading a router, processing unit \"%s\" already exists",
139              router->id);
140
141   RoutingEdge *info = new RoutingEdgeImpl(xbt_strdup(router->id),
142                                             -1,
143                                             SURF_NETWORK_ELEMENT_ROUTER,
144                                             current_routing);
145   info->setId(current_routing->parsePU(info));
146   xbt_lib_set(as_router_lib, router->id, ROUTING_ASR_LEVEL, (void *) info);
147   XBT_DEBUG("Having set name '%s' id '%d'", router->id, info->getId());
148   routingEdgeCreatedCallbacks(info);
149
150   if (router->coord && strcmp(router->coord, "")) {
151     unsigned int cursor;
152     char*str;
153
154     if (!COORD_ASR_LEVEL)
155       xbt_die ("To use host coordinates, please add --cfg=network/coordinates:yes to your command line");
156     /* Pre-parse the host coordinates */
157     xbt_dynar_t ctn_str = xbt_str_split_str(router->coord, " ");
158     xbt_dynar_t ctn = xbt_dynar_new(sizeof(double),NULL);
159     xbt_dynar_foreach(ctn_str,cursor, str) {
160       double val = atof(str);
161       xbt_dynar_push(ctn,&val);
162     }
163     xbt_dynar_shrink(ctn, 0);
164     xbt_dynar_free(&ctn_str);
165     xbt_lib_set(as_router_lib, router->id, COORD_ASR_LEVEL, (void *) ctn);
166     XBT_DEBUG("Having set router coordinates for '%s'",router->id);
167   }
168
169   if (TRACE_is_enabled())
170     sg_instr_new_router(router);
171 }
172
173 void sg_platf_new_link(sg_platf_link_cbarg_t link){
174   unsigned int iterator;
175   sg_platf_link_cb_t fun;
176   xbt_dynar_foreach(sg_platf_link_cb_list, iterator, fun) {
177     fun(link);
178   }
179 }
180
181 void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster){
182   unsigned int iterator;
183   sg_platf_cluster_cb_t fun;
184   xbt_dynar_foreach(sg_platf_cluster_cb_list, iterator, fun) {
185     fun(cluster);
186   }
187 }
188 void sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet){
189   unsigned int iterator;
190   sg_platf_cabinet_cb_t fun;
191   xbt_dynar_foreach(sg_platf_cabinet_cb_list, iterator, fun) {
192     fun(cabinet);
193   }
194 }
195 void sg_platf_new_storage(sg_platf_storage_cbarg_t storage)
196 {
197   xbt_assert(!xbt_lib_get_or_null(storage_lib, storage->id,ROUTING_STORAGE_LEVEL),
198                "Reading a storage, processing unit \"%s\" already exists", storage->id);
199
200   // Verification of an existing type_id
201 #ifndef NDEBUG
202   void* storage_type = xbt_lib_get_or_null(storage_type_lib, storage->type_id,ROUTING_STORAGE_TYPE_LEVEL);
203 #endif
204   xbt_assert(storage_type,"Reading a storage, type id \"%s\" does not exists", storage->type_id);
205
206   XBT_DEBUG("ROUTING Create a storage name '%s' with type_id '%s' and content '%s'",
207       storage->id,
208       storage->type_id,
209       storage->content);
210
211   xbt_lib_set(storage_lib,
212       storage->id,
213       ROUTING_STORAGE_LEVEL,
214       (void *) xbt_strdup(storage->type_id));
215
216   void* stype = xbt_lib_get_or_null(storage_type_lib,
217                                     storage->type_id,
218                                     ROUTING_STORAGE_TYPE_LEVEL);
219   if(!stype) xbt_die("No storage type '%s'",storage->type_id);
220
221   // if storage content is not specified use the content of storage_type if exist
222   if(!strcmp(storage->content,"") && strcmp(((storage_type_t) stype)->content,"")){
223     storage->content = ((storage_type_t) stype)->content;
224     storage->content_type = ((storage_type_t) stype)->content_type;
225     XBT_DEBUG("For disk '%s' content is empty, inherit the content (of type %s) from storage type '%s' ",
226         storage->id,((storage_type_t) stype)->content_type,
227         ((storage_type_t) stype)->type_id);
228   }
229
230   XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s' "
231       "\n\t\tmodel '%s' \n\t\tcontent '%s'\n\t\tcontent_type '%s' "
232       "\n\t\tproperties '%p''\n",
233       storage->id,
234       ((storage_type_t) stype)->model,
235       ((storage_type_t) stype)->type_id,
236       storage->content,
237       storage->content_type,
238       storage->properties);
239
240   surf_storage_model->createStorage(storage->id,
241                                      ((storage_type_t) stype)->type_id,
242                                      storage->content,
243                                      storage->content_type,
244                                      storage->properties,
245                                      storage->attach);
246 }
247 void sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type){
248
249   xbt_assert(!xbt_lib_get_or_null(storage_type_lib, storage_type->id,ROUTING_STORAGE_TYPE_LEVEL),
250                "Reading a storage type, processing unit \"%s\" already exists", storage_type->id);
251
252   storage_type_t stype = xbt_new0(s_storage_type_t, 1);
253   stype->model = xbt_strdup(storage_type->model);
254   stype->properties = storage_type->properties;
255   stype->content = xbt_strdup(storage_type->content);
256   stype->content_type = xbt_strdup(storage_type->content_type);
257   stype->type_id = xbt_strdup(storage_type->id);
258   stype->size = storage_type->size;
259   stype->model_properties = storage_type->model_properties;
260
261   XBT_DEBUG("ROUTING Create a storage type id '%s' with model '%s', "
262       "content '%s', and content_type '%s'",
263       stype->type_id,
264       stype->model,
265       storage_type->content,
266       storage_type->content_type);
267
268   xbt_lib_set(storage_type_lib,
269       stype->type_id,
270       ROUTING_STORAGE_TYPE_LEVEL,
271       (void *) stype);
272 }
273 void sg_platf_new_mstorage(sg_platf_mstorage_cbarg_t mstorage)
274 {
275   THROW_UNIMPLEMENTED;
276 //  mount_t mnt = xbt_new0(s_mount_t, 1);
277 //  mnt->id = xbt_strdup(mstorage->type_id);
278 //  mnt->name = xbt_strdup(mstorage->name);
279 //
280 //  if(!mount_list){
281 //    XBT_DEBUG("Creata a Mount list for %s",A_surfxml_host_id);
282 //    mount_list = xbt_dynar_new(sizeof(char *), NULL);
283 //  }
284 //  xbt_dynar_push(mount_list,(void *) mnt);
285 //  free(mnt->id);
286 //  free(mnt->name);
287 //  xbt_free(mnt);
288 //  XBT_DEBUG("ROUTING Mount a storage name '%s' with type_id '%s'",mstorage->name, mstorage->id);
289 }
290
291 static void mount_free(void *p)
292 {
293   mount_t mnt = (mount_t) p;
294   xbt_free(mnt->name);
295 }
296
297 void sg_platf_new_mount(sg_platf_mount_cbarg_t mount){
298   // Verification of an existing storage
299 #ifndef NDEBUG
300   void* storage = xbt_lib_get_or_null(storage_lib, mount->storageId, ROUTING_STORAGE_LEVEL);
301 #endif
302   xbt_assert(storage,"Disk id \"%s\" does not exists", mount->storageId);
303
304   XBT_DEBUG("ROUTING Mount '%s' on '%s'",mount->storageId, mount->name);
305
306   s_mount_t mnt;
307   mnt.storage = surf_storage_resource_priv(surf_storage_resource_by_name(mount->storageId));
308   mnt.name = xbt_strdup(mount->name);
309
310   if(!mount_list){
311     XBT_DEBUG("Create a Mount list for %s",A_surfxml_host_id);
312     mount_list = xbt_dynar_new(sizeof(s_mount_t), mount_free);
313   }
314   xbt_dynar_push(mount_list, &mnt);
315 }
316
317 void sg_platf_new_route(sg_platf_route_cbarg_t route) {
318   unsigned int iterator;
319   sg_platf_route_cb_t fun;
320   xbt_dynar_foreach(sg_platf_route_cb_list, iterator, fun) {
321     fun(route);
322   }
323 }
324 void sg_platf_new_ASroute(sg_platf_route_cbarg_t ASroute) {
325   unsigned int iterator;
326   sg_platf_route_cb_t fun;
327   xbt_dynar_foreach(sg_platf_ASroute_cb_list, iterator, fun) {
328     fun(ASroute);
329   }
330 }
331 void sg_platf_new_bypassRoute(sg_platf_route_cbarg_t bypassRoute) {
332   unsigned int iterator;
333   sg_platf_route_cb_t fun;
334   xbt_dynar_foreach(sg_platf_bypassRoute_cb_list, iterator, fun) {
335     fun(bypassRoute);
336   }
337 }
338 void sg_platf_new_bypassASroute(sg_platf_route_cbarg_t bypassASroute) {
339   unsigned int iterator;
340   sg_platf_route_cb_t fun;
341   xbt_dynar_foreach(sg_platf_bypassASroute_cb_list, iterator, fun) {
342     fun(bypassASroute);
343   }
344 }
345 void sg_platf_new_prop(sg_platf_prop_cbarg_t prop) {
346   unsigned int iterator;
347   sg_platf_prop_cb_t fun;
348   xbt_dynar_foreach(sg_platf_prop_cb_list, iterator, fun) {
349     fun(prop);
350   }
351 }
352 void sg_platf_new_trace(sg_platf_trace_cbarg_t trace) {
353   unsigned int iterator;
354   sg_platf_trace_cb_t fun;
355   xbt_dynar_foreach(sg_platf_trace_cb_list, iterator, fun) {
356     fun(trace);
357   }
358 }
359 void sg_platf_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect) {
360   unsigned int iterator;
361   sg_platf_trace_connect_cb_t fun;
362   xbt_dynar_foreach(sg_platf_trace_connect_cb_list, iterator, fun) {
363     fun(trace_connect);
364   }
365 }
366
367 void sg_platf_new_process(sg_platf_process_cbarg_t process)
368 {
369   if (!simix_global)
370     xbt_die("Cannot create process without SIMIX.");
371
372   sg_host_t host = sg_host_by_name(process->host);
373   if (!host)
374     THROWF(arg_error, 0, "Host '%s' unknown", process->host);
375   xbt_main_func_t parse_code = SIMIX_get_registered_function(process->function);
376   xbt_assert(parse_code, "Function '%s' unknown", process->function);
377
378   double start_time = process->start_time;
379   double kill_time  = process->kill_time;
380   int auto_restart = process->on_failure == SURF_PROCESS_ON_FAILURE_DIE ? 0 : 1;
381
382   smx_process_arg_t arg = NULL;
383   smx_process_t process_created = NULL;
384
385   arg = xbt_new0(s_smx_process_arg_t, 1);
386   arg->code = parse_code;
387   arg->data = NULL;
388   arg->hostname = sg_host_get_name(host);
389   arg->argc = process->argc;
390   arg->argv = xbt_new(char *,process->argc);
391   int i;
392   for (i=0; i<process->argc; i++)
393     arg->argv[i] = xbt_strdup(process->argv[i]);
394   arg->name = xbt_strdup(arg->argv[0]);
395   arg->kill_time = kill_time;
396   arg->properties = current_property_set;
397   if (!sg_host_simix(host)->boot_processes) {
398     sg_host_simix(host)->boot_processes = xbt_dynar_new(sizeof(smx_process_arg_t), _SIMIX_host_free_process_arg);
399   }
400   xbt_dynar_push_as(sg_host_simix(host)->boot_processes,smx_process_arg_t,arg);
401
402   if (start_time > SIMIX_get_clock()) {
403     arg = xbt_new0(s_smx_process_arg_t, 1);
404     arg->name = (char*)(process->argv)[0];
405     arg->code = parse_code;
406     arg->data = NULL;
407     arg->hostname = sg_host_get_name(host);
408     arg->argc = process->argc;
409     arg->argv = (char**)(process->argv);
410     arg->kill_time = kill_time;
411     arg->properties = current_property_set;
412
413     XBT_DEBUG("Process %s(%s) will be started at time %f", arg->name,
414            arg->hostname, start_time);
415     SIMIX_timer_set(start_time, [](void* arg) {
416       SIMIX_process_create_from_wrapper((smx_process_arg_t) arg);
417     }, arg);
418   } else {                      // start_time <= SIMIX_get_clock()
419     XBT_DEBUG("Starting Process %s(%s) right now", process->argv[0], sg_host_get_name(host));
420
421     if (simix_global->create_process_function)
422       process_created = simix_global->create_process_function(
423                                             (char*)(process->argv)[0],
424                                             parse_code,
425                                             NULL,
426                                             sg_host_get_name(host),
427                                             kill_time,
428                                             process->argc,
429                                             (char**)(process->argv),
430                                             current_property_set,
431                                             auto_restart, NULL);
432     else
433       process_created = simcall_process_create((char*)(process->argv)[0], parse_code, NULL, sg_host_get_name(host), kill_time, process->argc,
434           (char**)process->argv, current_property_set,auto_restart);
435
436     /* verify if process has been created (won't be the case if the host is currently dead, but that's fine) */
437     if (!process_created) {
438       return;
439     }
440   }
441   current_property_set = NULL;
442 }
443
444 void sg_platf_route_begin (sg_platf_route_cbarg_t route){
445   route->link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
446 }
447 void sg_platf_ASroute_begin (sg_platf_route_cbarg_t ASroute){
448   ASroute->link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
449 }
450
451 void sg_platf_route_end (sg_platf_route_cbarg_t route){
452   sg_platf_new_route(route);
453 }
454 void sg_platf_ASroute_end (sg_platf_route_cbarg_t ASroute){
455   sg_platf_new_ASroute(ASroute);
456 }
457
458 void sg_platf_route_add_link (const char* link_id, sg_platf_route_cbarg_t route){
459   char *link_name = xbt_strdup(link_id);
460   xbt_dynar_push(route->link_list, &link_name);
461 }
462 void sg_platf_ASroute_add_link (const char* link_id, sg_platf_route_cbarg_t ASroute){
463   char *link_name = xbt_strdup(link_id);
464   xbt_dynar_push(ASroute->link_list, &link_name);
465 }
466
467 void sg_platf_begin() { /* Do nothing: just for symmetry of user code */ }
468
469 void sg_platf_end() {
470   unsigned int iterator;
471   void_f_void_t fun;
472   xbt_dynar_foreach(sg_platf_postparse_cb_list, iterator, fun) {
473     fun();
474   }
475 }
476
477 void sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS)
478 {
479   if (!surf_parse_models_setup_already_called) {
480     /* Initialize the surf models. That must be done after we got all config, and before we need the models.
481      * That is, after the last <config> tag, if any, and before the first of cluster|peer|AS|trace|trace_connect
482      *
483      * I'm not sure for <trace> and <trace_connect>, there may be a bug here
484      * (FIXME: check it out by creating a file beginning with one of these tags)
485      * but cluster and peer create ASes internally, so putting the code in there is ok.
486      *
487      * TODO, There used to be a guard protecting here against
488      * xbt_dynar_length(sg_platf_AS_begin_cb_list) because we don't want to
489      * initialize the models if we are parsing the file to get the deployment.
490      * That could happen if the same file would be used for platf and deploy:
491      * it'd contain AS tags even during the deploy parsing. Removing that guard
492      * would result of the models to get re-inited when parsing for deploy.
493      * Currently using the same file for platform and deployment is broken
494      * however. This guard will have to ba adapted in order to make this feature
495      * work again.
496      */
497     surf_parse_models_setup_already_called = 1;
498     surf_config_models_setup();
499   }
500
501   routing_AS_begin(AS);
502   if (TRACE_is_enabled())
503     sg_instr_AS_begin(AS);
504 }
505
506 void sg_platf_new_AS_end()
507 {
508   routing_AS_end();
509   if (TRACE_is_enabled())
510     sg_instr_AS_end();
511 }
512
513 /* ***************************************** */
514 /* TUTORIAL: New TAG                         */
515
516 void sg_platf_new_gpu(sg_platf_gpu_cbarg_t gpu) {
517   unsigned int iterator;
518   void_f_void_t fun;
519   xbt_dynar_foreach(sg_platf_gpu_cb_list, iterator, fun) {
520     fun();
521   }
522 }
523
524 void sg_platf_gpu_add_cb(sg_platf_gpu_cb_t fct) {
525   xbt_dynar_push(sg_platf_gpu_cb_list, &fct);
526 }
527
528 /* ***************************************** */
529
530 void sg_platf_link_add_cb(sg_platf_link_cb_t fct) {
531   xbt_dynar_push(sg_platf_link_cb_list, &fct);
532 }
533 void sg_platf_cluster_add_cb(sg_platf_cluster_cb_t fct) {
534   xbt_dynar_push(sg_platf_cluster_cb_list, &fct);
535 }
536 void sg_platf_cabinet_add_cb(sg_platf_cabinet_cb_t fct) {
537   xbt_dynar_push(sg_platf_cabinet_cb_list, &fct);
538 }
539 void sg_platf_postparse_add_cb(void_f_void_t fct) {
540   xbt_dynar_push(sg_platf_postparse_cb_list, &fct);
541 }
542 void sg_platf_route_add_cb(sg_platf_route_cb_t fct) {
543   xbt_dynar_push(sg_platf_route_cb_list, &fct);
544 }
545 void sg_platf_ASroute_add_cb(sg_platf_route_cb_t fct) {
546   xbt_dynar_push(sg_platf_ASroute_cb_list, &fct);
547 }
548 void sg_platf_bypassRoute_add_cb(sg_platf_route_cb_t fct) {
549   xbt_dynar_push(sg_platf_bypassRoute_cb_list, &fct);
550 }
551 void sg_platf_bypassASroute_add_cb(sg_platf_route_cb_t fct) {
552   xbt_dynar_push(sg_platf_bypassASroute_cb_list, &fct);
553 }
554 void sg_platf_prop_add_cb(sg_platf_prop_cb_t fct) {
555   xbt_dynar_push(sg_platf_prop_cb_list, &fct);
556 }
557 void sg_platf_trace_add_cb(sg_platf_trace_cb_t fct) {
558   xbt_dynar_push(sg_platf_trace_cb_list, &fct);
559 }
560 void sg_platf_trace_connect_add_cb(sg_platf_trace_connect_cb_t fct) {
561   xbt_dynar_push(sg_platf_trace_connect_cb_list, &fct);
562 }
563 void sg_platf_rng_stream_init(unsigned long seed[6]) {
564   RngStream_SetPackageSeed(seed);
565   sg_platf_rng_stream = RngStream_CreateStream(NULL);
566 }
567
568 RngStream sg_platf_rng_stream_get(const char* id) {
569   RngStream stream = NULL;
570   unsigned int id_hash;
571
572   stream = RngStream_CopyStream(sg_platf_rng_stream);
573   id_hash = xbt_str_hash(id);
574   RngStream_AdvanceState(stream, 0, (long)id_hash);
575
576   return stream;
577 }