Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Comment unused parameters.
[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(){};
81   NetworkCm02Link(NetworkCm02ModelPtr model, const char* name, xbt_dict_t properties) : Resource(model, name, properties) {};
82   virtual double getBandwidth()=0;
83   virtual double getLatency();
84   virtual bool isShared()=0;
85   /* Using this object with the public part of
86     model does not make sense */
87   double m_latCurrent;
88   tmgr_trace_event_t p_latEvent;
89 };
90
91 class NetworkCm02LinkLmm : public ResourceLmm, public NetworkCm02Link {
92 public:
93   NetworkCm02LinkLmm(NetworkCm02ModelPtr model, const char* name, xbt_dict_t properties)
94    : ResourceLmm(), NetworkCm02Link(model, name, properties) {};
95   NetworkCm02LinkLmm(NetworkCm02ModelPtr model, const char *name, xbt_dict_t props,
96                                    lmm_system_t system,
97                                    double constraint_value,
98                                    tmgr_history_t history,
99                                    e_surf_resource_state_t state_init,
100                                    tmgr_trace_t state_trace,
101                                    double metric_peak,
102                                    tmgr_trace_t metric_trace,
103                                    double lat_initial,
104                                    tmgr_trace_t lat_trace,
105                                e_surf_link_sharing_policy_t policy);
106   bool isShared();
107   bool isUsed();
108   double getBandwidth();
109   void updateState(tmgr_trace_event_t event_type, double value, double date);
110 };
111
112
113 /**********
114  * Action *
115  **********/
116 class NetworkCm02Action : virtual public Action {
117 public:
118   NetworkCm02Action(ModelPtr model, double cost, bool failed)
119  : Action(model, cost, failed) {};
120   double m_latency;
121   double m_latCurrent;
122   double m_weight;
123   double m_rate;
124   const char* p_senderLinkName;
125   double m_senderGap;
126   double m_senderSize;
127   xbt_fifo_item_t p_senderFifoItem;
128 #ifdef HAVE_LATENCY_BOUND_TRACKING
129   int m_latencyLimited;
130 #endif
131
132 };
133
134 class NetworkCm02ActionLmm : public ActionLmm, public NetworkCm02Action {
135 public:
136   NetworkCm02ActionLmm(ModelPtr model, double cost, bool failed)
137  : Action(model, cost, failed),
138    ActionLmm(model, cost, failed),
139    NetworkCm02Action(model, cost, failed) {};
140   void updateRemainingLazy(double now);
141   void recycle();
142 };
143
144 #endif /* SURF_MODEL_NETWORK_H_ */