package experiments.e2dc2015.models.arm; import schedframe.resources.StandardResourceType; import schedframe.resources.computing.Node; import schedframe.resources.computing.Processor; import schedframe.resources.computing.coolemall.NodeGroup; import schedframe.resources.computing.profiles.energy.ResourceEvent; import schedframe.resources.devices.Device; import schedframe.resources.devices.Fan; import schedframe.resources.devices.PhysicalResource; import schedframe.scheduling.manager.tasks.JobRegistry; import eduni.simjava.Sim_system; import example.energy.BaseEnergyEstimationPlugin; import experiments.e2dc2015.EnvironmentConditions; public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin { private double timestamp = 0; private double old_temperature = EnvironmentConditions.arm_nodeTidle; private double new_temperature = -1; private double objective_temperature = EnvironmentConditions.arm_nodeTidle; private static double Pidle = 2; private static double Pfull = 3; public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) { Node node = (Node) resource; double powerConsumption = 0; double Pcpu = 0; for(Processor cpu: node.getProcessors()){ Pcpu = Pcpu + cpu.getPowerInterface().getRecentPowerUsage().getValue(); } powerConsumption = Pcpu + Pidle + (Pfull- Pidle) * node.getLoadInterface().getRecentUtilization().getValue()/100; //powerConsumption = powerConsumption + node.getProcessors().get(0).getResourceCharacteristic().getDevices().get(0).getPowerInterface().getRecentPowerUsage().getValue(); return powerConsumption; } @Override public double estimateTemperature(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) { Node node = (Node) resource; Processor cpu = node.getProcessors().get(0); double Pserv = 0; double R = 0; double Rb = 0; double Rcv = 0; try{ Rb = Double.valueOf(cpu.getPowerInterface().getParameters().get("thermalResistance").get(0).getContent()).doubleValue(); } catch (Exception e){ // } double k = 0; try{ k = Double.valueOf(cpu.getPowerInterface().getParameters().get("k").get(0).getContent()).doubleValue(); } catch (Exception e){ // } double a = 0; try{ a = Double.valueOf(cpu.getPowerInterface().getParameters().get("a").get(0).getContent()).doubleValue(); } catch (Exception e){ a = 1; } double C = 0; try{ C = Double.valueOf(cpu.getPowerInterface().getParameters().get("thermalCapacity").get(0).getContent()).doubleValue(); } catch (Exception e){ // } double V = 0; double Pfan = 0; for(Device device: node.getParent().getResourceCharacteristic().getDevices()){ if(device.getType().equals(StandardResourceType.Fan)){ int fanId = Integer.valueOf(device.getName().split("_")[1]).intValue(); int nodeId = Integer.valueOf(node.getName().split("_")[1]).intValue(); if(nodeId == fanId){ Fan fan = (Fan) device; V = fan.getAirflowInterface().getRecentAirflow().getValue(); Pfan = fan.getPowerInterface().getRecentPowerUsage().getValue(); break; } } } Rcv = 1/ (k * Math.pow(V, a)); R = Rb + Rcv; double K = 0; double Cair = EnvironmentConditions.AIR_HEAT_CAPACITY; double ro = EnvironmentConditions.AIR_DENSITY; K = V * Cair * ro; //System.out.println("-------K: " + K + "; V:" + V); double delta_t = Sim_system.clock() - timestamp; double Tin = EnvironmentConditions.ROOM_TEMPERATURE; Pserv = node.getPowerInterface().getRecentPowerUsage().getValue(); Pserv = Pserv + Pfan; NodeGroup ng = (NodeGroup) node.getParent(); for(Node n: ng.getNodes()){ int cpuNodeId = Integer.valueOf(cpu.getParent().getName().split("_")[1]).intValue(); int nodeId = Integer.valueOf(n.getName().split("_")[1]).intValue(); if(nodeId - cpuNodeId == 9){ if(n.getThermalInterface().getRecentTemperature().getValue() == 0){ Tin = EnvironmentConditions.arm_nodeTidle; } else Tin = n.getThermalInterface().getRecentTemperature().getValue(); //System.out.println("======" + cpu.getFullName() + " previous node: " + n.getFullName() + "; " + Tin); break; } } double targetTemp = Pserv/K + Tin; objective_temperature = targetTemp; new_temperature = objective_temperature + (old_temperature - objective_temperature) * Math.exp(-delta_t / (R * C)); // 5) save everything timestamp = Sim_system.clock(); old_temperature = new_temperature; return new_temperature; } }