Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
d28defd275300d21b2b65c229058f550f86a9dc6
[simgrid.git] / src / surf / network_cm02.hpp
1 /* Copyright (c) 2013-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef SURF_NETWORK_CM02_HPP_
8 #define SURF_NETWORK_CM02_HPP_
9
10 #include <xbt/base.h>
11
12 #include "network_interface.hpp"
13 #include "xbt/fifo.h"
14 #include "xbt/graph.h"
15
16
17
18 /***********
19  * Classes *
20  ***********/
21
22 namespace simgrid {
23   namespace surf {
24
25     class XBT_PRIVATE NetworkCm02Model;
26     class XBT_PRIVATE NetworkCm02Action;
27     class XBT_PRIVATE NetworkSmpiModel;
28
29   }
30 }
31
32 /*********
33  * Model *
34  *********/
35
36 namespace simgrid {
37   namespace surf {
38
39     class NetworkCm02Model : public NetworkModel {
40     public:
41       NetworkCm02Model();
42       ~NetworkCm02Model() { }
43       Link* createLink(const char *name,
44           double bw_initial, tmgr_trace_t bw_trace,
45           double lat_initial, tmgr_trace_t lat_trace,
46           e_surf_link_sharing_policy_t policy,
47           xbt_dict_t properties) override;
48       void updateActionsStateLazy(double now, double delta) override;
49       void updateActionsStateFull(double now, double delta) override;
50       Action *communicate(NetCard *src, NetCard *dst, double size, double rate) override;
51       bool next_occuring_event_isIdempotent() override {return true;}
52       virtual void gapAppend(double /*size*/, const Link* /*link*/, NetworkAction * /*action*/) {};
53     protected:
54       bool m_haveGap = false;
55     };
56
57     /************
58      * Resource *
59      ************/
60
61     class NetworkCm02Link : public Link {
62     public:
63       NetworkCm02Link(NetworkCm02Model *model, const char *name, xbt_dict_t props,
64           lmm_system_t system,
65           double constraint_value,
66           double bw_peak, tmgr_trace_t bw_trace,
67           double lat_initial, tmgr_trace_t lat_trace,
68           e_surf_link_sharing_policy_t policy);
69
70       void apply_event(tmgr_trace_iterator_t event, double value) override;
71       void updateBandwidth(double value) override;
72       void updateLatency(double value) override;
73       virtual void gapAppend(double /*size*/, const Link* /*link*/, NetworkAction * /*action*/) {};
74     };
75
76
77     /**********
78      * Action *
79      **********/
80     class NetworkCm02Action : public NetworkAction {
81       friend Action *NetworkCm02Model::communicate(NetCard *src, NetCard *dst, double size, double rate);
82       friend NetworkSmpiModel;
83
84     public:
85       NetworkCm02Action(Model *model, double cost, bool failed)
86     : NetworkAction(model, cost, failed) {};
87       void updateRemainingLazy(double now);
88     protected:
89       double m_senderGap;
90     };
91
92   }
93 }
94
95 #endif /* SURF_NETWORK_CM02_HPP_ */