X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e26d84ebd86c18af7d79d4afd659e53fd62ac9eb..62b54dd272b6f669c0a9b231991d572c3bec52b5:/src/include/surf/surf.h?ds=sidebyside diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 98b848fa46..a6bb939848 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2014. The SimGrid Team. +/* Copyright (c) 2004-2015. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -12,8 +12,8 @@ #include "xbt/dict.h" #include "xbt/graph.h" #include "xbt/misc.h" -#include "portable.h" #include "xbt/config.h" +#include "src/portable.h" #include "surf/datatypes.h" #include "xbt/lib.h" #include "surf/surf_routing.h" @@ -25,17 +25,13 @@ SG_BEGIN_DECL() /* Actions and models are highly connected structures... */ /* user-visible parameters */ -extern double sg_tcp_gamma; -extern double sg_sender_gap; -extern double sg_latency_factor; -extern double sg_bandwidth_factor; -extern double sg_weight_S_parameter; -extern int sg_network_crosstraffic; -#ifdef HAVE_GTNETS -extern double sg_gtnets_jitter; -extern int sg_gtnets_jitter_seed; -#endif -extern xbt_dynar_t surf_path; +extern XBT_PRIVATE double sg_tcp_gamma; +extern XBT_PRIVATE double sg_sender_gap; +extern XBT_PRIVATE double sg_latency_factor; +extern XBT_PRIVATE double sg_bandwidth_factor; +extern XBT_PRIVATE double sg_weight_S_parameter; +extern XBT_PRIVATE int sg_network_crosstraffic; +extern XBT_PRIVATE xbt_dynar_t surf_path; typedef enum { SURF_NETWORK_ELEMENT_NULL = 0, /* NULL */ @@ -53,14 +49,14 @@ class NetworkModel; class StorageModel; class Resource; class ResourceLmm; +class Host; class HostCLM03; class NetworkCm02Link; -class Cpu; class Action; class ActionLmm; class StorageActionLmm; -struct As; -struct RoutingEdge; +class As; +class RoutingEdge; class RoutingPlatf; #else typedef struct Model Model; @@ -72,8 +68,8 @@ typedef struct StorageModel StorageModel; typedef struct Resource Resource; typedef struct ResourceLmm ResourceLmm; typedef struct HostCLM03 HostCLM03; +typedef struct Host Host; typedef struct NetworkCm02Link NetworkCm02Link; -typedef struct Cpu Cpu; typedef struct Action Action; typedef struct ActionLmm ActionLmm; typedef struct StorageActionLmm StorageActionLmm; @@ -98,9 +94,7 @@ typedef StorageModel *surf_storage_model_t; typedef xbt_dictelm_t surf_resource_t; typedef Resource *surf_cpp_resource_t; -typedef HostCLM03 *surf_host_CLM03_t; -typedef NetworkCm02Link *surf_network_link_t; -typedef Cpu *surf_cpu_t; +typedef Host *surf_host_t; /** @ingroup SURF_c_bindings * \brief Action structure @@ -150,8 +144,6 @@ XBT_PUBLIC(void) model_help(const char *category, /** @ingroup SURF_interface * @brief Action states * - * Action states. - * * @see Action */ typedef enum { @@ -160,8 +152,7 @@ typedef enum { SURF_ACTION_FAILED, /**< Task Failure */ SURF_ACTION_DONE, /**< Completed */ SURF_ACTION_TO_FREE, /**< Action to free in next cleanup */ - SURF_ACTION_NOT_IN_THE_SYSTEM - /**< Not in the system anymore. Why did you ask ? */ + SURF_ACTION_NOT_IN_THE_SYSTEM /**< Not in the system anymore. Why did you ask ? */ } e_surf_action_state_t; /** @ingroup SURF_vm_interface @@ -183,47 +174,21 @@ typedef enum { /* Generic model object */ /***************************/ -//FIXME:REMOVE typedef struct s_routing_platf s_routing_platf_t, *routing_platf_t; XBT_PUBLIC_DATA(routing_platf_t) routing_platf; -static inline void *surf_cpu_resource_priv(const void *host) { - return xbt_lib_get_level((xbt_dictelm_t)host, SURF_CPU_LEVEL); -} -static inline void *surf_host_resource_priv(const void *host){ - return (void*)xbt_lib_get_level((xbt_dictelm_t)host, SURF_HOST_LEVEL); -} -static inline void *surf_routing_resource_priv(const void *host){ - return (void*)xbt_lib_get_level((xbt_dictelm_t)host, ROUTING_HOST_LEVEL); +static inline surf_host_t surf_host_resource_priv(const void *host){ + return (surf_host_t) xbt_lib_get_level((xbt_dictelm_t)host, SURF_HOST_LEVEL); } static inline void *surf_storage_resource_priv(const void *storage){ return (void*)xbt_lib_get_level((xbt_dictelm_t)storage, SURF_STORAGE_LEVEL); } -static inline void *surf_cpu_resource_by_name(const char *name) { - return xbt_lib_get_elm_or_null(host_lib, name); -} -static inline void *surf_host_resource_by_name(const char *name){ - return xbt_lib_get_elm_or_null(host_lib, name); -} static inline void *surf_storage_resource_by_name(const char *name){ return xbt_lib_get_elm_or_null(storage_lib, name); } - -XBT_PUBLIC(char *) surf_routing_edge_name(sg_routing_edge_t edge); -XBT_PUBLIC(void *) surf_as_cluster_get_backbone(AS_t as); -XBT_PUBLIC(void) surf_as_cluster_set_backbone(AS_t as, void* backbone); - /** @{ @ingroup SURF_c_bindings */ -/** - * @brief Get the name of a surf model - * - * @param model A model - * @return The name of the model - */ -XBT_PUBLIC(const char *) surf_model_name(surf_model_t model); - /** * @brief Pop an action from the done actions set * @@ -278,45 +243,18 @@ XBT_PUBLIC(int) surf_model_running_action_set_size(surf_model_t model); */ XBT_PUBLIC(surf_action_t) surf_host_model_execute_parallel_task(surf_host_model_t model, int host_nb, - void **host_list, + sg_host_t *host_list, double *flops_amount, double *bytes_amount, double rate); -/** - * @brief Create a communication between two hosts - * - * @param model The model which handle the communication - * @param src The source host - * @param dst The destination host - * @param size The amount of data (in bytes) needed to transfer - * @param rate [description] - * @return The action corresponding to the communication - */ -XBT_PUBLIC(surf_action_t) surf_host_model_communicate(surf_host_model_t model, surf_resource_t src, surf_resource_t dst, double size, double rate); - -/** - * @brief Get the route between two hosts - * @details [long description] - * - * @param model The model which handle the routes - * @param src The source host - * @param dst The destination host - * @return The list of [TODO] from the source to the host - */ +/** @brief Get the route (dynar of sg_link_t) between two hosts */ XBT_PUBLIC(xbt_dynar_t) surf_host_model_get_route(surf_host_model_t model, surf_resource_t src, surf_resource_t dst); -/** - * @brief Create a new VM on the specified host - * - * @param name The name of the VM - * @param host_PM The host on which the VM is created - */ +/** @brief Create a new VM on the specified host */ XBT_PUBLIC(void) surf_vm_model_create(const char *name, surf_resource_t host_PM); -/** - * @brief Create a communication between two routing edges [TODO] - * @details [long description] +/** @brief Create a communication between two hosts * * @param model The model which handle the communication * @param src The source host @@ -325,7 +263,7 @@ XBT_PUBLIC(void) surf_vm_model_create(const char *name, surf_resource_t host_PM) * @param rate [description] * @return The action corresponding to the communication */ -XBT_PUBLIC(surf_action_t) surf_network_model_communicate(surf_network_model_t model, sg_routing_edge_t src, sg_routing_edge_t dst, double size, double rate); +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); /** * @brief Get the name of a surf resource (cpu, host, network, …) @@ -334,113 +272,56 @@ XBT_PUBLIC(surf_action_t) surf_network_model_communicate(surf_network_model_t mo * @return The name of the surf resource */ XBT_PUBLIC(const char * ) surf_resource_name(surf_cpp_resource_t resource); +static inline const char * surf_cpu_name(surf_cpu_t cpu) { + return surf_resource_name((surf_cpp_resource_t)cpu); +} -/** - * @brief Get the properties of a surf resource (cpu, host, network, …) - * - * @param resource The surf resource - * @return The properties of the surf resource - */ +/** @brief Get the properties of a surf resource (cpu, host, network, …) */ XBT_PUBLIC(xbt_dict_t) surf_resource_get_properties(surf_cpp_resource_t resource); +static XBT_INLINE xbt_dict_t surf_host_get_properties(surf_host_t host) { + return surf_resource_get_properties((surf_cpp_resource_t)host); +} -/** - * @brief Get the state of a surf resource (cpu, host, network, …) - * - * @param resource The surf resource - * @return The state of the surf resource - */ + +/** @brief Get the state of a surf resource (cpu, host, network, …) */ XBT_PUBLIC(e_surf_resource_state_t) surf_resource_get_state(surf_cpp_resource_t resource); -/** - * @brief Set the state of a surf resource (cpu, host, network, …) - * - * @param resource The surf resource - * @param state The new state of the surf resource - */ +static XBT_INLINE e_surf_resource_state_t surf_host_get_state(surf_host_t host) { + return surf_resource_get_state((surf_cpp_resource_t)host); +} + + +/** @brief Set the state of a surf resource (cpu, host, network, …) */ XBT_PUBLIC(void) surf_resource_set_state(surf_cpp_resource_t resource, e_surf_resource_state_t state); +static inline void surf_host_set_state(surf_host_t host, e_surf_resource_state_t state) { + surf_resource_set_state((surf_cpp_resource_t)host, state); +} -/** - * @brief Get the speed of the cpu associated to a host - * - * @param resource The surf host - * @param load [description] - * - * @return [description] - */ +/** @brief Get the speed of the cpu associated to a host */ XBT_PUBLIC(double) surf_host_get_speed(surf_resource_t resource, double load); -/** - * @brief Get the available speed of cpu associated to a host - * - * @param resource The surf host - * @return [description] - */ -XBT_PUBLIC(double) surf_host_get_available_speed(surf_resource_t resource); +/** @brief Get the available speed of cpu associated to a host */ +XBT_PUBLIC(double) surf_host_get_available_speed(surf_resource_t host); -/** - * @brief Get the number of cores of the cpu associated to a host - * - * @param resource The surf host - * @return The number of cores - */ -XBT_PUBLIC(int) surf_host_get_core(surf_resource_t resource); +/** @brief Get the number of cores of the cpu associated to a host */ +XBT_PUBLIC(int) surf_host_get_core(surf_resource_t host); -/** - * @brief Execute some quantity of computation - * - * @param resource The surf host - * @param size The value of the processing amount (in flop) needed to process - * - * @return The surf action corresponding to the processing - */ -XBT_PUBLIC(surf_action_t) surf_host_execute(surf_resource_t resource, double size); +/** @brief Create a computation action on the given host */ +XBT_PUBLIC(surf_action_t) surf_host_execute(surf_resource_t host, double size); -/** - * @brief Make the host sleep - * - * @param resource The surf host - * @param duration The number of seconds to sleep - * @return The surf action corresponding to the sleep - */ -XBT_PUBLIC(surf_action_t) surf_host_sleep(surf_resource_t resource, double duration); +/** @brief Create a sleep action on the given host */ +XBT_PUBLIC(surf_action_t) surf_host_sleep(surf_resource_t host, double duration); -/** - * @brief Open a file on an host - * - * @param host The surf host - * @param fullpath The path to the file - * @return The surf action corresponding to the openning - */ +/** @brief Create a file opening action on the given host */ XBT_PUBLIC(surf_action_t) surf_host_open(surf_resource_t host, const char* fullpath); -/** - * @brief Close a file descriptor on an host - * - * @param host The surf host - * @param fd The file descriptor - * - * @return The surf action corresponding to the closing - */ +/** @brief Create a file closing action on the given host */ XBT_PUBLIC(surf_action_t) surf_host_close(surf_resource_t host, surf_file_t fd); -/** - * @brief Read a file - * - * @param host The surf host - * @param fd The file descriptor to read - * @param size The size in bytes to read - * @return The surf action corresponding to the reading - */ +/** @brief Create a file reading action on the given host */ XBT_PUBLIC(surf_action_t) surf_host_read(surf_resource_t host, surf_file_t fd, sg_size_t size); -/** - * @brief Write a file - * - * @param host The surf host - * @param fd The file descriptor to write - * @param size The size in bytes to write - * @return The surf action corresponding to the writing - */ +/** @brief Create a file writing action on the given host */ XBT_PUBLIC(surf_action_t) surf_host_write(surf_resource_t host, surf_file_t fd, sg_size_t size); /** @@ -476,31 +357,18 @@ XBT_PUBLIC(sg_size_t) surf_host_get_free_size(surf_resource_t resource, const ch */ XBT_PUBLIC(sg_size_t) surf_host_get_used_size(surf_resource_t resource, const char* name); -/** - * @brief Get the VMs hosted on the host - * - * @param resource The surf host - * @return The list of VMs on the host - */ +/** @brief Get the list of VMs hosted on the host */ XBT_PUBLIC(xbt_dynar_t) surf_host_get_vms(surf_resource_t resource); -/** - * @brief [brief description] - * @details [long description] - * - * @param resource [description] - * @param params [description] +/** @brief Retrieve the params of that VM + * @details You can use fields ramsize and overcommit on a PM, too. */ -XBT_PUBLIC(void) surf_host_get_params(surf_resource_t resource, ws_params_t params); +XBT_PUBLIC(void) surf_host_get_params(surf_resource_t resource, vm_params_t params); -/** - * @brief [brief description] - * @details [long description] - * - * @param resource [description] - * @param params [description] +/** @brief Sets the params of that VM/PM + * @details You can use fields ramsize and overcommit on a PM, too. */ -XBT_PUBLIC(void) surf_host_set_params(surf_resource_t resource, ws_params_t params); +XBT_PUBLIC(void) surf_host_set_params(surf_resource_t resource, vm_params_t params); /** * @brief Destroy a VM @@ -509,18 +377,10 @@ XBT_PUBLIC(void) surf_host_set_params(surf_resource_t resource, ws_params_t para */ XBT_PUBLIC(void) surf_vm_destroy(surf_resource_t resource); -/** - * @brief Suspend a VM - * - * @param resource The surf vm - */ +/** @brief Suspend a VM */ XBT_PUBLIC(void) surf_vm_suspend(surf_resource_t resource); -/** - * @brief Resume a VM - * - * @param resource The surf vm - */ +/** @brief Resume a VM */ XBT_PUBLIC(void) surf_vm_resume(surf_resource_t resource); /** @@ -707,31 +567,6 @@ XBT_PUBLIC(int) surf_host_file_seek(surf_resource_t host, surf_file_t fd, sg_offset_t offset, int origin); -/** - * @brief [brief description] - * @details [long description] - * - * @param link [description] - * @return [description] - */ -XBT_PUBLIC(int) surf_network_link_is_shared(surf_cpp_resource_t link); - -/** - * @brief Get the bandwidth of a link in bytes per second - * - * @param link The surf link - * @return The bandwidth in bytes per second - */ -XBT_PUBLIC(double) surf_network_link_get_bandwidth(surf_cpp_resource_t link); - -/** - * @brief Get the latency of a link in seconds - * - * @param link The surf link - * @return The latency in seconds - */ -XBT_PUBLIC(double) surf_network_link_get_latency(surf_cpp_resource_t link); - /** * @brief Get the content of a storage * @@ -1047,23 +882,9 @@ XBT_PUBLIC(void) surf_network_model_init_Constant(void); */ XBT_PUBLIC(void) surf_network_model_init_CM02(void); -#ifdef HAVE_GTNETS -/** \ingroup SURF_models - * \brief Initializes the platform with the network model GTNETS - * \param filename XML platform file name - * - * This function is called by surf_host_model_init_GTNETS - * or by yourself only if you plan using surf_host_model_init_compound - * - * \see surf_host_model_init_GTNETS() - */ -XBT_PUBLIC(void) surf_network_model_init_GTNETS(void); -#endif - #ifdef HAVE_NS3 /** \ingroup SURF_models * \brief Initializes the platform with the network model NS3 - * \param filename XML platform file name * * This function is called by surf_host_model_init_NS3 * or by yourself only if you plan using surf_host_model_init_compound @@ -1075,7 +896,6 @@ XBT_PUBLIC(void) surf_network_model_init_NS3(void); /** \ingroup SURF_models * \brief Initializes the platform with the network model Reno - * \param filename XML platform file name * * The problem is related to max( sum( arctan(C * Df * xi) ) ). * @@ -1090,7 +910,6 @@ XBT_PUBLIC(void) surf_network_model_init_Reno(void); /** \ingroup SURF_models * \brief Initializes the platform with the network model Reno2 - * \param filename XML platform file name * * The problem is related to max( sum( arctan(C * Df * xi) ) ). * @@ -1105,7 +924,6 @@ XBT_PUBLIC(void) surf_network_model_init_Reno2(void); /** \ingroup SURF_models * \brief Initializes the platform with the network model Vegas - * \param filename XML platform file name * * This problem is related to max( sum( a * Df * ln(xi) ) ) which is equivalent * to the proportional fairness. @@ -1218,11 +1036,10 @@ XBT_PUBLIC_DATA(s_surf_model_description_t) /** \ingroup SURF_models * \brief List of initialized models */ -XBT_PUBLIC_DATA(xbt_dynar_t) model_list; -XBT_PUBLIC_DATA(xbt_dynar_t) model_list_invoke; +XBT_PUBLIC_DATA(xbt_dynar_t) all_existing_models; /** \ingroup SURF_simulation - * \brief List of hosts that have juste restarted and whose autorestart process should be restarted. + * \brief List of hosts that have just restarted and whose autorestart process should be restarted. */ XBT_PUBLIC_DATA(xbt_dynar_t) host_that_restart; @@ -1347,5 +1164,12 @@ int instr_platform_traced (void); xbt_graph_t instr_routing_platform_graph (void); void instr_routing_platform_graph_export_graphviz (xbt_graph_t g, const char *filename); +/********** Routing **********/ +void routing_AS_begin(sg_platf_AS_cbarg_t AS); +void routing_AS_end(void); +RoutingEdge *routing_add_host(As* as, sg_platf_host_cbarg_t host); +void routing_cluster_add_backbone(void* bb); +As* routing_get_current(); + SG_END_DECL() #endif /* _SURF_SURF_H */