Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove useless function
[simgrid.git] / src / surf / maxmin_private.hpp
1 /* Copyright (c) 2004-2017. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef SURF_MAXMIN_PRIVATE_H
7 #define SURF_MAXMIN_PRIVATE_H
8
9 #include "surf/maxmin.h"
10 #include "xbt/swag.h"
11 #include "xbt/mallocator.h"
12 #include "surf_interface.hpp"
13
14 /** @ingroup SURF_lmm
15  * @brief LMM element
16  * Elements can be seen as glue between constraint objects and variable objects.
17  * Basically, each variable will have a set of elements, one for each constraint where it is involved.
18  * Then, it is used to list all variables involved in constraint through constraint's xxx_element_set lists, or vice-versa list all constraints for a given variable.
19  */
20 typedef struct lmm_element {
21   /* hookup to constraint */
22   s_xbt_swag_hookup_t enabled_element_set_hookup;
23   s_xbt_swag_hookup_t disabled_element_set_hookup;
24   s_xbt_swag_hookup_t active_element_set_hookup;
25
26   lmm_constraint_t constraint;
27   lmm_variable_t variable;
28
29   // consumption_weight: impact of 1 byte or flop of your application onto the resource (in byte or flop)
30   //   - if CPU, then probably 1.
31   //   - If network, then 1 in forward direction and 0.05 backward for the ACKs
32   double consumption_weight;
33 } s_lmm_element_t;
34 #define make_elem_active(elem) xbt_swag_insert_at_head(elem,&(elem->constraint->active_element_set))
35 #define make_elem_inactive(elem) xbt_swag_remove(elem,&(elem->constraint->active_element_set))
36
37 typedef struct lmm_constraint_light {
38   double remaining_over_usage;
39   lmm_constraint_t cnst;
40 } s_lmm_constraint_light_t;
41
42 /** @ingroup SURF_lmm
43  * @brief LMM constraint
44  * Each constraint contains several partially overlapping logical sets of elements:
45  * \li Disabled elements which variable's weight is zero. This variables are not at all processed by LMM, but eventually the corresponding action will enable it (at least this is the idea).
46  * \li Enabled elements which variable's weight is non-zero. They are utilized in some LMM functions.
47  * \li Active elements which variable's weight is non-zero (i.e. it is enabled) AND its element value is non-zero. LMM_solve iterates over active elements during resolution, dynamically making them active or unactive.
48  *
49  */
50 typedef struct lmm_constraint {
51   /* hookup to system */
52   s_xbt_swag_hookup_t constraint_set_hookup;
53   s_xbt_swag_hookup_t active_constraint_set_hookup;
54   s_xbt_swag_hookup_t modified_constraint_set_hookup;
55   s_xbt_swag_hookup_t saturated_constraint_set_hookup;
56
57   s_xbt_swag_t enabled_element_set;     /* a list of lmm_element_t */
58   s_xbt_swag_t disabled_element_set;     /* a list of lmm_element_t */
59   s_xbt_swag_t active_element_set;      /* a list of lmm_element_t */
60   double remaining;
61   double usage;
62   double bound;
63   int concurrency_limit; /* The maximum number of variables that may be enabled at any time (stage variables if necessary) */
64   //TODO MARTIN Check maximum value across resources at the end of simulation and give a warning is more than e.g. 500
65   int concurrency_current; /* The current concurrency */
66   int concurrency_maximum; /* The maximum number of (enabled and disabled) variables associated to the constraint at any given time (essentially for tracing)*/
67
68   int sharing_policy; /* see @e_surf_link_sharing_policy_t (0: FATPIPE, 1: SHARED, 2: FULLDUPLEX) */
69   void *id;
70   int id_int;
71   double lambda;
72   double new_lambda;
73   lmm_constraint_light_t cnst_light;
74 } s_lmm_constraint_t;
75
76 /** @ingroup SURF_lmm
77  * @brief LMM variable
78  *
79  * When something prevents us from enabling a variable, we "stage" the weight that we would have like to set, so that as soon as possible we enable the variable with desired weight
80  */
81 typedef struct lmm_variable {
82   /* hookup to system */
83   s_xbt_swag_hookup_t variable_set_hookup;
84   s_xbt_swag_hookup_t saturated_variable_set_hookup;
85
86   s_lmm_element_t *cnsts;
87   int cnsts_size;
88   int cnsts_number;
89
90   // sharing_weight: variable's impact on the resource during the sharing
91   //   if == 0, the variable is not considered by LMM
92   //   on CPU, actions with N threads have a sharing of N
93   //   on network, the actions with higher latency have a lesser sharing_weight
94   double sharing_weight;
95
96   double staged_weight; /* If non-zero, variable is staged for addition as soon as maxconcurrency constraints will be met */
97   double bound;
98   double value;
99   short int concurrency_share; /* The maximum number of elements that variable will add to a constraint */
100   simgrid::surf::Action* id;
101   int id_int;
102   unsigned visited;             /* used by lmm_update_modified_set */
103   /* \begin{For Lagrange only} */
104   double mu;
105   double new_mu;
106   double (*func_f) (struct lmm_variable * var, double x);       /* (f)    */
107   double (*func_fp) (struct lmm_variable * var, double x);      /* (f')    */
108   double (*func_fpi) (struct lmm_variable * var, double x);     /* (f')^{-1}    */
109   /* \end{For Lagrange only} */
110 } s_lmm_variable_t;
111
112 /** @ingroup SURF_lmm
113  * @brief LMM system
114  */
115 typedef struct lmm_system {
116   int modified;
117   bool selective_update_active;  /* flag to update partially the system only selecting changed portions */
118   unsigned visited_counter;     /* used by lmm_update_modified_set  and lmm_remove_modified_set to cleverly (un-)flag the constraints (more details in these functions)*/
119   s_xbt_swag_t variable_set;    /* a list of lmm_variable_t */
120   s_xbt_swag_t constraint_set;  /* a list of lmm_constraint_t */
121
122   s_xbt_swag_t active_constraint_set;   /* a list of lmm_constraint_t */
123   s_xbt_swag_t modified_constraint_set; /* a list of modified lmm_constraint_t */
124
125   s_xbt_swag_t saturated_variable_set;  /* a list of lmm_variable_t */
126   s_xbt_swag_t saturated_constraint_set;        /* a list of lmm_constraint_t_t */
127
128   simgrid::surf::ActionLmmListPtr keep_track;
129
130   xbt_mallocator_t variable_mallocator;
131
132   void (*solve_fun)(lmm_system_t self);
133 } s_lmm_system_t;
134
135 #define extract_variable(sys) xbt_swag_extract(&(sys->variable_set))
136 #define extract_constraint(sys) xbt_swag_extract(&(sys->constraint_set))
137 #define insert_constraint(sys,cnst) xbt_swag_insert(cnst,&(sys->constraint_set))
138 #define remove_variable(sys,var) do {xbt_swag_remove(var,&(sys->variable_set));\
139                                  xbt_swag_remove(var,&(sys->saturated_variable_set));} while(0)
140 #define remove_constraint(sys,cnst) do {xbt_swag_remove(cnst,&(sys->constraint_set));\
141                                         xbt_swag_remove(cnst,&(sys->saturated_constraint_set));} while(0)
142 #define make_constraint_active(sys,cnst) xbt_swag_insert(cnst,&(sys->active_constraint_set))
143 #define make_constraint_inactive(sys,cnst) \
144   do { xbt_swag_remove(cnst, &sys->active_constraint_set);              \
145     xbt_swag_remove(cnst, &sys->modified_constraint_set); } while (0)
146
147 /** @ingroup SURF_lmm
148  * @brief Print information about a lmm system
149  *
150  * @param sys A lmm system
151  */
152 //XBT_PRIVATE void lmm_print(lmm_system_t sys);
153
154 extern XBT_PRIVATE double (*func_f_def) (lmm_variable_t, double);
155 extern XBT_PRIVATE double (*func_fp_def) (lmm_variable_t, double);
156 extern XBT_PRIVATE double (*func_fpi_def) (lmm_variable_t, double);
157
158 #endif /* SURF_MAXMIN_PRIVATE_H */