Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
less void*, more sg_host_t
[simgrid.git] / src / include / surf / surf.h
index 98b848f..3d2b1f7 100644 (file)
@@ -53,9 +53,9 @@ class NetworkModel;
 class StorageModel;
 class Resource;
 class ResourceLmm;
+class Host;
 class HostCLM03;
 class NetworkCm02Link;
-class Cpu;
 class Action;
 class ActionLmm;
 class StorageActionLmm;
@@ -72,8 +72,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 +98,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
@@ -160,8 +158,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,44 +180,27 @@ 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
+/** @brief Get the name of a surf model (dont rely on exact value)
  *
- * @param model A model
- * @return The name of the model
+ * This is implemented using typeid(), so it may change with the compiler
  */
 XBT_PUBLIC(const char *) surf_model_name(surf_model_t model);
 
@@ -278,23 +258,11 @@ 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]
@@ -315,8 +283,7 @@ XBT_PUBLIC(xbt_dynar_t) surf_host_model_get_route(surf_host_model_t model, surf_
 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 routing edges
  *
  * @param model The model which handle the communication
  * @param src The source host
@@ -325,7 +292,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,6 +301,9 @@ 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, …)
@@ -342,6 +312,10 @@ XBT_PUBLIC(const char * ) surf_resource_name(surf_cpp_resource_t resource);
  * @return The properties of the surf resource
  */
 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, …)
@@ -351,6 +325,11 @@ XBT_PUBLIC(xbt_dict_t) surf_resource_get_properties(surf_cpp_resource_t resource
  */
 XBT_PUBLIC(e_surf_resource_state_t) surf_resource_get_state(surf_cpp_resource_t 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, …)
  *
@@ -358,6 +337,9 @@ XBT_PUBLIC(e_surf_resource_state_t) surf_resource_get_state(surf_cpp_resource_t
  * @param state The new state of the surf resource
  */
 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
@@ -707,31 +689,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
  *