diff --git a/src/main/java/mvd/jester/App.java b/src/main/java/mvd/jester/App.java index 3a6e89d..9696b53 100644 --- a/src/main/java/mvd/jester/App.java +++ b/src/main/java/mvd/jester/App.java @@ -12,9 +12,11 @@ import mvd.jester.tests.FonsecaNelis; import mvd.jester.tests.JiangYi; import mvd.jester.tests.MelaniButtazzo; import mvd.jester.tests.SchmidMottok; +import mvd.jester.tests.Tester; import mvd.jester.tests.TypeFunction.KnownStructureWithMaxThreads; import mvd.jester.tests.TypeFunction.KnownStructure; import mvd.jester.tests.TypeFunction.UnkownStructure; +import mvd.jester.tests.TypeFunction.TestFunction; /** @@ -25,29 +27,30 @@ public class App { public static void main(String[] args) { { SystemManager manager = new SystemManager<>(DagTaskBuilder.class); + manager.setNumberOfProcessors(32); TestEnvironment te = new TestEnvironment(); List> tests = te.registerTests(Arrays.asList( new SchmidMottok(new KnownStructureWithMaxThreads(manager), manager), - new SchmidMottok(new KnownStructure(), manager), + new Tester(new KnownStructure(), manager), // new MelaniButtazzo(manager), - new FonsecaNelis(manager) - /* new JiangYi(manager) */)); + // new FonsecaNelis(manager) + new JiangYi(manager))); te.varyRenyiUtilization(manager, tests, 100); } // { - // SystemManager manager = new SystemManager<>(DagTaskBuilder.class); - // TestEnvironment te = new TestEnvironment(); + // SystemManager manager = new SystemManager<>(DagTaskBuilder.class); + // TestEnvironment te = new TestEnvironment(); - // List> tests = te.registerTests(Arrays.asList( - // new SchmidMottok(new KnownStructureWithMaxThreads(manager), manager), - // new SchmidMottok(new KnownStructure(), manager) - // // new MelaniButtazzo(manager) - // , new FonsecaNelis(manager) - // )); + // List> tests = te.registerTests(Arrays.asList( + // new SchmidMottok(new KnownStructureWithMaxThreads(manager), manager), + // new SchmidMottok(new KnownStructure(), manager) + // // new MelaniButtazzo(manager) + // , new FonsecaNelis(manager) + // )); - // te.varyUtilization(manager, tests, 500); + // te.varyUtilization(manager, tests, 500); // } // { // SystemManager manager = new SystemManager<>(DagTaskBuilder.class); diff --git a/src/main/java/mvd/jester/TestEnvironment.java b/src/main/java/mvd/jester/TestEnvironment.java index a715e25..a210696 100644 --- a/src/main/java/mvd/jester/TestEnvironment.java +++ b/src/main/java/mvd/jester/TestEnvironment.java @@ -244,7 +244,7 @@ public class TestEnvironment { abstractTestInstances.forEach(t -> resultMap.put(t, (long) 0)); resultLogger.logHeader(resultMap, "Utilization"); - for (double util = 1; util <= numberOfProcessors; util += 0.25) { + for (double util = 1; util <= numberOfProcessors; util += (double)numberOfProcessors/32) { resultMap.replaceAll((k, v) -> (long) 0); for (int i = 0; i < numberOfTaskSetsPerUtil; ++i) { final Set taskSet = manager.getBuilder().generateRenyiTaskSet(util); diff --git a/src/main/java/mvd/jester/model/SystemManager.java b/src/main/java/mvd/jester/model/SystemManager.java index cfd4026..10cea1c 100644 --- a/src/main/java/mvd/jester/model/SystemManager.java +++ b/src/main/java/mvd/jester/model/SystemManager.java @@ -179,7 +179,7 @@ public class SystemManager implements SystemManagerInterface private long maxNumberOfThreads = numberOfProcessors; private long depth = 2; private long p_par = 80; - private long p_add = 20; + private long p_add = 10; public DagTaskBuilder() { } @@ -280,14 +280,18 @@ public class SystemManager implements SystemManagerInterface final long criticalPath = DagUtils.calculateCriticalPath(jobDag); final long period = randomRenyiPeriod(workload, criticalPath, totalUtilization); - final long numberOfThreads = randomNumberOfThreads(numberOfProcessors / 2); + // final long numberOfThreads = randomNumberOfThreads(numberOfProcessors / 2); + // TODO: Change back to above + final long numberOfThreads = LongMath.divide(workload - + criticalPath, period - criticalPath, RoundingMode.CEILING); return new DagTask(jobDag, period, numberOfThreads); } private long randomRenyiPeriod(final long workload, final long criticalPath, final double totalUtilization) { - final double firstPart = (criticalPath + (double) (workload) / (0.4 * totalUtilization)); + final double firstPart = + (criticalPath + (double) (workload) / (0.4 * totalUtilization)); final double gamma = new GammaDistribution(2, 1).sample(); final double secondPart = 1 + 0.25 * gamma; diff --git a/src/main/java/mvd/jester/tests/Tester.java b/src/main/java/mvd/jester/tests/Tester.java new file mode 100644 index 0000000..d551589 --- /dev/null +++ b/src/main/java/mvd/jester/tests/Tester.java @@ -0,0 +1,93 @@ +package mvd.jester.tests; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import mvd.jester.info.SchedulingInfo; +import mvd.jester.info.TerminationInfo; +import mvd.jester.model.DagTask; +import mvd.jester.model.SortedTaskSet; +import mvd.jester.model.SystemManagerInterface; +import mvd.jester.model.Task; +import mvd.jester.priority.PriorityManager; +import mvd.jester.priority.RateMonotonic; + +public class Tester extends AbstractTest { + + private final Map responseTimes; + private final PriorityManager priorityManager; + private final TypeFunction structure; + + public Tester(TypeFunction structure, final SystemManagerInterface manager) { + super(manager); + this.responseTimes = new HashMap<>(); + this.priorityManager = new RateMonotonic(); + this.structure = structure; + } + + + @Override + public SchedulingInfo runSchedulabilityCheck(SortedTaskSet tasks) { + responseTimes.clear(); + for (final DagTask t : tasks) { + final long responseTime = calculateResponseTime(tasks, t); + responseTimes.put(t, new TerminationInfo(t.getDeadline(), responseTime)); + } + + return new SchedulingInfo(responseTimes.values()); + } + + @Override + public PriorityManager getPriorityManager() { + return priorityManager; + } + + @Override + public String getName() { + return "Tester_" + structure.getType(); + } + + private long calculateResponseTime(final Set tasks, final DagTask task) { + final long minimumWcet = task.getCriticalPath(); + long responseTime = minimumWcet; + long previousResponseTime = 0; + + long currentNumberOfThreads = 0; + for (final DagTask t : tasks) { + if (t.getPeriod() < task.getPeriod()) { + final long numberOfThreads = structure.getNumberOfThreads(t); + currentNumberOfThreads += numberOfThreads; + } + } + + do { + previousResponseTime = responseTime; + double taskInterference = 0; + if (currentNumberOfThreads + structure.getNumberOfThreads(task) > manager + .getNumberOfProcessors()) { + for (final DagTask t : tasks) { + if (t.getPeriod() < task.getPeriod()) { + final long numberOfThreads = structure.getNumberOfThreads(t); + + for (int p = 0; p < numberOfThreads; ++p) { + taskInterference += + Math.min( + structure.getTaskInterference(t, responseTimes, + responseTime, p + 1), + responseTime - minimumWcet + 1); + } + } + } + + taskInterference /= manager.getNumberOfProcessors(); + } + final double selfInterference = structure.getSelfInterference(task); + + final long totalInterference = (long) Math.floor(taskInterference + selfInterference); + + responseTime = minimumWcet + totalInterference; + } while (previousResponseTime != responseTime); + + return responseTime; + } +} diff --git a/src/main/java/mvd/jester/tests/TypeFunction.java b/src/main/java/mvd/jester/tests/TypeFunction.java index 8ce6295..0750775 100644 --- a/src/main/java/mvd/jester/tests/TypeFunction.java +++ b/src/main/java/mvd/jester/tests/TypeFunction.java @@ -181,4 +181,54 @@ public interface TypeFunction { } } + public class TestFunction implements TypeFunction { + + @Override + public double getTaskInterference(final DagTask task, + final Map responseTimes, final long interval, + final long parallelism) { + if (responseTimes.containsKey(task)) { + final long minWcet = task.getCriticalPath(); + final long period = task.getPeriod(); + final long amountOfJobs = (LongMath.divide(interval + period - minWcet, + period, RoundingMode.FLOOR) + 1); + + double workload = 0; + + for (final Segment s : task.getWorkloadDistribution()) { + final long numberOfThreads = s.getHeight() > 1 ? task.getNumberOfThreads() : 1; + if (numberOfThreads >= parallelism) { + workload += (double) (s.getHeight() * s.getWidth()) / numberOfThreads; + } + } + + final double interference = amountOfJobs * workload; + + return interference; + } else { + throw new RuntimeException("Task was not found in task set!"); + } + } + + @Override + public double getSelfInterference(final DagTask task) { + final long numberOfThreads = task.getNumberOfThreads(); + + double interference = task.getWorkload() - task.getCriticalPath(); + interference /= numberOfThreads; + + return interference; + } + + @Override + public String getType() { + return "TS"; + } + + @Override + public long getNumberOfThreads(final DagTask task) { + return task.getNumberOfThreads(); + } + } + }