[506] | 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 | int cnt = peUnit.getUsedAmount(); |
---|
| 33 | |
---|
[1084] | 34 | double remainingLength = task.getLength() * (1 - completionPercentage/100); |
---|
[506] | 35 | |
---|
| 36 | double execTime = (remainingLength / (cnt * speed)); |
---|
| 37 | |
---|
| 38 | if (Double.compare(execTime, 0.001) < 0) { |
---|
| 39 | execTime = 0.001; |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | execTime = Math.ceil(execTime); |
---|
| 43 | return execTime; |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | } |
---|