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