source: DCWoRMS/trunk/src/test/ariel/CPUFreqScalingExecTimeEstimationPlugin.java @ 506

Revision 506, 1.4 KB checked in by wojtekp, 13 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package test.ariel;
2
3import java.util.Map;
4
5import schedframe.events.scheduling.SchedulingEvent;
6import schedframe.resources.computing.Processor;
7import schedframe.resources.units.PEUnit;
8import schedframe.resources.units.ProcessingElements;
9import schedframe.resources.units.ResourceUnit;
10import schedframe.resources.units.ResourceUnitName;
11import schedframe.resources.units.StandardResourceUnitName;
12import dcworms.schedframe.scheduling.ExecTask;
13import example.timeestimation.BaseTimeEstimationPlugin;
14
15public class CPUFreqScalingExecTimeEstimationPlugin extends BaseTimeEstimationPlugin{
16
17        public double execTimeEstimation(SchedulingEvent event, ExecTask task,
18                        Map<ResourceUnitName, ResourceUnit> allocatedResources,
19                        double completionPercentage) {
20
21                PEUnit peUnit = (PEUnit) allocatedResources.get(StandardResourceUnitName.PE);
22
23                double speed;
24                if(peUnit instanceof ProcessingElements){
25                        ProcessingElements pe = (ProcessingElements)peUnit;
26                        Processor cpu = (Processor)pe.get(0);
27                        speed = cpu.getPowerInterface().getPState().getFrequency()/1000;
28                }
29                else
30                        speed = peUnit.getSpeed();
31               
32               
33
34                int cnt = peUnit.getUsedAmount();
35
36                double remainingLength =  task.getLength() * (1 - completionPercentage/100);
37
38                double execTime = (remainingLength / (cnt * speed));
39
40                if (Double.compare(execTime, 0.001) < 0) {
41                        execTime = 0.001;
42                }
43
44                execTime = Math.ceil(execTime);
45                return execTime;
46        }
47
48}
Note: See TracBrowser for help on using the repository browser.