1 | package experiments.e2dc2013.recs.plugins.energy; |
---|
2 | |
---|
3 | import schedframe.events.EventReason; |
---|
4 | import schedframe.resources.computing.ComputingResource; |
---|
5 | import schedframe.resources.computing.Processor; |
---|
6 | import schedframe.resources.computing.profiles.energy.ResourceEvent; |
---|
7 | import schedframe.resources.computing.profiles.energy.airthroughput.StandardAirflowStateName; |
---|
8 | import schedframe.resources.devices.PhysicalResource; |
---|
9 | import schedframe.scheduling.manager.tasks.JobRegistry; |
---|
10 | import example.energy.BaseEnergyEstimationPlugin; |
---|
11 | |
---|
12 | public class RecsCpuBaseEEP extends BaseEnergyEstimationPlugin { |
---|
13 | |
---|
14 | private static int START_ID = 0; |
---|
15 | private static int END_ID = 8; |
---|
16 | |
---|
17 | protected double cpuTypeConstant; |
---|
18 | protected double inletTemperature; |
---|
19 | |
---|
20 | public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry, |
---|
21 | PhysicalResource resource) { |
---|
22 | |
---|
23 | double powerConsumption = 0; |
---|
24 | Processor cpu = (Processor) resource; |
---|
25 | |
---|
26 | try { |
---|
27 | powerConsumption = cpu.getPowerInterface().getPowerConsumption(cpu.getPowerInterface().getPState()); |
---|
28 | } catch (NoSuchFieldException e) { |
---|
29 | // TODO Auto-generated catch block |
---|
30 | e.printStackTrace(); |
---|
31 | } |
---|
32 | |
---|
33 | return powerConsumption; |
---|
34 | } |
---|
35 | |
---|
36 | public double estimateAirThroughput(ResourceEvent event, JobRegistry jobRegistry, ComputingResource resource) { |
---|
37 | |
---|
38 | double airThroughput = 0; |
---|
39 | try { |
---|
40 | if(event.getReason() == EventReason.SIM_INIT) |
---|
41 | airThroughput = resource.getAirflowInterface().getAirflow(StandardAirflowStateName.OFF); |
---|
42 | else |
---|
43 | airThroughput = resource.getAirflowInterface().getAirflow(resource.getAirflowInterface().getAirflowState()); |
---|
44 | } catch (NoSuchFieldException e) { |
---|
45 | // TODO Auto-generated catch block |
---|
46 | e.printStackTrace(); |
---|
47 | } |
---|
48 | |
---|
49 | Integer resId = Integer.parseInt(resource.getName().split("_")[1]); |
---|
50 | if(resId >= START_ID && resId <= END_ID){ |
---|
51 | for(ComputingResource compResource: resource.getParent().getChildren()){ |
---|
52 | Integer id = Integer.parseInt(compResource.getName().split("_")[1]); |
---|
53 | if(id - resId == 9 || id - resId == -9){ |
---|
54 | try { |
---|
55 | airThroughput = airThroughput + compResource.getAirflowInterface().getAirflow(compResource.getAirflowInterface().getAirflowState())/2; |
---|
56 | } catch (NoSuchFieldException e) { |
---|
57 | |
---|
58 | } |
---|
59 | } |
---|
60 | } |
---|
61 | } |
---|
62 | |
---|
63 | return airThroughput; |
---|
64 | } |
---|
65 | } |
---|
66 | |
---|