Logo AND Algorithmique Numérique Distribuée

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