Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix network_interface bug
[simgrid.git] / src / surf / network_interface.hpp
1 /*
2  * network_interface.hpp
3  *
4  *  Created on: Nov 29, 2013
5  *      Author: bedaride
6  */
7 #include "surf.hpp"
8 #include "surf_routing.hpp"
9
10 #ifndef SURF_NETWORK_INTERFACE_HPP_
11 #define SURF_NETWORK_INTERFACE_HPP_
12
13 /***********
14  * Classes *
15  ***********/
16 class NetworkModel;
17 typedef NetworkModel *NetworkModelPtr;
18
19 class NetworkLink;
20 typedef NetworkLink *NetworkLinkPtr;
21
22 class NetworkLinkLmm;
23 typedef NetworkLinkLmm *NetworkLinkLmmPtr;
24
25 class NetworkAction;
26 typedef NetworkAction *NetworkActionPtr;
27
28 class NetworkActionLmm;
29 typedef NetworkActionLmm *NetworkActionLmmPtr;
30
31 /*********
32  * Tools *
33  *********/
34
35 void net_define_callbacks(void);
36
37 /*********
38  * Model *
39  *********/
40 class NetworkModel : public Model {
41 public:
42   NetworkModel() : Model("network") {
43   };
44   NetworkModel(string name) : Model(name) {
45         f_networkSolve = lmm_solve;
46         m_haveGap = false;
47   };
48   ~NetworkModel() {
49         if (p_maxminSystem)
50           lmm_system_free(p_maxminSystem);
51         if (p_actionHeap)
52           xbt_heap_free(p_actionHeap);
53         if (p_modifiedSet)
54           xbt_swag_free(p_modifiedSet);
55   }
56
57   virtual NetworkLinkPtr createResource(const char *name,
58                                    double bw_initial,
59                                    tmgr_trace_t bw_trace,
60                                    double lat_initial,
61                                    tmgr_trace_t lat_trace,
62                                    e_surf_resource_state_t state_initial,
63                                    tmgr_trace_t state_trace,
64                                    e_surf_link_sharing_policy_t policy,
65                                    xbt_dict_t properties)=0;
66
67   //FIXME:void updateActionsStateLazy(double now, double delta);
68   virtual void gapAppend(double /*size*/, const NetworkLinkLmmPtr /*link*/, NetworkActionLmmPtr /*action*/) {};
69   virtual ActionPtr communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
70                                            double size, double rate)=0;
71   virtual xbt_dynar_t getRoute(RoutingEdgePtr src, RoutingEdgePtr dst); //FIXME: kill field? That is done by the routing nowadays
72   void (*f_networkSolve)(lmm_system_t);
73   virtual double latencyFactor(double size);
74   virtual double bandwidthFactor(double size);
75   virtual double bandwidthConstraint(double rate, double bound, double size);
76   bool m_haveGap;
77 };
78
79 /************
80  * Resource *
81  ************/
82
83 class NetworkLink : virtual public Resource {
84 public:
85   NetworkLink() : p_latEvent(NULL) {};
86   virtual double getBandwidth()=0;
87   virtual double getLatency();
88   virtual bool isShared()=0;
89
90   /* Using this object with the public part of
91     model does not make sense */
92   double m_latCurrent;
93   tmgr_trace_event_t p_latEvent;
94 };
95
96 class NetworkLinkLmm : public ResourceLmm, public NetworkLink {
97 public:
98   NetworkLinkLmm() {};
99   NetworkLinkLmm(lmm_system_t system,
100                      double constraint_value,
101                      tmgr_history_t history,
102                      e_surf_resource_state_t state_init,
103                      tmgr_trace_t state_trace,
104                      double metric_peak,
105                      tmgr_trace_t metric_trace)
106  : ResourceLmm(system, constraint_value, history, state_init, state_trace, metric_peak, metric_trace)
107 {
108 }
109   bool isShared();
110   bool isUsed();
111   double getBandwidth();
112 };
113
114 /**********
115  * Action *
116  **********/
117 class NetworkAction : virtual public Action {
118 public:
119   NetworkAction() {};
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 NetworkActionLmm : public ActionLmm, public NetworkAction {
135 public:
136   NetworkActionLmm() {};
137 };
138
139 #endif /* SURF_NETWORK_INTERFACE_HPP_ */
140
141