Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Put ns3 sources in place.
[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 #ifdef HAVE_NS3
501 /** \brief Initializes the platform with the network model NS3
502  *  \ingroup SURF_models
503  *  \param filename XML platform file name
504  *
505  *  This function is called by surf_workstation_model_init_NS3
506  *  or by yourself only if you plan using surf_workstation_model_init_compound
507  *
508  *  \see surf_workstation_model_init_NS3()
509  */
510 XBT_PUBLIC(void) surf_network_model_init_NS3(const char *filename);
511
512 XBT_PUBLIC(void) parse_ns3_add_host(void);
513 XBT_PUBLIC(void) parse_ns3_add_router(void);
514 XBT_PUBLIC(void) parse_ns3_add_link(void);
515 XBT_PUBLIC(void) parse_ns3_add_AS(void);
516 XBT_PUBLIC(void) parse_ns3_add_route(void);
517 XBT_PUBLIC(void) parse_ns3_add_ASroute(void);
518 XBT_PUBLIC(void) parse_ns3_add_cluster(void);
519
520 #endif
521
522 /** \brief Initializes the platform with the network model Reno
523  *  \ingroup SURF_models
524  *  \param filename XML platform file name
525  *
526  *  The problem is related to max( sum( arctan(C * Df * xi) ) ).
527  *
528  *  Reference:
529  *  [LOW03] S. H. Low. A duality model of TCP and queue management algorithms.
530  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
531  *
532  *  Call this function only if you plan using surf_workstation_model_init_compound.
533  *
534  */
535 XBT_PUBLIC(void) surf_network_model_init_Reno(const char *filename);
536
537 /** \brief Initializes the platform with the network model Reno2
538  *  \ingroup SURF_models
539  *  \param filename XML platform file name
540  *
541  *  The problem is related to max( sum( arctan(C * Df * xi) ) ).
542  *
543  *  Reference:
544  *  [LOW01] S. H. Low. A duality model of TCP and queue management algorithms.
545  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
546  *
547  *  Call this function only if you plan using surf_workstation_model_init_compound.
548  *
549  */
550 XBT_PUBLIC(void) surf_network_model_init_Reno2(const char *filename);
551
552 /** \brief Initializes the platform with the network model Vegas
553  *  \ingroup SURF_models
554  *  \param filename XML platform file name
555  *
556  *  This problem is related to max( sum( a * Df * ln(xi) ) ) which is equivalent
557  *  to the proportional fairness.
558  *
559  *  Reference:
560  *  [LOW03] S. H. Low. A duality model of TCP and queue management algorithms.
561  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
562  *
563  *  Call this function only if you plan using surf_workstation_model_init_compound.
564  *
565  */
566 XBT_PUBLIC(void) surf_network_model_init_Vegas(const char *filename);
567
568 /** \brief The list of all available network model models
569  *  \ingroup SURF_models
570  */
571 XBT_PUBLIC_DATA(s_surf_model_description_t)
572     surf_network_model_description[];
573
574
575 /** \brief The workstation model
576  *  \ingroup SURF_models
577  *
578  *  Note that when you create an API on top of SURF,
579  *  the workstation model should be the only one you use
580  *  because depending on the platform model, the network model and the CPU model
581  *  may not exist.
582  */
583 XBT_PUBLIC_DATA(surf_model_t) surf_workstation_model;
584
585 /** \brief Initializes the platform with a compound workstation model
586  *  \ingroup SURF_models
587  *  \param filename XML platform file name
588  *
589  *  This function should be called after a cpu_model and a
590  *  network_model have been set up.
591  *
592  */
593 XBT_PUBLIC(void) surf_workstation_model_init_compound(const char
594                                                       *filename);
595
596 /** \brief Initializes the platform with the workstation model CLM03
597  *  \ingroup SURF_models
598  *  \param filename XML platform file name
599  *
600  *  This platform model seperates the workstation model and the network model.
601  *  The workstation model will be initialized with the model CLM03, the network
602  *  model with the model CM02 and the CPU model with the model Cas01.
603  *  In future releases, some other network models will be implemented and will be
604  *  combined with the workstation model CLM03.
605  *
606  *  \see surf_workstation_model_init_KCCFLN05()
607  */
608 XBT_PUBLIC(void) surf_workstation_model_init_CLM03(const char *filename);
609
610 /** \brief Initializes the platform with the model KCCFLN05
611  *  \ingroup SURF_models
612  *  \param filename XML platform file name
613  *
614  *  With this model, the workstations and the network are handled
615  *  together. The network model is roughly the same as in CM02 but
616  *  interference between computations and communications can be taken
617  *  into account. This platform model is the default one for MSG and
618  *  SimDag.
619  *
620  */
621 XBT_PUBLIC(void) surf_workstation_model_init_KCCFLN05(const char
622                                                       *filename);
623
624 /** \brief Initializes the platform with the model KCCFLN05
625  *  \ingroup SURF_models
626  *  \param filename XML platform file name
627  *
628  *  With this model, only parallel tasks can be used. Resource sharing
629  *  is done by identifying bottlenecks and giving an equal share of
630  *  the model to each action.
631  *
632  */
633 XBT_PUBLIC(void) surf_workstation_model_init_ptask_L07(const char
634                                                        *filename);
635
636 /** \brief The list of all available workstation model models
637  *  \ingroup SURF_models
638  */
639 XBT_PUBLIC_DATA(s_surf_model_description_t)
640     surf_workstation_model_description[];
641
642 /** \brief List of initialized models
643  *  \ingroup SURF_models
644  */
645 XBT_PUBLIC_DATA(xbt_dynar_t) model_list;
646
647 /*******************************************/
648 /*** SURF Globals **************************/
649 /*******************************************/
650 XBT_PUBLIC_DATA(xbt_cfg_t) _surf_cfg_set;
651
652 /** \brief Initialize SURF
653  *  \ingroup SURF_simulation
654  *  \param argc argument number
655  *  \param argv arguments
656  *
657  *  This function has to be called to initialize the common
658  *  structures.  Then you will have to create the environment by
659  *  calling 
660  *  e.g. surf_workstation_model_init_CLM03() or
661  *  surf_workstation_model_init_KCCFLN05().
662  *
663  *  \see surf_workstation_model_init_CLM03(),
664  *  surf_workstation_model_init_KCCFLN05(), surf_workstation_model_init_compound(), surf_exit()
665  */
666 XBT_PUBLIC(void) surf_init(int *argc, char **argv);     /* initialize common structures */
667
668 /** \brief Initialize the used models.
669  *
670  * Must be called after the surf_init so that configuration infrastructure is created
671  * Must be called before parsing/creating the environment
672  * Must not be called within the initialization process so that the use get a chance to change the settings from
673  * its code between, say, MSG_init and MSG_create_environment using MSG_config
674  */
675 XBT_PUBLIC(void) surf_config_models_setup(const char *platform_file);
676
677 /** \brief create the elements of the models
678  *
679  * Must be called after parsing the platform file and before using any elements
680  */
681 XBT_PUBLIC(void) surf_config_models_create_elms(void);
682
683 /** \brief Finish simulation initialization
684  *  \ingroup SURF_simulation
685  *
686  *  This function must be called before the first call to surf_solve()
687  */
688 XBT_PUBLIC(void) surf_presolve(void);
689
690 /** \brief Performs a part of the simulation
691  *  \ingroup SURF_simulation
692  *  \param max_date Maximum date to update the simulation to, or -1
693  *  \return the elapsed time, or -1.0 if no event could be executed
694  *
695  *  This function execute all possible events, update the action states
696  *  and returns the time elapsed.
697  *  When you call execute or communicate on a model, the corresponding actions
698  *  are not executed immediately but only when you call surf_solve.
699  *  Note that the returned elapsed time can be zero.
700  */
701 XBT_PUBLIC(double) surf_solve(double max_date);
702
703 /** \brief Return the current time
704  *  \ingroup SURF_simulation
705  *
706  *  Return the current time in millisecond.
707  */
708 XBT_INLINE XBT_PUBLIC(double) surf_get_clock(void);
709
710 /** \brief Exit SURF
711  *  \ingroup SURF_simulation
712  *
713  *  Clean everything.
714  *
715  *  \see surf_init()
716  */
717 XBT_PUBLIC(void) surf_exit(void);
718
719 /* Prototypes of the functions that handle the properties */
720 XBT_PUBLIC_DATA(xbt_dict_t) current_property_set;       /* the prop set for the currently parsed element (also used in SIMIX) */
721 XBT_PUBLIC_DATA(void) parse_properties(const char* prop_id, const char* prop_value);
722 XBT_PUBLIC_DATA(void) parse_properties_XML(void);
723 XBT_PUBLIC_DATA(void) parse_properties_lua(const char* prop_id, const char* prop_value);
724
725 /* surf parse file related (public because called from a test suite) */
726 XBT_PUBLIC(void) parse_platform_file(const char *file);
727
728 /* Stores the sets */
729 XBT_PUBLIC_DATA(xbt_dict_t) set_list;
730
731 /* For the trace and trace:connect tag (store their content till the end of the parsing) */
732 XBT_PUBLIC_DATA(xbt_dict_t) traces_set_list;
733 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_host_avail;
734 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_power;
735 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_avail;
736 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_bandwidth;
737 XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_latency;
738
739
740 XBT_PUBLIC(double) get_cpu_power(const char *power);
741
742 /*public interface to create resource bypassing the parser via cpu/network model
743  *
744  * see surfxml_parse.c
745  * */
746 XBT_PUBLIC(void) surf_host_create_resource(char *name, double power_peak,
747                                            double power_scale,
748                                            tmgr_trace_t power_trace,
749                                            int core,
750                                            e_surf_resource_state_t
751                                            state_initial,
752                                            tmgr_trace_t state_trace,
753                                            xbt_dict_t cpu_properties);
754
755 /*public interface to create resource bypassing the parser via workstation_ptask_L07 model
756  *
757  * see surfxml_parse.c
758  * */
759 XBT_PUBLIC(void) surf_wsL07_host_create_resource(char *name,
760                                                  double power_peak,
761                                                  double power_scale,
762                                                  tmgr_trace_t power_trace,
763                                                  e_surf_resource_state_t
764                                                  state_initial,
765                                                  tmgr_trace_t state_trace,
766                                                  xbt_dict_t
767                                                  cpu_properties);
768 /**
769  * create link resource
770  * see surfxml_parse.c
771  */
772 XBT_PUBLIC(void) surf_link_create_resource(char *name,
773                                            double bw_initial,
774                                            tmgr_trace_t bw_trace,
775                                            double lat_initial,
776                                            tmgr_trace_t lat_trace,
777                                            e_surf_resource_state_t
778                                            state_initial,
779                                            tmgr_trace_t state_trace,
780                                            e_surf_link_sharing_policy_t
781                                            policy, xbt_dict_t properties);
782
783
784 XBT_PUBLIC(void) surf_wsL07_link_create_resource(char *name,
785                                                  double bw_initial,
786                                                  tmgr_trace_t bw_trace,
787                                                  double lat_initial,
788                                                  tmgr_trace_t lat_trace,
789                                                  e_surf_resource_state_t
790                                                  state_initial,
791                                                  tmgr_trace_t state_trace,
792                                                  e_surf_link_sharing_policy_t
793                                                  policy,
794                                                  xbt_dict_t properties);
795 /**
796  * add route element (link_ctn) bypassing the parser
797  *
798  * see surfxml_parse.c
799  *
800  */
801 XBT_PUBLIC(void) surf_add_route_element(char *link_ctn_id);
802
803 /**
804  * set route src_id,dest_id, and create a route resource
805  *
806  * see surf_routing.c && surfxml_parse.c
807  */
808
809 XBT_PUBLIC(void) surf_set_routes(void);
810
811
812 /**
813  * add traces
814  * see surfxml_parse.c
815  */
816 XBT_PUBLIC(void) surf_add_host_traces(void);
817 XBT_PUBLIC(void) surf_add_link_traces(void);
818 XBT_PUBLIC(void) surf_wsL07_add_traces(void);
819
820 /*
821  * init AS from lua console
822  * see surf_routing.c
823  */
824 XBT_PUBLIC(void) routing_AS_init(const char *id, const char *mode);
825 XBT_PUBLIC(void) routing_AS_end(const char *id);
826 // add host to network element list
827 XBT_PUBLIC(void) routing_add_host(const char *host_id);
828 //Set a new link on the actual list of link for a route or ASroute
829 XBT_PUBLIC(void) routing_add_link(const char *link_id);
830 //Set the endpoints for a route
831 XBT_PUBLIC(void) routing_set_route(const char *src_id, const char *dst_id);
832 //Store the route
833 XBT_PUBLIC(void) routing_store_route(void);
834
835 /*
836  * interface between surf and lua bindings
837  * see surfxml_parse.c
838  */
839 XBT_PUBLIC(void) surf_AS_new(const char *id, const char *mode);
840 XBT_PUBLIC(void) surf_AS_finalize(const char *id);
841 XBT_PUBLIC(void) surf_route_add_host(const char *id);
842 XBT_PUBLIC(void) surf_routing_add_route(const char *src_id,
843                                         const char *dest_id,
844                                         xbt_dynar_t links_id);
845
846 #include "surf/surf_resource.h"
847 #include "surf/surf_resource_lmm.h"
848
849 SG_END_DECL()
850 #endif                          /* _SURF_SURF_H */