Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill some unused or dupplicated functions
[simgrid.git] / src / include / surf / surf.h
1 /* Copyright (c) 2004-2015. 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/graph.h"
14 #include "xbt/misc.h"
15 #include "xbt/config.h"
16 #include "src/portable.h"
17 #include "surf/surf_routing.h"
18 #include "surf/datatypes.h"
19 #include "xbt/lib.h"
20 #include "surf/surf_routing.h"
21 #include "simgrid/platf_interface.h"
22 #include "simgrid/datatypes.h"
23 #include "simgrid/forward.h"
24
25 SG_BEGIN_DECL()
26 /* Actions and models are highly connected structures... */
27
28 /* user-visible parameters */
29 extern XBT_PRIVATE double sg_tcp_gamma;
30 extern XBT_PRIVATE double sg_sender_gap;
31 extern XBT_PRIVATE double sg_latency_factor;
32 extern XBT_PRIVATE double sg_bandwidth_factor;
33 extern XBT_PRIVATE double sg_weight_S_parameter;
34 extern XBT_PRIVATE int sg_network_crosstraffic;
35 extern XBT_PRIVATE xbt_dynar_t surf_path;
36
37 typedef enum {
38   SURF_NETWORK_ELEMENT_HOST=1,     /* host type */
39   SURF_NETWORK_ELEMENT_ROUTER,   /* router type */
40   SURF_NETWORK_ELEMENT_AS        /* AS type */
41 } e_surf_network_element_type_t;
42
43 #ifdef __cplusplus
44
45 namespace simgrid {
46 namespace surf {
47
48 class Model;
49 class CpuModel;
50 class HostModel;
51 class VMModel;
52 class NetworkModel;
53 class StorageModel;
54 class Resource;
55 class ResourceLmm;
56 class Host;
57 class HostCLM03;
58 class NetworkCm02Link;
59 class Action;
60 class ActionLmm;
61 class StorageActionLmm;
62 class As;
63 class RoutingPlatf;
64
65 }
66 }
67
68 typedef simgrid::surf::Model surf_Model;
69 typedef simgrid::surf::CpuModel surf_CpuModel;
70 typedef simgrid::surf::HostModel surf_HostModel;
71 typedef simgrid::surf::VMModel surf_VMModel;
72 typedef simgrid::surf::NetworkModel surf_NetworkModel;
73 typedef simgrid::surf::StorageModel surf_StorageModel;
74 typedef simgrid::surf::Resource surf_Resource;
75 typedef simgrid::surf::ResourceLmm surf_ResourceLmm;
76 typedef simgrid::surf::Host surf_Host;
77 typedef simgrid::surf::HostCLM03 surf_HostCLM03;
78 typedef simgrid::surf::NetworkCm02Link surf_NetworkCm02Link;
79 typedef simgrid::surf::Action surf_Action;
80 typedef simgrid::surf::ActionLmm surf_ActionLmm;
81 typedef simgrid::surf::StorageActionLmm surf_StorageActionLmm;
82 typedef simgrid::surf::RoutingPlatf surf_RoutingPlatf;
83
84 #else
85
86 typedef struct surf_Model surf_Model;
87 typedef struct surf_CpuModel surf_CpuModel;
88 typedef struct surf_HostModel surf_HostModel;
89 typedef struct surf_VMModel surf_VMModel;
90 typedef struct surf_NetworkModel surf_NetworkModel;
91 typedef struct surf_StorageModel surf_StorageModel;
92 typedef struct surf_Resource surf_Resource;
93 typedef struct surf_ResourceLmm surf_ResourceLmm;
94 typedef struct surf_HostCLM03 surf_HostCLM03;
95 typedef struct surf_Host surf_Host;
96 typedef struct surf_NetworkCm02Link surf_NetworkCm02Link;
97 typedef struct surf_Action surf_Action;
98 typedef struct surf_ActionLmm surf_ActionLmm;
99 typedef struct surf_StorageActionLmm surf_StorageActionLmm;
100 typedef struct surf_RoutingPlatf surf_RoutingPlatf;
101
102 #endif
103
104 /** @ingroup SURF_c_bindings
105  *  \brief Model datatype
106  *
107  *  Generic data structure for a model. The hosts,
108  *  the CPUs and the network links are examples of models.
109  */
110 typedef surf_Model *surf_model_t;
111 typedef surf_CpuModel *surf_cpu_model_t;
112 typedef surf_HostModel *surf_host_model_t;
113 typedef surf_VMModel *surf_vm_model_t;
114 typedef surf_NetworkModel *surf_network_model_t;
115 typedef surf_StorageModel *surf_storage_model_t;
116
117 typedef xbt_dictelm_t surf_resource_t;
118 typedef surf_Resource *surf_cpp_resource_t;
119 typedef surf_Host *surf_host_t;
120 typedef surf_Cpu *surf_cpu_t;
121
122 /** @ingroup SURF_c_bindings
123  *  \brief Action structure
124  *
125  *  Never create s_surf_action_t by yourself ! The actions are created
126  *  on the fly when you call execute or communicate on a model.
127  *
128  *  \see e_surf_action_state_t
129  */
130 typedef surf_Action *surf_action_t;
131 typedef surf_RoutingPlatf *routing_platf_t;
132
133 typedef struct surf_file *surf_file_t;
134
135 /** @Brief Specify that we use that action */
136 XBT_PUBLIC(void) surf_action_ref(surf_action_t action);
137
138 /** @brief Creates a new action.
139  *
140  * @param size The size is the one of the subtype you want to create
141  * @param cost initial value
142  * @param model to which model we should attach this action
143  * @param failed whether we should start this action in failed mode
144  */
145 XBT_PUBLIC(void *) surf_action_new(size_t size, double cost,
146                                    surf_model_t model, int failed);
147
148 /** \brief Resource model description
149  */
150 typedef struct surf_model_description {
151   const char *name;
152   const char *description;
153   void_f_void_t model_init_preparse;
154 } s_surf_model_description_t, *surf_model_description_t;
155
156 XBT_PUBLIC(int) find_model_description(s_surf_model_description_t * table,
157                                        const char *name);
158 XBT_PUBLIC(void) model_help(const char *category,
159                             s_surf_model_description_t * table);
160
161 /** @ingroup SURF_interface
162  *  @brief Action states
163  *
164  *  @see Action
165  */
166 typedef enum {
167   SURF_ACTION_READY = 0,        /**< Ready        */
168   SURF_ACTION_RUNNING,          /**< Running      */
169   SURF_ACTION_FAILED,           /**< Task Failure */
170   SURF_ACTION_DONE,             /**< Completed    */
171   SURF_ACTION_TO_FREE,          /**< Action to free in next cleanup */
172   SURF_ACTION_NOT_IN_THE_SYSTEM /**< Not in the system anymore. Why did you ask ? */
173 } e_surf_action_state_t;
174
175 /** @ingroup SURF_vm_interface
176  *
177  *
178  */
179 /* FIXME: Where should the VM state be defined? */
180 typedef enum {
181   SURF_VM_STATE_CREATED, /**< created, but not yet started */
182   SURF_VM_STATE_RUNNING,
183   SURF_VM_STATE_SUSPENDED, /**< Suspend/resume does not involve disk I/O, so we assume there is no transition states. */
184
185   SURF_VM_STATE_SAVING, /**< Save/restore involves disk I/O, so there should be transition states. */
186   SURF_VM_STATE_SAVED,
187   SURF_VM_STATE_RESTORING,
188 } e_surf_vm_state_t;
189
190 /***************************/
191 /* Generic model object */
192 /***************************/
193
194 XBT_PUBLIC_DATA(routing_platf_t) routing_platf;
195
196 static inline void *surf_storage_resource_priv(const void *storage){
197   return (void*)xbt_lib_get_level((xbt_dictelm_t)storage, SURF_STORAGE_LEVEL);
198 }
199
200 static inline void *surf_storage_resource_by_name(const char *name){
201   return xbt_lib_get_elm_or_null(storage_lib, name);
202 }
203
204 /** @{ @ingroup SURF_c_bindings */
205
206 /**
207  * @brief Pop an action from the done actions set
208  *
209  * @param model The model from which the action is extracted
210  * @return An action in done state
211  */
212 XBT_PUBLIC(surf_action_t) surf_model_extract_done_action_set(surf_model_t model);
213
214 /**
215  * @brief Pop an action from the failed actions set
216  *
217  * @param model The model from which the action is extracted
218  * @return An action in failed state
219  */
220 XBT_PUBLIC(surf_action_t) surf_model_extract_failed_action_set(surf_model_t model);
221
222 /**
223  * @brief Get the size of the running action set of a model
224  *
225  * @param model The model
226  * @return The size of the running action set
227  */
228 XBT_PUBLIC(int) surf_model_running_action_set_size(surf_model_t model);
229
230 /** @brief Get the route (dynar of sg_link_t) between two hosts */
231 XBT_PUBLIC(xbt_dynar_t) surf_host_model_get_route(
232   surf_host_model_t model, sg_host_t src, sg_host_t dst);
233
234 /** @brief Create a new VM on the specified host */
235 XBT_PUBLIC(void) surf_vm_model_create(const char *name, sg_host_t host_PM);
236
237 /** @brief Create a communication between two hosts
238  *
239  * @param model The model which handle the communication
240  * @param src The source host
241  * @param dst The destination host
242  * @param size The amount of data (in bytes) needed to transfer
243  * @param rate [description]
244  * @return The action corresponding to the communication
245  */
246 XBT_PUBLIC(surf_action_t) surf_network_model_communicate(surf_network_model_t model, sg_host_t src, sg_host_t dst, double size, double rate);
247
248 /**
249  * @brief Get the name of a surf resource (cpu, host, network, …)
250  *
251  * @param resource The surf resource
252  * @return The name of the surf resource
253  */
254 XBT_PUBLIC(const char * ) surf_resource_name(surf_cpp_resource_t resource);
255 static inline const char * surf_cpu_name(surf_cpu_t cpu) {
256   return surf_resource_name((surf_cpp_resource_t)cpu);
257 }
258
259 /** @brief Get the available speed of cpu associated to a host */
260 XBT_PUBLIC(double) surf_host_get_available_speed(sg_host_t host);
261
262 /** @brief Create a sleep action on the given host */
263 XBT_PUBLIC(surf_action_t) surf_host_sleep(sg_host_t host, double duration);
264
265 /** @brief Create a file opening action on the given host */
266 XBT_PUBLIC(surf_action_t) surf_host_open(sg_host_t host, const char* fullpath);
267
268 /** @brief Create a file closing action on the given host */
269 XBT_PUBLIC(surf_action_t) surf_host_close(sg_host_t host, surf_file_t fd);
270
271 /** @brief Create a file reading action on the given host */
272 XBT_PUBLIC(surf_action_t) surf_host_read(sg_host_t host, surf_file_t fd, sg_size_t size);
273
274 /** @brief Create a file writing action on the given host  */
275 XBT_PUBLIC(surf_action_t) surf_host_write(sg_host_t host, surf_file_t fd, sg_size_t size);
276
277 /**
278  * @brief Get the informations of a file descriptor
279  * @details The returned xbt_dynar_t contains:
280  *  - the size of the file,
281  *  - the mount point,
282  *  - the storage name,
283  *  - the storage typeId,
284  *  - the storage content type
285  *
286  * @param host The surf host
287  * @param fd The file descriptor
288  * @return An xbt_dynar_t with the file informations
289  */
290 XBT_PUBLIC(xbt_dynar_t) surf_host_get_info(sg_host_t host, surf_file_t fd);
291
292 /**
293  * @brief Get the available space of the storage at the mount point
294  *
295  * @param resource The surf host
296  * @param name The mount point
297  * @return The amount of available space in bytes
298  */
299 XBT_PUBLIC(sg_size_t) surf_host_get_free_size(sg_host_t resource, const char* name);
300
301 /**
302  * @brief Get the used space of the storage at the mount point
303  *
304  * @param resource The surf host
305  * @param name The mount point
306  * @return The amount of used space in bytes
307  */
308 XBT_PUBLIC(sg_size_t) surf_host_get_used_size(sg_host_t resource, const char* name);
309
310 /** @brief Get the list of VMs hosted on the host */
311 XBT_PUBLIC(xbt_dynar_t) surf_host_get_vms(sg_host_t resource);
312
313 /** @brief Retrieve the params of that VM
314  * @details You can use fields ramsize and overcommit on a PM, too.
315  */
316 XBT_PUBLIC(void) surf_host_get_params(sg_host_t resource, vm_params_t params);
317
318 /** @brief Sets the params of that VM/PM
319  * @details You can use fields ramsize and overcommit on a PM, too.
320  */
321 XBT_PUBLIC(void) surf_host_set_params(sg_host_t resource, vm_params_t params);
322
323 /**
324  * @brief Destroy a VM
325  *
326  * @param resource The surf vm
327  */
328 XBT_PUBLIC(void) surf_vm_destroy(sg_host_t resource);
329
330 /** @brief Suspend a VM */
331 XBT_PUBLIC(void) surf_vm_suspend(sg_host_t resource);
332
333 /** @brief Resume a VM */
334 XBT_PUBLIC(void) surf_vm_resume(sg_host_t resource);
335
336 /**
337  * @brief Save the VM (Not yet implemented)
338  *
339  * @param resource The surf vm
340  */
341 XBT_PUBLIC(void) surf_vm_save(sg_host_t resource);
342
343 /**
344  * @brief Restore the VM (Not yet implemented)
345  *
346  * @param resource The surf vm
347  */
348 XBT_PUBLIC(void) surf_vm_restore(sg_host_t resource);
349
350 /**
351  * @brief Migrate the VM to the destination host
352  *
353  * @param resource The surf vm
354  * @param ind_vm_ws_dest The destination host
355  */
356 XBT_PUBLIC(void) surf_vm_migrate(sg_host_t resource, sg_host_t ind_vm_ws_dest);
357
358 /**
359  * @brief Get the physical machine hosting the VM
360  *
361  * @param resource The surf vm
362  * @return The physical machine hosting the VM
363  */
364 XBT_PUBLIC(sg_host_t) surf_vm_get_pm(sg_host_t resource);
365
366 /**
367  * @brief [brief description]
368  * @details [long description]
369  *
370  * @param resource [description]
371  * @param bound [description]
372  */
373 XBT_PUBLIC(void) surf_vm_set_bound(sg_host_t resource, double bound);
374
375 /**
376  * @brief [brief description]
377  * @details [long description]
378  *
379  * @param resource [description]
380  * @param cpu [description]
381  * @param mask [description]
382  */
383 XBT_PUBLIC(void) surf_vm_set_affinity(sg_host_t resource, sg_host_t cpu, unsigned long mask);
384
385 /**
386  * @brief Get the list of storages attached to an host
387  *
388  * @param host The surf host
389  * @return Dictionary of storage
390  */
391 XBT_PUBLIC(xbt_dynar_t) surf_host_get_attached_storage_list(sg_host_t host);
392
393 /**
394  * @brief Unlink a file descriptor
395  *
396  * @param host The surf host
397  * @param fd The file descriptor
398  *
399  * @return 0 if failed to unlink, 1 otherwise
400  */
401 XBT_PUBLIC(int) surf_host_unlink(sg_host_t host, surf_file_t fd);
402
403 /**
404  * @brief Get the size of a file on a host
405  *
406  * @param host The surf host
407  * @param fd The file descriptor
408  *
409  * @return The size in bytes of the file
410  */
411 XBT_PUBLIC(size_t) surf_host_get_size(sg_host_t host, surf_file_t fd);
412
413 /**
414  * @brief Get the current position of the file descriptor
415  *
416  * @param host The surf host
417  * @param fd The file descriptor
418  * @return The current position of the file descriptor
419  */
420 XBT_PUBLIC(size_t) surf_host_file_tell(sg_host_t host, surf_file_t fd);
421
422 /**
423  * @brief Move a file to another location on the *same mount point*.
424  * @details [long description]
425  *
426  * @param host The surf host
427  * @param fd The file descriptor
428  * @param fullpath The new full path
429  *
430  * @return MSG_OK if successful, otherwise MSG_TASK_CANCELED
431  */
432 XBT_PUBLIC(int) surf_host_file_move(sg_host_t host, surf_file_t fd, const char* fullpath);
433
434 /**
435  * @brief Set the position indictator assiociated with the file descriptor to a new position
436  * @details [long description]
437  *
438  * @param host The surf host
439  * @param fd The file descriptor
440  * @param offset The offset from the origin
441  * @param origin Position used as a reference for the offset
442  *  - SEEK_SET: beginning of the file
443  *  - SEEK_CUR: current position indicator
444  *  - SEEK_END: end of the file
445  * @return MSG_OK if successful, otherwise MSG_TASK_CANCELED
446  */
447 XBT_PUBLIC(int) surf_host_file_seek(sg_host_t host,
448                                            surf_file_t fd, sg_offset_t offset,
449                                            int origin);
450
451 /**
452  * @brief Get the content of a storage
453  *
454  * @param resource The surf storage
455  * @return A xbt_dict_t with path as keys and size in bytes as values
456  */
457 XBT_PUBLIC(xbt_dict_t) surf_storage_get_content(surf_resource_t resource);
458
459 /**
460  * @brief Get the size in bytes of a storage
461  *
462  * @param resource The surf storage
463  * @return The size in bytes of the storage
464  */
465 XBT_PUBLIC(sg_size_t) surf_storage_get_size(surf_resource_t resource);
466
467 /**
468  * @brief Get the available size in bytes of a storage
469  *
470  * @param resource The surf storage
471  * @return The available size in bytes of the storage
472  */
473 XBT_PUBLIC(sg_size_t) surf_storage_get_free_size(surf_resource_t resource);
474
475 /**
476  * @brief Get the size in bytes of a storage
477  *
478  * @param resource The surf storage
479  * @return The used size in bytes of the storage
480  */
481 XBT_PUBLIC(sg_size_t) surf_storage_get_used_size(surf_resource_t resource);
482
483 /** @brief return the properties set associated to that storage */
484 XBT_PUBLIC(xbt_dict_t) surf_storage_get_properties(surf_resource_t resource);
485
486 /**
487  * @brief Get the data associated to the action
488  *
489  * @param action The surf action
490  * @return The data associated to the action
491  */
492 XBT_PUBLIC(void*) surf_action_get_data(surf_action_t action);
493
494 /**
495  * @brief Set the data associated to the action
496  * @details [long description]
497  *
498  * @param action The surf action
499  * @param data The new data associated to the action
500  */
501 XBT_PUBLIC(void) surf_action_set_data(surf_action_t action, void *data);
502
503 /**
504  * @brief Get the start time of an action
505  *
506  * @param action The surf action
507  * @return The start time in seconds from the beginning of the simulation
508  */
509 XBT_PUBLIC(double) surf_action_get_start_time(surf_action_t action);
510
511 /**
512  * @brief Get the finish time of an action
513  *
514  * @param action The surf action
515  * @return The finish time in seconds from the beginning of the simulation
516  */
517 XBT_PUBLIC(double) surf_action_get_finish_time(surf_action_t action);
518
519 /**
520  * @brief Get the remains amount of work to do of an action
521  *
522  * @param action The surf action
523  * @return  The remains amount of work to do
524  */
525 XBT_PUBLIC(double) surf_action_get_remains(surf_action_t action);
526
527 /**
528  * @brief Set the category of an action
529  * @details [long description]
530  *
531  * @param action The surf action
532  * @param category The new category of the action
533  */
534 XBT_PUBLIC(void) surf_action_set_category(surf_action_t action, const char *category);
535
536 /**
537  * @brief Get the state of an action
538  *
539  * @param action The surf action
540  * @return The state of the action
541  */
542 XBT_PUBLIC(e_surf_action_state_t) surf_action_get_state(surf_action_t action);
543
544 /**
545  * @brief Get the cost of an action
546  *
547  * @param action The surf action
548  * @return The cost of the action
549  */
550 XBT_PUBLIC(double) surf_action_get_cost(surf_action_t action);
551
552 /**
553  * @brief [brief desrciption]
554  * @details [long description]
555  *
556  * @param action The surf cpu action
557  * @param cpu [description]
558  * @param mask [description]
559  */
560 XBT_PUBLIC(void) surf_cpu_action_set_affinity(surf_action_t action, sg_host_t cpu, unsigned long mask);
561
562 /**
563  * @brief [brief description]
564  * @details [long description]
565  *
566  * @param action The surf cpu action
567  * @param bound [description]
568  */
569 XBT_PUBLIC(void) surf_cpu_action_set_bound(surf_action_t action, double bound);
570
571 /**
572  * @brief [brief description]
573  * @details [long description]
574  *
575  * @param action The surf network action
576  */
577 XBT_PUBLIC(double) surf_network_action_get_latency_limited(surf_action_t action);
578
579 /**
580  * @brief Get the file associated to a storage action
581  *
582  * @param action The surf storage action
583  * @return The file associated to a storage action
584  */
585 XBT_PUBLIC(surf_file_t) surf_storage_action_get_file(surf_action_t action);
586
587 /**
588  * @brief Get the result dictionary of an ls action
589  *
590  * @param action The surf storage action
591  * @return The dictionry listing a path
592  */
593 XBT_PUBLIC(xbt_dict_t) surf_storage_action_get_ls_dict(surf_action_t action);
594
595
596 /**
597  * @brief Get the host the storage is attached to
598  *
599  * @param resource The surf storage
600  * @return The host name
601  * may not exist.
602  */
603 XBT_PUBLIC(const char * ) surf_storage_get_host(surf_resource_t resource);
604
605 /** @} */
606
607 /**************************************/
608 /* Implementations of model object */
609 /**************************************/
610
611 XBT_PUBLIC_DATA(int) autoload_surf_cpu_model;
612 XBT_PUBLIC_DATA(void_f_void_t) surf_cpu_model_init_preparse;
613
614 /** \ingroup SURF_models
615  *  \brief The CPU model object for the physical machine layer
616  */
617 XBT_PUBLIC_DATA(surf_cpu_model_t) surf_cpu_model_pm;
618
619 /** \ingroup SURF_models
620  *  \brief The CPU model object for the virtual machine layer
621  */
622 XBT_PUBLIC_DATA(surf_cpu_model_t) surf_cpu_model_vm;
623
624
625 /** \ingroup SURF_models
626  *  \brief Initializes the CPU model with the model Cas01
627  *
628  *  By default, this model uses the lazy optimization mechanism that
629  *  relies on partial invalidation in LMM and a heap for lazy action update.
630  *  You can change this behavior by setting the cpu/optim configuration
631  *  variable to a different value.
632  *
633  *  You shouldn't have to call it by yourself.
634  */
635 XBT_PUBLIC(void) surf_cpu_model_init_Cas01(void);
636
637 /** \ingroup SURF_models
638  *  \brief Initializes the CPU model with trace integration [Deprecated]
639  *
640  *  You shouldn't have to call it by yourself.
641  */
642 XBT_PUBLIC(void) surf_cpu_model_init_ti(void);
643
644 /** \ingroup SURF_models
645  *  \brief The list of all available optimization modes (both for cpu and networks).
646  *  These optimization modes can be set using --cfg=cpu/optim:... and --cfg=network/optim:...
647  */
648 XBT_PUBLIC_DATA(s_surf_model_description_t) surf_optimization_mode_description[];
649
650 /** \ingroup SURF_plugins
651  *  \brief The list of all available surf plugins
652  */
653 XBT_PUBLIC_DATA(s_surf_model_description_t) surf_plugin_description[];
654
655 /** \ingroup SURF_models
656  *  \brief The list of all available cpu model models
657  */
658 XBT_PUBLIC_DATA(s_surf_model_description_t) surf_cpu_model_description[];
659
660 /**\brief create new host bypass the parser
661  *
662  */
663
664
665 /** \ingroup SURF_models
666  *  \brief The network model
667  *
668  *  When creating a new API on top on SURF, you shouldn't use the
669  *  network model unless you know what you are doing. Only the host
670  *  model should be accessed because depending on the platform model,
671  *  the network model can be NULL.
672  */
673 XBT_PUBLIC_DATA(surf_network_model_t) surf_network_model;
674
675 /** \ingroup SURF_models
676  *  \brief Same as network model 'LagrangeVelho', only with different correction factors.
677  *
678  * This model is proposed by Pierre-Nicolas Clauss and Martin Quinson and Stéphane Génaud
679  * based on the model 'LV08' and different correction factors depending on the communication
680  * size (< 1KiB, < 64KiB, >= 64KiB).
681  * See comments in the code for more information.
682  *
683  *  \see surf_host_model_init_SMPI()
684  */
685 XBT_PUBLIC(void) surf_network_model_init_SMPI(void);
686
687 /** \ingroup SURF_models
688  *  \brief Same as network model 'LagrangeVelho', only with different correction factors.
689  *
690  * This model impelments a variant of the contention model on Infinband networks based on
691  * the works of Jérôme Vienne : http://mescal.imag.fr/membres/jean-marc.vincent/index.html/PhD/Vienne.pdf
692  *
693  *  \see surf_host_model_init_IB()
694  */
695 XBT_PUBLIC(void) surf_network_model_init_IB(void);
696
697 /** \ingroup SURF_models
698  *  \brief Initializes the platform with the network model 'LegrandVelho'
699  *
700  * This model is proposed by Arnaud Legrand and Pedro Velho based on
701  * the results obtained with the GTNets simulator for onelink and
702  * dogbone sharing scenarios. See comments in the code for more information.
703  *
704  *  \see surf_host_model_init_LegrandVelho()
705  */
706 XBT_PUBLIC(void) surf_network_model_init_LegrandVelho(void);
707
708 /** \ingroup SURF_models
709  *  \brief Initializes the platform with the network model 'Constant'
710  *
711  *  In this model, the communication time between two network cards is
712  *  constant, hence no need for a routing table. This is particularly
713  *  usefull when simulating huge distributed algorithms where
714  *  scalability is really an issue. This function is called in
715  *  conjunction with surf_host_model_init_compound.
716  *
717  *  \see surf_host_model_init_compound()
718  */
719 XBT_PUBLIC(void) surf_network_model_init_Constant(void);
720
721 /** \ingroup SURF_models
722  *  \brief Initializes the platform with the network model CM02
723  *
724  *  You sould call this function by yourself only if you plan using
725  *  surf_host_model_init_compound.
726  *  See comments in the code for more information.
727  */
728 XBT_PUBLIC(void) surf_network_model_init_CM02(void);
729
730 #ifdef HAVE_NS3
731 /** \ingroup SURF_models
732  *  \brief Initializes the platform with the network model NS3
733  *
734  *  This function is called by surf_host_model_init_NS3
735  *  or by yourself only if you plan using surf_host_model_init_compound
736  *
737  *  \see surf_host_model_init_NS3()
738  */
739 XBT_PUBLIC(void) surf_network_model_init_NS3(void);
740 #endif
741
742 /** \ingroup SURF_models
743  *  \brief Initializes the platform with the network model Reno
744  *
745  *  The problem is related to max( sum( arctan(C * Df * xi) ) ).
746  *
747  *  Reference:
748  *  [LOW03] S. H. Low. A duality model of TCP and queue management algorithms.
749  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
750  *
751  *  Call this function only if you plan using surf_host_model_init_compound.
752  *
753  */
754 XBT_PUBLIC(void) surf_network_model_init_Reno(void);
755
756 /** \ingroup SURF_models
757  *  \brief Initializes the platform with the network model Reno2
758  *
759  *  The problem is related to max( sum( arctan(C * Df * xi) ) ).
760  *
761  *  Reference:
762  *  [LOW01] S. H. Low. A duality model of TCP and queue management algorithms.
763  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
764  *
765  *  Call this function only if you plan using surf_host_model_init_compound.
766  *
767  */
768 XBT_PUBLIC(void) surf_network_model_init_Reno2(void);
769
770 /** \ingroup SURF_models
771  *  \brief Initializes the platform with the network model Vegas
772  *
773  *  This problem is related to max( sum( a * Df * ln(xi) ) ) which is equivalent
774  *  to the proportional fairness.
775  *
776  *  Reference:
777  *  [LOW03] S. H. Low. A duality model of TCP and queue management algorithms.
778  *  IEEE/ACM Transaction on Networking, 11(4):525-536, 2003.
779  *
780  *  Call this function only if you plan using surf_host_model_init_compound.
781  *
782  */
783 XBT_PUBLIC(void) surf_network_model_init_Vegas(void);
784
785 /** \ingroup SURF_models
786  *  \brief The list of all available network model models
787  */
788 XBT_PUBLIC_DATA(s_surf_model_description_t)
789     surf_network_model_description[];
790
791 /** \ingroup SURF_models
792  *  \brief The storage model
793  */
794 XBT_PUBLIC(void) surf_storage_model_init_default(void);
795
796 /** \ingroup SURF_models
797  *  \brief The list of all available storage modes.
798  *  This storage mode can be set using --cfg=storage/model:...
799  */
800 XBT_PUBLIC_DATA(s_surf_model_description_t) surf_storage_model_description[];
801
802 XBT_PUBLIC_DATA(surf_storage_model_t) surf_storage_model;
803
804 /** \ingroup SURF_models
805  *  \brief The host model
806  *
807  *  Note that when you create an API on top of SURF,
808  *  the host model should be the only one you use
809  *  because depending on the platform model, the network model and the CPU model
810  *  may not exist.
811  */
812 XBT_PUBLIC_DATA(surf_host_model_t) surf_host_model;
813
814 /** \ingroup SURF_models
815  *  \brief The vm model
816  *
817  *  Note that when you create an API on top of SURF,
818  *  the vm model should be the only one you use
819  *  because depending on the platform model, the network model and the CPU model
820  *  may not exist.
821  */
822 XBT_PUBLIC_DATA(surf_vm_model_t) surf_vm_model;
823
824 /** \ingroup SURF_models
825  *  \brief Initializes the platform with a compound host model
826  *
827  *  This function should be called after a cpu_model and a
828  *  network_model have been set up.
829  *
830  */
831 XBT_PUBLIC(void) surf_host_model_init_compound(void);
832
833 /** \ingroup SURF_models
834  *  \brief Initializes the platform with the current best network and cpu models at hand
835  *
836  *  This platform model separates the host model and the network model.
837  *  The host model will be initialized with the model compound, the network
838  *  model with the model LV08 (with cross traffic support) and the CPU model with
839  *  the model Cas01.
840  *  Such model is subject to modification with warning in the ChangeLog so monitor it!
841  *
842  */
843 XBT_PUBLIC(void) surf_host_model_init_current_default(void);
844
845 /** \ingroup SURF_models
846  *  \brief Initializes the platform with the model L07
847  *
848  *  With this model, only parallel tasks can be used. Resource sharing
849  *  is done by identifying bottlenecks and giving an equal share of
850  *  the model to each action.
851  *
852  */
853 XBT_PUBLIC(void) surf_host_model_init_ptask_L07(void);
854
855 /** \ingroup SURF_models
856  *  \brief The list of all available host model models
857  */
858 XBT_PUBLIC_DATA(s_surf_model_description_t)
859     surf_host_model_description[];
860
861 /** \ingroup SURF_models
862  *  \brief Initializes the platform with the current best network and cpu models at hand
863  *
864  *  This platform model seperates the host model and the network model.
865  *  The host model will be initialized with the model compound, the network
866  *  model with the model LV08 (with cross traffic support) and the CPU model with
867  *  the model Cas01.
868  *  Such model is subject to modification with warning in the ChangeLog so monitor it!
869  *
870  */
871 XBT_PUBLIC(void) surf_vm_model_init_HL13(void);
872
873 /** \ingroup SURF_models
874  *  \brief The list of all available vm model models
875  */
876 XBT_PUBLIC_DATA(s_surf_model_description_t)
877     surf_vm_model_description[];
878
879 /*******************************************/
880
881 /** \ingroup SURF_models
882  *  \brief List of initialized models
883  */
884 XBT_PUBLIC_DATA(xbt_dynar_t) all_existing_models;
885
886 /** \ingroup SURF_simulation
887  *  \brief List of hosts that have just restarted and whose autorestart process should be restarted.
888  */
889 XBT_PUBLIC_DATA(xbt_dynar_t) host_that_restart;
890
891 /** \ingroup SURF_simulation
892  *  \brief List of hosts for which one want to be notified if they ever restart.
893  */
894 XBT_PUBLIC_DATA(xbt_dict_t) watched_hosts_lib;
895
896 /*******************************************/
897 /*** SURF Platform *************************/
898 /*******************************************/
899 XBT_PUBLIC_DATA(AS_t) surf_AS_get_routing_root(void);
900 XBT_PUBLIC_DATA(const char *) surf_AS_get_name(AS_t as);
901 XBT_PUBLIC_DATA(AS_t) surf_AS_get_by_name(const char * name);
902 XBT_PUBLIC_DATA(xbt_dict_t) surf_AS_get_routing_sons(AS_t as);
903 XBT_PUBLIC_DATA(xbt_dynar_t) surf_AS_get_hosts(AS_t as);
904 XBT_PUBLIC_DATA(void) surf_AS_get_graph(AS_t as, xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges);
905
906 /*******************************************/
907 /*** SURF Globals **************************/
908 /*******************************************/
909
910 /** \ingroup SURF_simulation
911  *  \brief Initialize SURF
912  *  \param argc argument number
913  *  \param argv arguments
914  *
915  *  This function has to be called to initialize the common
916  *  structures.  Then you will have to create the environment by
917  *  calling
918  *  e.g. surf_host_model_init_CM02()
919  *
920  *  \see surf_host_model_init_CM02(), surf_host_model_init_compound(), surf_exit()
921  */
922 XBT_PUBLIC(void) surf_init(int *argc, char **argv);     /* initialize common structures */
923
924 /** \ingroup SURF_simulation
925  *  \brief Finish simulation initialization
926  *
927  *  This function must be called before the first call to surf_solve()
928  */
929 XBT_PUBLIC(void) surf_presolve(void);
930
931 /** \ingroup SURF_simulation
932  *  \brief Performs a part of the simulation
933  *  \param max_date Maximum date to update the simulation to, or -1
934  *  \return the elapsed time, or -1.0 if no event could be executed
935  *
936  *  This function execute all possible events, update the action states
937  *  and returns the time elapsed.
938  *  When you call execute or communicate on a model, the corresponding actions
939  *  are not executed immediately but only when you call surf_solve.
940  *  Note that the returned elapsed time can be zero.
941  */
942 XBT_PUBLIC(double) surf_solve(double max_date);
943
944 /** \ingroup SURF_simulation
945  *  \brief Return the current time
946  *
947  *  Return the current time in millisecond.
948  */
949 XBT_PUBLIC(double) surf_get_clock(void);
950
951 /** \ingroup SURF_simulation
952  *  \brief Exit SURF
953  *
954  *  Clean everything.
955  *
956  *  \see surf_init()
957  */
958 XBT_PUBLIC(void) surf_exit(void);
959
960 /* Prototypes of the functions that handle the properties */
961 XBT_PUBLIC_DATA(xbt_dict_t) current_property_set;       /* the prop set for the currently parsed element (also used in SIMIX) */
962
963 /* The same for model_prop set*/
964 XBT_PUBLIC_DATA(xbt_dict_t) current_model_property_set;
965
966 /* surf parse file related (public because called from a test suite) */
967 XBT_PUBLIC(void) parse_platform_file(const char *file);
968
969 /* For the trace and trace:connect tag (store their content till the end of the parsing) */
970 XBT_PUBLIC_DATA(xbt_dict_t) traces_set_list;
971
972 XBT_PUBLIC(xbt_dict_t) get_as_router_properties(const char* name);
973
974 /*
975  * Returns the initial path. On Windows the initial path is
976  * the current directory for the current process in the other
977  * case the function returns "./" that represents the current
978  * directory on Unix/Linux platforms.
979  */
980 const char *__surf_get_initial_path(void);
981
982 /********** Tracing **********/
983 /* from surf_instr.c */
984 void TRACE_surf_action(surf_action_t surf_action, const char *category);
985 void TRACE_surf_alloc(void);
986 void TRACE_surf_release(void);
987
988 /* instr_routing.c */
989 void instr_routing_define_callbacks (void);
990 void instr_new_variable_type (const char *new_typename, const char *color);
991 void instr_new_user_variable_type  (const char *father_type, const char *new_typename, const char *color);
992 void instr_new_user_state_type (const char *father_type, const char *new_typename);
993 void instr_new_value_for_user_state_type (const char *_typename, const char *value, const char *color);
994 int instr_platform_traced (void);
995 xbt_graph_t instr_routing_platform_graph (void);
996 void instr_routing_platform_graph_export_graphviz (xbt_graph_t g, const char *filename);
997
998 /********** Routing **********/
999 void routing_AS_begin(sg_platf_AS_cbarg_t AS);
1000 void routing_AS_end(void);
1001 void routing_cluster_add_backbone(Link* bb);
1002 surf_As* routing_get_current();
1003
1004 SG_END_DECL()
1005 #endif                          /* _SURF_SURF_H */