1 | package experiments.simpat2014.models.article; |
---|
2 | |
---|
3 | |
---|
4 | import java.util.List; |
---|
5 | |
---|
6 | import schedframe.resources.CoolEmAllResourceType; |
---|
7 | import schedframe.resources.StandardResourceType; |
---|
8 | import schedframe.resources.computing.ComputingResource; |
---|
9 | import schedframe.resources.computing.Node; |
---|
10 | import schedframe.resources.computing.Processor; |
---|
11 | import schedframe.resources.computing.Rack; |
---|
12 | import schedframe.resources.computing.coolemall.NodeGroup; |
---|
13 | import schedframe.resources.computing.profiles.energy.ResourceEvent; |
---|
14 | import schedframe.resources.computing.profiles.energy.airthroughput.CustomAirflowStateName; |
---|
15 | import schedframe.resources.computing.profiles.energy.power.PState; |
---|
16 | import schedframe.resources.devices.Device; |
---|
17 | import schedframe.resources.devices.Fan; |
---|
18 | import schedframe.resources.devices.PhysicalResource; |
---|
19 | import schedframe.scheduling.manager.tasks.JobRegistry; |
---|
20 | import simulator.DataCenterWorkloadSimulator; |
---|
21 | import eduni.simjava.Sim_system; |
---|
22 | import example.energy.BaseEnergyEstimationPlugin; |
---|
23 | import example.energy.coolemall.CoolEmAllTestbedMeasurements; |
---|
24 | import experiments.simpat2014.EnvironmentConditions; |
---|
25 | import gridsim.dcworms.DCWormsTags; |
---|
26 | |
---|
27 | |
---|
28 | public class NodeEnergyEstimationPluginPowerCapping extends BaseEnergyEstimationPlugin { |
---|
29 | |
---|
30 | //double powerCapLevel = -1; |
---|
31 | //double powerUpgradeLevel = -1; |
---|
32 | |
---|
33 | |
---|
34 | private static double Tidle = 26; |
---|
35 | |
---|
36 | private double timestamp = 0; |
---|
37 | private double old_temperature = Tidle; |
---|
38 | private double new_temperature = -1; |
---|
39 | private double objective_temperature = Tidle; |
---|
40 | private boolean fan = false; |
---|
41 | |
---|
42 | private double next_timer = -1; |
---|
43 | |
---|
44 | private static double Pidle = 15; |
---|
45 | private static double Pfull = 76; |
---|
46 | |
---|
47 | |
---|
48 | public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry, |
---|
49 | PhysicalResource resource) { |
---|
50 | |
---|
51 | |
---|
52 | //loadThresholds((ComputingResource)resource); |
---|
53 | |
---|
54 | Node node = (Node) resource; |
---|
55 | double powerConsumption = 0; |
---|
56 | |
---|
57 | /*double Pcpu = 0; |
---|
58 | for(Processor cpu: node.getProcessors()){ |
---|
59 | Pcpu = Pcpu + cpu.getPowerInterface().getRecentPowerUsage().getValue(); |
---|
60 | }*/ |
---|
61 | |
---|
62 | //powerConsumption = Pidle + (Pfull- Pidle) * node.getLoadInterface().getRecentUtilization().getValue()/100; |
---|
63 | powerConsumption = Pidle + node.getProcessors().get(0).getPowerInterface().getRecentPowerUsage().getValue(); |
---|
64 | |
---|
65 | /*if(powerCapLevel!= -1 && powerConsumption > powerCapLevel){ |
---|
66 | DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_POWER_LIMIT_EXCEEDED, null); |
---|
67 | } |
---|
68 | else if(powerUpgradeLevel != -1 && powerConsumption < powerUpgradeLevel){ |
---|
69 | DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_POWER_LIMIT_EXCEEDED, null); |
---|
70 | }*/ |
---|
71 | return powerConsumption; |
---|
72 | } |
---|
73 | |
---|
74 | @Override |
---|
75 | public double estimateTemperature(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) { |
---|
76 | |
---|
77 | Node node = (Node) resource; |
---|
78 | Processor cpu = node.getProcessors().get(0); |
---|
79 | double Pserv = 0; |
---|
80 | |
---|
81 | double R = 0; |
---|
82 | double Rb = 0; |
---|
83 | double Rcv = 0; |
---|
84 | try{ |
---|
85 | Rb = Double.valueOf(cpu.getPowerInterface().getParameters().get("thermalResistance").get(0).getContent()).doubleValue(); |
---|
86 | } catch (Exception e){ |
---|
87 | // |
---|
88 | } |
---|
89 | |
---|
90 | double k = 0; |
---|
91 | try{ |
---|
92 | k = Double.valueOf(cpu.getPowerInterface().getParameters().get("k").get(0).getContent()).doubleValue(); |
---|
93 | } catch (Exception e){ |
---|
94 | // |
---|
95 | } |
---|
96 | |
---|
97 | double a = 0; |
---|
98 | try{ |
---|
99 | a = Double.valueOf(cpu.getPowerInterface().getParameters().get("a").get(0).getContent()).doubleValue(); |
---|
100 | } catch (Exception e){ |
---|
101 | a = 1; |
---|
102 | } |
---|
103 | |
---|
104 | |
---|
105 | double C = 0; |
---|
106 | try{ |
---|
107 | C = Double.valueOf(cpu.getPowerInterface().getParameters().get("thermalCapacity").get(0).getContent()).doubleValue(); |
---|
108 | } catch (Exception e){ |
---|
109 | // |
---|
110 | } |
---|
111 | |
---|
112 | double V = 0; |
---|
113 | double Pfan = 0; |
---|
114 | for(Device device: node.getParent().getResourceCharacteristic().getDevices()){ |
---|
115 | if(device.getType().equals(StandardResourceType.Fan)){ |
---|
116 | if(Integer.valueOf(device.getName().split("_")[1]) == Integer.valueOf(node.getName().split("_")[1]) || Integer.valueOf(device.getName().split("_")[1]) == Integer.valueOf(cpu.getParent().getName().split("_")[1]) - EnvironmentConditions.NODES_IN_A_ROW){ |
---|
117 | Fan fan = (Fan) device; |
---|
118 | V = fan.getAirflowInterface().getRecentAirflow().getValue(); |
---|
119 | Pfan = fan.getPowerInterface().getRecentPowerUsage().getValue(); |
---|
120 | break; |
---|
121 | } |
---|
122 | } |
---|
123 | } |
---|
124 | |
---|
125 | Rcv = 1/ (k * Math.pow(V, a)); |
---|
126 | R = Rb + Rcv; |
---|
127 | |
---|
128 | double K = 0; |
---|
129 | double Cair = EnvironmentConditions.AIR_HEAT_CAPACITY; |
---|
130 | double ro = EnvironmentConditions.AIR_DENSITY; |
---|
131 | |
---|
132 | K = V * Cair * ro; |
---|
133 | //System.out.println("-------K: " + K + "; V:" + V); |
---|
134 | |
---|
135 | double delta_t = Sim_system.clock() - timestamp; |
---|
136 | |
---|
137 | double Tin = EnvironmentConditions.ROOM_TEMPERATURE; |
---|
138 | Pserv = node.getPowerInterface().getRecentPowerUsage().getValue(); |
---|
139 | Pserv = Pserv + Pfan; |
---|
140 | |
---|
141 | NodeGroup ng = (NodeGroup) node.getParent(); |
---|
142 | for(Node n: ng.getNodes()){ |
---|
143 | if(Integer.valueOf(n.getName().split("_")[1]) - Integer.valueOf(node.getName().split("_")[1]) == EnvironmentConditions.NODES_IN_A_ROW){ |
---|
144 | Tin = n.getThermalInterface().getRecentTemperature().getValue(); |
---|
145 | } |
---|
146 | } |
---|
147 | |
---|
148 | double targetTemp = Pserv/K + Tin; |
---|
149 | objective_temperature = targetTemp; |
---|
150 | |
---|
151 | new_temperature = objective_temperature + (old_temperature - objective_temperature) * Math.exp(-delta_t / (R * C)); |
---|
152 | |
---|
153 | // 5) save everything |
---|
154 | timestamp = Sim_system.clock(); |
---|
155 | old_temperature = new_temperature; |
---|
156 | |
---|
157 | return new_temperature; |
---|
158 | } |
---|
159 | |
---|
160 | /*private void loadThresholds(ComputingResource compResource){ |
---|
161 | |
---|
162 | Node n = (Node) compResource; |
---|
163 | double pcLevel = 0; |
---|
164 | double puLevel = 0; |
---|
165 | for(Processor proc: n.getProcessors()){ |
---|
166 | PState highestPState = proc.getPowerInterface().getHighestPState(); |
---|
167 | PState secondHighestPState = proc.getPowerInterface().getLowestPState(); |
---|
168 | for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){ |
---|
169 | PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName); |
---|
170 | if(pState.getFrequency() < secondHighestPState.getFrequency() && pState.getFrequency() > highestPState.getFrequency()){ |
---|
171 | secondHighestPState = pState; |
---|
172 | } |
---|
173 | } |
---|
174 | double maxMinPowerUsage = 0; |
---|
175 | double powerUsage = 0; |
---|
176 | |
---|
177 | for(Double load: highestPState.getLoadPowerUsage().keySet()){ |
---|
178 | powerUsage = highestPState.getLoadPowerUsage().get(load); |
---|
179 | if(powerUsage > maxMinPowerUsage){ |
---|
180 | maxMinPowerUsage= powerUsage; |
---|
181 | } |
---|
182 | } |
---|
183 | pcLevel = pcLevel + maxMinPowerUsage; |
---|
184 | |
---|
185 | maxMinPowerUsage = 0; |
---|
186 | powerUsage = 0; |
---|
187 | |
---|
188 | for(Double load: secondHighestPState.getLoadPowerUsage().keySet()){ |
---|
189 | powerUsage = secondHighestPState.getLoadPowerUsage().get(load); |
---|
190 | if(powerUsage > maxMinPowerUsage){ |
---|
191 | maxMinPowerUsage= powerUsage; |
---|
192 | } |
---|
193 | } |
---|
194 | puLevel = puLevel + maxMinPowerUsage; |
---|
195 | |
---|
196 | } |
---|
197 | |
---|
198 | puLevel = (pcLevel * pcLevel / puLevel); |
---|
199 | |
---|
200 | //powerCapLevel = pcLevel; |
---|
201 | //powerUpgradeLevel = puLevel; |
---|
202 | |
---|
203 | powerCapLevel = 60; |
---|
204 | powerUpgradeLevel = 40; |
---|
205 | }*/ |
---|
206 | } |
---|