1 /* Copyright (c) 2013-2015. The SimGrid Team.
2 * All rights reserved. */
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. */
13 #include "host_interface.hpp"
25 class XBT_PRIVATE HostL07Model;
26 class XBT_PRIVATE CpuL07Model;
27 class XBT_PRIVATE NetworkL07Model;
29 class XBT_PRIVATE HostL07;
30 class XBT_PRIVATE CpuL07;
31 class XBT_PRIVATE LinkL07;
33 class XBT_PRIVATE L07Action;
41 class HostL07Model : public HostModel {
46 double shareResources(double now) override;
47 void updateActionsState(double now, double delta);
48 Host *createHost(const char *name,RoutingEdge *netElm, Cpu *cpu, xbt_dict_t props) override;
49 Action *executeParallelTask(int host_nb,
53 double rate) override;
54 void addTraces() override;
57 class CpuL07Model : public CpuModel {
59 CpuL07Model(HostL07Model *hmodel) : CpuModel() {p_hostModel = hmodel;};
60 ~CpuL07Model() {surf_cpu_model_pm = NULL;};
62 Cpu *createCpu(const char *name, xbt_dynar_t speedPeak,
63 int pstate, double speedScale,
64 tmgr_trace_t speedTrace, int core,
65 e_surf_resource_state_t state_initial,
66 tmgr_trace_t state_trace) override;
67 void addTraces() override {DIE_IMPOSSIBLE;};
69 HostL07Model *p_hostModel;
72 class NetworkL07Model : public NetworkModel {
74 NetworkL07Model(HostL07Model *hmodel) : NetworkModel() {p_hostModel = hmodel;};
75 ~NetworkL07Model() {surf_network_model = NULL;};
76 Link* createLink(const char *name,
78 tmgr_trace_t bw_trace,
80 tmgr_trace_t lat_trace,
81 e_surf_resource_state_t state_initial,
82 tmgr_trace_t state_trace,
83 e_surf_link_sharing_policy_t policy,
84 xbt_dict_t properties) override;
86 Action *communicate(RoutingEdge *src, RoutingEdge *dst, double size, double rate) override;
87 void addTraces() override {DIE_IMPOSSIBLE;};
88 bool shareResourcesIsIdempotent() override {return true;}
90 HostL07Model *p_hostModel;
97 class CpuL07 : public Cpu {
98 friend void HostL07Model::addTraces();
99 tmgr_trace_event_t p_stateEvent;
100 tmgr_trace_event_t p_speedEvent;
102 CpuL07(CpuL07Model *model, const char* name,
103 double power_scale, double power_initial, tmgr_trace_t power_trace,
104 int core, e_surf_resource_state_t state_initial, tmgr_trace_t state_trace);
106 bool isUsed() override;
107 void updateState(tmgr_trace_event_t event_type, double value, double date) override;
108 Action *execute(double size) override;
109 Action *sleep(double duration) override;
111 double getCurrentPowerPeak() override {THROW_UNIMPLEMENTED;};
112 double getPowerPeakAt(int /*pstate_index*/) override {THROW_UNIMPLEMENTED;};
113 int getNbPstates() override {THROW_UNIMPLEMENTED;};
114 void setPstate(int /*pstate_index*/) override {THROW_UNIMPLEMENTED;};
115 int getPstate() override {THROW_UNIMPLEMENTED;};
118 class LinkL07 : public Link {
120 LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props,
122 tmgr_trace_t bw_trace,
124 tmgr_trace_t lat_trace,
125 e_surf_resource_state_t
127 tmgr_trace_t state_trace,
128 e_surf_link_sharing_policy_t policy);
130 bool isUsed() override;
131 void updateState(tmgr_trace_event_t event_type, double value, double date) override;
132 double getBandwidth() override;
133 void updateBandwidth(double value, double date=surf_get_clock()) override;
134 void updateLatency(double value, double date=surf_get_clock()) override;
137 tmgr_trace_event_t p_bwEvent;
143 class L07Action : public HostAction {
144 friend Action *CpuL07::execute(double size);
145 friend Action *CpuL07::sleep(double duration);
146 friend Action *HostL07Model::executeParallelTask(int host_nb,
148 double *flops_amount,
149 double *bytes_amount,
152 L07Action(Model *model, double cost, bool failed)
153 : HostAction(model, cost, failed) {};
158 int unref() override;
159 void cancel() override;
160 void suspend() override;
161 void resume() override;
162 bool isSuspended() override;
163 void setMaxDuration(double duration) override;
164 void setPriority(double priority) override;
165 double getRemains() override;
167 std::vector<RoutingEdge*> * p_edgeList = new std::vector<RoutingEdge*>();
168 double *p_computationAmount;
169 double *p_communicationAmount;
177 #endif /* HOST_L07_HPP_ */