Commit 84d3cbf6 by Michael Schmid

added tester

parent 9ad4681d
......@@ -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<DagTaskBuilder> manager = new SystemManager<>(DagTaskBuilder.class);
manager.setNumberOfProcessors(32);
TestEnvironment te = new TestEnvironment();
List<AbstractTest<DagTask>> 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<DagTaskBuilder> manager = new SystemManager<>(DagTaskBuilder.class);
// TestEnvironment te = new TestEnvironment();
// SystemManager<DagTaskBuilder> manager = new SystemManager<>(DagTaskBuilder.class);
// TestEnvironment te = new TestEnvironment();
// List<AbstractTest<DagTask>> tests = te.registerTests(Arrays.asList(
// new SchmidMottok(new KnownStructureWithMaxThreads(manager), manager),
// new SchmidMottok(new KnownStructure(), manager)
// // new MelaniButtazzo(manager)
// , new FonsecaNelis(manager)
// ));
// List<AbstractTest<DagTask>> 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<DagTaskBuilder> manager = new SystemManager<>(DagTaskBuilder.class);
......
......@@ -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<DagTask> taskSet = manager.getBuilder().generateRenyiTaskSet(util);
......
......@@ -179,7 +179,7 @@ public class SystemManager<T extends Builder> 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<T extends Builder> 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;
......
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<DagTask> {
private final Map<Task, TerminationInfo> 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<DagTask> 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<DagTask> 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;
}
}
......@@ -181,4 +181,54 @@ public interface TypeFunction {
}
}
public class TestFunction implements TypeFunction {
@Override
public double getTaskInterference(final DagTask task,
final Map<Task, TerminationInfo> 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();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment