Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
9a72f08740970b865e94cd53f9ce7c413e7e3533
[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
15 #include "src/simix/smx_private.h"
16
17 #include "cpu_interface.hpp"
18 #include "host_interface.hpp"
19
20 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse);
21 xbt_dynar_t sg_platf_host_cb_list = NULL;   // of sg_platf_host_cb_t
22 xbt_dynar_t sg_platf_host_link_cb_list = NULL;   // of sg_platf_host_link_cb_t
23 xbt_dynar_t sg_platf_link_cb_list = NULL;   // of sg_platf_link_cb_t
24 xbt_dynar_t sg_platf_router_cb_list = NULL; // of sg_platf_router_cb_t
25 xbt_dynar_t sg_platf_peer_cb_list = NULL; // of sg_platf_peer_cb_t
26 xbt_dynar_t sg_platf_cluster_cb_list = NULL; // of sg_platf_cluster_cb_t
27 xbt_dynar_t sg_platf_cabinet_cb_list = NULL; // of sg_platf_cluster_cb_t
28 xbt_dynar_t sg_platf_AS_begin_cb_list = NULL; //of sg_platf_AS_begin_cb_t
29 xbt_dynar_t sg_platf_AS_end_cb_list = NULL; //of void_f_void_t
30 xbt_dynar_t sg_platf_postparse_cb_list = NULL; // of void_f_void_t
31 xbt_dynar_t sg_platf_prop_cb_list = NULL; // of sg_platf_prop_cb_t
32
33 xbt_dynar_t sg_platf_route_cb_list = NULL; // of sg_platf_route_cb_t
34 xbt_dynar_t sg_platf_ASroute_cb_list = NULL; // of sg_platf_ASroute_cb_t
35 xbt_dynar_t sg_platf_bypassRoute_cb_list = NULL; // of sg_platf_bypassRoute_cb_t
36 xbt_dynar_t sg_platf_bypassASroute_cb_list = NULL; // of sg_platf_bypassASroute_cb_t
37
38 xbt_dynar_t sg_platf_trace_cb_list = NULL;
39 xbt_dynar_t sg_platf_trace_connect_cb_list = NULL;
40
41 xbt_dynar_t sg_platf_storage_cb_list = NULL; // of sg_platf_storage_cb_t
42 xbt_dynar_t sg_platf_storage_type_cb_list = NULL; // of sg_platf_storage_cb_t
43 xbt_dynar_t sg_platf_mstorage_cb_list = NULL; // of sg_platf_storage_cb_t
44 xbt_dynar_t sg_platf_mount_cb_list = NULL; // of sg_platf_storage_cb_t
45
46 /* ***************************************** */
47 /* TUTORIAL: New TAG                         */
48
49 xbt_dynar_t sg_platf_gpu_cb_list = NULL;
50 /* ***************************************** */
51
52
53 static int surf_parse_models_setup_already_called = 0;
54
55 /* one RngStream for the platform, to respect some statistic rules */
56 static RngStream sg_platf_rng_stream = NULL;
57
58 /** Module management function: creates all internal data structures */
59 void sg_platf_init(void) {
60
61   //FIXME : Ugly, but useful...
62   if(sg_platf_host_cb_list)
63     return; //Already initialized, so do nothing...
64
65   sg_platf_host_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL);
66   sg_platf_host_link_cb_list = xbt_dynar_new(sizeof(sg_platf_host_link_cb_t), NULL);
67   sg_platf_router_cb_list = xbt_dynar_new(sizeof(sg_platf_router_cb_t), NULL);
68   sg_platf_link_cb_list = xbt_dynar_new(sizeof(sg_platf_link_cb_t), NULL);
69   sg_platf_peer_cb_list = xbt_dynar_new(sizeof(sg_platf_peer_cb_t), NULL);
70   sg_platf_cluster_cb_list = xbt_dynar_new(sizeof(sg_platf_cluster_cb_t), NULL);
71   sg_platf_cabinet_cb_list = xbt_dynar_new(sizeof(sg_platf_cabinet_cb_t), NULL);
72   sg_platf_postparse_cb_list = xbt_dynar_new(sizeof(sg_platf_link_cb_t),NULL);
73   sg_platf_AS_begin_cb_list = xbt_dynar_new(sizeof(sg_platf_AS_cb_t),NULL);
74   sg_platf_AS_end_cb_list = xbt_dynar_new(sizeof(sg_platf_AS_cb_t),NULL);
75   sg_platf_prop_cb_list = xbt_dynar_new(sizeof(sg_platf_prop_cb_t),NULL);
76
77   sg_platf_route_cb_list = xbt_dynar_new(sizeof(sg_platf_route_cb_t), NULL);
78   sg_platf_ASroute_cb_list = xbt_dynar_new(sizeof(sg_platf_route_cb_t), NULL);
79   sg_platf_bypassRoute_cb_list = xbt_dynar_new(sizeof(sg_platf_route_cb_t), NULL);
80   sg_platf_bypassASroute_cb_list = xbt_dynar_new(sizeof(sg_platf_route_cb_t), NULL);
81
82   sg_platf_trace_cb_list = xbt_dynar_new(sizeof(sg_platf_trace_cb_t), NULL);
83   sg_platf_trace_connect_cb_list = xbt_dynar_new(sizeof(sg_platf_trace_connect_cb_t), NULL);
84
85   sg_platf_storage_cb_list = xbt_dynar_new(sizeof(sg_platf_storage_cb_t), NULL);
86   sg_platf_storage_type_cb_list = xbt_dynar_new(sizeof(sg_platf_storage_cb_t), NULL);
87   sg_platf_mstorage_cb_list = xbt_dynar_new(sizeof(sg_platf_storage_cb_t), NULL);
88   sg_platf_mount_cb_list = xbt_dynar_new(sizeof(sg_platf_storage_cb_t), NULL);
89
90   /* ***************************************** */
91   /* TUTORIAL: New TAG                         */
92
93   sg_platf_gpu_cb_list = xbt_dynar_new(sizeof(sg_platf_gpu_cb_t), NULL);
94   /* ***************************************** */
95 }
96 /** Module management function: frees all internal data structures */
97 void sg_platf_exit(void) {
98   xbt_dynar_free(&sg_platf_host_cb_list);
99   xbt_dynar_free(&sg_platf_host_link_cb_list);
100   xbt_dynar_free(&sg_platf_router_cb_list);
101   xbt_dynar_free(&sg_platf_link_cb_list);
102   xbt_dynar_free(&sg_platf_postparse_cb_list);
103   xbt_dynar_free(&sg_platf_peer_cb_list);
104   xbt_dynar_free(&sg_platf_cluster_cb_list);
105   xbt_dynar_free(&sg_platf_cabinet_cb_list);
106   xbt_dynar_free(&sg_platf_AS_begin_cb_list);
107   xbt_dynar_free(&sg_platf_AS_end_cb_list);
108   xbt_dynar_free(&sg_platf_prop_cb_list);
109
110   xbt_dynar_free(&sg_platf_trace_cb_list);
111   xbt_dynar_free(&sg_platf_trace_connect_cb_list);
112
113   xbt_dynar_free(&sg_platf_route_cb_list);
114   xbt_dynar_free(&sg_platf_ASroute_cb_list);
115   xbt_dynar_free(&sg_platf_bypassRoute_cb_list);
116   xbt_dynar_free(&sg_platf_bypassASroute_cb_list);
117
118   xbt_dynar_free(&sg_platf_storage_cb_list);
119   xbt_dynar_free(&sg_platf_storage_type_cb_list);
120   xbt_dynar_free(&sg_platf_mstorage_cb_list);
121   xbt_dynar_free(&sg_platf_mount_cb_list);
122
123   /* ***************************************** */
124   /* TUTORIAL: New TAG                         */
125
126   xbt_dynar_free(&sg_platf_gpu_cb_list);
127
128   /* ***************************************** */
129
130   /* make sure that we will reinit the models while loading the platf once reinited */
131   surf_parse_models_setup_already_called = 0;
132 }
133
134 void sg_platf_new_host(sg_platf_host_cbarg_t host)
135 {
136
137   xbt_assert(! sg_host_by_name(host->id),
138                      "Refusing to create a second host named '%s'.", host->id);
139
140   RoutingEdge *net = NULL;
141   As* current_routing = routing_get_current();
142   if (current_routing)
143     net = routing_add_host(current_routing, host);
144
145   Cpu *cpu = surf_cpu_model_pm->createCpu(
146         host->id,
147         host->power_peak,
148         host->pstate,
149         host->power_scale,
150         host->power_trace,
151         host->core_amount,
152         host->initial_state,
153         host->state_trace,
154         host->properties);
155   surf_host_model->createHost(host->id, net, cpu);
156
157   unsigned int iterator;
158   sg_platf_host_cb_t fun;
159   xbt_dynar_foreach(sg_platf_host_cb_list, iterator, fun) {
160     fun(host);
161   }
162 }
163 void sg_platf_new_host_link(sg_platf_host_link_cbarg_t h){
164   unsigned int iterator;
165   sg_platf_host_link_cb_t fun;
166   xbt_dynar_foreach(sg_platf_host_link_cb_list, iterator, fun) {
167     fun(h);
168   }
169 }
170 void sg_platf_new_router(sg_platf_router_cbarg_t router) {
171   unsigned int iterator;
172   sg_platf_router_cb_t fun;
173   xbt_dynar_foreach(sg_platf_router_cb_list, iterator, fun) {
174     fun(router);
175   }
176 }
177 void sg_platf_new_link(sg_platf_link_cbarg_t link){
178   unsigned int iterator;
179   sg_platf_link_cb_t fun;
180   xbt_dynar_foreach(sg_platf_link_cb_list, iterator, fun) {
181     fun(link);
182   }
183 }
184
185 void sg_platf_new_peer(sg_platf_peer_cbarg_t peer){
186   unsigned int iterator;
187   sg_platf_peer_cb_t fun;
188   xbt_dynar_foreach(sg_platf_peer_cb_list, iterator, fun) {
189     fun(peer);
190   }
191 }
192 void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster){
193   unsigned int iterator;
194   sg_platf_cluster_cb_t fun;
195   xbt_dynar_foreach(sg_platf_cluster_cb_list, iterator, fun) {
196     fun(cluster);
197   }
198 }
199 void sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet){
200   unsigned int iterator;
201   sg_platf_cabinet_cb_t fun;
202   xbt_dynar_foreach(sg_platf_cabinet_cb_list, iterator, fun) {
203     fun(cabinet);
204   }
205 }
206 void sg_platf_new_storage(sg_platf_storage_cbarg_t storage){
207   unsigned int iterator;
208   sg_platf_storage_cb_t fun;
209   xbt_dynar_foreach(sg_platf_storage_cb_list, iterator, fun) {
210     fun(storage);
211   }
212 }
213 void sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type){
214   unsigned int iterator;
215   sg_platf_storage_type_cb_t fun;
216   xbt_dynar_foreach(sg_platf_storage_type_cb_list, iterator, fun) {
217     fun(storage_type);
218   }
219 }
220 void sg_platf_new_mstorage(sg_platf_mstorage_cbarg_t mstorage){
221   unsigned int iterator;
222   sg_platf_mstorage_cb_t fun;
223   xbt_dynar_foreach(sg_platf_mstorage_cb_list, iterator, fun) {
224     fun(mstorage);
225   }
226 }
227 void sg_platf_new_mount(sg_platf_mount_cbarg_t mount){
228   unsigned int iterator;
229   sg_platf_mount_cb_t fun;
230   xbt_dynar_foreach(sg_platf_mount_cb_list, iterator, fun) {
231     fun(mount);
232   }
233 }
234 void sg_platf_new_route(sg_platf_route_cbarg_t route) {
235   unsigned int iterator;
236   sg_platf_route_cb_t fun;
237   xbt_dynar_foreach(sg_platf_route_cb_list, iterator, fun) {
238     fun(route);
239   }
240 }
241 void sg_platf_new_ASroute(sg_platf_route_cbarg_t ASroute) {
242   unsigned int iterator;
243   sg_platf_route_cb_t fun;
244   xbt_dynar_foreach(sg_platf_ASroute_cb_list, iterator, fun) {
245     fun(ASroute);
246   }
247 }
248 void sg_platf_new_bypassRoute(sg_platf_route_cbarg_t bypassRoute) {
249   unsigned int iterator;
250   sg_platf_route_cb_t fun;
251   xbt_dynar_foreach(sg_platf_bypassRoute_cb_list, iterator, fun) {
252     fun(bypassRoute);
253   }
254 }
255 void sg_platf_new_bypassASroute(sg_platf_route_cbarg_t bypassASroute) {
256   unsigned int iterator;
257   sg_platf_route_cb_t fun;
258   xbt_dynar_foreach(sg_platf_bypassASroute_cb_list, iterator, fun) {
259     fun(bypassASroute);
260   }
261 }
262 void sg_platf_new_prop(sg_platf_prop_cbarg_t prop) {
263   unsigned int iterator;
264   sg_platf_prop_cb_t fun;
265   xbt_dynar_foreach(sg_platf_prop_cb_list, iterator, fun) {
266     fun(prop);
267   }
268 }
269 void sg_platf_new_trace(sg_platf_trace_cbarg_t trace) {
270   unsigned int iterator;
271   sg_platf_trace_cb_t fun;
272   xbt_dynar_foreach(sg_platf_trace_cb_list, iterator, fun) {
273     fun(trace);
274   }
275 }
276 void sg_platf_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect) {
277   unsigned int iterator;
278   sg_platf_trace_connect_cb_t fun;
279   xbt_dynar_foreach(sg_platf_trace_connect_cb_list, iterator, fun) {
280     fun(trace_connect);
281   }
282 }
283
284 void sg_platf_new_process(sg_platf_process_cbarg_t process)
285 {
286   if (!simix_global)
287     xbt_die("Cannot create process without SIMIX.");
288
289   sg_host_t host = sg_host_by_name(process->host);
290   if (!host)
291     THROWF(arg_error, 0, "Host '%s' unknown", process->host);
292   xbt_main_func_t parse_code = SIMIX_get_registered_function(process->function);
293   xbt_assert(parse_code, "Function '%s' unknown", process->function);
294
295   double start_time = process->start_time;
296   double kill_time  = process->kill_time;
297   int auto_restart = process->on_failure == SURF_PROCESS_ON_FAILURE_DIE ? 0 : 1;
298
299   smx_process_arg_t arg = NULL;
300   smx_process_t process_created = NULL;
301
302   arg = xbt_new0(s_smx_process_arg_t, 1);
303   arg->code = parse_code;
304   arg->data = NULL;
305   arg->hostname = sg_host_get_name(host);
306   arg->argc = process->argc;
307   arg->argv = xbt_new(char *,process->argc);
308   int i;
309   for (i=0; i<process->argc; i++)
310     arg->argv[i] = xbt_strdup(process->argv[i]);
311   arg->name = xbt_strdup(arg->argv[0]);
312   arg->kill_time = kill_time;
313   arg->properties = current_property_set;
314   if (!sg_host_simix(host)->boot_processes) {
315     sg_host_simix(host)->boot_processes = xbt_dynar_new(sizeof(smx_process_arg_t), _SIMIX_host_free_process_arg);
316   }
317   xbt_dynar_push_as(sg_host_simix(host)->boot_processes,smx_process_arg_t,arg);
318
319   if (start_time > SIMIX_get_clock()) {
320     arg = xbt_new0(s_smx_process_arg_t, 1);
321     arg->name = (char*)(process->argv)[0];
322     arg->code = parse_code;
323     arg->data = NULL;
324     arg->hostname = sg_host_get_name(host);
325     arg->argc = process->argc;
326     arg->argv = (char**)(process->argv);
327     arg->kill_time = kill_time;
328     arg->properties = current_property_set;
329
330     XBT_DEBUG("Process %s(%s) will be started at time %f", arg->name,
331            arg->hostname, start_time);
332     SIMIX_timer_set(start_time, (void*) SIMIX_process_create_from_wrapper, arg);
333   } else {                      // start_time <= SIMIX_get_clock()
334     XBT_DEBUG("Starting Process %s(%s) right now", process->argv[0], sg_host_get_name(host));
335
336     if (simix_global->create_process_function)
337       process_created = simix_global->create_process_function(
338                                             (char*)(process->argv)[0],
339                                             parse_code,
340                                             NULL,
341                                             sg_host_get_name(host),
342                                             kill_time,
343                                             process->argc,
344                                             (char**)(process->argv),
345                                             current_property_set,
346                                             auto_restart, NULL);
347     else
348       process_created = simcall_process_create((char*)(process->argv)[0], parse_code, NULL, sg_host_get_name(host), kill_time, process->argc,
349           (char**)process->argv, current_property_set,auto_restart);
350
351     /* verify if process has been created (won't be the case if the host is currently dead, but that's fine) */
352     if (!process_created) {
353       return;
354     }
355   }
356   current_property_set = NULL;
357 }
358
359 void sg_platf_route_begin (sg_platf_route_cbarg_t route){
360   route->link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
361 }
362 void sg_platf_ASroute_begin (sg_platf_route_cbarg_t ASroute){
363   ASroute->link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
364 }
365
366 void sg_platf_route_end (sg_platf_route_cbarg_t route){
367   sg_platf_new_route(route);
368 }
369 void sg_platf_ASroute_end (sg_platf_route_cbarg_t ASroute){
370   sg_platf_new_ASroute(ASroute);
371 }
372
373 void sg_platf_route_add_link (const char* link_id, sg_platf_route_cbarg_t route){
374   char *link_name = xbt_strdup(link_id);
375   xbt_dynar_push(route->link_list, &link_name);
376 }
377 void sg_platf_ASroute_add_link (const char* link_id, sg_platf_route_cbarg_t ASroute){
378   char *link_name = xbt_strdup(link_id);
379   xbt_dynar_push(ASroute->link_list, &link_name);
380 }
381
382 void sg_platf_begin() { /* Do nothing: just for symmetry of user code */ }
383
384 void sg_platf_end() {
385   unsigned int iterator;
386   void_f_void_t fun;
387   xbt_dynar_foreach(sg_platf_postparse_cb_list, iterator, fun) {
388     fun();
389   }
390 }
391
392 void sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS) {
393   unsigned int iterator;
394   sg_platf_AS_cb_t fun;
395
396   if (!surf_parse_models_setup_already_called && !xbt_dynar_is_empty(sg_platf_AS_begin_cb_list)) {
397     /* Initialize the surf models. That must be done after we got all config, and before we need the models.
398      * That is, after the last <config> tag, if any, and before the first of cluster|peer|AS|trace|trace_connect
399      *
400      * I'm not sure for <trace> and <trace_connect>, there may be a bug here
401      * (FIXME: check it out by creating a file beginning with one of these tags)
402      * but cluster and peer create ASes internally, so putting the code in there is ok.
403      *
404      * We are also guarding against xbt_dynar_length(sg_platf_AS_begin_cb_list) because we don't
405      * want to initialize the models if we are parsing the file to get the deployment. That could happen if
406      * the same file would be used for platf and deploy: it'd contain AS tags even during the deploy parsing.
407      * Removing that guard would result of the models to get re-inited when parsing for deploy.
408      */
409     surf_parse_models_setup_already_called = 1;
410     surf_config_models_setup();
411   }
412
413   xbt_dynar_foreach(sg_platf_AS_begin_cb_list, iterator, fun) {
414     fun(AS);
415   }
416 }
417
418 void sg_platf_new_AS_end() {
419   unsigned int iterator;
420   void_f_void_t fun;
421   xbt_dynar_foreach(sg_platf_AS_end_cb_list, iterator, fun) {
422     fun();
423   }
424 }
425
426 /* ***************************************** */
427 /* TUTORIAL: New TAG                         */
428
429 void sg_platf_new_gpu(sg_platf_gpu_cbarg_t gpu) {
430   unsigned int iterator;
431   void_f_void_t fun;
432   xbt_dynar_foreach(sg_platf_gpu_cb_list, iterator, fun) {
433     fun();
434   }
435 }
436
437 void sg_platf_gpu_add_cb(sg_platf_gpu_cb_t fct) {
438   xbt_dynar_push(sg_platf_gpu_cb_list, &fct);
439 }
440
441 /* ***************************************** */
442
443
444 void sg_platf_host_add_cb(sg_platf_host_cb_t fct) {
445   xbt_dynar_push(sg_platf_host_cb_list, &fct);
446 }
447 void sg_platf_host_link_add_cb(sg_platf_host_link_cb_t fct) {
448   xbt_dynar_push(sg_platf_host_link_cb_list, &fct);
449 }
450 void sg_platf_link_add_cb(sg_platf_link_cb_t fct) {
451   xbt_dynar_push(sg_platf_link_cb_list, &fct);
452 }
453 void sg_platf_router_add_cb(sg_platf_router_cb_t fct) {
454   xbt_dynar_push(sg_platf_router_cb_list, &fct);
455 }
456 void sg_platf_peer_add_cb(sg_platf_peer_cb_t fct) {
457   xbt_dynar_push(sg_platf_peer_cb_list, &fct);
458 }
459 void sg_platf_cluster_add_cb(sg_platf_cluster_cb_t fct) {
460   xbt_dynar_push(sg_platf_cluster_cb_list, &fct);
461 }
462 void sg_platf_cabinet_add_cb(sg_platf_cabinet_cb_t fct) {
463   xbt_dynar_push(sg_platf_cabinet_cb_list, &fct);
464 }
465 void sg_platf_postparse_add_cb(void_f_void_t fct) {
466   xbt_dynar_push(sg_platf_postparse_cb_list, &fct);
467 }
468 void sg_platf_AS_begin_add_cb(sg_platf_AS_cb_t fct) {
469   xbt_dynar_push(sg_platf_AS_begin_cb_list, &fct);
470 }
471 void sg_platf_AS_end_add_cb(sg_platf_AS_cb_t fct) {
472   xbt_dynar_push(sg_platf_AS_end_cb_list, &fct);
473 }
474 void sg_platf_storage_add_cb(sg_platf_storage_cb_t fct) {
475   xbt_dynar_push(sg_platf_storage_cb_list, &fct);
476 }
477 void sg_platf_storage_type_add_cb(sg_platf_storage_type_cb_t fct) {
478   xbt_dynar_push(sg_platf_storage_type_cb_list, &fct);
479 }
480 void sg_platf_mstorage_add_cb(sg_platf_mstorage_cb_t fct) {
481   xbt_dynar_push(sg_platf_mstorage_cb_list, &fct);
482 }
483 void sg_platf_mount_add_cb(sg_platf_mount_cb_t fct) {
484   xbt_dynar_push(sg_platf_mount_cb_list, &fct);
485 }
486 void sg_platf_route_add_cb(sg_platf_route_cb_t fct) {
487   xbt_dynar_push(sg_platf_route_cb_list, &fct);
488 }
489 void sg_platf_ASroute_add_cb(sg_platf_route_cb_t fct) {
490   xbt_dynar_push(sg_platf_ASroute_cb_list, &fct);
491 }
492 void sg_platf_bypassRoute_add_cb(sg_platf_route_cb_t fct) {
493   xbt_dynar_push(sg_platf_bypassRoute_cb_list, &fct);
494 }
495 void sg_platf_bypassASroute_add_cb(sg_platf_route_cb_t fct) {
496   xbt_dynar_push(sg_platf_bypassASroute_cb_list, &fct);
497 }
498 void sg_platf_prop_add_cb(sg_platf_prop_cb_t fct) {
499   xbt_dynar_push(sg_platf_prop_cb_list, &fct);
500 }
501 void sg_platf_trace_add_cb(sg_platf_trace_cb_t fct) {
502   xbt_dynar_push(sg_platf_trace_cb_list, &fct);
503 }
504 void sg_platf_trace_connect_add_cb(sg_platf_trace_connect_cb_t fct) {
505   xbt_dynar_push(sg_platf_trace_connect_cb_list, &fct);
506 }
507 void sg_platf_rng_stream_init(unsigned long seed[6]) {
508   RngStream_SetPackageSeed(seed);
509   sg_platf_rng_stream = RngStream_CreateStream(NULL);
510 }
511
512 RngStream sg_platf_rng_stream_get(const char* id) {
513   RngStream stream = NULL;
514   unsigned int id_hash;
515
516   stream = RngStream_CopyStream(sg_platf_rng_stream);
517   id_hash = xbt_str_hash(id);
518   RngStream_AdvanceState(stream, 0, (long)id_hash);
519
520   return stream;
521 }