Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a1a2837ebde66e303216080f73d1c0ac5079b449
[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   xbt_dict_t resource_set;
301
302
303   surf_model_private_t model_private;
304
305
306   union extension {
307     s_surf_model_extension_cpu_t cpu;
308     s_surf_model_extension_network_t network;
309     s_surf_model_extension_workstation_t workstation;
310   } extension;
311 } s_surf_model_t;
312
313 surf_model_t surf_model_init(void);
314 void surf_model_exit(surf_model_t model);
315
316 void *surf_model_resource_by_name(surf_model_t model, const char *name);
317 #define surf_model_resource_set(model) (model)->resource_set
318
319 typedef struct surf_resource {
320   surf_model_t model;
321   char *name;
322   xbt_dict_t properties;
323 } s_surf_resource_t, *surf_resource_t;
324
325
326
327 /**
328  * Resource which have a metric handled by a maxmin system
329  */
330 typedef struct {
331   double scale;
332   double peak;
333   tmgr_trace_event_t event;
334 } s_surf_metric_t;
335
336 typedef struct surf_resource_lmm {
337   s_surf_resource_t generic_resource;
338   lmm_constraint_t constraint;
339   e_surf_resource_state_t state_current;
340   tmgr_trace_event_t state_event;
341   s_surf_metric_t power;
342 } s_surf_resource_lmm_t, *surf_resource_lmm_t;
343
344 /**************************************/
345 /* Implementations of model object */
346 /**************************************/
347
348
349 /** \brief The CPU model
350  *  \ingroup SURF_models
351  */
352 XBT_PUBLIC_DATA(surf_model_t) surf_cpu_model;
353
354 /** \brief Initializes the CPU model with the model Cas01
355  *  \ingroup SURF_models
356  *
357  *  This function is called by surf_workstation_model_init_CLM03
358  *  so you shouldn't have to call it by yourself.
359  *
360  *  \see surf_workstation_model_init_CLM03()
361  */
362 XBT_PUBLIC(void) surf_cpu_model_init_Cas01(const char *filename);
363
364 /** \brief Initializes the CPU model with trace integration
365  *  \ingroup SURF_models
366  *
367  */
368 XBT_PUBLIC(void) surf_cpu_model_init_ti(const char *filename);
369
370 /** \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.
371  *  \ingroup SURF_models
372  *
373  *  This function is called by surf_workstation_model_init_CLM03
374  *  so you shouldn't have to call it by yourself.
375  *
376  *  \see surf_workstation_model_init_CLM03()
377  */
378 XBT_PUBLIC(void) surf_cpu_model_init_Cas01_im(const char *filename);
379
380 /** \brief The list of all available cpu model models
381  *  \ingroup SURF_models
382  */
383 XBT_PUBLIC_DATA(s_surf_model_description_t) surf_cpu_model_description[];
384
385 XBT_PUBLIC(void) create_workstations(void);
386
387 /**\brief create new host bypass the parser
388  *
389  */
390
391
392 /** \brief The network model
393  *  \ingroup SURF_models
394  *
395  *  When creating a new API on top on SURF, you shouldn't use the
396  *  network model unless you know what you are doing. Only the workstation
397  *  model should be accessed because depending on the platform model,
398  *  the network model can be NULL.
399  */
400 XBT_PUBLIC_DATA(surf_model_t) surf_network_model;
401
402 /** \brief Same as network model 'LagrangeVelho', only with different correction factors.
403  *  \ingroup SURF_models
404  *  \param filename XML platform file name
405  *
406  * This model is proposed by Pierre-Nicolas Clauss and Martin Quinson and Stéphane Génaud
407  * based on the model 'LV08' and different correction factors depending on the communication
408  * size (< 1KiB, < 64KiB, >= 64KiB).
409  *
410  *  \see surf_workstation_model_init_SMPI()
411  */
412 XBT_PUBLIC(void) surf_network_model_init_SMPI(const char *filename);
413
414 /** \brief Initializes the platform with the network model 'LagrangeVelho'
415  *  \ingroup SURF_models
416  *  \param filename XML platform file name
417  *
418  * This model is proposed by Arnaud Legrand and Pedro Velho based on
419  * the results obtained with the GTNets simulator for onelink and
420  * dogbone sharing scenarios.
421  *
422  *  \see surf_workstation_model_init_LegrandVelho()
423  */
424 XBT_PUBLIC(void) surf_network_model_init_LegrandVelho(const char
425                                                       *filename);
426
427
428 /** \brief Initializes the platform with the network model 'LV08_im'
429  *  \ingroup SURF_models
430  *  \param filename XML platform file name
431  *
432  * This model is adds the lazy management improvement to Legrand and
433  * Velho model. This improvement essentially replaces the list of actions
434  * inside the simulation kernel by a heap in order to reduce the complexity
435  * at each iteration of the simulation kernel.
436  *
437  *  \see surf_workstation_model_init_LegrandVelho()
438  */
439 XBT_PUBLIC(void) im_surf_network_model_init_LegrandVelho(const char
440                                                       *filename);
441
442 /** \brief Initializes the platform with the network model 'Constant'
443  *  \ingroup SURF_models
444  *  \param filename XML platform file name
445  *
446  *  In this model, the communication time between two network cards is
447  *  constant, hence no need for a routing table. This is particularly
448  *  usefull when simulating huge distributed algorithms where
449  *  scalability is really an issue. This function is called in
450  *  conjunction with surf_workstation_model_init_compound.
451  *
452  *  \see surf_workstation_model_init_compound()
453  */
454 XBT_PUBLIC(void) surf_network_model_init_Constant(const char *filename);
455
456 /** \brief Initializes the platform with the network model CM02
457  *  \ingroup SURF_models
458  *  \param filename XML platform file name
459  *
460  *  This function is called by surf_workstation_model_init_CLM03
461  *  or by yourself only if you plan using surf_workstation_model_init_compound
462  *
463  *  \see surf_workstation_model_init_CLM03()
464  */
465 XBT_PUBLIC(void) surf_network_model_init_CM02(const char *filename);
466
467 /**
468  * brief initialize the the network model bypassing the XML parser
469  */
470 XBT_PUBLIC(void) surf_network_model_init_bypass(const char *id,
471                                                 double initial_bw,
472                                                 double initial_lat);
473
474 #ifdef HAVE_GTNETS
475 /** \brief Initializes the platform with the network model GTNETS
476  *  \ingroup SURF_models
477  *  \param filename XML platform file name
478  *
479  *  This function is called by surf_workstation_model_init_GTNETS
480  *  or by yourself only if you plan using surf_workstation_model_init_compound
481  *
482  *  \see surf_workstation_model_init_GTNETS()
483  */
484 XBT_PUBLIC(void) surf_network_model_init_GTNETS(const char *filename);
485 #endif
486
487 /** \brief Initializes the platform with the network model Reno
488  *  \ingroup SURF_models
489  *  \param filename XML platform file name
490  *
491  *  The problem is related to max( sum( arctan(C * Df * xi) ) ).
492  *
493  *  Reference:
494  *  [LOW03] S. H. Low. A duality model of TCP and queue management algorithms.
495  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
496  *
497  *  Call this function only if you plan using surf_workstation_model_init_compound.
498  *
499  */
500 XBT_PUBLIC(void) surf_network_model_init_Reno(const char *filename);
501
502 /** \brief Initializes the platform with the network model Reno2
503  *  \ingroup SURF_models
504  *  \param filename XML platform file name
505  *
506  *  The problem is related to max( sum( arctan(C * Df * xi) ) ).
507  *
508  *  Reference:
509  *  [LOW01] S. H. Low. A duality model of TCP and queue management algorithms.
510  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
511  *
512  *  Call this function only if you plan using surf_workstation_model_init_compound.
513  *
514  */
515 XBT_PUBLIC(void) surf_network_model_init_Reno2(const char *filename);
516
517 /** \brief Initializes the platform with the network model Vegas
518  *  \ingroup SURF_models
519  *  \param filename XML platform file name
520  *
521  *  This problem is related to max( sum( a * Df * ln(xi) ) ) which is equivalent
522  *  to the proportional fairness.
523  *
524  *  Reference:
525  *  [LOW03] S. H. Low. A duality model of TCP and queue management algorithms.
526  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
527  *
528  *  Call this function only if you plan using surf_workstation_model_init_compound.
529  *
530  */
531 XBT_PUBLIC(void) surf_network_model_init_Vegas(const char *filename);
532
533 /** \brief The list of all available network model models
534  *  \ingroup SURF_models
535  */
536 XBT_PUBLIC_DATA(s_surf_model_description_t)
537     surf_network_model_description[];
538
539
540 /** \brief The workstation model
541  *  \ingroup SURF_models
542  *
543  *  Note that when you create an API on top of SURF,
544  *  the workstation model should be the only one you use
545  *  because depending on the platform model, the network model and the CPU model
546  *  may not exist.
547  */
548 XBT_PUBLIC_DATA(surf_model_t) surf_workstation_model;
549
550 /** \brief Initializes the platform with a compound workstation model
551  *  \ingroup SURF_models
552  *  \param filename XML platform file name
553  *
554  *  This function should be called after a cpu_model and a
555  *  network_model have been set up.
556  *
557  */
558 XBT_PUBLIC(void) surf_workstation_model_init_compound(const char
559                                                       *filename);
560
561 /** \brief Initializes the platform with the workstation model CLM03
562  *  \ingroup SURF_models
563  *  \param filename XML platform file name
564  *
565  *  This platform model seperates the workstation model and the network model.
566  *  The workstation model will be initialized with the model CLM03, the network
567  *  model with the model CM02 and the CPU model with the model Cas01.
568  *  In future releases, some other network models will be implemented and will be
569  *  combined with the workstation model CLM03.
570  *
571  *  \see surf_workstation_model_init_KCCFLN05()
572  */
573 XBT_PUBLIC(void) surf_workstation_model_init_CLM03(const char *filename);
574
575 /** \brief Initializes the platform with the model KCCFLN05
576  *  \ingroup SURF_models
577  *  \param filename XML platform file name
578  *
579  *  With this model, the workstations and the network are handled
580  *  together. The network model is roughly the same as in CM02 but
581  *  interference between computations and communications can be taken
582  *  into account. This platform model is the default one for MSG and
583  *  SimDag.
584  *
585  */
586 XBT_PUBLIC(void) surf_workstation_model_init_KCCFLN05(const char
587                                                       *filename);
588
589 /** \brief Initializes the platform with the model KCCFLN05
590  *  \ingroup SURF_models
591  *  \param filename XML platform file name
592  *
593  *  With this model, only parallel tasks can be used. Resource sharing
594  *  is done by identifying bottlenecks and giving an equal share of
595  *  the model to each action.
596  *
597  */
598 XBT_PUBLIC(void) surf_workstation_model_init_ptask_L07(const char
599                                                        *filename);
600
601 /** \brief The list of all available workstation model models
602  *  \ingroup SURF_models
603  */
604 XBT_PUBLIC_DATA(s_surf_model_description_t)
605     surf_workstation_model_description[];
606
607 /** \brief List of initialized models
608  *  \ingroup SURF_models
609  */
610 XBT_PUBLIC_DATA(xbt_dynar_t) model_list;
611
612 /*******************************************/
613 /*** SURF Globals **************************/
614 /*******************************************/
615 XBT_PUBLIC_DATA(xbt_cfg_t) _surf_cfg_set;
616
617 /** \brief Initialize SURF
618  *  \ingroup SURF_simulation
619  *  \param argc argument number
620  *  \param argv arguments
621  *
622  *  This function has to be called to initialize the common
623  *  structures.  Then you will have to create the environment by
624  *  calling 
625  *  e.g. surf_workstation_model_init_CLM03() or
626  *  surf_workstation_model_init_KCCFLN05().
627  *
628  *  \see surf_workstation_model_init_CLM03(),
629  *  surf_workstation_model_init_KCCFLN05(), surf_workstation_model_init_compound(), surf_exit()
630  */
631 XBT_PUBLIC(void) surf_init(int *argc, char **argv);     /* initialize common structures */
632
633 /** \brief Initialize the used models.
634  *
635  * Must be called after the surf_init so that configuration infrastructure is created
636  * Must be called before parsing/creating the environment
637  * Must not be called within the initialization process so that the use get a chance to change the settings from
638  * its code between, say, MSG_init and MSG_create_environment using MSG_config
639  */
640 XBT_PUBLIC(void) surf_config_models_setup(const char *platform_file);
641
642 /** \brief create the elements of the models
643  *
644  * Must be called after parsing the platform file and before using any elements
645  */
646 XBT_PUBLIC(void) surf_config_models_create_elms(void);
647
648 /** \brief Finish simulation initialization
649  *  \ingroup SURF_simulation
650  *
651  *  This function must be called before the first call to surf_solve()
652  */
653 XBT_PUBLIC(void) surf_presolve(void);
654
655 /** \brief Performs a part of the simulation
656  *  \ingroup SURF_simulation
657  *  \param max_date Maximum date to update the simulation to, or -1
658  *  \return the elapsed time, or -1.0 if no event could be executed
659  *
660  *  This function execute all possible events, update the action states
661  *  and returns the time elapsed.
662  *  When you call execute or communicate on a model, the corresponding actions
663  *  are not executed immediately but only when you call surf_solve.
664  *  Note that the returned elapsed time can be zero.
665  */
666 XBT_PUBLIC(double) surf_solve(double max_date);
667
668 /** \brief Return the current time
669  *  \ingroup SURF_simulation
670  *
671  *  Return the current time in millisecond.
672  */
673 XBT_INLINE XBT_PUBLIC(double) surf_get_clock(void);
674
675 /** \brief Exit SURF
676  *  \ingroup SURF_simulation
677  *
678  *  Clean everything.
679  *
680  *  \see surf_init()
681  */
682 XBT_PUBLIC(void) surf_exit(void);
683
684 /* Prototypes of the functions that handle the properties */
685 XBT_PUBLIC_DATA(xbt_dict_t) current_property_set;       /* the prop set for the currently parsed element (also used in SIMIX) */
686 XBT_PUBLIC_DATA(void) parse_properties(void);
687
688 /* surf parse file related (public because called from a test suite) */
689 XBT_PUBLIC(void) parse_platform_file(const char *file);
690
691 /* Stores the sets */
692 XBT_PUBLIC_DATA(xbt_dict_t) set_list;
693
694 /* For the trace and trace:connect tag (store their content till the end of the parsing) */
695 XBT_PUBLIC_DATA(xbt_dict_t) traces_set_list;
696 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_host_avail;
697 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_power;
698 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_avail;
699 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_bandwidth;
700 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_latency;
701
702
703 XBT_PUBLIC(double) get_cpu_power(const char *power);
704
705 /*public interface to create resource bypassing the parser via cpu/network model
706  *
707  * see surfxml_parse.c
708  * */
709 XBT_PUBLIC(void) surf_host_create_resource(char *name, double power_peak,
710                                            double power_scale,
711                                            tmgr_trace_t power_trace,
712                                            int core,
713                                            e_surf_resource_state_t
714                                            state_initial,
715                                            tmgr_trace_t state_trace,
716                                            xbt_dict_t cpu_properties);
717
718 /*public interface to create resource bypassing the parser via workstation_ptask_L07 model
719  *
720  * see surfxml_parse.c
721  * */
722 XBT_PUBLIC(void) surf_wsL07_host_create_resource(char *name,
723                                                  double power_peak,
724                                                  double power_scale,
725                                                  tmgr_trace_t power_trace,
726                                                  e_surf_resource_state_t
727                                                  state_initial,
728                                                  tmgr_trace_t state_trace,
729                                                  xbt_dict_t
730                                                  cpu_properties);
731 /**
732  * create link resource
733  * see surfxml_parse.c
734  */
735 XBT_PUBLIC(void) surf_link_create_resource(char *name,
736                                            double bw_initial,
737                                            tmgr_trace_t bw_trace,
738                                            double lat_initial,
739                                            tmgr_trace_t lat_trace,
740                                            e_surf_resource_state_t
741                                            state_initial,
742                                            tmgr_trace_t state_trace,
743                                            e_surf_link_sharing_policy_t
744                                            policy, xbt_dict_t properties);
745
746
747 XBT_PUBLIC(void) surf_wsL07_link_create_resource(char *name,
748                                                  double bw_initial,
749                                                  tmgr_trace_t bw_trace,
750                                                  double lat_initial,
751                                                  tmgr_trace_t lat_trace,
752                                                  e_surf_resource_state_t
753                                                  state_initial,
754                                                  tmgr_trace_t state_trace,
755                                                  e_surf_link_sharing_policy_t
756                                                  policy,
757                                                  xbt_dict_t properties);
758 /**
759  * add route element (link_ctn) bypassing the parser
760  *
761  * see surfxml_parse.c
762  *
763  */
764 XBT_PUBLIC(void) surf_add_route_element(char *link_ctn_id);
765
766 /**
767  * set route src_id,dest_id, and create a route resource
768  *
769  * see surf_routing.c && surfxml_parse.c
770  */
771
772 XBT_PUBLIC(void) surf_set_routes(void);
773
774
775 /**
776  * add traces
777  * see surfxml_parse.c
778  */
779 XBT_PUBLIC(void) surf_add_host_traces(void);
780 XBT_PUBLIC(void) surf_add_link_traces(void);
781 XBT_PUBLIC(void) surf_wsL07_add_traces(void);
782
783 /*
784  * init AS from lua console
785  * see surf_routing.c
786  */
787 XBT_PUBLIC(void) routing_AS_init(const char *id, const char *mode);
788 XBT_PUBLIC(void) routing_AS_end(const char *id);
789 // add host to network element list
790 XBT_PUBLIC(void) routing_add_host(const char *host_id);
791 //Set a new link on the actual list of link for a route or ASroute
792 XBT_PUBLIC(void) routing_add_link(const char *link_id);
793 //Set the endpoints for a route
794 XBT_PUBLIC(void) routing_set_route(const char *src_id, const char *dst_id);
795 //Store the route
796 XBT_PUBLIC(void) routing_store_route(void);
797
798 /*
799  * interface between surf and lua bindings
800  * see surfxml_parse.c
801  */
802 XBT_PUBLIC(void) surf_AS_new(const char *id, const char *mode);
803 XBT_PUBLIC(void) surf_AS_finalize(const char *id);
804 XBT_PUBLIC(void) surf_route_add_host(const char *id);
805 XBT_PUBLIC(void) surf_routing_add_route(const char *src_id,
806                                         const char *dest_id,
807                                         xbt_dynar_t links_id);
808
809 #include "surf/surf_resource.h"
810 #include "surf/surf_resource_lmm.h"
811
812 SG_END_DECL()
813 #endif                          /* _SURF_SURF_H */