1 | package test.ariel; |
---|
2 | |
---|
3 | import java.util.Map; |
---|
4 | |
---|
5 | import schedframe.events.scheduling.SchedulingEvent; |
---|
6 | import schedframe.resources.computing.Processor; |
---|
7 | import schedframe.resources.units.PEUnit; |
---|
8 | import schedframe.resources.units.ProcessingElements; |
---|
9 | import schedframe.resources.units.ResourceUnit; |
---|
10 | import schedframe.resources.units.ResourceUnitName; |
---|
11 | import schedframe.resources.units.StandardResourceUnitName; |
---|
12 | import dcworms.schedframe.scheduling.ExecTask; |
---|
13 | import example.timeestimation.BaseTimeEstimationPlugin; |
---|
14 | |
---|
15 | public 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 | } |
---|