Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Energy is now a plugin
[simgrid.git] / src / include / surf / surf.h
1 /* Copyright (c) 2004-2013. 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 #ifndef _SURF_SURF_H
8 #define _SURF_SURF_H
9
10 #include "xbt/swag.h"
11 #include "xbt/dynar.h"
12 #include "xbt/dict.h"
13 #include "xbt/graph.h"
14 #include "xbt/misc.h"
15 #include "portable.h"
16 #include "xbt/config.h"
17 #include "surf/datatypes.h"
18 #include "xbt/lib.h"
19 #include "surf/surf_routing.h"
20 #include "simgrid/platf_interface.h"
21 #include "simgrid/datatypes.h"
22 #include "simgrid/plugins.h"
23
24 SG_BEGIN_DECL()
25 /* Actions and models are highly connected structures... */
26
27 /* user-visible parameters */
28 extern double sg_tcp_gamma;
29 extern double sg_sender_gap;
30 extern double sg_latency_factor;
31 extern double sg_bandwidth_factor;
32 extern double sg_weight_S_parameter;
33 extern int sg_network_crosstraffic;
34 #ifdef HAVE_GTNETS
35 extern double sg_gtnets_jitter;
36 extern int sg_gtnets_jitter_seed;
37 #endif
38 extern xbt_dynar_t surf_path;
39
40 typedef enum {
41   SURF_NETWORK_ELEMENT_NULL = 0,        /* NULL */
42   SURF_NETWORK_ELEMENT_HOST,    /* host type */
43   SURF_NETWORK_ELEMENT_ROUTER,  /* router type */
44   SURF_NETWORK_ELEMENT_AS       /* AS type */
45 } e_surf_network_element_type_t;
46
47 #ifdef __cplusplus
48 class Model;
49 class CpuModel;
50 class WorkstationModel;
51 class WorkstationVMModel;
52 class NetworkModel;
53 class StorageModel;
54 class Resource;
55 class ResourceLmm;
56 class WorkstationCLM03;
57 class NetworkCm02Link;
58 class Cpu;
59 class Action;
60 class ActionLmm;
61 class StorageActionLmm;
62 struct As;
63 struct RoutingEdge;
64 class RoutingPlatf;
65 #else
66 typedef struct Model Model;
67 typedef struct CpuModel CpuModel;
68 typedef struct WorkstationModel WorkstationModel;
69 typedef struct WorkstationVMModel WorkstationVMModel;
70 typedef struct NetworkModel NetworkModel;
71 typedef struct StorageModel StorageModel;
72 typedef struct Resource Resource;
73 typedef struct ResourceLmm ResourceLmm;
74 typedef struct WorkstationCLM03 WorkstationCLM03;
75 typedef struct NetworkCm02Link NetworkCm02Link;
76 typedef struct Cpu Cpu;
77 typedef struct Action Action;
78 typedef struct ActionLmm ActionLmm;
79 typedef struct StorageActionLmm StorageActionLmm;
80 typedef struct As As;
81 typedef struct RoutingEdge RoutingEdge;
82 typedef struct RoutingPlatf RoutingPlatf;
83 #endif
84
85 /** \ingroup SURF_models
86  *  \brief Model datatype
87  *
88  *  Generic data structure for a model. The workstations,
89  *  the CPUs and the network links are examples of models.
90  */
91 typedef Model *surf_model_t;
92 typedef CpuModel *surf_cpu_model_t;
93 typedef WorkstationModel *surf_workstation_model_t;
94 typedef WorkstationVMModel *surf_vm_workstation_model_t;
95
96 typedef NetworkModel *surf_network_model_t;
97 typedef StorageModel *surf_storage_model_t;
98
99 typedef xbt_dictelm_t surf_resource_t;
100 typedef Resource *surf_cpp_resource_t;
101 typedef WorkstationCLM03 *surf_workstation_CLM03_t;
102 typedef NetworkCm02Link *surf_network_link_t;
103 typedef Cpu *surf_cpu_t;
104
105 /** \ingroup SURF_actions
106  *  \brief Action structure
107  *
108  *  Never create s_surf_action_t by yourself ! The actions are created
109  *  on the fly when you call execute or communicate on a model.
110  *
111  *  \see e_surf_action_state_t
112  */
113 typedef Action *surf_action_t;
114 typedef ActionLmm *surf_action_lmm_t;
115 typedef StorageActionLmm *surf_storage_action_lmm_t;
116
117 typedef As *AS_t;
118 typedef RoutingEdge *routing_edge_t;
119 typedef RoutingPlatf *routing_platf_t;
120
121 typedef struct surf_file *surf_file_t;
122
123 XBT_PUBLIC(e_surf_network_element_type_t)
124   routing_get_network_element_type(const char* name);
125
126 /** @Brief Specify that we use that action */
127 XBT_PUBLIC(void) surf_action_ref(surf_action_t action);
128
129 /** @brief Creates a new action.
130  *
131  * @param size The size is the one of the subtype you want to create
132  * @param cost initial value
133  * @param model to which model we should attach this action
134  * @param failed whether we should start this action in failed mode
135  */
136 XBT_PUBLIC(void *) surf_action_new(size_t size, double cost,
137                                    surf_model_t model, int failed);
138
139 /** \brief Resource model description
140  */
141 typedef struct surf_model_description {
142   const char *name;
143   const char *description;
144   void_f_void_t model_init_preparse;
145 } s_surf_model_description_t, *surf_model_description_t;
146
147 XBT_PUBLIC(int) find_model_description(s_surf_model_description_t * table,
148                                        const char *name);
149 XBT_PUBLIC(void) model_help(const char *category,
150                             s_surf_model_description_t * table);
151
152 /** \ingroup SURF_actions
153  *  \brief Action states
154  *
155  *  Action states.
156  *
157  *  \see surf_action_t, surf_action_state_t
158  */
159
160 typedef enum {
161   SURF_ACTION_READY = 0,        /**< Ready        */
162   SURF_ACTION_RUNNING,          /**< Running      */
163   SURF_ACTION_FAILED,           /**< Task Failure */
164   SURF_ACTION_DONE,             /**< Completed    */
165   SURF_ACTION_TO_FREE,          /**< Action to free in next cleanup */
166   SURF_ACTION_NOT_IN_THE_SYSTEM
167                                 /**< Not in the system anymore. Why did you ask ? */
168 } e_surf_action_state_t;
169
170 /* FIXME: Where should the VM state be defined? */
171 typedef enum {
172   /* created, but not yet started */
173   SURF_VM_STATE_CREATED,
174
175   SURF_VM_STATE_RUNNING,
176   SURF_VM_STATE_MIGRATING,
177
178   /* Suspend/resume does not involve disk I/O, so we assume there is no transition states. */
179   SURF_VM_STATE_SUSPENDED,
180
181   /* Save/restore involves disk I/O, so there should be transition states. */
182   SURF_VM_STATE_SAVING,
183   SURF_VM_STATE_SAVED,
184   SURF_VM_STATE_RESTORING,
185
186 } e_surf_vm_state_t;
187
188 /***************************/
189 /* Generic model object */
190 /***************************/
191 //FIXME:REMOVE typedef struct s_routing_platf s_routing_platf_t, *routing_platf_t;
192 XBT_PUBLIC_DATA(routing_platf_t) routing_platf;
193
194 static inline void *surf_cpu_resource_priv(const void *host) {
195   return xbt_lib_get_level((xbt_dictelm_t)host, SURF_CPU_LEVEL);
196 }
197 static inline void *surf_workstation_resource_priv(const void *host){
198   return (void*)xbt_lib_get_level((xbt_dictelm_t)host, SURF_WKS_LEVEL);
199 }
200 static inline void *surf_storage_resource_priv(const void *storage){
201   return (void*)xbt_lib_get_level((xbt_dictelm_t)storage, SURF_STORAGE_LEVEL);
202 }
203
204 static inline void *surf_cpu_resource_by_name(const char *name) {
205   return xbt_lib_get_elm_or_null(host_lib, name);
206 }
207 static inline void *surf_workstation_resource_by_name(const char *name){
208   return xbt_lib_get_elm_or_null(host_lib, name);
209 }
210 static inline void *surf_storage_resource_by_name(const char *name){
211   return xbt_lib_get_elm_or_null(storage_lib, name);
212 }
213
214 XBT_PUBLIC(char *) surf_routing_edge_name(sg_routing_edge_t edge);
215 XBT_PUBLIC(void *) surf_as_cluster_get_backbone(AS_t as);
216 XBT_PUBLIC(void) surf_as_cluster_set_backbone(AS_t as, void* backbone);
217 XBT_PUBLIC(const char *) surf_model_name(surf_model_t model);
218 XBT_PUBLIC(surf_action_t) surf_model_extract_done_action_set(surf_model_t model);
219 XBT_PUBLIC(surf_action_t) surf_model_extract_failed_action_set(surf_model_t model);
220 XBT_PUBLIC(surf_action_t) surf_model_extract_ready_action_set(surf_model_t model);
221 XBT_PUBLIC(surf_action_t) surf_model_extract_running_action_set(surf_model_t model);
222 XBT_PUBLIC(int) surf_model_running_action_set_size(surf_model_t model);
223 XBT_PUBLIC(surf_action_t) surf_workstation_model_execute_parallel_task(surf_workstation_model_t model,
224                                                     int workstation_nb,
225                                             void **workstation_list,
226                                             double *computation_amount,
227                                             double *communication_amount,
228                                             double rate);
229 XBT_PUBLIC(surf_action_t) surf_workstation_model_communicate(surf_workstation_model_t model, surf_resource_t src, surf_resource_t dst, double size, double rate);
230 XBT_PUBLIC(xbt_dynar_t) surf_workstation_model_get_route(surf_workstation_model_t model, surf_resource_t src, surf_resource_t dst);
231 XBT_PUBLIC(void) surf_vm_workstation_model_create(const char *name, surf_resource_t ind_phys_host);
232 XBT_PUBLIC(surf_action_t) surf_network_model_communicate(surf_network_model_t model, sg_routing_edge_t src, sg_routing_edge_t dst, double size, double rate);
233 XBT_PUBLIC(const char * ) surf_resource_name(surf_cpp_resource_t resource);
234 XBT_PUBLIC(xbt_dict_t) surf_resource_get_properties(surf_cpp_resource_t resource);
235 XBT_PUBLIC(e_surf_resource_state_t) surf_resource_get_state(surf_cpp_resource_t resource);
236 XBT_PUBLIC(void) surf_resource_set_state(surf_cpp_resource_t resource, e_surf_resource_state_t state);
237 XBT_PUBLIC(double) surf_workstation_get_speed(surf_resource_t resource, double load);
238 XBT_PUBLIC(double) surf_workstation_get_available_speed(surf_resource_t resource);
239 XBT_PUBLIC(int) surf_workstation_get_core(surf_resource_t resource);
240 XBT_PUBLIC(surf_action_t) surf_workstation_execute(surf_resource_t resource, double size);
241 XBT_PUBLIC(surf_action_t) surf_workstation_sleep(surf_resource_t resource, double duration);
242 XBT_PUBLIC(surf_action_t) surf_workstation_open(surf_resource_t workstation, const char* mount, const char* path);
243 XBT_PUBLIC(surf_action_t) surf_workstation_close(surf_resource_t workstation, surf_file_t fd);
244 XBT_PUBLIC(surf_action_t) surf_workstation_read(surf_resource_t resource, surf_file_t fd, sg_size_t size);
245 XBT_PUBLIC(surf_action_t) surf_workstation_write(surf_resource_t resource, surf_file_t fd, sg_size_t size);
246 XBT_PUBLIC(xbt_dynar_t) surf_workstation_get_info(surf_resource_t resource, surf_file_t fd);
247 XBT_PUBLIC(sg_size_t) surf_workstation_get_free_size(surf_resource_t resource, const char* name);
248 XBT_PUBLIC(sg_size_t) surf_workstation_get_used_size(surf_resource_t resource, const char* name);
249 XBT_PUBLIC(xbt_dynar_t) surf_workstation_get_vms(surf_resource_t resource);
250 XBT_PUBLIC(void) surf_workstation_get_params(surf_resource_t resource, ws_params_t params);
251 XBT_PUBLIC(void) surf_workstation_set_params(surf_resource_t resource, ws_params_t params);
252 XBT_PUBLIC(void) surf_vm_workstation_destroy(surf_resource_t resource);
253 XBT_PUBLIC(void) surf_vm_workstation_suspend(surf_resource_t resource);
254 XBT_PUBLIC(void) surf_vm_workstation_resume(surf_resource_t resource);
255 XBT_PUBLIC(void) surf_vm_workstation_save(surf_resource_t resource);
256 XBT_PUBLIC(void) surf_vm_workstation_restore(surf_resource_t resource);
257 XBT_PUBLIC(void) surf_vm_workstation_migrate(surf_resource_t resource, surf_resource_t ind_vm_ws_dest);
258 XBT_PUBLIC(surf_resource_t) surf_vm_workstation_get_pm(surf_resource_t resource);
259 XBT_PUBLIC(void) surf_vm_workstation_set_bound(surf_resource_t resource, double bound);
260 XBT_PUBLIC(void) surf_vm_workstation_set_affinity(surf_resource_t resource, surf_resource_t cpu, unsigned long mask);
261 XBT_PUBLIC(surf_action_t) surf_cpu_execute(surf_resource_t cpu, double size);
262 XBT_PUBLIC(surf_action_t) surf_cpu_sleep(surf_resource_t cpu, double duration);
263 XBT_PUBLIC(double) surf_workstation_get_current_power_peak(surf_resource_t host);
264 XBT_PUBLIC(double) surf_workstation_get_power_peak_at(surf_resource_t host, int pstate_index);
265 XBT_PUBLIC(int) surf_workstation_get_nb_pstates(surf_resource_t host);
266 XBT_PUBLIC(void) surf_workstation_set_power_peak_at(surf_resource_t host, int pstate_index);
267 XBT_PUBLIC(double) surf_workstation_get_consumed_energy(surf_resource_t host);
268 XBT_PUBLIC(xbt_dict_t) surf_workstation_get_storage_list(surf_resource_t workstation);
269 XBT_PUBLIC(int) surf_workstation_unlink(surf_resource_t workstation, surf_file_t fd);
270 XBT_PUBLIC(surf_action_t) surf_workstation_ls(surf_resource_t workstation, const char* mount, const char *path);
271 XBT_PUBLIC(size_t) surf_workstation_get_size(surf_resource_t workstation, surf_file_t fd);
272 XBT_PUBLIC(size_t) surf_workstation_file_tell(surf_resource_t workstation, surf_file_t fd);
273 XBT_PUBLIC(int) surf_workstation_file_seek(surf_resource_t workstation, surf_file_t fd, sg_size_t offset, int origin);
274 XBT_PUBLIC(int) surf_network_link_is_shared(surf_cpp_resource_t link);
275 XBT_PUBLIC(double) surf_network_link_get_bandwidth(surf_cpp_resource_t link);
276 XBT_PUBLIC(double) surf_network_link_get_latency(surf_cpp_resource_t link);
277 XBT_PUBLIC(xbt_dict_t) surf_storage_get_content(surf_resource_t resource);
278 XBT_PUBLIC(sg_size_t) surf_storage_get_size(surf_resource_t resource);
279 XBT_PUBLIC(void) surf_storage_rename(surf_resource_t resource, const char* src, const char* dest);
280 XBT_PUBLIC(void*) surf_action_get_data(surf_action_t action);
281 XBT_PUBLIC(void) surf_action_set_data(surf_action_t action, void *data);
282 XBT_PUBLIC(void) surf_action_unref(surf_action_t action);
283 XBT_PUBLIC(double) surf_action_get_start_time(surf_action_t action);
284 XBT_PUBLIC(double) surf_action_get_finish_time(surf_action_t action);
285 XBT_PUBLIC(double) surf_action_get_remains(surf_action_t action);
286 XBT_PUBLIC(void) surf_action_suspend(surf_action_t action);
287 XBT_PUBLIC(void) surf_action_resume(surf_action_t action);
288 XBT_PUBLIC(void) surf_action_cancel(surf_action_t action);
289 XBT_PUBLIC(void) surf_action_set_priority(surf_action_t action, double priority);
290 XBT_PUBLIC(void) surf_action_set_category(surf_action_t action, const char *category);
291 XBT_PUBLIC(e_surf_action_state_t) surf_action_get_state(surf_action_t action);
292 XBT_PUBLIC(int) surf_action_get_cost(surf_action_t action);
293 XBT_PUBLIC(void) surf_cpu_action_set_affinity(surf_action_t action, surf_resource_t cpu, unsigned long mask);
294 XBT_PUBLIC(void) surf_cpu_action_set_bound(surf_action_t action, double bound);
295 XBT_PUBLIC(surf_file_t) surf_storage_action_get_file(surf_action_t action);
296 XBT_PUBLIC(xbt_dict_t) surf_storage_action_get_ls_dict(surf_action_t action);
297 XBT_PUBLIC(surf_model_t) surf_resource_model(const void *host, int level);
298
299 /**************************************/
300 /* Implementations of model object */
301 /**************************************/
302
303 /** \ingroup SURF_models
304  *  \brief The CPU model object for the physical machine layer
305  */
306 XBT_PUBLIC_DATA(surf_cpu_model_t) surf_cpu_model_pm;
307
308 /** \ingroup SURF_models
309  *  \brief The CPU model object for the virtual machine layer
310  */
311 XBT_PUBLIC_DATA(surf_cpu_model_t) surf_cpu_model_vm;
312
313
314 /** \ingroup SURF_models
315  *  \brief Initializes the CPU model with the model Cas01
316  *
317  *  By default, this model uses the lazy optimization mechanism that
318  *  relies on partial invalidation in LMM and a heap for lazy action update.
319  *  You can change this behavior by setting the cpu/optim configuration
320  *  variable to a different value.
321  *
322  *  You shouldn't have to call it by yourself.
323  */
324 XBT_PUBLIC(void) surf_cpu_model_init_Cas01(void);
325
326 /** \ingroup SURF_models
327  *  \brief Initializes the CPU model with trace integration [Deprecated]
328  *
329  *  You shouldn't have to call it by yourself.
330  */
331 XBT_PUBLIC(void) surf_cpu_model_init_ti(void);
332
333 /** \ingroup SURF_models
334  *  \brief The list of all available optimization modes (both for cpu and networks).
335  *  These optimization modes can be set using --cfg=cpu/optim:... and --cfg=network/optim:...
336  */
337 XBT_PUBLIC_DATA(s_surf_model_description_t) surf_optimization_mode_description[];
338
339 /** \ingroup SURF_plugins
340  *  \brief The list of all available surf plugins
341  */
342 XBT_PUBLIC_DATA(s_surf_model_description_t) surf_plugin_description[];
343
344 /** \ingroup SURF_models
345  *  \brief The list of all available cpu model models
346  */
347 XBT_PUBLIC_DATA(s_surf_model_description_t) surf_cpu_model_description[];
348
349 /**\brief create new host bypass the parser
350  *
351  */
352
353
354 /** \ingroup SURF_models
355  *  \brief The network model
356  *
357  *  When creating a new API on top on SURF, you shouldn't use the
358  *  network model unless you know what you are doing. Only the workstation
359  *  model should be accessed because depending on the platform model,
360  *  the network model can be NULL.
361  */
362 XBT_PUBLIC_DATA(surf_network_model_t) surf_network_model;
363
364 /** \ingroup SURF_models
365  *  \brief Same as network model 'LagrangeVelho', only with different correction factors.
366  *
367  * This model is proposed by Pierre-Nicolas Clauss and Martin Quinson and Stéphane Génaud
368  * based on the model 'LV08' and different correction factors depending on the communication
369  * size (< 1KiB, < 64KiB, >= 64KiB).
370  * See comments in the code for more information.
371  *
372  *  \see surf_workstation_model_init_SMPI()
373  */
374 XBT_PUBLIC(void) surf_network_model_init_SMPI(void);
375
376 /** \ingroup SURF_models
377  *  \brief Initializes the platform with the network model 'LegrandVelho'
378  *
379  * This model is proposed by Arnaud Legrand and Pedro Velho based on
380  * the results obtained with the GTNets simulator for onelink and
381  * dogbone sharing scenarios. See comments in the code for more information.
382  *
383  *  \see surf_workstation_model_init_LegrandVelho()
384  */
385 XBT_PUBLIC(void) surf_network_model_init_LegrandVelho(void);
386
387 /** \ingroup SURF_models
388  *  \brief Initializes the platform with the network model 'Constant'
389  *
390  *  In this model, the communication time between two network cards is
391  *  constant, hence no need for a routing table. This is particularly
392  *  usefull when simulating huge distributed algorithms where
393  *  scalability is really an issue. This function is called in
394  *  conjunction with surf_workstation_model_init_compound.
395  *
396  *  \see surf_workstation_model_init_compound()
397  */
398 XBT_PUBLIC(void) surf_network_model_init_Constant(void);
399
400 /** \ingroup SURF_models
401  *  \brief Initializes the platform with the network model CM02
402  *
403  *  You sould call this function by yourself only if you plan using
404  *  surf_workstation_model_init_compound.
405  *  See comments in the code for more information.
406  */
407 XBT_PUBLIC(void) surf_network_model_init_CM02(void);
408
409 #ifdef HAVE_GTNETS
410 /** \ingroup SURF_models
411  *  \brief Initializes the platform with the network model GTNETS
412  *  \param filename XML platform file name
413  *
414  *  This function is called by surf_workstation_model_init_GTNETS
415  *  or by yourself only if you plan using surf_workstation_model_init_compound
416  *
417  *  \see surf_workstation_model_init_GTNETS()
418  */
419 XBT_PUBLIC(void) surf_network_model_init_GTNETS(void);
420 #endif
421
422 #ifdef HAVE_NS3
423 /** \ingroup SURF_models
424  *  \brief Initializes the platform with the network model NS3
425  *  \param filename XML platform file name
426  *
427  *  This function is called by surf_workstation_model_init_NS3
428  *  or by yourself only if you plan using surf_workstation_model_init_compound
429  *
430  *  \see surf_workstation_model_init_NS3()
431  */
432 XBT_PUBLIC(void) surf_network_model_init_NS3(void);
433 #endif
434
435 /** \ingroup SURF_models
436  *  \brief Initializes the platform with the network model Reno
437  *  \param filename XML platform file name
438  *
439  *  The problem is related to max( sum( arctan(C * Df * xi) ) ).
440  *
441  *  Reference:
442  *  [LOW03] S. H. Low. A duality model of TCP and queue management algorithms.
443  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
444  *
445  *  Call this function only if you plan using surf_workstation_model_init_compound.
446  *
447  */
448 XBT_PUBLIC(void) surf_network_model_init_Reno(void);
449
450 /** \ingroup SURF_models
451  *  \brief Initializes the platform with the network model Reno2
452  *  \param filename XML platform file name
453  *
454  *  The problem is related to max( sum( arctan(C * Df * xi) ) ).
455  *
456  *  Reference:
457  *  [LOW01] S. H. Low. A duality model of TCP and queue management algorithms.
458  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
459  *
460  *  Call this function only if you plan using surf_workstation_model_init_compound.
461  *
462  */
463 XBT_PUBLIC(void) surf_network_model_init_Reno2(void);
464
465 /** \ingroup SURF_models
466  *  \brief Initializes the platform with the network model Vegas
467  *  \param filename XML platform file name
468  *
469  *  This problem is related to max( sum( a * Df * ln(xi) ) ) which is equivalent
470  *  to the proportional fairness.
471  *
472  *  Reference:
473  *  [LOW03] S. H. Low. A duality model of TCP and queue management algorithms.
474  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
475  *
476  *  Call this function only if you plan using surf_workstation_model_init_compound.
477  *
478  */
479 XBT_PUBLIC(void) surf_network_model_init_Vegas(void);
480
481 /** \ingroup SURF_models
482  *  \brief The list of all available network model models
483  */
484 XBT_PUBLIC_DATA(s_surf_model_description_t)
485     surf_network_model_description[];
486
487 /** \ingroup SURF_models
488  *  \brief The storage model
489  */
490 XBT_PUBLIC(void) surf_storage_model_init_default(void);
491
492 /** \ingroup SURF_models
493  *  \brief The list of all available storage modes.
494  *  This storage mode can be set using --cfg=storage/model:...
495  */
496 XBT_PUBLIC_DATA(s_surf_model_description_t) surf_storage_model_description[];
497
498 XBT_PUBLIC_DATA(surf_storage_model_t) surf_storage_model;
499
500 /** \ingroup SURF_models
501  *  \brief The workstation model
502  *
503  *  Note that when you create an API on top of SURF,
504  *  the workstation model should be the only one you use
505  *  because depending on the platform model, the network model and the CPU model
506  *  may not exist.
507  */
508 XBT_PUBLIC_DATA(surf_workstation_model_t) surf_workstation_model;
509
510 /** \ingroup SURF_models
511  *  \brief The vm_workstation model
512  *
513  *  Note that when you create an API on top of SURF,
514  *  the vm_workstation model should be the only one you use
515  *  because depending on the platform model, the network model and the CPU model
516  *  may not exist.
517  */
518 XBT_PUBLIC_DATA(surf_vm_workstation_model_t) surf_vm_workstation_model;
519
520 /** \ingroup SURF_models
521  *  \brief Initializes the platform with a compound workstation model
522  *
523  *  This function should be called after a cpu_model and a
524  *  network_model have been set up.
525  *
526  */
527 XBT_PUBLIC(void) surf_workstation_model_init_compound(void);
528
529 /** \ingroup SURF_models
530  *  \brief Initializes the platform with the current best network and cpu models at hand
531  *
532  *  This platform model seperates the workstation model and the network model.
533  *  The workstation model will be initialized with the model compound, the network
534  *  model with the model LV08 (with cross traffic support) and the CPU model with
535  *  the model Cas01.
536  *  Such model is subject to modification with warning in the ChangeLog so monitor it!
537  *
538  */
539 XBT_PUBLIC(void) surf_workstation_model_init_current_default(void);
540
541 /** \ingroup SURF_models
542  *  \brief Initializes the platform with the model KCCFLN05
543  *
544  *  With this model, only parallel tasks can be used. Resource sharing
545  *  is done by identifying bottlenecks and giving an equal share of
546  *  the model to each action.
547  *
548  */
549 XBT_PUBLIC(void) surf_workstation_model_init_ptask_L07(void);
550
551 /** \ingroup SURF_models
552  *  \brief The list of all available workstation model models
553  */
554 XBT_PUBLIC_DATA(s_surf_model_description_t)
555     surf_workstation_model_description[];
556
557 /** \ingroup SURF_models
558  *  \brief Initializes the platform with the current best network and cpu models at hand
559  *
560  *  This platform model seperates the workstation model and the network model.
561  *  The workstation model will be initialized with the model compound, the network
562  *  model with the model LV08 (with cross traffic support) and the CPU model with
563  *  the model Cas01.
564  *  Such model is subject to modification with warning in the ChangeLog so monitor it!
565  *
566  */
567 XBT_PUBLIC(void) surf_vm_workstation_model_init_current_default(void);
568
569 /** \ingroup SURF_models
570  *  \brief The list of all available vm workstation model models
571  */
572 XBT_PUBLIC_DATA(s_surf_model_description_t)
573     surf_vm_workstation_model_description[];
574
575 /*******************************************/
576
577 /** \ingroup SURF_models
578  *  \brief List of initialized models
579  */
580 XBT_PUBLIC_DATA(xbt_dynar_t) model_list;
581 XBT_PUBLIC_DATA(xbt_dynar_t) model_list_invoke;
582
583 /** \ingroup SURF_simulation
584  *  \brief List of hosts that have juste restarted and whose autorestart process should be restarted.
585  */
586 XBT_PUBLIC_DATA(xbt_dynar_t) host_that_restart;
587
588 /** \ingroup SURF_simulation
589  *  \brief List of hosts for which one want to be notified if they ever restart.
590  */
591 XBT_PUBLIC(xbt_dict_t) watched_hosts_lib;
592
593 /*******************************************/
594 /*** SURF Platform *************************/
595 /*******************************************/
596 XBT_PUBLIC_DATA(AS_t) surf_AS_get_routing_root(void); 
597 XBT_PUBLIC_DATA(const char *) surf_AS_get_name(AS_t as);
598 XBT_PUBLIC_DATA(xbt_dict_t) surf_AS_get_routing_sons(AS_t as);
599 XBT_PUBLIC_DATA(const char *) surf_AS_get_model(AS_t as);
600 XBT_PUBLIC_DATA(xbt_dynar_t) surf_AS_get_hosts(AS_t as);
601 XBT_PUBLIC_DATA(void) surf_AS_get_graph(AS_t as, xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges);
602 XBT_PUBLIC_DATA(AS_t) surf_platf_get_root(routing_platf_t platf);
603 XBT_PUBLIC_DATA(e_surf_network_element_type_t) surf_routing_edge_get_rc_type(sg_routing_edge_t edge);
604
605 /*******************************************/
606 /*** SURF Globals **************************/
607 /*******************************************/
608
609 /** \ingroup SURF_simulation
610  *  \brief Initialize SURF
611  *  \param argc argument number
612  *  \param argv arguments
613  *
614  *  This function has to be called to initialize the common
615  *  structures.  Then you will have to create the environment by
616  *  calling 
617  *  e.g. surf_workstation_model_init_CM02()
618  *
619  *  \see surf_workstation_model_init_CM02(), surf_workstation_model_init_compound(), surf_exit()
620  */
621 XBT_PUBLIC(void) surf_init(int *argc, char **argv);     /* initialize common structures */
622
623 /** \ingroup SURF_simulation
624  *  \brief Finish simulation initialization
625  *
626  *  This function must be called before the first call to surf_solve()
627  */
628 XBT_PUBLIC(void) surf_presolve(void);
629
630 /** \ingroup SURF_simulation
631  *  \brief Performs a part of the simulation
632  *  \param max_date Maximum date to update the simulation to, or -1
633  *  \return the elapsed time, or -1.0 if no event could be executed
634  *
635  *  This function execute all possible events, update the action states
636  *  and returns the time elapsed.
637  *  When you call execute or communicate on a model, the corresponding actions
638  *  are not executed immediately but only when you call surf_solve.
639  *  Note that the returned elapsed time can be zero.
640  */
641 XBT_PUBLIC(double) surf_solve(double max_date);
642
643 /** \ingroup SURF_simulation
644  *  \brief Return the current time
645  *
646  *  Return the current time in millisecond.
647  */
648 XBT_PUBLIC(double) surf_get_clock(void);
649
650 /** \ingroup SURF_simulation
651  *  \brief Exit SURF
652  *
653  *  Clean everything.
654  *
655  *  \see surf_init()
656  */
657 XBT_PUBLIC(void) surf_exit(void);
658
659 /* Prototypes of the functions that handle the properties */
660 XBT_PUBLIC_DATA(xbt_dict_t) current_property_set;       /* the prop set for the currently parsed element (also used in SIMIX) */
661
662 /* surf parse file related (public because called from a test suite) */
663 XBT_PUBLIC(void) parse_platform_file(const char *file);
664
665 /* For the trace and trace:connect tag (store their content till the end of the parsing) */
666 XBT_PUBLIC_DATA(xbt_dict_t) traces_set_list;
667 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_host_avail;
668 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_power;
669 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_avail;
670 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_bandwidth;
671 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_latency;
672
673
674 XBT_PUBLIC(double) get_cpu_power(const char *power);
675
676 XBT_PUBLIC(xbt_dict_t) get_as_router_properties(const char* name);
677
678 int surf_get_nthreads(void);
679 void surf_set_nthreads(int nthreads);
680
681 /*
682  * Returns the initial path. On Windows the initial path is
683  * the current directory for the current process in the other
684  * case the function returns "./" that represents the current
685  * directory on Unix/Linux platforms.
686  */
687 const char *__surf_get_initial_path(void);
688
689 /********** Tracing **********/
690 /* from surf_instr.c */
691 void TRACE_surf_action(surf_action_t surf_action, const char *category);
692 void TRACE_surf_alloc(void);
693 void TRACE_surf_release(void);
694
695 /* instr_routing.c */
696 void instr_routing_define_callbacks (void);
697 void instr_new_variable_type (const char *new_typename, const char *color);
698 void instr_new_user_variable_type  (const char *father_type, const char *new_typename, const char *color);
699 void instr_new_user_state_type (const char *father_type, const char *new_typename);
700 void instr_new_value_for_user_state_type (const char *_typename, const char *value, const char *color);
701 int instr_platform_traced (void);
702 xbt_graph_t instr_routing_platform_graph (void);
703 void instr_routing_platform_graph_export_graphviz (xbt_graph_t g, const char *filename);
704
705 SG_END_DECL()
706 #endif                          /* _SURF_SURF_H */