Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add model storage to surf and add a tag storage to dtd.
[simgrid.git] / src / include / surf / surf.h
index bc8b862..2c0d086 100644 (file)
@@ -25,7 +25,7 @@ typedef enum {
   SURF_NETWORK_ELEMENT_NULL = 0,        /* NULL */
   SURF_NETWORK_ELEMENT_HOST,    /* host type */
   SURF_NETWORK_ELEMENT_ROUTER,  /* router type */
-  SURF_NETWORK_ELEMENT_AS,      /* AS type */
+  SURF_NETWORK_ELEMENT_AS       /* AS type */
 } e_surf_network_element_type_t;
 
 XBT_PUBLIC(e_surf_network_element_type_t)
@@ -193,6 +193,30 @@ typedef struct surf_network_model_extension_public {
                            xbt_dict_t properties);
 } s_surf_model_extension_network_t;
 
+typedef struct s_surf_file {
+  char *name;                   /**< @brief host name if any */
+  void *data;                   /**< @brief user data */
+} s_surf_file_t;
+typedef struct s_surf_file *surf_file_t;
+
+/* Storage model */
+
+/** \brief Storage model extension public
+ *  \ingroup SURF_models
+ *
+ *  Public functions specific to the Storage model.
+ */
+
+typedef struct surf_storage_model_extension_public {
+  surf_action_t(*open) (void *workstation, const char* path, const char* mode);
+  surf_action_t(*close) (void *workstation, surf_file_t fp);
+  surf_action_t(*read) (void *workstation, void* ptr, size_t size, size_t nmemb, surf_file_t stream);
+  surf_action_t(*write) (void *workstation, const void* ptr, size_t size, size_t nmemb, surf_file_t stream);
+  surf_action_t(*stat) (void *workstation, int fd, void* buf);
+  void* (*create_resource) (const char* id, const char* model,
+      const char* content, xbt_dict_t properties);
+} s_surf_model_extension_storage_t;
+
      /** \brief Workstation model extension public
       *  \ingroup SURF_models
       *
@@ -218,6 +242,11 @@ typedef struct surf_workstation_model_extension_public {
                                           double amount, double rate);
   double (*get_link_bandwidth) (const void *link);                                         /**< Return the current bandwidth of a network link */
   double (*get_link_latency) (const void *link);                                           /**< Return the current latency of a network link */
+  surf_action_t(*open) (void *workstation, const char* path, const char* mode);
+  surf_action_t(*close) (void *workstation, surf_file_t fp);
+  surf_action_t(*read) (void *workstation, void* ptr, size_t size, size_t nmemb, surf_file_t stream);
+  surf_action_t(*write) (void *workstation, const void* ptr, size_t size, size_t nmemb, surf_file_t stream);
+  surf_action_t(*stat) (void *workstation, int fd, void* buf);
   int (*link_shared) (const void *link);
    xbt_dict_t(*get_properties) (const void *resource);
   void* (*link_create_resource) (const char *name,
@@ -283,6 +312,7 @@ typedef struct surf_model {
   union extension {
     s_surf_model_extension_cpu_t cpu;
     s_surf_model_extension_network_t network;
+    s_surf_model_extension_storage_t storage;
     s_surf_model_extension_workstation_t workstation;
   } extension;
 } s_surf_model_t;
@@ -299,6 +329,9 @@ static inline void *surf_workstation_resource_by_name(const char *name){
 static inline void *surf_network_resource_by_name(const char *name){
        return xbt_lib_get_or_null(link_lib, name, SURF_LINK_LEVEL);
 }
+static inline void *surf_storage_resource_by_name(const char *name) {
+    return xbt_lib_get_or_null(storage_lib, name, SURF_STORAGE_LEVEL);
+}
 
 typedef struct surf_resource {
   surf_model_t model;
@@ -306,8 +339,6 @@ typedef struct surf_resource {
   xbt_dict_t properties;
 } s_surf_resource_t, *surf_resource_t;
 
-
-
 /**
  * Resource which have a metric handled by a maxmin system
  */
@@ -398,45 +429,29 @@ XBT_PUBLIC_DATA(surf_model_t) surf_network_model;
 
 /** \brief Same as network model 'LagrangeVelho', only with different correction factors.
  *  \ingroup SURF_models
- *  \param filename XML platform file name
  *
  * This model is proposed by Pierre-Nicolas Clauss and Martin Quinson and Stéphane Génaud
  * based on the model 'LV08' and different correction factors depending on the communication
  * size (< 1KiB, < 64KiB, >= 64KiB).
+ * See comments in the code for more information.
  *
  *  \see surf_workstation_model_init_SMPI()
  */
 XBT_PUBLIC(void) surf_network_model_init_SMPI(void);
 
-/** \brief Initializes the platform with the network model 'LagrangeVelho'
+/** \brief Initializes the platform with the network model 'LegrandVelho'
  *  \ingroup SURF_models
- *  \param filename XML platform file name
  *
  * This model is proposed by Arnaud Legrand and Pedro Velho based on
  * the results obtained with the GTNets simulator for onelink and
- * dogbone sharing scenarios.
+ * dogbone sharing scenarios. See comments in the code for more information.
  *
  *  \see surf_workstation_model_init_LegrandVelho()
  */
 XBT_PUBLIC(void) surf_network_model_init_LegrandVelho(void);
 
-
-/** \brief Initializes the platform with the network model 'LV08_im'
- *  \ingroup SURF_models
- *  \param filename XML platform file name
- *
- * This model is adds the lazy management improvement to Legrand and
- * Velho model. This improvement essentially replaces the list of actions
- * inside the simulation kernel by a heap in order to reduce the complexity
- * at each iteration of the simulation kernel.
- *
- *  \see surf_workstation_model_init_LegrandVelho()
- */
-XBT_PUBLIC(void) im_surf_network_model_init_LegrandVelho(void);
-
 /** \brief Initializes the platform with the network model 'Constant'
  *  \ingroup SURF_models
- *  \param filename XML platform file name
  *
  *  In this model, the communication time between two network cards is
  *  constant, hence no need for a routing table. This is particularly
@@ -450,10 +465,10 @@ XBT_PUBLIC(void) surf_network_model_init_Constant(void);
 
 /** \brief Initializes the platform with the network model CM02
  *  \ingroup SURF_models
- *  \param filename XML platform file name
  *
  *  This function is called by surf_workstation_model_init_CLM03
  *  or by yourself only if you plan using surf_workstation_model_init_compound
+ *  See comments in the code for more information.
  *
  *  \see surf_workstation_model_init_CLM03()
  */
@@ -558,6 +573,27 @@ XBT_PUBLIC_DATA(s_surf_model_description_t)
     surf_network_model_description[];
 
 
+
+
+
+
+/** \brief The storage model
+ *  \ingroup SURF_models
+ */
+XBT_PUBLIC(void) surf_storage_model_init_default(void);
+
+/** \brief The list of all available storage modes.
+ *  \ingroup SURF_models
+ *  This storage mode can be set using --cfg=storage/model:...
+ */
+XBT_PUBLIC_DATA(s_surf_model_description_t) surf_storage_model_description[];
+
+
+
+
+
+
+
 /** \brief The workstation model
  *  \ingroup SURF_models
  *
@@ -666,7 +702,7 @@ XBT_PUBLIC(double) surf_solve(double max_date);
  *
  *  Return the current time in millisecond.
  */
-XBT_INLINE XBT_PUBLIC(double) surf_get_clock(void);
+XBT_PUBLIC(double) surf_get_clock(void);
 
 /** \brief Exit SURF
  *  \ingroup SURF_simulation
@@ -698,5 +734,8 @@ XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_latency;
 
 XBT_PUBLIC(double) get_cpu_power(const char *power);
 
+int surf_get_nthreads(void);
+void surf_set_nthreads(int nthreads);
+
 SG_END_DECL()
 #endif                          /* _SURF_SURF_H */