[1593] | 1 | package experiments.e2dc2015.models.i5; |
---|
| 2 | |
---|
| 3 | |
---|
| 4 | import schedframe.resources.StandardResourceType; |
---|
| 5 | import schedframe.resources.computing.Node; |
---|
| 6 | import schedframe.resources.computing.Processor; |
---|
| 7 | import schedframe.resources.computing.coolemall.NodeGroup; |
---|
| 8 | import schedframe.resources.computing.profiles.energy.ResourceEvent; |
---|
| 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 eduni.simjava.Sim_system; |
---|
| 14 | import example.energy.BaseEnergyEstimationPlugin; |
---|
| 15 | import experiments.e2dc2015.EnvironmentConditions; |
---|
| 16 | |
---|
| 17 | public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin { |
---|
| 18 | |
---|
| 19 | private double timestamp = 0; |
---|
| 20 | private double old_temperature = EnvironmentConditions.i5_nodeTidle; |
---|
| 21 | private double new_temperature = -1; |
---|
| 22 | private double objective_temperature = EnvironmentConditions.i5_nodeTidle; |
---|
| 23 | |
---|
| 24 | private static double Pidle = 6; |
---|
| 25 | private static double Pfull = 10; |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry, |
---|
| 29 | PhysicalResource resource) { |
---|
| 30 | Node node = (Node) resource; |
---|
| 31 | double powerConsumption = 0; |
---|
| 32 | |
---|
| 33 | double Pcpu = 0; |
---|
| 34 | for(Processor cpu: node.getProcessors()){ |
---|
| 35 | Pcpu = Pcpu + cpu.getPowerInterface().getRecentPowerUsage().getValue(); |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | powerConsumption = Pcpu + Pidle + (Pfull- Pidle) * node.getLoadInterface().getRecentUtilization().getValue()/100; |
---|
| 39 | //powerConsumption = powerConsumption + node.getProcessors().get(0).getResourceCharacteristic().getDevices().get(0).getPowerInterface().getRecentPowerUsage().getValue(); |
---|
| 40 | return powerConsumption; |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | @Override |
---|
| 44 | public double estimateTemperature(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) { |
---|
| 45 | |
---|
| 46 | Node node = (Node) resource; |
---|
| 47 | Processor cpu = node.getProcessors().get(0); |
---|
| 48 | double Pserv = 0; |
---|
| 49 | |
---|
| 50 | double R = 0; |
---|
| 51 | double Rb = 0; |
---|
| 52 | double Rcv = 0; |
---|
| 53 | try{ |
---|
| 54 | Rb = Double.valueOf(cpu.getPowerInterface().getParameters().get("thermalResistance").get(0).getContent()).doubleValue(); |
---|
| 55 | } catch (Exception e){ |
---|
| 56 | // |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | double k = 0; |
---|
| 60 | try{ |
---|
| 61 | k = Double.valueOf(cpu.getPowerInterface().getParameters().get("k").get(0).getContent()).doubleValue(); |
---|
| 62 | } catch (Exception e){ |
---|
| 63 | // |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | double a = 0; |
---|
| 67 | try{ |
---|
| 68 | a = Double.valueOf(cpu.getPowerInterface().getParameters().get("a").get(0).getContent()).doubleValue(); |
---|
| 69 | } catch (Exception e){ |
---|
| 70 | a = 1; |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | double C = 0; |
---|
| 75 | try{ |
---|
| 76 | C = Double.valueOf(cpu.getPowerInterface().getParameters().get("thermalCapacity").get(0).getContent()).doubleValue(); |
---|
| 77 | } catch (Exception e){ |
---|
| 78 | // |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | double V = 0; |
---|
| 82 | double Pfan = 0; |
---|
| 83 | for(Device device: node.getParent().getResourceCharacteristic().getDevices()){ |
---|
| 84 | if(device.getType().equals(StandardResourceType.Fan)){ |
---|
| 85 | int fanId = Integer.valueOf(device.getName().split("_")[1]).intValue(); |
---|
| 86 | int nodeId = Integer.valueOf(node.getName().split("_")[1]).intValue(); |
---|
| 87 | if(nodeId > (fanId - 1) * EnvironmentConditions.NODES_IN_A_COLUMN && nodeId <= fanId * EnvironmentConditions.NODES_IN_A_COLUMN){ |
---|
| 88 | Fan fan = (Fan) device; |
---|
| 89 | V = fan.getAirflowInterface().getRecentAirflow().getValue(); |
---|
| 90 | Pfan = fan.getPowerInterface().getRecentPowerUsage().getValue(); |
---|
| 91 | break; |
---|
| 92 | } |
---|
| 93 | } |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | Rcv = 1/ (k * Math.pow(V, a)); |
---|
| 97 | R = Rb + Rcv; |
---|
| 98 | |
---|
| 99 | double K = 0; |
---|
| 100 | double Cair = EnvironmentConditions.AIR_HEAT_CAPACITY; |
---|
| 101 | double ro = EnvironmentConditions.AIR_DENSITY; |
---|
| 102 | |
---|
| 103 | K = V * Cair * ro; |
---|
| 104 | //System.out.println("-------K: " + K + "; V:" + V); |
---|
| 105 | |
---|
| 106 | double delta_t = Sim_system.clock() - timestamp; |
---|
| 107 | |
---|
| 108 | double Tin = EnvironmentConditions.ROOM_TEMPERATURE; |
---|
| 109 | Pserv = node.getPowerInterface().getRecentPowerUsage().getValue(); |
---|
| 110 | Pserv = Pserv + Pfan; |
---|
| 111 | |
---|
| 112 | NodeGroup ng = (NodeGroup) node.getParent(); |
---|
| 113 | for(Node n: ng.getNodes()){ |
---|
| 114 | int cpuNodeId = Integer.valueOf(cpu.getParent().getName().split("_")[1]).intValue(); |
---|
| 115 | int nodeId = Integer.valueOf(n.getName().split("_")[1]).intValue(); |
---|
| 116 | if(nodeId - cpuNodeId == 1 && (cpuNodeId - 1)/3 == (nodeId - 1)/3){ |
---|
| 117 | if(n.getThermalInterface().getRecentTemperature().getValue() == 0){ |
---|
| 118 | Tin = EnvironmentConditions.i5_nodeTidle; |
---|
| 119 | } else |
---|
| 120 | Tin = n.getThermalInterface().getRecentTemperature().getValue(); |
---|
| 121 | //System.out.println("======" + cpu.getFullName() + " previous node: " + n.getFullName() + "; " + Tin); |
---|
| 122 | break; |
---|
| 123 | } |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | double targetTemp = Pserv/K + Tin; |
---|
| 127 | objective_temperature = targetTemp; |
---|
| 128 | |
---|
| 129 | new_temperature = objective_temperature + (old_temperature - objective_temperature) * Math.exp(-delta_t / (R * C)); |
---|
| 130 | |
---|
| 131 | // 5) save everything |
---|
| 132 | timestamp = Sim_system.clock(); |
---|
| 133 | old_temperature = new_temperature; |
---|
| 134 | //System.out.println(node.getFullName() + "; node temp:" + new_temperature + "; "+ objective_temperature ); |
---|
| 135 | return new_temperature; |
---|
| 136 | } |
---|
| 137 | } |
---|