Logo AND Algorithmique Numérique Distribuée

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