Logo AND Algorithmique Numérique Distribuée

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