Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Factorize some code in SURF
[simgrid.git] / src / include / surf / surf.h
index 92b1c62da5bfb0ab1e239eb00f0a09e41394e2ea..9ea2ec230d0130ecc2f804825ff3ce81c490596a 100644 (file)
@@ -13,6 +13,7 @@
 #include "xbt/dict.h"
 #include "xbt/misc.h"
 #include "portable.h"
+#include "xbt/config.h"
 
 SG_BEGIN_DECL()
 
@@ -21,7 +22,7 @@ SG_BEGIN_DECL()
 /* Actions and models are higly connected structures... */
 /** \brief Action datatype
  *  \ingroup SURF_actions
- *  
+ *
  * An action is some working amount on a model.
  * It is represented as a cost, a priority, a duration and a state.
  *
@@ -31,7 +32,7 @@ SG_BEGIN_DECL()
 
 /** \brief Model datatype
  *  \ingroup SURF_models
- *  
+ *
  *  Generic data structure for a model. The workstations,
  *  the CPUs and the network links are examples of models.
  */
@@ -57,7 +58,7 @@ XBT_PUBLIC(int) find_model_description(s_surf_model_description_t * table,
  *
  *  Never create s_surf_action_t by yourself ! The actions are created
  *  on the fly when you call execute or communicate on a model.
- *  
+ *
  *  \see e_surf_action_state_t
  */
      typedef struct surf_action {
@@ -172,15 +173,19 @@ XBT_PUBLIC(int) find_model_description(s_surf_model_description_t * table,
 
 /** \brief Model datatype
  *  \ingroup SURF_models
- *  
+ *
  *  Generic data structure for a model. The workstations,
  *  the CPUs and the network links are examples of models.
  */
      typedef struct surf_model {
+       s_surf_model_public_t common_public;
        surf_model_private_t common_private;
-       surf_model_public_t common_public;
      } s_surf_model_t;
 
+     void surf_model_init(surf_model_t model);
+     void surf_model_exit(surf_model_t model);
+
+
 /**************************************/
 /* Implementations of model object */
 /**************************************/
@@ -200,8 +205,8 @@ XBT_PUBLIC(int) find_model_description(s_surf_model_description_t * table,
  *  \ingroup SURF_models
  */
      typedef struct surf_timer_model {
+       s_surf_model_public_t common_public;
        surf_model_private_t common_private;
-       surf_model_public_t common_public;
        surf_timer_model_extension_public_t extension_public;
      } s_surf_timer_model_t, *surf_timer_model_t;
 
@@ -227,7 +232,7 @@ XBT_PUBLIC(void) surf_timer_model_init(const char *filename);
 
 /** \brief CPU model extension public
  *  \ingroup SURF_models
- *  
+ *
  *  Public functions specific to the CPU model.
  */
      typedef struct surf_cpu_model_extension_public {
@@ -243,8 +248,8 @@ XBT_PUBLIC(void) surf_timer_model_init(const char *filename);
  *  \ingroup SURF_models
  */
      typedef struct surf_cpu_model {
+       s_surf_model_public_t common_public;
        surf_model_private_t common_private;
-       surf_model_public_t common_public;
        surf_cpu_model_extension_public_t extension_public;
      } s_surf_cpu_model_t, *surf_cpu_model_t;
 
@@ -291,8 +296,8 @@ XBT_PUBLIC_DATA(s_surf_model_description_t) surf_cpu_model_description[];
  *  \ingroup SURF_models
  */
      typedef struct surf_network_model {
+       s_surf_model_public_t common_public;
        surf_model_private_t common_private;
-       surf_model_public_t common_public;
        surf_network_model_extension_public_t extension_public;
      } s_surf_network_model_t, *surf_network_model_t;
 
@@ -392,7 +397,7 @@ XBT_PUBLIC(void) surf_network_model_init_Reno2(const char *filename);
  *  \ingroup SURF_models
  *  \param filename XML platform file name
  *
- *  This problem is related to max( sum( a * Df * ln(xi) ) ) which is equivalent 
+ *  This problem is related to max( sum( a * Df * ln(xi) ) ) which is equivalent
  *  to the proportional fairness.
  *
  *  Reference:
@@ -414,7 +419,7 @@ XBT_PUBLIC(void) surf_network_model_init_Vegas(const char *filename);
  *
  *  Reference:
  *
- *  [TAG03]. Corinne Touati, Eitan Altman, and Jerome Galtier.  
+ *  [TAG03]. Corinne Touati, Eitan Altman, and Jerome Galtier.
  *  Semi-definite programming approach for bandwidth allocation and routing in networks.
  *  Game Theory and Applications, 9:169-179, December 2003. Nova publisher.
  *
@@ -463,8 +468,8 @@ XBT_PUBLIC_DATA(s_surf_model_description_t) surf_network_model_description[];
  *
  */
      typedef struct surf_workstation_model {
+       s_surf_model_public_t common_public;
        surf_model_private_t common_private;
-       surf_model_public_t common_public;
        surf_workstation_model_extension_public_t extension_public;
      } s_surf_workstation_model_t, *surf_workstation_model_t;
 
@@ -558,6 +563,7 @@ XBT_PUBLIC_DATA(xbt_dynar_t) model_list;
 /*******************************************/
 /*** SURF Globals **************************/
 /*******************************************/
+XBT_PUBLIC_DATA(xbt_cfg_t) _surf_cfg_set;
 
 /** \brief Initialize SURF
  *  \ingroup SURF_simulation
@@ -575,6 +581,21 @@ XBT_PUBLIC_DATA(xbt_dynar_t) model_list;
  */
 XBT_PUBLIC(void) surf_init(int *argc, char **argv);     /* initialize common structures */
 
+/** \brief Initialize the used models.
+ *
+ * Must be called after the surf_init so that configuration infrastructure is created
+ * Must be called before parsing/creating the environment
+ * Must not be called within the initialization process so that the use get a chance to change the settings from
+ * its code between, say, MSG_init and MSG_create_environment using MSG_config
+ */
+XBT_PUBLIC(void) surf_config_models_setup(const char *platform_file);
+
+/** \brief create the elements of the models
+ *
+ * Must be called after parsing the platform file and before using any elements
+ */
+XBT_PUBLIC(void) surf_config_models_create_elms(void);
+
 /** \brief Finish simulation initialization
  *  \ingroup SURF_simulation
  *