Logo AND Algorithmique Numérique Distribuée

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