Logo AND Algorithmique Numérique Distribuée

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