Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix Network Constant
[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
33
34 /*********
35  * Model *
36  *********/
37 class NetworkCm02Model : public Model {
38 public:
39   NetworkCm02Model(int i) : Model("network") {};//FIXME: add network clean interface
40   NetworkCm02Model(string name);
41   NetworkCm02Model();
42   //FIXME:NetworkCm02LinkPtr createResource(string name);
43   NetworkCm02LinkLmmPtr createResource(const char *name,
44                                    double bw_initial,
45                                    tmgr_trace_t bw_trace,
46                                    double lat_initial,
47                                    tmgr_trace_t lat_trace,
48                                    e_surf_resource_state_t state_initial,
49                                    tmgr_trace_t state_trace,
50                                    e_surf_link_sharing_policy_t policy,
51                                    xbt_dict_t properties);
52   void updateActionsStateLazy(double now, double delta);
53   virtual void gapAppend(double size, const NetworkCm02LinkLmmPtr link, NetworkCm02ActionLmmPtr action) {};
54   virtual ActionPtr communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
55                                            double size, double rate);
56   xbt_dynar_t getRoute(RoutingEdgePtr src, RoutingEdgePtr dst); //FIXME: kill field? That is done by the routing nowadays
57   //FIXME: virtual void addTraces() =0;
58   void (*f_networkSolve)(lmm_system_t) = lmm_solve;
59   double latencyFactor(double size);
60   double bandwidthFactor(double size);
61   double bandwidthConstraint(double rate, double bound, double size);
62   bool m_haveGap = false;
63 };
64
65 /************
66  * Resource *
67  ************/
68
69 class NetworkCm02Link : virtual public Resource {
70 public:
71   NetworkCm02Link(){};
72   NetworkCm02Link(NetworkCm02ModelPtr model, const char* name, xbt_dict_t properties) : Resource(model, name, properties) {};
73   virtual double getBandwidth()=0;
74   virtual double getLatency();
75   virtual bool isShared()=0;
76   /* Using this object with the public part of
77     model does not make sense */
78   double m_latCurrent;
79   tmgr_trace_event_t p_latEvent;
80 };
81
82 class NetworkCm02LinkLmm : public ResourceLmm, public NetworkCm02Link {
83 public:
84   NetworkCm02LinkLmm(NetworkCm02ModelPtr model, const char* name, xbt_dict_t properties)
85    : ResourceLmm(), NetworkCm02Link(model, name, properties) {};
86   NetworkCm02LinkLmm(NetworkCm02ModelPtr model, const char *name, xbt_dict_t props,
87                                    lmm_system_t system,
88                                    double constraint_value,
89                                    tmgr_history_t history,
90                                    e_surf_resource_state_t state_init,
91                                    tmgr_trace_t state_trace,
92                                    double metric_peak,
93                                    tmgr_trace_t metric_trace,
94                                    double lat_initial,
95                                    tmgr_trace_t lat_trace,
96                                e_surf_link_sharing_policy_t policy);
97   bool isShared();
98   bool isUsed();
99   double getBandwidth();
100   void updateState(tmgr_trace_event_t event_type, double value, double date);
101 };
102
103
104 /**********
105  * Action *
106  **********/
107 class NetworkCm02Action : virtual public Action {
108 public:
109   NetworkCm02Action(ModelPtr model, double cost, bool failed)
110  : Action(model, cost, failed) {};
111   double m_latency;
112   double m_latCurrent;
113   double m_weight;
114   double m_rate;
115   const char* p_senderLinkName;
116   double m_senderGap;
117   double m_senderSize;
118   xbt_fifo_item_t p_senderFifoItem;
119 #ifdef HAVE_LATENCY_BOUND_TRACKING
120   int m_latencyLimited;
121 #endif
122
123 };
124
125 class NetworkCm02ActionLmm : public ActionLmm, public NetworkCm02Action {
126 public:
127   NetworkCm02ActionLmm(ModelPtr model, double cost, bool failed)
128  : Action(model, cost, failed),
129    ActionLmm(model, cost, failed),
130    NetworkCm02Action(model, cost, failed) {};
131   void updateRemainingLazy(double now);
132   void recycle();
133 };
134
135 #endif /* SURF_MODEL_NETWORK_H_ */