[1500] | 1 | package experiments.simpat2014.models.article; |
---|
[1469] | 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; |
---|
[1500] | 24 | import experiments.simpat2014.EnvironmentConditions; |
---|
[1469] | 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 | |
---|
[1583] | 44 | private static double Pidle = 6; |
---|
| 45 | private static double Pfull = 20; |
---|
[1469] | 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 | |
---|
[1583] | 57 | double Pcpu = 0; |
---|
[1469] | 58 | for(Processor cpu: node.getProcessors()){ |
---|
| 59 | Pcpu = Pcpu + cpu.getPowerInterface().getRecentPowerUsage().getValue(); |
---|
[1583] | 60 | } |
---|
[1469] | 61 | |
---|
[1583] | 62 | powerConsumption = Pcpu + Pidle + (Pfull- Pidle) * node.getLoadInterface().getRecentUtilization().getValue()/100; |
---|
[1469] | 63 | |
---|
| 64 | /*if(powerCapLevel!= -1 && powerConsumption > powerCapLevel){ |
---|
| 65 | DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_POWER_LIMIT_EXCEEDED, null); |
---|
| 66 | } |
---|
| 67 | else if(powerUpgradeLevel != -1 && powerConsumption < powerUpgradeLevel){ |
---|
| 68 | DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_POWER_LIMIT_EXCEEDED, null); |
---|
| 69 | }*/ |
---|
| 70 | return powerConsumption; |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | @Override |
---|
| 74 | public double estimateTemperature(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) { |
---|
| 75 | |
---|
| 76 | Node node = (Node) resource; |
---|
| 77 | Processor cpu = node.getProcessors().get(0); |
---|
| 78 | double Pserv = 0; |
---|
| 79 | |
---|
| 80 | double R = 0; |
---|
| 81 | double Rb = 0; |
---|
| 82 | double Rcv = 0; |
---|
| 83 | try{ |
---|
| 84 | Rb = Double.valueOf(cpu.getPowerInterface().getParameters().get("thermalResistance").get(0).getContent()).doubleValue(); |
---|
| 85 | } catch (Exception e){ |
---|
| 86 | // |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | double k = 0; |
---|
| 90 | try{ |
---|
| 91 | k = Double.valueOf(cpu.getPowerInterface().getParameters().get("k").get(0).getContent()).doubleValue(); |
---|
| 92 | } catch (Exception e){ |
---|
| 93 | // |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | double a = 0; |
---|
| 97 | try{ |
---|
| 98 | a = Double.valueOf(cpu.getPowerInterface().getParameters().get("a").get(0).getContent()).doubleValue(); |
---|
| 99 | } catch (Exception e){ |
---|
| 100 | a = 1; |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | |
---|
| 104 | double C = 0; |
---|
| 105 | try{ |
---|
| 106 | C = Double.valueOf(cpu.getPowerInterface().getParameters().get("thermalCapacity").get(0).getContent()).doubleValue(); |
---|
| 107 | } catch (Exception e){ |
---|
| 108 | // |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | double V = 0; |
---|
| 112 | double Pfan = 0; |
---|
| 113 | for(Device device: node.getParent().getResourceCharacteristic().getDevices()){ |
---|
| 114 | if(device.getType().equals(StandardResourceType.Fan)){ |
---|
[1583] | 115 | if(Integer.valueOf(device.getName().split("_")[1]).intValue() == Integer.valueOf(node.getName().split("_")[1]).intValue() || Integer.valueOf(device.getName().split("_")[1]).intValue() == Integer.valueOf(cpu.getParent().getName().split("_")[1]).intValue() - EnvironmentConditions.NODES_IN_A_ROW){ |
---|
[1469] | 116 | Fan fan = (Fan) device; |
---|
| 117 | V = fan.getAirflowInterface().getRecentAirflow().getValue(); |
---|
| 118 | Pfan = fan.getPowerInterface().getRecentPowerUsage().getValue(); |
---|
| 119 | break; |
---|
| 120 | } |
---|
| 121 | } |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | Rcv = 1/ (k * Math.pow(V, a)); |
---|
| 125 | R = Rb + Rcv; |
---|
| 126 | |
---|
| 127 | double K = 0; |
---|
| 128 | double Cair = EnvironmentConditions.AIR_HEAT_CAPACITY; |
---|
| 129 | double ro = EnvironmentConditions.AIR_DENSITY; |
---|
| 130 | |
---|
| 131 | K = V * Cair * ro; |
---|
| 132 | //System.out.println("-------K: " + K + "; V:" + V); |
---|
| 133 | |
---|
| 134 | double delta_t = Sim_system.clock() - timestamp; |
---|
| 135 | |
---|
| 136 | double Tin = EnvironmentConditions.ROOM_TEMPERATURE; |
---|
| 137 | Pserv = node.getPowerInterface().getRecentPowerUsage().getValue(); |
---|
| 138 | Pserv = Pserv + Pfan; |
---|
| 139 | |
---|
| 140 | NodeGroup ng = (NodeGroup) node.getParent(); |
---|
| 141 | for(Node n: ng.getNodes()){ |
---|
| 142 | if(Integer.valueOf(n.getName().split("_")[1]) - Integer.valueOf(node.getName().split("_")[1]) == EnvironmentConditions.NODES_IN_A_ROW){ |
---|
| 143 | Tin = n.getThermalInterface().getRecentTemperature().getValue(); |
---|
| 144 | } |
---|
| 145 | } |
---|
| 146 | |
---|
| 147 | double targetTemp = Pserv/K + Tin; |
---|
| 148 | objective_temperature = targetTemp; |
---|
| 149 | |
---|
| 150 | new_temperature = objective_temperature + (old_temperature - objective_temperature) * Math.exp(-delta_t / (R * C)); |
---|
| 151 | |
---|
| 152 | // 5) save everything |
---|
| 153 | timestamp = Sim_system.clock(); |
---|
| 154 | old_temperature = new_temperature; |
---|
| 155 | |
---|
| 156 | return new_temperature; |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | /*private void loadThresholds(ComputingResource compResource){ |
---|
| 160 | |
---|
| 161 | Node n = (Node) compResource; |
---|
| 162 | double pcLevel = 0; |
---|
| 163 | double puLevel = 0; |
---|
| 164 | for(Processor proc: n.getProcessors()){ |
---|
| 165 | PState highestPState = proc.getPowerInterface().getHighestPState(); |
---|
| 166 | PState secondHighestPState = proc.getPowerInterface().getLowestPState(); |
---|
| 167 | for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){ |
---|
| 168 | PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName); |
---|
| 169 | if(pState.getFrequency() < secondHighestPState.getFrequency() && pState.getFrequency() > highestPState.getFrequency()){ |
---|
| 170 | secondHighestPState = pState; |
---|
| 171 | } |
---|
| 172 | } |
---|
| 173 | double maxMinPowerUsage = 0; |
---|
| 174 | double powerUsage = 0; |
---|
| 175 | |
---|
| 176 | for(Double load: highestPState.getLoadPowerUsage().keySet()){ |
---|
| 177 | powerUsage = highestPState.getLoadPowerUsage().get(load); |
---|
| 178 | if(powerUsage > maxMinPowerUsage){ |
---|
| 179 | maxMinPowerUsage= powerUsage; |
---|
| 180 | } |
---|
| 181 | } |
---|
| 182 | pcLevel = pcLevel + maxMinPowerUsage; |
---|
| 183 | |
---|
| 184 | maxMinPowerUsage = 0; |
---|
| 185 | powerUsage = 0; |
---|
| 186 | |
---|
| 187 | for(Double load: secondHighestPState.getLoadPowerUsage().keySet()){ |
---|
| 188 | powerUsage = secondHighestPState.getLoadPowerUsage().get(load); |
---|
| 189 | if(powerUsage > maxMinPowerUsage){ |
---|
| 190 | maxMinPowerUsage= powerUsage; |
---|
| 191 | } |
---|
| 192 | } |
---|
| 193 | puLevel = puLevel + maxMinPowerUsage; |
---|
| 194 | |
---|
| 195 | } |
---|
| 196 | |
---|
| 197 | puLevel = (pcLevel * pcLevel / puLevel); |
---|
| 198 | |
---|
| 199 | //powerCapLevel = pcLevel; |
---|
| 200 | //powerUpgradeLevel = puLevel; |
---|
| 201 | |
---|
| 202 | powerCapLevel = 60; |
---|
| 203 | powerUpgradeLevel = 40; |
---|
| 204 | }*/ |
---|
| 205 | } |
---|