Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ed28c8663c860b7231ea6bfe678dab27cdaf0526
[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_interface.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(const char *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           delete 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 protected:
98 public:
99   NetworkLinkLmm() {};
100   NetworkLinkLmm(lmm_constraint_t constraint, tmgr_history_t history, tmgr_trace_t state_trace);
101   bool isShared();
102   bool isUsed();
103   double getBandwidth();
104   tmgr_trace_event_t p_stateEvent;
105   s_surf_metric_t p_power;
106 };
107
108 /**********
109  * Action *
110  **********/
111 class NetworkAction : virtual public Action {
112 public:
113   NetworkAction() {};
114   double m_latency;
115   double m_latCurrent;
116   double m_weight;
117   double m_rate;
118   const char* p_senderLinkName;
119   double m_senderGap;
120   double m_senderSize;
121   xbt_fifo_item_t p_senderFifoItem;
122 #ifdef HAVE_LATENCY_BOUND_TRACKING
123   int m_latencyLimited;
124 #endif
125
126 };
127
128 class NetworkActionLmm : public ActionLmm, public NetworkAction {
129 public:
130   NetworkActionLmm() {};
131 };
132
133 #endif /* SURF_NETWORK_INTERFACE_HPP_ */
134
135