1 | package experiments.simpat2012.recs.plugins.energy; |
---|
2 | |
---|
3 | import java.io.FileNotFoundException; |
---|
4 | import java.io.IOException; |
---|
5 | |
---|
6 | import schedframe.resources.computing.Node; |
---|
7 | import schedframe.resources.computing.Processor; |
---|
8 | import schedframe.resources.computing.profiles.energy.ResourceEvent; |
---|
9 | import schedframe.resources.devices.PhysicalResource; |
---|
10 | import schedframe.scheduling.manager.tasks.JobRegistry; |
---|
11 | |
---|
12 | public class IntelNodeEEP extends RecsNodeBaseEEP { |
---|
13 | |
---|
14 | public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry, |
---|
15 | PhysicalResource resource) { |
---|
16 | double powerConsumption = 0; |
---|
17 | Node node = (Node) resource; |
---|
18 | |
---|
19 | try { |
---|
20 | if(jobRegistry.getRunningTasks().size() > 0) { |
---|
21 | powerConsumption = powerConsumption + getMeasuredPower(createQuery(jobRegistry.getRunningTasks().get(0))); |
---|
22 | } |
---|
23 | else { |
---|
24 | for(Processor cpu: node.getProcessors()){ |
---|
25 | try{ |
---|
26 | //powerConsumption = powerConsumption + cpu.getPowerInterface().getRecentPowerUsage().getValue(); |
---|
27 | } catch (Exception e){ |
---|
28 | |
---|
29 | } |
---|
30 | } |
---|
31 | try { |
---|
32 | powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState()); |
---|
33 | } catch (NoSuchFieldException e) { |
---|
34 | } |
---|
35 | } |
---|
36 | } catch (FileNotFoundException e) { |
---|
37 | // TODO Auto-generated catch block |
---|
38 | e.printStackTrace(); |
---|
39 | } catch (IOException e) { |
---|
40 | // TODO Auto-generated catch block |
---|
41 | e.printStackTrace(); |
---|
42 | } |
---|
43 | |
---|
44 | return powerConsumption; |
---|
45 | |
---|
46 | /*double nodeIdle = 11.5; |
---|
47 | double cpuBase = 8; |
---|
48 | double c = 1.12; |
---|
49 | double f; |
---|
50 | double fbase; |
---|
51 | double papp = 0; |
---|
52 | double load = 0; |
---|
53 | |
---|
54 | double powerConsumption = 0; |
---|
55 | ComputingNode node = (ComputingNode) resource; |
---|
56 | |
---|
57 | if(jobRegistry.getRunningTasks().size() > 0) { |
---|
58 | ExecTask task = jobRegistry.getRunningTasks().get(0); |
---|
59 | try { |
---|
60 | load = task.getCpuCntRequest()/8; |
---|
61 | } catch (NoSuchFieldException e) { |
---|
62 | // TODO Auto-generated catch block |
---|
63 | e.printStackTrace(); |
---|
64 | } |
---|
65 | f = node.getProcessors().get(0).getPowerInterface().getFrequency(); |
---|
66 | fbase = node.getProcessors().get(0).getPowerInterface().getHighestPState().getFrequency(); |
---|
67 | TaskToApp tta = new TaskToApp(); |
---|
68 | switch(tta.getAppType(task)){ |
---|
69 | case abinit:{ |
---|
70 | papp = 3.3; |
---|
71 | break; |
---|
72 | } |
---|
73 | case c_ray:{ |
---|
74 | papp = 4; |
---|
75 | break; |
---|
76 | } |
---|
77 | case fft: { |
---|
78 | papp = 3.5; |
---|
79 | break; |
---|
80 | } |
---|
81 | case lin_3gb: { |
---|
82 | papp = 6; |
---|
83 | break; |
---|
84 | } |
---|
85 | case lin_tiny: { |
---|
86 | papp = 2.5; |
---|
87 | break; |
---|
88 | } |
---|
89 | case tar: { |
---|
90 | papp = 3; |
---|
91 | break; |
---|
92 | } |
---|
93 | } |
---|
94 | try { |
---|
95 | load = getLoad(createQuery(jobRegistry.getRunningTasks().get(0)))/100; |
---|
96 | } catch (FileNotFoundException e) { |
---|
97 | // TODO Auto-generated catch block |
---|
98 | e.printStackTrace(); |
---|
99 | } catch (IOException e) { |
---|
100 | // TODO Auto-generated catch block |
---|
101 | e.printStackTrace(); |
---|
102 | } |
---|
103 | powerConsumption = nodeIdle + load * cpuBase * Math.pow(c, (f-fbase)/100) + papp; |
---|
104 | try { |
---|
105 | double temp = nodeIdle + task.getCpuCntRequest()/8 * cpuBase * Math.pow(c, (f-fbase)/100) + papp; |
---|
106 | try { |
---|
107 | System.out.println(tta.getAppType(task).name()+":"+node.getName()+":"+task.getCpuCntRequest() +":"+powerConsumption+";"+ temp+";"+getMeasuredPower(createQuery(task))); |
---|
108 | } catch (FileNotFoundException e) { |
---|
109 | // TODO Auto-generated catch block |
---|
110 | e.printStackTrace(); |
---|
111 | } catch (IOException e) { |
---|
112 | // TODO Auto-generated catch block |
---|
113 | e.printStackTrace(); |
---|
114 | } |
---|
115 | } catch (NoSuchFieldException e) { |
---|
116 | // TODO Auto-generated catch block |
---|
117 | e.printStackTrace(); |
---|
118 | } |
---|
119 | } |
---|
120 | else { |
---|
121 | for(Processor cpu: node.getProcessors()){ |
---|
122 | try{ |
---|
123 | //powerConsumption = powerConsumption + cpu.getPowerInterface().getRecentPowerUsage().getValue(); |
---|
124 | } catch (Exception e){ |
---|
125 | |
---|
126 | } |
---|
127 | } |
---|
128 | try { |
---|
129 | powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState()); |
---|
130 | } catch (NoSuchFieldException e) { |
---|
131 | } |
---|
132 | } |
---|
133 | */ |
---|
134 | |
---|
135 | /*double powerConsumption = 0; |
---|
136 | ComputingNode node = (ComputingNode) resource; |
---|
137 | if(jobRegistry.getRunningTasks().size() > 0) { |
---|
138 | for(Processor cpu: node.getProcessors()){ |
---|
139 | try{ |
---|
140 | powerConsumption = powerConsumption + cpu.getPowerInterface().getPState().getPower(); |
---|
141 | } catch (Exception e){ |
---|
142 | |
---|
143 | } |
---|
144 | } |
---|
145 | } |
---|
146 | try { |
---|
147 | powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState()); |
---|
148 | } catch (NoSuchFieldException e) { |
---|
149 | } |
---|
150 | System.out.println("pci:" + powerConsumption);*/ |
---|
151 | //return powerConsumption; |
---|
152 | } |
---|
153 | |
---|
154 | } |
---|