Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot//simgrid/simgrid
[simgrid.git] / src / include / surf / surf.h
1 /* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. 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/misc.h"
14 #include "portable.h"
15 #include "xbt/config.h"
16 #include "surf/datatypes.h"
17 #include "xbt/lib.h"
18
19 xbt_lib_t host_lib;
20 int ROUTING_HOST_LEVEL; //Routing level
21 int     SURF_CPU_LEVEL;         //Surf cpu level
22 int SURF_WKS_LEVEL;             //Surf workstation level
23 int SIMIX_HOST_LEVEL;   //Simix level
24 int     MSG_HOST_LEVEL;         //Msg level
25 int     SD_HOST_LEVEL;          //Simdag level
26 int     COORD_HOST_LEVEL;       //Coordinates level
27
28 xbt_lib_t link_lib;
29 int SD_LINK_LEVEL;              //Simdag level
30 int SURF_LINK_LEVEL;    //Surf level
31
32 xbt_lib_t as_router_lib;
33 int ROUTING_ASR_LEVEL;  //Routing level
34 int COORD_ASR_LEVEL;    //Coordinates level
35
36 SG_BEGIN_DECL()
37 /* Actions and models are highly connected structures... */
38 typedef enum {
39   SURF_RESOURCE_ON = 1,                   /**< Up & ready        */
40   SURF_RESOURCE_OFF = 0                   /**< Down & broken     */
41 } e_surf_resource_state_t;
42
43 typedef enum {
44   SURF_LINK_FULLDUPLEX = 2,
45   SURF_LINK_SHARED = 1,
46   SURF_LINK_FATPIPE = 0
47 } e_surf_link_sharing_policy_t;
48
49 typedef enum {
50   SURF_NETWORK_ELEMENT_NULL = 0,        /* NULL */
51   SURF_NETWORK_ELEMENT_HOST,    /* host type */
52   SURF_NETWORK_ELEMENT_ROUTER,  /* router type */
53   SURF_NETWORK_ELEMENT_AS,      /* AS type */
54 } e_surf_network_element_type_t;
55
56 XBT_PUBLIC(e_surf_network_element_type_t) get_network_element_type(const char
57                                                               *name);
58
59 /** @Brief Specify that we use that action */
60 XBT_PUBLIC(void) surf_action_ref(surf_action_t action);
61 /** @brief Creates a new action.
62  *
63  * @param size The size is the one of the subtype you want to create
64  * @param cost initial value
65  * @param model to which model we should attach this action
66  * @param failed whether we should start this action in failed mode
67  */
68 XBT_PUBLIC(void *) surf_action_new(size_t size, double cost,
69                                    surf_model_t model, int failed);
70
71 /** \brief Resource model description
72  */
73 typedef struct surf_model_description {
74   const char *name;
75   const char *description;
76   surf_model_t model;
77   void (*model_init_preparse) (const char *filename);
78   void (*model_init_postparse) (void);
79 } s_surf_model_description_t, *surf_model_description_t;
80
81 XBT_PUBLIC(void) update_model_description(s_surf_model_description_t *
82                                           table, const char *name,
83                                           surf_model_t model);
84 XBT_PUBLIC(int) find_model_description(s_surf_model_description_t * table,
85                                        const char *name);
86 XBT_PUBLIC(void) model_help(const char *category,
87                             s_surf_model_description_t * table);
88
89 /** \brief Action structure
90  * \ingroup SURF_actions
91  *
92  *  Never create s_surf_action_t by yourself ! The actions are created
93  *  on the fly when you call execute or communicate on a model.
94  *
95  *  \see e_surf_action_state_t
96  */
97 typedef struct surf_action {
98   s_xbt_swag_hookup_t state_hookup;
99   xbt_swag_t state_set;
100   double cost;                  /**< cost        */
101   double priority;              /**< priority (1.0 by default) */
102   double max_duration;          /**< max_duration (may fluctuate until
103                                    the task is completed) */
104   double remains;               /**< How much of that cost remains to
105                                  * be done in the currently running task */
106 #ifdef HAVE_LATENCY_BOUND_TRACKING
107   int latency_limited;               /**< Set to 1 if is limited by latency, 0 otherwise */
108 #endif
109
110   double start;                 /**< start time  */
111   double finish;                /**< finish time : this is modified during the run
112                                  * and fluctuates until the task is completed */
113   void *data;                   /**< for your convenience */
114   int refcount;
115   surf_model_t model_type;
116 #ifdef HAVE_TRACING
117   char *category;               /**< tracing category for categorized resource utilization monitoring */
118 #endif
119 } s_surf_action_t;
120
121 typedef struct surf_action_lmm {
122   s_surf_action_t generic_action;
123   lmm_variable_t variable;
124   int suspended;
125 } s_surf_action_lmm_t, *surf_action_lmm_t;
126
127 /** \brief Action states
128  *  \ingroup SURF_actions
129  *
130  *  Action states.
131  *
132  *  \see surf_action_t, surf_action_state_t
133  */
134 typedef enum {
135   SURF_ACTION_READY = 0,        /**< Ready        */
136   SURF_ACTION_RUNNING,          /**< Running      */
137   SURF_ACTION_FAILED,           /**< Task Failure */
138   SURF_ACTION_DONE,             /**< Completed    */
139   SURF_ACTION_TO_FREE,          /**< Action to free in next cleanup */
140   SURF_ACTION_NOT_IN_THE_SYSTEM
141                                 /**< Not in the system anymore. Why did you ask ? */
142 } e_surf_action_state_t;
143
144 /** \brief Action state sets
145  *  \ingroup SURF_actions
146  *
147  *  This structure contains some sets of actions.
148  *  It provides a fast access to the actions in each state.
149  *
150  *  \see surf_action_t, e_surf_action_state_t
151  */
152 typedef struct surf_action_state {
153   xbt_swag_t ready_action_set;
154                                  /**< Actions in state SURF_ACTION_READY */
155   xbt_swag_t running_action_set;
156                                  /**< Actions in state SURF_ACTION_RUNNING */
157   xbt_swag_t failed_action_set;
158                                  /**< Actions in state SURF_ACTION_FAILED */
159   xbt_swag_t done_action_set;
160                                  /**< Actions in state SURF_ACTION_DONE */
161 } s_surf_action_state_t, *surf_action_state_t;
162
163 /***************************/
164 /* Generic model object */
165 /***************************/
166 typedef struct s_routing_global s_routing_global_t, *routing_global_t;
167 XBT_PUBLIC_DATA(routing_global_t) global_routing;
168
169
170 /** \brief Private data available on all models
171  *  \ingroup SURF_models
172  */
173 typedef struct surf_model_private *surf_model_private_t;
174
175      /* Cpu model */
176
177      /** \brief CPU model extension public
178       *  \ingroup SURF_models
179       *
180       *  Public functions specific to the CPU model.
181       */
182 typedef struct surf_cpu_model_extension_public {
183   surf_action_t(*execute) (void *cpu, double size);
184   surf_action_t(*sleep) (void *cpu, double duration);
185   e_surf_resource_state_t(*get_state) (void *cpu);
186   double (*get_speed) (void *cpu, double load);
187   double (*get_available_speed) (void *cpu);
188   void (*create_resource) (char *name, double power_peak,
189                            double power_scale,
190                            tmgr_trace_t power_trace,
191                            int core,
192                            e_surf_resource_state_t state_initial,
193                            tmgr_trace_t state_trace,
194                            xbt_dict_t cpu_properties);
195   void (*add_traces) (void);
196 } s_surf_model_extension_cpu_t;
197
198      /* Network model */
199
200      /** \brief Network model extension public
201       *  \ingroup SURF_models
202       *
203       *  Public functions specific to the network model
204       */
205 typedef struct surf_network_model_extension_public {
206   surf_action_t(*communicate) (const char *src_name,
207                                const char *dst_name,
208                                double size, double rate);
209   xbt_dynar_t(*get_route) (const char *src_name, const char *dst_name);
210   double (*get_link_bandwidth) (const void *link);
211   double (*get_link_latency) (const void *link);
212   int (*link_shared) (const void *link);
213   void (*add_traces) (void);
214   void (*create_resource) (char *name,
215                            double bw_initial,
216                            tmgr_trace_t bw_trace,
217                            double lat_initial,
218                            tmgr_trace_t lat_trace,
219                            e_surf_resource_state_t
220                            state_initial,
221                            tmgr_trace_t state_trace,
222                            e_surf_link_sharing_policy_t policy,
223                            xbt_dict_t properties);
224 } s_surf_model_extension_network_t;
225
226      /** \brief Workstation model extension public
227       *  \ingroup SURF_models
228       *
229       *  Public functions specific to the workstation model.
230       */
231 typedef struct surf_workstation_model_extension_public {
232   surf_action_t(*execute) (void *workstation, double size);                                /**< Execute a computation amount on a workstation
233                                                                                         and create the corresponding action */
234   surf_action_t(*sleep) (void *workstation, double duration);                              /**< Make a workstation sleep during a given duration */
235   e_surf_resource_state_t(*get_state) (void *workstation);                                      /**< Return the CPU state of a workstation */
236   double (*get_speed) (void *workstation, double load);                                    /**< Return the speed of a workstation */
237   double (*get_available_speed) (void *workstation);                                       /**< Return tha available speed of a workstation */
238    surf_action_t(*communicate) (void *workstation_src,                                     /**< Execute a communication amount between two workstations */
239                                 void *workstation_dst, double size,
240                                 double max_rate);
241    xbt_dynar_t(*get_route) (void *workstation_src, void *workstation_dst);                 /**< Get the list of links between two ws */
242
243    surf_action_t(*execute_parallel_task) (int workstation_nb,                              /**< Execute a parallel task on several workstations */
244                                           void **workstation_list,
245                                           double *computation_amount,
246                                           double *communication_amount,
247                                           double amount, double rate);
248   double (*get_link_bandwidth) (const void *link);                                         /**< Return the current bandwidth of a network link */
249   double (*get_link_latency) (const void *link);                                           /**< Return the current latency of a network link */
250   int (*link_shared) (const void *link);
251    xbt_dict_t(*get_properties) (const void *resource);
252   void (*link_create_resource) (char *name,
253                                 double bw_initial,
254                                 tmgr_trace_t bw_trace,
255                                 double lat_initial,
256                                 tmgr_trace_t lat_trace,
257                                 e_surf_resource_state_t
258                                 state_initial,
259                                 tmgr_trace_t state_trace,
260                                 e_surf_link_sharing_policy_t
261                                 policy, xbt_dict_t properties);
262   void (*cpu_create_resource) (char *name, double power_peak,
263                                double power_scale,
264                                tmgr_trace_t power_trace,
265                                e_surf_resource_state_t state_initial,
266                                tmgr_trace_t state_trace,
267                                xbt_dict_t cpu_properties);
268   void (*add_traces) (void);
269
270 } s_surf_model_extension_workstation_t;
271
272
273
274
275 /** \brief Model datatype
276  *  \ingroup SURF_models
277  *
278  *  Generic data structure for a model. The workstations,
279  *  the CPUs and the network links are examples of models.
280  */
281 typedef struct surf_model {
282   const char *name;     /**< Name of this model */
283   s_surf_action_state_t states;      /**< Any living action on this model */
284
285    e_surf_action_state_t(*action_state_get) (surf_action_t action);
286                                                                        /**< Return the state of an action */
287   void (*action_state_set) (surf_action_t action,
288                             e_surf_action_state_t state);
289                                                                   /**< Change an action state*/
290
291   double (*action_get_start_time) (surf_action_t action);     /**< Return the start time of an action */
292   double (*action_get_finish_time) (surf_action_t action);     /**< Return the finish time of an action */
293   int (*action_unref) (surf_action_t action);     /**< Specify that we don't use that action anymore */
294   void (*action_cancel) (surf_action_t action);     /**< Cancel a running action */
295   void (*action_recycle) (surf_action_t action);     /**< Recycle an action */
296   void (*action_data_set) (surf_action_t action, void *data);     /**< Set the user data of an action */
297   void (*suspend) (surf_action_t action);     /**< Suspend an action */
298   void (*resume) (surf_action_t action);     /**< Resume a suspended action */
299   int (*is_suspended) (surf_action_t action);     /**< Return whether an action is suspended */
300   void (*set_max_duration) (surf_action_t action, double duration);     /**< Set the max duration of an action*/
301   void (*set_priority) (surf_action_t action, double priority);     /**< Set the priority of an action */
302 #ifdef HAVE_TRACING
303   void (*set_category) (surf_action_t action, const char *category); /**< Set the category of an action */
304 #endif
305   double (*get_remains) (surf_action_t action);     /**< Get the remains of an action */
306 #ifdef HAVE_LATENCY_BOUND_TRACKING
307   int (*get_latency_limited) (surf_action_t action);     /**< Return 1 if action is limited by latency, 0 otherwise */
308 #endif
309
310   surf_model_private_t model_private;
311
312   union extension {
313     s_surf_model_extension_cpu_t cpu;
314     s_surf_model_extension_network_t network;
315     s_surf_model_extension_workstation_t workstation;
316   } extension;
317 } s_surf_model_t;
318
319 surf_model_t surf_model_init(void);
320 void surf_model_exit(surf_model_t model);
321
322 static inline void *surf_cpu_resource_by_name(const char *name) {
323         return xbt_lib_get_or_null(host_lib, name, SURF_CPU_LEVEL);
324 }
325 static inline void *surf_workstation_resource_by_name(const char *name){
326         return xbt_lib_get_or_null(host_lib, name, SURF_WKS_LEVEL);
327 }
328 static inline void *surf_network_resource_by_name(const char *name){
329         return xbt_lib_get_or_null(link_lib, name, SURF_LINK_LEVEL);
330 }
331
332 typedef struct surf_resource {
333   surf_model_t model;
334   char *name;
335   xbt_dict_t properties;
336 } s_surf_resource_t, *surf_resource_t;
337
338
339
340 /**
341  * Resource which have a metric handled by a maxmin system
342  */
343 typedef struct {
344   double scale;
345   double peak;
346   tmgr_trace_event_t event;
347 } s_surf_metric_t;
348
349 typedef struct surf_resource_lmm {
350   s_surf_resource_t generic_resource;
351   lmm_constraint_t constraint;
352   e_surf_resource_state_t state_current;
353   tmgr_trace_event_t state_event;
354   s_surf_metric_t power;
355 } s_surf_resource_lmm_t, *surf_resource_lmm_t;
356
357 /**************************************/
358 /* Implementations of model object */
359 /**************************************/
360
361
362 /** \brief The CPU model
363  *  \ingroup SURF_models
364  */
365 XBT_PUBLIC_DATA(surf_model_t) surf_cpu_model;
366
367 /** \brief Initializes the CPU model with the model Cas01
368  *  \ingroup SURF_models
369  *
370  *  This function is called by surf_workstation_model_init_CLM03
371  *  so you shouldn't have to call it by yourself.
372  *
373  *  \see surf_workstation_model_init_CLM03()
374  */
375 XBT_PUBLIC(void) surf_cpu_model_init_Cas01(const char *filename);
376
377 /** \brief Initializes the CPU model with trace integration
378  *  \ingroup SURF_models
379  *
380  */
381 XBT_PUBLIC(void) surf_cpu_model_init_ti(const char *filename);
382
383 /** \brief Initializes the CPU model with the model Cas01 Improved. This model uses a heap to order the events, decreasing the time complexity to get the minimum next event.
384  *  \ingroup SURF_models
385  *
386  *  This function is called by surf_workstation_model_init_CLM03
387  *  so you shouldn't have to call it by yourself.
388  *
389  *  \see surf_workstation_model_init_CLM03()
390  */
391 XBT_PUBLIC(void) surf_cpu_model_init_Cas01_im(const char *filename);
392
393 /** \brief The list of all available cpu model models
394  *  \ingroup SURF_models
395  */
396 XBT_PUBLIC_DATA(s_surf_model_description_t) surf_cpu_model_description[];
397
398 XBT_PUBLIC(void) create_workstations(void);
399
400 /**\brief create new host bypass the parser
401  *
402  */
403
404
405 /** \brief The network model
406  *  \ingroup SURF_models
407  *
408  *  When creating a new API on top on SURF, you shouldn't use the
409  *  network model unless you know what you are doing. Only the workstation
410  *  model should be accessed because depending on the platform model,
411  *  the network model can be NULL.
412  */
413 XBT_PUBLIC_DATA(surf_model_t) surf_network_model;
414
415 /** \brief Same as network model 'LagrangeVelho', only with different correction factors.
416  *  \ingroup SURF_models
417  *  \param filename XML platform file name
418  *
419  * This model is proposed by Pierre-Nicolas Clauss and Martin Quinson and Stéphane Génaud
420  * based on the model 'LV08' and different correction factors depending on the communication
421  * size (< 1KiB, < 64KiB, >= 64KiB).
422  *
423  *  \see surf_workstation_model_init_SMPI()
424  */
425 XBT_PUBLIC(void) surf_network_model_init_SMPI(const char *filename);
426
427 /** \brief Initializes the platform with the network model 'LagrangeVelho'
428  *  \ingroup SURF_models
429  *  \param filename XML platform file name
430  *
431  * This model is proposed by Arnaud Legrand and Pedro Velho based on
432  * the results obtained with the GTNets simulator for onelink and
433  * dogbone sharing scenarios.
434  *
435  *  \see surf_workstation_model_init_LegrandVelho()
436  */
437 XBT_PUBLIC(void) surf_network_model_init_LegrandVelho(const char
438                                                       *filename);
439
440
441 /** \brief Initializes the platform with the network model 'LV08_im'
442  *  \ingroup SURF_models
443  *  \param filename XML platform file name
444  *
445  * This model is adds the lazy management improvement to Legrand and
446  * Velho model. This improvement essentially replaces the list of actions
447  * inside the simulation kernel by a heap in order to reduce the complexity
448  * at each iteration of the simulation kernel.
449  *
450  *  \see surf_workstation_model_init_LegrandVelho()
451  */
452 XBT_PUBLIC(void) im_surf_network_model_init_LegrandVelho(const char
453                                                       *filename);
454
455 /** \brief Initializes the platform with the network model 'Constant'
456  *  \ingroup SURF_models
457  *  \param filename XML platform file name
458  *
459  *  In this model, the communication time between two network cards is
460  *  constant, hence no need for a routing table. This is particularly
461  *  usefull when simulating huge distributed algorithms where
462  *  scalability is really an issue. This function is called in
463  *  conjunction with surf_workstation_model_init_compound.
464  *
465  *  \see surf_workstation_model_init_compound()
466  */
467 XBT_PUBLIC(void) surf_network_model_init_Constant(const char *filename);
468
469 /** \brief Initializes the platform with the network model CM02
470  *  \ingroup SURF_models
471  *  \param filename XML platform file name
472  *
473  *  This function is called by surf_workstation_model_init_CLM03
474  *  or by yourself only if you plan using surf_workstation_model_init_compound
475  *
476  *  \see surf_workstation_model_init_CLM03()
477  */
478 XBT_PUBLIC(void) surf_network_model_init_CM02(const char *filename);
479
480 /**
481  * brief initialize the the network model bypassing the XML parser
482  */
483 XBT_PUBLIC(void) surf_network_model_init_bypass(const char *id,
484                                                 double initial_bw,
485                                                 double initial_lat);
486
487 #ifdef HAVE_GTNETS
488 /** \brief Initializes the platform with the network model GTNETS
489  *  \ingroup SURF_models
490  *  \param filename XML platform file name
491  *
492  *  This function is called by surf_workstation_model_init_GTNETS
493  *  or by yourself only if you plan using surf_workstation_model_init_compound
494  *
495  *  \see surf_workstation_model_init_GTNETS()
496  */
497 XBT_PUBLIC(void) surf_network_model_init_GTNETS(const char *filename);
498 #endif
499
500 /** \brief Initializes the platform with the network model Reno
501  *  \ingroup SURF_models
502  *  \param filename XML platform file name
503  *
504  *  The problem is related to max( sum( arctan(C * Df * xi) ) ).
505  *
506  *  Reference:
507  *  [LOW03] S. H. Low. A duality model of TCP and queue management algorithms.
508  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
509  *
510  *  Call this function only if you plan using surf_workstation_model_init_compound.
511  *
512  */
513 XBT_PUBLIC(void) surf_network_model_init_Reno(const char *filename);
514
515 /** \brief Initializes the platform with the network model Reno2
516  *  \ingroup SURF_models
517  *  \param filename XML platform file name
518  *
519  *  The problem is related to max( sum( arctan(C * Df * xi) ) ).
520  *
521  *  Reference:
522  *  [LOW01] S. H. Low. A duality model of TCP and queue management algorithms.
523  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
524  *
525  *  Call this function only if you plan using surf_workstation_model_init_compound.
526  *
527  */
528 XBT_PUBLIC(void) surf_network_model_init_Reno2(const char *filename);
529
530 /** \brief Initializes the platform with the network model Vegas
531  *  \ingroup SURF_models
532  *  \param filename XML platform file name
533  *
534  *  This problem is related to max( sum( a * Df * ln(xi) ) ) which is equivalent
535  *  to the proportional fairness.
536  *
537  *  Reference:
538  *  [LOW03] S. H. Low. A duality model of TCP and queue management algorithms.
539  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
540  *
541  *  Call this function only if you plan using surf_workstation_model_init_compound.
542  *
543  */
544 XBT_PUBLIC(void) surf_network_model_init_Vegas(const char *filename);
545
546 /** \brief The list of all available network model models
547  *  \ingroup SURF_models
548  */
549 XBT_PUBLIC_DATA(s_surf_model_description_t)
550     surf_network_model_description[];
551
552
553 /** \brief The workstation model
554  *  \ingroup SURF_models
555  *
556  *  Note that when you create an API on top of SURF,
557  *  the workstation model should be the only one you use
558  *  because depending on the platform model, the network model and the CPU model
559  *  may not exist.
560  */
561 XBT_PUBLIC_DATA(surf_model_t) surf_workstation_model;
562
563 /** \brief Initializes the platform with a compound workstation model
564  *  \ingroup SURF_models
565  *  \param filename XML platform file name
566  *
567  *  This function should be called after a cpu_model and a
568  *  network_model have been set up.
569  *
570  */
571 XBT_PUBLIC(void) surf_workstation_model_init_compound(const char
572                                                       *filename);
573
574 /** \brief Initializes the platform with the workstation model CLM03
575  *  \ingroup SURF_models
576  *  \param filename XML platform file name
577  *
578  *  This platform model seperates the workstation model and the network model.
579  *  The workstation model will be initialized with the model CLM03, the network
580  *  model with the model CM02 and the CPU model with the model Cas01.
581  *  In future releases, some other network models will be implemented and will be
582  *  combined with the workstation model CLM03.
583  *
584  *  \see surf_workstation_model_init_KCCFLN05()
585  */
586 XBT_PUBLIC(void) surf_workstation_model_init_CLM03(const char *filename);
587
588 /** \brief Initializes the platform with the model KCCFLN05
589  *  \ingroup SURF_models
590  *  \param filename XML platform file name
591  *
592  *  With this model, the workstations and the network are handled
593  *  together. The network model is roughly the same as in CM02 but
594  *  interference between computations and communications can be taken
595  *  into account. This platform model is the default one for MSG and
596  *  SimDag.
597  *
598  */
599 XBT_PUBLIC(void) surf_workstation_model_init_KCCFLN05(const char
600                                                       *filename);
601
602 /** \brief Initializes the platform with the model KCCFLN05
603  *  \ingroup SURF_models
604  *  \param filename XML platform file name
605  *
606  *  With this model, only parallel tasks can be used. Resource sharing
607  *  is done by identifying bottlenecks and giving an equal share of
608  *  the model to each action.
609  *
610  */
611 XBT_PUBLIC(void) surf_workstation_model_init_ptask_L07(const char
612                                                        *filename);
613
614 /** \brief The list of all available workstation model models
615  *  \ingroup SURF_models
616  */
617 XBT_PUBLIC_DATA(s_surf_model_description_t)
618     surf_workstation_model_description[];
619
620 /** \brief List of initialized models
621  *  \ingroup SURF_models
622  */
623 XBT_PUBLIC_DATA(xbt_dynar_t) model_list;
624
625 /*******************************************/
626 /*** SURF Globals **************************/
627 /*******************************************/
628 XBT_PUBLIC_DATA(xbt_cfg_t) _surf_cfg_set;
629
630 /** \brief Initialize SURF
631  *  \ingroup SURF_simulation
632  *  \param argc argument number
633  *  \param argv arguments
634  *
635  *  This function has to be called to initialize the common
636  *  structures.  Then you will have to create the environment by
637  *  calling 
638  *  e.g. surf_workstation_model_init_CLM03() or
639  *  surf_workstation_model_init_KCCFLN05().
640  *
641  *  \see surf_workstation_model_init_CLM03(),
642  *  surf_workstation_model_init_KCCFLN05(), surf_workstation_model_init_compound(), surf_exit()
643  */
644 XBT_PUBLIC(void) surf_init(int *argc, char **argv);     /* initialize common structures */
645
646 /** \brief Initialize the used models.
647  *
648  * Must be called after the surf_init so that configuration infrastructure is created
649  * Must be called before parsing/creating the environment
650  * Must not be called within the initialization process so that the use get a chance to change the settings from
651  * its code between, say, MSG_init and MSG_create_environment using MSG_config
652  */
653 XBT_PUBLIC(void) surf_config_models_setup(const char *platform_file);
654
655 /** \brief create the elements of the models
656  *
657  * Must be called after parsing the platform file and before using any elements
658  */
659 XBT_PUBLIC(void) surf_config_models_create_elms(void);
660
661 /** \brief Finish simulation initialization
662  *  \ingroup SURF_simulation
663  *
664  *  This function must be called before the first call to surf_solve()
665  */
666 XBT_PUBLIC(void) surf_presolve(void);
667
668 /** \brief Performs a part of the simulation
669  *  \ingroup SURF_simulation
670  *  \param max_date Maximum date to update the simulation to, or -1
671  *  \return the elapsed time, or -1.0 if no event could be executed
672  *
673  *  This function execute all possible events, update the action states
674  *  and returns the time elapsed.
675  *  When you call execute or communicate on a model, the corresponding actions
676  *  are not executed immediately but only when you call surf_solve.
677  *  Note that the returned elapsed time can be zero.
678  */
679 XBT_PUBLIC(double) surf_solve(double max_date);
680
681 /** \brief Return the current time
682  *  \ingroup SURF_simulation
683  *
684  *  Return the current time in millisecond.
685  */
686 XBT_INLINE XBT_PUBLIC(double) surf_get_clock(void);
687
688 /** \brief Exit SURF
689  *  \ingroup SURF_simulation
690  *
691  *  Clean everything.
692  *
693  *  \see surf_init()
694  */
695 XBT_PUBLIC(void) surf_exit(void);
696
697 /* Prototypes of the functions that handle the properties */
698 XBT_PUBLIC_DATA(xbt_dict_t) current_property_set;       /* the prop set for the currently parsed element (also used in SIMIX) */
699 XBT_PUBLIC_DATA(void) parse_properties(const char* prop_id, const char* prop_value);
700 XBT_PUBLIC_DATA(void) parse_properties_XML(void);
701 XBT_PUBLIC_DATA(void) parse_properties_lua(const char* prop_id, const char* prop_value);
702
703 /* surf parse file related (public because called from a test suite) */
704 XBT_PUBLIC(void) parse_platform_file(const char *file);
705
706 /* Stores the sets */
707 XBT_PUBLIC_DATA(xbt_dict_t) set_list;
708
709 /* For the trace and trace:connect tag (store their content till the end of the parsing) */
710 XBT_PUBLIC_DATA(xbt_dict_t) traces_set_list;
711 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_host_avail;
712 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_power;
713 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_avail;
714 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_bandwidth;
715 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_latency;
716
717
718 XBT_PUBLIC(double) get_cpu_power(const char *power);
719
720 /*public interface to create resource bypassing the parser via cpu/network model
721  *
722  * see surfxml_parse.c
723  * */
724 XBT_PUBLIC(void) surf_host_create_resource(char *name, double power_peak,
725                                            double power_scale,
726                                            tmgr_trace_t power_trace,
727                                            int core,
728                                            e_surf_resource_state_t
729                                            state_initial,
730                                            tmgr_trace_t state_trace,
731                                            xbt_dict_t cpu_properties);
732
733 /*public interface to create resource bypassing the parser via workstation_ptask_L07 model
734  *
735  * see surfxml_parse.c
736  * */
737 XBT_PUBLIC(void) surf_wsL07_host_create_resource(char *name,
738                                                  double power_peak,
739                                                  double power_scale,
740                                                  tmgr_trace_t power_trace,
741                                                  e_surf_resource_state_t
742                                                  state_initial,
743                                                  tmgr_trace_t state_trace,
744                                                  xbt_dict_t
745                                                  cpu_properties);
746 /**
747  * create link resource
748  * see surfxml_parse.c
749  */
750 XBT_PUBLIC(void) surf_link_create_resource(char *name,
751                                            double bw_initial,
752                                            tmgr_trace_t bw_trace,
753                                            double lat_initial,
754                                            tmgr_trace_t lat_trace,
755                                            e_surf_resource_state_t
756                                            state_initial,
757                                            tmgr_trace_t state_trace,
758                                            e_surf_link_sharing_policy_t
759                                            policy, xbt_dict_t properties);
760
761
762 XBT_PUBLIC(void) surf_wsL07_link_create_resource(char *name,
763                                                  double bw_initial,
764                                                  tmgr_trace_t bw_trace,
765                                                  double lat_initial,
766                                                  tmgr_trace_t lat_trace,
767                                                  e_surf_resource_state_t
768                                                  state_initial,
769                                                  tmgr_trace_t state_trace,
770                                                  e_surf_link_sharing_policy_t
771                                                  policy,
772                                                  xbt_dict_t properties);
773 /**
774  * add route element (link_ctn) bypassing the parser
775  *
776  * see surfxml_parse.c
777  *
778  */
779 XBT_PUBLIC(void) surf_add_route_element(char *link_ctn_id);
780
781 /**
782  * set route src_id,dest_id, and create a route resource
783  *
784  * see surf_routing.c && surfxml_parse.c
785  */
786
787 XBT_PUBLIC(void) surf_set_routes(void);
788
789
790 /**
791  * add traces
792  * see surfxml_parse.c
793  */
794 XBT_PUBLIC(void) surf_add_host_traces(void);
795 XBT_PUBLIC(void) surf_add_link_traces(void);
796 XBT_PUBLIC(void) surf_wsL07_add_traces(void);
797
798 /*
799  * init AS from lua console
800  * see surf_routing.c
801  */
802 XBT_PUBLIC(void) routing_AS_init(const char *id, const char *mode);
803 XBT_PUBLIC(void) routing_AS_end(const char *id);
804 // add host to network element list
805 XBT_PUBLIC(void) routing_add_host(const char *host_id);
806 //Set a new link on the actual list of link for a route or ASroute
807 XBT_PUBLIC(void) routing_add_link(const char *link_id);
808 //Set the endpoints for a route
809 XBT_PUBLIC(void) routing_set_route(const char *src_id, const char *dst_id);
810 //Store the route
811 XBT_PUBLIC(void) routing_store_route(void);
812
813 /*
814  * interface between surf and lua bindings
815  * see surfxml_parse.c
816  */
817 XBT_PUBLIC(void) surf_AS_new(const char *id, const char *mode);
818 XBT_PUBLIC(void) surf_AS_finalize(const char *id);
819 XBT_PUBLIC(void) surf_route_add_host(const char *id);
820 XBT_PUBLIC(void) surf_routing_add_route(const char *src_id,
821                                         const char *dest_id,
822                                         xbt_dynar_t links_id);
823
824 #include "surf/surf_resource.h"
825 #include "surf/surf_resource_lmm.h"
826
827 SG_END_DECL()
828 #endif                          /* _SURF_SURF_H */