Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Initialize another bunch of variables.
[simgrid.git] / src / surf / network.hpp
1 #include "surf.hpp"
2 #include "xbt/fifo.h"
3 #include "xbt/graph.h"
4 #include "surf_routing.hpp"
5
6 #ifndef SURF_MODEL_NETWORK_H_
7 #define SURF_MODEL_NETWORK_H_
8
9 /***********
10  * Classes *
11  ***********/
12 class NetworkCm02Model;
13 typedef NetworkCm02Model *NetworkCm02ModelPtr;
14
15 class NetworkCm02Link;
16 typedef NetworkCm02Link *NetworkCm02LinkPtr;
17
18 class NetworkCm02LinkLmm;
19 typedef NetworkCm02LinkLmm *NetworkCm02LinkLmmPtr;
20
21 class NetworkCm02Action;
22 typedef NetworkCm02Action *NetworkCm02ActionPtr;
23
24 class NetworkCm02ActionLmm;
25 typedef NetworkCm02ActionLmm *NetworkCm02ActionLmmPtr;
26
27 /*********
28  * Tools *
29  *********/
30 extern NetworkCm02ModelPtr surf_network_model;
31
32 void net_define_callbacks(void);
33
34 /*********
35  * Model *
36  *********/
37 class NetworkCm02Model : public Model {
38 private:
39   void initialize();
40 public:
41   NetworkCm02Model(int /*i*/) : Model("network") {
42         f_networkSolve = lmm_solve;
43         m_haveGap = false;
44   };//FIXME: add network clean interface
45   NetworkCm02Model(string name) : Model(name) {
46     this->initialize();
47   }
48   NetworkCm02Model() : Model("network") {
49     this->initialize();
50   }
51   //FIXME:NetworkCm02LinkPtr createResource(string name);
52   NetworkCm02LinkLmmPtr createResource(const char *name,
53                                    double bw_initial,
54                                    tmgr_trace_t bw_trace,
55                                    double lat_initial,
56                                    tmgr_trace_t lat_trace,
57                                    e_surf_resource_state_t state_initial,
58                                    tmgr_trace_t state_trace,
59                                    e_surf_link_sharing_policy_t policy,
60                                    xbt_dict_t properties);
61   void updateActionsStateLazy(double now, double delta);
62   virtual void gapAppend(double /*size*/, const NetworkCm02LinkLmmPtr /*link*/, NetworkCm02ActionLmmPtr /*action*/) {};
63   virtual ActionPtr communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
64                                            double size, double rate);
65   xbt_dynar_t getRoute(RoutingEdgePtr src, RoutingEdgePtr dst); //FIXME: kill field? That is done by the routing nowadays
66   //FIXME: virtual void addTraces() =0;
67   void (*f_networkSolve)(lmm_system_t);
68   virtual double latencyFactor(double size);
69   virtual double bandwidthFactor(double size);
70   virtual double bandwidthConstraint(double rate, double bound, double size);
71   bool m_haveGap;
72 };
73
74 /************
75  * Resource *
76  ************/
77
78 class NetworkCm02Link : virtual public Resource {
79 public:
80   NetworkCm02Link() : p_latEvent(NULL) {};
81   NetworkCm02Link(NetworkCm02ModelPtr model, const char* name, xbt_dict_t properties)
82     : Resource(model, name, properties), p_latEvent(NULL) {};
83   virtual double getBandwidth()=0;
84   virtual double getLatency();
85   virtual bool isShared()=0;
86   /* Using this object with the public part of
87     model does not make sense */
88   double m_latCurrent;
89   tmgr_trace_event_t p_latEvent;
90 };
91
92 class NetworkCm02LinkLmm : public ResourceLmm, public NetworkCm02Link {
93 public:
94   NetworkCm02LinkLmm(NetworkCm02ModelPtr model, const char* name, xbt_dict_t properties)
95    : ResourceLmm(), NetworkCm02Link(model, name, properties) {};
96   NetworkCm02LinkLmm(NetworkCm02ModelPtr model, const char *name, xbt_dict_t props,
97                                    lmm_system_t system,
98                                    double constraint_value,
99                                    tmgr_history_t history,
100                                    e_surf_resource_state_t state_init,
101                                    tmgr_trace_t state_trace,
102                                    double metric_peak,
103                                    tmgr_trace_t metric_trace,
104                                    double lat_initial,
105                                    tmgr_trace_t lat_trace,
106                                e_surf_link_sharing_policy_t policy);
107   bool isShared();
108   bool isUsed();
109   double getBandwidth();
110   void updateState(tmgr_trace_event_t event_type, double value, double date);
111 };
112
113
114 /**********
115  * Action *
116  **********/
117 class NetworkCm02Action : virtual public Action {
118 public:
119   NetworkCm02Action(ModelPtr model, double cost, bool failed)
120  : Action(model, cost, failed) {};
121   double m_latency;
122   double m_latCurrent;
123   double m_weight;
124   double m_rate;
125   const char* p_senderLinkName;
126   double m_senderGap;
127   double m_senderSize;
128   xbt_fifo_item_t p_senderFifoItem;
129 #ifdef HAVE_LATENCY_BOUND_TRACKING
130   int m_latencyLimited;
131 #endif
132
133 };
134
135 class NetworkCm02ActionLmm : public ActionLmm, public NetworkCm02Action {
136 public:
137   NetworkCm02ActionLmm(ModelPtr model, double cost, bool failed)
138  : Action(model, cost, failed),
139    ActionLmm(model, cost, failed),
140    NetworkCm02Action(model, cost, failed) {};
141   void updateRemainingLazy(double now);
142   void recycle();
143 };
144
145 #endif /* SURF_MODEL_NETWORK_H_ */