[1501] | 1 | package experiments.e2dc2014; |
---|
[1323] | 2 | |
---|
[1420] | 3 | import schedframe.events.EventReason; |
---|
[1323] | 4 | import schedframe.resources.computing.ComputingResource; |
---|
| 5 | import schedframe.resources.computing.Node; |
---|
| 6 | import schedframe.resources.computing.Processor; |
---|
[1420] | 7 | import schedframe.resources.computing.profiles.energy.ResourceEvent; |
---|
[1323] | 8 | import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; |
---|
| 9 | import schedframe.resources.devices.Device; |
---|
| 10 | import schedframe.resources.devices.Fan; |
---|
| 11 | import schedframe.resources.devices.PhysicalResource; |
---|
| 12 | import schedframe.scheduling.manager.tasks.JobRegistry; |
---|
| 13 | import example.energy.BaseEnergyEstimationPlugin; |
---|
| 14 | |
---|
| 15 | public class FanEnergyEstimationPlugin extends BaseEnergyEstimationPlugin { |
---|
| 16 | |
---|
[1420] | 17 | public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry, |
---|
[1323] | 18 | PhysicalResource resource) { |
---|
| 19 | |
---|
| 20 | double powerConsumption = 0; |
---|
| 21 | |
---|
| 22 | Fan fan = (Fan) resource; |
---|
| 23 | try { |
---|
[1399] | 24 | powerConsumption = fan.getAirflowInterface().getPowerConsumption(fan.getAirflowInterface().getAirflowState()); |
---|
[1323] | 25 | } catch (NoSuchFieldException e) { |
---|
| 26 | // TODO Auto-generated catch block |
---|
| 27 | e.printStackTrace(); |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | /*if(resource.getAirThroughputInterface().getAirThroughputState().getName().equals(new UserAirThroughputStateName("1").getName())){ |
---|
| 31 | powerConsumption = CoolEmAllTestbedMeasurements.SINGLE_FAN_OFF_POWER_CONSUMPTION; |
---|
| 32 | } else { |
---|
| 33 | powerConsumption = CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION; |
---|
| 34 | }*/ |
---|
| 35 | return powerConsumption * getFactor(fan)/(double)fan.getChilledResources().size(); |
---|
| 36 | } |
---|
| 37 | |
---|
[1420] | 38 | public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) { |
---|
[1323] | 39 | |
---|
[1399] | 40 | double airflow = 0; |
---|
[1323] | 41 | Fan fan = (Fan) resource; |
---|
| 42 | try { |
---|
| 43 | if(event.getReason() == EventReason.SIM_INIT) |
---|
[1399] | 44 | airflow = fan.getAirflowInterface().getAirflow(fan.getAirflowInterface().getAirflowState()); |
---|
[1323] | 45 | else |
---|
[1399] | 46 | airflow = fan.getAirflowInterface().getAirflow(fan.getAirflowInterface().getAirflowState()); |
---|
[1323] | 47 | } catch (NoSuchFieldException e) { |
---|
| 48 | // TODO Auto-generated catch block |
---|
| 49 | e.printStackTrace(); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | /*if(event.getReason() == EventReason.SIM_INIT){ |
---|
| 53 | if(resource.getAirThroughputInterface().getAirThroughputState().getName().equals(new UserAirThroughputStateName("1").getName())){ |
---|
| 54 | airThroughput = CoolEmAllTestbedMeasurements.SINGLE_FAN_OFF_AIR_FLOW; |
---|
| 55 | } else { |
---|
| 56 | airThroughput = CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_AIR_FLOW; |
---|
| 57 | } |
---|
| 58 | } |
---|
| 59 | else { |
---|
| 60 | if(resource.getAirThroughputInterface().getAirThroughputState().getName().equals(new UserAirThroughputStateName("1").getName())){ |
---|
| 61 | airThroughput = CoolEmAllTestbedMeasurements.SINGLE_FAN_OFF_AIR_FLOW; |
---|
| 62 | } else { |
---|
| 63 | airThroughput = CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_AIR_FLOW; |
---|
| 64 | } |
---|
| 65 | }*/ |
---|
| 66 | |
---|
[1399] | 67 | return airflow * getFactor(fan)/(double)fan.getChilledResources().size(); |
---|
[1323] | 68 | } |
---|
| 69 | |
---|
| 70 | private int getNumberOfWorkingNodes(Device device){ |
---|
| 71 | int quantity = 0; |
---|
| 72 | Fan fan = (Fan) device; |
---|
| 73 | for(ComputingResource compRes: device.getComputingResource().getChildren()){ |
---|
| 74 | Node node = (Node)compRes; |
---|
| 75 | if(fan.getChilledResources().contains(node.getFullName()) && node.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON) ){ |
---|
| 76 | quantity++; |
---|
| 77 | } |
---|
| 78 | } |
---|
| 79 | return quantity; |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | private double getFactor(Device device){ |
---|
| 83 | |
---|
| 84 | double factor = 0;; |
---|
| 85 | Fan fan = (Fan) device; |
---|
| 86 | for(ComputingResource compRes: device.getComputingResource().getChildren()){ |
---|
| 87 | Node node = (Node)compRes; |
---|
| 88 | double nrOfComputingProcessor = 0; |
---|
| 89 | double meanCurrFrequency = 0; |
---|
| 90 | double meanMaxFrequency = 0; |
---|
| 91 | if(fan.getChilledResources().contains(node.getFullName()) && node.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON) ){ |
---|
| 92 | for(Processor proc: node.getProcessors()){ |
---|
| 93 | if(proc.getCores().size() != proc.getFreeCores().size()){ |
---|
| 94 | nrOfComputingProcessor++; |
---|
| 95 | meanCurrFrequency = meanCurrFrequency + proc.getPowerInterface().getFrequency(); |
---|
| 96 | meanMaxFrequency = meanMaxFrequency + proc.getPowerInterface().getLowestPState().getFrequency(); |
---|
| 97 | } else { |
---|
| 98 | meanCurrFrequency = meanCurrFrequency + proc.getPowerInterface().getHighestPState().getFrequency(); |
---|
| 99 | meanMaxFrequency = meanMaxFrequency + proc.getPowerInterface().getLowestPState().getFrequency(); |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | } |
---|
| 103 | meanCurrFrequency = meanCurrFrequency/node.getProcessors().size(); |
---|
| 104 | meanMaxFrequency = meanMaxFrequency/node.getProcessors().size(); |
---|
[1425] | 105 | factor = factor + (meanCurrFrequency /meanMaxFrequency) * (0.5 + nrOfComputingProcessor/node.getProcessors().size()); |
---|
[1323] | 106 | } |
---|
| 107 | } |
---|
| 108 | return factor; |
---|
| 109 | } |
---|
| 110 | } |
---|