Logo AND Algorithmique Numérique Distribuée

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