1 /* Copyright (c) 2004-2015. The SimGrid Team.
2 * All rights reserved. */
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. */
11 #include "xbt/dynar.h"
13 #include "xbt/graph.h"
15 #include "xbt/config.h"
16 #include "src/portable.h"
17 #include "surf/surf_routing.h"
18 #include "surf/datatypes.h"
20 #include "surf/surf_routing.h"
21 #include "simgrid/platf_interface.h"
22 #include "simgrid/datatypes.h"
23 #include "simgrid/forward.h"
26 /* Actions and models are highly connected structures... */
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;
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;
58 class NetworkCm02Link;
61 class StorageActionLmm;
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;
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;
104 /** @ingroup SURF_c_bindings
105 * \brief Model datatype
107 * Generic data structure for a model. The hosts,
108 * the CPUs and the network links are examples of models.
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;
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;
122 /** @ingroup SURF_c_bindings
123 * \brief Action structure
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.
128 * \see e_surf_action_state_t
130 typedef surf_Action *surf_action_t;
131 typedef surf_RoutingPlatf *routing_platf_t;
133 typedef struct surf_file *surf_file_t;
135 /** @Brief Specify that we use that action */
136 XBT_PUBLIC(void) surf_action_ref(surf_action_t action);
138 /** @brief Creates a new action.
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
145 XBT_PUBLIC(void *) surf_action_new(size_t size, double cost,
146 surf_model_t model, int failed);
148 /** \brief Resource model description
150 typedef struct surf_model_description {
152 const char *description;
153 void_f_void_t model_init_preparse;
154 } s_surf_model_description_t, *surf_model_description_t;
156 XBT_PUBLIC(int) find_model_description(s_surf_model_description_t * table,
158 XBT_PUBLIC(void) model_help(const char *category,
159 s_surf_model_description_t * table);
161 /** @ingroup SURF_interface
162 * @brief Action states
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;
175 /** @ingroup SURF_vm_interface
179 /* FIXME: Where should the VM state be defined? */
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. */
185 SURF_VM_STATE_SAVING, /**< Save/restore involves disk I/O, so there should be transition states. */
187 SURF_VM_STATE_RESTORING,
190 /***************************/
191 /* Generic model object */
192 /***************************/
194 XBT_PUBLIC_DATA(routing_platf_t) routing_platf;
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);
200 static inline void *surf_storage_resource_by_name(const char *name){
201 return xbt_lib_get_elm_or_null(storage_lib, name);
204 /** @{ @ingroup SURF_c_bindings */
207 * @brief Pop an action from the done actions set
209 * @param model The model from which the action is extracted
210 * @return An action in done state
212 XBT_PUBLIC(surf_action_t) surf_model_extract_done_action_set(surf_model_t model);
215 * @brief Pop an action from the failed actions set
217 * @param model The model from which the action is extracted
218 * @return An action in failed state
220 XBT_PUBLIC(surf_action_t) surf_model_extract_failed_action_set(surf_model_t model);
223 * @brief Get the size of the running action set of a model
225 * @param model The model
226 * @return The size of the running action set
228 XBT_PUBLIC(int) surf_model_running_action_set_size(surf_model_t model);
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);
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);
237 /** @brief Create a communication between two hosts
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
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);
249 * @brief Get the name of a surf resource (cpu, host, network, …)
251 * @param resource The surf resource
252 * @return The name of the surf resource
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);
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);
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);
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);
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);
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);
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);
278 * @brief Get the informations of a file descriptor
279 * @details The returned xbt_dynar_t contains:
280 * - the size of the file,
282 * - the storage name,
283 * - the storage typeId,
284 * - the storage content type
286 * @param host The surf host
287 * @param fd The file descriptor
288 * @return An xbt_dynar_t with the file informations
290 XBT_PUBLIC(xbt_dynar_t) surf_host_get_info(sg_host_t host, surf_file_t fd);
293 * @brief Get the available space of the storage at the mount point
295 * @param resource The surf host
296 * @param name The mount point
297 * @return The amount of available space in bytes
299 XBT_PUBLIC(sg_size_t) surf_host_get_free_size(sg_host_t resource, const char* name);
302 * @brief Get the used space of the storage at the mount point
304 * @param resource The surf host
305 * @param name The mount point
306 * @return The amount of used space in bytes
308 XBT_PUBLIC(sg_size_t) surf_host_get_used_size(sg_host_t resource, const char* name);
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);
313 /** @brief Retrieve the params of that VM
314 * @details You can use fields ramsize and overcommit on a PM, too.
316 XBT_PUBLIC(void) surf_host_get_params(sg_host_t resource, vm_params_t params);
318 /** @brief Sets the params of that VM/PM
319 * @details You can use fields ramsize and overcommit on a PM, too.
321 XBT_PUBLIC(void) surf_host_set_params(sg_host_t resource, vm_params_t params);
324 * @brief Destroy a VM
326 * @param resource The surf vm
328 XBT_PUBLIC(void) surf_vm_destroy(sg_host_t resource);
330 /** @brief Suspend a VM */
331 XBT_PUBLIC(void) surf_vm_suspend(sg_host_t resource);
333 /** @brief Resume a VM */
334 XBT_PUBLIC(void) surf_vm_resume(sg_host_t resource);
337 * @brief Save the VM (Not yet implemented)
339 * @param resource The surf vm
341 XBT_PUBLIC(void) surf_vm_save(sg_host_t resource);
344 * @brief Restore the VM (Not yet implemented)
346 * @param resource The surf vm
348 XBT_PUBLIC(void) surf_vm_restore(sg_host_t resource);
351 * @brief Migrate the VM to the destination host
353 * @param resource The surf vm
354 * @param ind_vm_ws_dest The destination host
356 XBT_PUBLIC(void) surf_vm_migrate(sg_host_t resource, sg_host_t ind_vm_ws_dest);
359 * @brief Get the physical machine hosting the VM
361 * @param resource The surf vm
362 * @return The physical machine hosting the VM
364 XBT_PUBLIC(sg_host_t) surf_vm_get_pm(sg_host_t resource);
367 * @brief [brief description]
368 * @details [long description]
370 * @param resource [description]
371 * @param bound [description]
373 XBT_PUBLIC(void) surf_vm_set_bound(sg_host_t resource, double bound);
376 * @brief [brief description]
377 * @details [long description]
379 * @param resource [description]
380 * @param cpu [description]
381 * @param mask [description]
383 XBT_PUBLIC(void) surf_vm_set_affinity(sg_host_t resource, sg_host_t cpu, unsigned long mask);
386 * @brief Get the list of storages attached to an host
388 * @param host The surf host
389 * @return Dictionary of storage
391 XBT_PUBLIC(xbt_dynar_t) surf_host_get_attached_storage_list(sg_host_t host);
394 * @brief Unlink a file descriptor
396 * @param host The surf host
397 * @param fd The file descriptor
399 * @return 0 if failed to unlink, 1 otherwise
401 XBT_PUBLIC(int) surf_host_unlink(sg_host_t host, surf_file_t fd);
404 * @brief Get the size of a file on a host
406 * @param host The surf host
407 * @param fd The file descriptor
409 * @return The size in bytes of the file
411 XBT_PUBLIC(size_t) surf_host_get_size(sg_host_t host, surf_file_t fd);
414 * @brief Get the current position of the file descriptor
416 * @param host The surf host
417 * @param fd The file descriptor
418 * @return The current position of the file descriptor
420 XBT_PUBLIC(size_t) surf_host_file_tell(sg_host_t host, surf_file_t fd);
423 * @brief Move a file to another location on the *same mount point*.
424 * @details [long description]
426 * @param host The surf host
427 * @param fd The file descriptor
428 * @param fullpath The new full path
430 * @return MSG_OK if successful, otherwise MSG_TASK_CANCELED
432 XBT_PUBLIC(int) surf_host_file_move(sg_host_t host, surf_file_t fd, const char* fullpath);
435 * @brief Set the position indictator assiociated with the file descriptor to a new position
436 * @details [long description]
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
447 XBT_PUBLIC(int) surf_host_file_seek(sg_host_t host,
448 surf_file_t fd, sg_offset_t offset,
452 * @brief Get the content of a storage
454 * @param resource The surf storage
455 * @return A xbt_dict_t with path as keys and size in bytes as values
457 XBT_PUBLIC(xbt_dict_t) surf_storage_get_content(surf_resource_t resource);
460 * @brief Get the size in bytes of a storage
462 * @param resource The surf storage
463 * @return The size in bytes of the storage
465 XBT_PUBLIC(sg_size_t) surf_storage_get_size(surf_resource_t resource);
468 * @brief Get the available size in bytes of a storage
470 * @param resource The surf storage
471 * @return The available size in bytes of the storage
473 XBT_PUBLIC(sg_size_t) surf_storage_get_free_size(surf_resource_t resource);
476 * @brief Get the size in bytes of a storage
478 * @param resource The surf storage
479 * @return The used size in bytes of the storage
481 XBT_PUBLIC(sg_size_t) surf_storage_get_used_size(surf_resource_t resource);
483 /** @brief return the properties set associated to that storage */
484 XBT_PUBLIC(xbt_dict_t) surf_storage_get_properties(surf_resource_t resource);
487 * @brief Get the data associated to the action
489 * @param action The surf action
490 * @return The data associated to the action
492 XBT_PUBLIC(void*) surf_action_get_data(surf_action_t action);
495 * @brief Set the data associated to the action
496 * @details [long description]
498 * @param action The surf action
499 * @param data The new data associated to the action
501 XBT_PUBLIC(void) surf_action_set_data(surf_action_t action, void *data);
504 * @brief Get the start time of an action
506 * @param action The surf action
507 * @return The start time in seconds from the beginning of the simulation
509 XBT_PUBLIC(double) surf_action_get_start_time(surf_action_t action);
512 * @brief Get the finish time of an action
514 * @param action The surf action
515 * @return The finish time in seconds from the beginning of the simulation
517 XBT_PUBLIC(double) surf_action_get_finish_time(surf_action_t action);
520 * @brief Get the remains amount of work to do of an action
522 * @param action The surf action
523 * @return The remains amount of work to do
525 XBT_PUBLIC(double) surf_action_get_remains(surf_action_t action);
528 * @brief Set the category of an action
529 * @details [long description]
531 * @param action The surf action
532 * @param category The new category of the action
534 XBT_PUBLIC(void) surf_action_set_category(surf_action_t action, const char *category);
537 * @brief Get the state of an action
539 * @param action The surf action
540 * @return The state of the action
542 XBT_PUBLIC(e_surf_action_state_t) surf_action_get_state(surf_action_t action);
545 * @brief Get the cost of an action
547 * @param action The surf action
548 * @return The cost of the action
550 XBT_PUBLIC(double) surf_action_get_cost(surf_action_t action);
553 * @brief [brief desrciption]
554 * @details [long description]
556 * @param action The surf cpu action
557 * @param cpu [description]
558 * @param mask [description]
560 XBT_PUBLIC(void) surf_cpu_action_set_affinity(surf_action_t action, sg_host_t cpu, unsigned long mask);
563 * @brief [brief description]
564 * @details [long description]
566 * @param action The surf cpu action
567 * @param bound [description]
569 XBT_PUBLIC(void) surf_cpu_action_set_bound(surf_action_t action, double bound);
572 * @brief [brief description]
573 * @details [long description]
575 * @param action The surf network action
577 XBT_PUBLIC(double) surf_network_action_get_latency_limited(surf_action_t action);
580 * @brief Get the file associated to a storage action
582 * @param action The surf storage action
583 * @return The file associated to a storage action
585 XBT_PUBLIC(surf_file_t) surf_storage_action_get_file(surf_action_t action);
588 * @brief Get the result dictionary of an ls action
590 * @param action The surf storage action
591 * @return The dictionry listing a path
593 XBT_PUBLIC(xbt_dict_t) surf_storage_action_get_ls_dict(surf_action_t action);
597 * @brief Get the host the storage is attached to
599 * @param resource The surf storage
600 * @return The host name
603 XBT_PUBLIC(const char * ) surf_storage_get_host(surf_resource_t resource);
607 /**************************************/
608 /* Implementations of model object */
609 /**************************************/
611 XBT_PUBLIC_DATA(int) autoload_surf_cpu_model;
612 XBT_PUBLIC_DATA(void_f_void_t) surf_cpu_model_init_preparse;
614 /** \ingroup SURF_models
615 * \brief The CPU model object for the physical machine layer
617 XBT_PUBLIC_DATA(surf_cpu_model_t) surf_cpu_model_pm;
619 /** \ingroup SURF_models
620 * \brief The CPU model object for the virtual machine layer
622 XBT_PUBLIC_DATA(surf_cpu_model_t) surf_cpu_model_vm;
625 /** \ingroup SURF_models
626 * \brief Initializes the CPU model with the model Cas01
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.
633 * You shouldn't have to call it by yourself.
635 XBT_PUBLIC(void) surf_cpu_model_init_Cas01(void);
637 /** \ingroup SURF_models
638 * \brief Initializes the CPU model with trace integration [Deprecated]
640 * You shouldn't have to call it by yourself.
642 XBT_PUBLIC(void) surf_cpu_model_init_ti(void);
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:...
648 XBT_PUBLIC_DATA(s_surf_model_description_t) surf_optimization_mode_description[];
650 /** \ingroup SURF_plugins
651 * \brief The list of all available surf plugins
653 XBT_PUBLIC_DATA(s_surf_model_description_t) surf_plugin_description[];
655 /** \ingroup SURF_models
656 * \brief The list of all available cpu model models
658 XBT_PUBLIC_DATA(s_surf_model_description_t) surf_cpu_model_description[];
660 /**\brief create new host bypass the parser
665 /** \ingroup SURF_models
666 * \brief The network model
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.
673 XBT_PUBLIC_DATA(surf_network_model_t) surf_network_model;
675 /** \ingroup SURF_models
676 * \brief Same as network model 'LagrangeVelho', only with different correction factors.
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.
683 * \see surf_host_model_init_SMPI()
685 XBT_PUBLIC(void) surf_network_model_init_SMPI(void);
687 /** \ingroup SURF_models
688 * \brief Same as network model 'LagrangeVelho', only with different correction factors.
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
693 * \see surf_host_model_init_IB()
695 XBT_PUBLIC(void) surf_network_model_init_IB(void);
697 /** \ingroup SURF_models
698 * \brief Initializes the platform with the network model 'LegrandVelho'
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.
704 * \see surf_host_model_init_LegrandVelho()
706 XBT_PUBLIC(void) surf_network_model_init_LegrandVelho(void);
708 /** \ingroup SURF_models
709 * \brief Initializes the platform with the network model 'Constant'
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.
717 * \see surf_host_model_init_compound()
719 XBT_PUBLIC(void) surf_network_model_init_Constant(void);
721 /** \ingroup SURF_models
722 * \brief Initializes the platform with the network model CM02
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.
728 XBT_PUBLIC(void) surf_network_model_init_CM02(void);
731 /** \ingroup SURF_models
732 * \brief Initializes the platform with the network model NS3
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
737 * \see surf_host_model_init_NS3()
739 XBT_PUBLIC(void) surf_network_model_init_NS3(void);
742 /** \ingroup SURF_models
743 * \brief Initializes the platform with the network model Reno
745 * The problem is related to max( sum( arctan(C * Df * xi) ) ).
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.
751 * Call this function only if you plan using surf_host_model_init_compound.
754 XBT_PUBLIC(void) surf_network_model_init_Reno(void);
756 /** \ingroup SURF_models
757 * \brief Initializes the platform with the network model Reno2
759 * The problem is related to max( sum( arctan(C * Df * xi) ) ).
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.
765 * Call this function only if you plan using surf_host_model_init_compound.
768 XBT_PUBLIC(void) surf_network_model_init_Reno2(void);
770 /** \ingroup SURF_models
771 * \brief Initializes the platform with the network model Vegas
773 * This problem is related to max( sum( a * Df * ln(xi) ) ) which is equivalent
774 * to the proportional fairness.
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.
780 * Call this function only if you plan using surf_host_model_init_compound.
783 XBT_PUBLIC(void) surf_network_model_init_Vegas(void);
785 /** \ingroup SURF_models
786 * \brief The list of all available network model models
788 XBT_PUBLIC_DATA(s_surf_model_description_t)
789 surf_network_model_description[];
791 /** \ingroup SURF_models
792 * \brief The storage model
794 XBT_PUBLIC(void) surf_storage_model_init_default(void);
796 /** \ingroup SURF_models
797 * \brief The list of all available storage modes.
798 * This storage mode can be set using --cfg=storage/model:...
800 XBT_PUBLIC_DATA(s_surf_model_description_t) surf_storage_model_description[];
802 XBT_PUBLIC_DATA(surf_storage_model_t) surf_storage_model;
804 /** \ingroup SURF_models
805 * \brief The host model
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
812 XBT_PUBLIC_DATA(surf_host_model_t) surf_host_model;
814 /** \ingroup SURF_models
815 * \brief The vm model
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
822 XBT_PUBLIC_DATA(surf_vm_model_t) surf_vm_model;
824 /** \ingroup SURF_models
825 * \brief Initializes the platform with a compound host model
827 * This function should be called after a cpu_model and a
828 * network_model have been set up.
831 XBT_PUBLIC(void) surf_host_model_init_compound(void);
833 /** \ingroup SURF_models
834 * \brief Initializes the platform with the current best network and cpu models at hand
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
840 * Such model is subject to modification with warning in the ChangeLog so monitor it!
843 XBT_PUBLIC(void) surf_host_model_init_current_default(void);
845 /** \ingroup SURF_models
846 * \brief Initializes the platform with the model L07
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.
853 XBT_PUBLIC(void) surf_host_model_init_ptask_L07(void);
855 /** \ingroup SURF_models
856 * \brief The list of all available host model models
858 XBT_PUBLIC_DATA(s_surf_model_description_t)
859 surf_host_model_description[];
861 /** \ingroup SURF_models
862 * \brief Initializes the platform with the current best network and cpu models at hand
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
868 * Such model is subject to modification with warning in the ChangeLog so monitor it!
871 XBT_PUBLIC(void) surf_vm_model_init_HL13(void);
873 /** \ingroup SURF_models
874 * \brief The list of all available vm model models
876 XBT_PUBLIC_DATA(s_surf_model_description_t)
877 surf_vm_model_description[];
879 /*******************************************/
881 /** \ingroup SURF_models
882 * \brief List of initialized models
884 XBT_PUBLIC_DATA(xbt_dynar_t) all_existing_models;
886 /** \ingroup SURF_simulation
887 * \brief List of hosts that have just restarted and whose autorestart process should be restarted.
889 XBT_PUBLIC_DATA(xbt_dynar_t) host_that_restart;
891 /** \ingroup SURF_simulation
892 * \brief List of hosts for which one want to be notified if they ever restart.
894 XBT_PUBLIC_DATA(xbt_dict_t) watched_hosts_lib;
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);
906 /*******************************************/
907 /*** SURF Globals **************************/
908 /*******************************************/
910 /** \ingroup SURF_simulation
911 * \brief Initialize SURF
912 * \param argc argument number
913 * \param argv arguments
915 * This function has to be called to initialize the common
916 * structures. Then you will have to create the environment by
918 * e.g. surf_host_model_init_CM02()
920 * \see surf_host_model_init_CM02(), surf_host_model_init_compound(), surf_exit()
922 XBT_PUBLIC(void) surf_init(int *argc, char **argv); /* initialize common structures */
924 /** \ingroup SURF_simulation
925 * \brief Finish simulation initialization
927 * This function must be called before the first call to surf_solve()
929 XBT_PUBLIC(void) surf_presolve(void);
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
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.
942 XBT_PUBLIC(double) surf_solve(double max_date);
944 /** \ingroup SURF_simulation
945 * \brief Return the current time
947 * Return the current time in millisecond.
949 XBT_PUBLIC(double) surf_get_clock(void);
951 /** \ingroup SURF_simulation
958 XBT_PUBLIC(void) surf_exit(void);
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) */
963 /* The same for model_prop set*/
964 XBT_PUBLIC_DATA(xbt_dict_t) current_model_property_set;
966 /* surf parse file related (public because called from a test suite) */
967 XBT_PUBLIC(void) parse_platform_file(const char *file);
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;
972 XBT_PUBLIC(xbt_dict_t) get_as_router_properties(const char* name);
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.
980 const char *__surf_get_initial_path(void);
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);
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);
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();
1005 #endif /* _SURF_SURF_H */