Logo AND Algorithmique Numérique Distribuée

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