Commit dbeac016 by Michael Schmid

Fonseca test now works as well

parent 75736ee6
......@@ -6,6 +6,8 @@ import mvd.jester.model.DagTask;
import mvd.jester.model.SystemSetup;
import mvd.jester.tests.AbstractTest;
import mvd.jester.tests.FonsecaNelis;
import mvd.jester.tests.MelaniButtazzo;
import mvd.jester.tests.SchmidMottok;
/**
......@@ -19,12 +21,10 @@ public class App {
new SystemSetup.DagTaskBuilder().setNumberOfProcessors(p);
TestEnvironment te = new TestEnvironment();
List<AbstractTest<DagTask>> tests =
te.registerTests(Arrays.asList(/*
* new SchmidMottok(p), new MelaniButtazzo(p) ,
*/ new FonsecaNelis(p)));
List<AbstractTest<DagTask>> tests = te.registerTests(Arrays.asList(new SchmidMottok(p),
/* new MelaniButtazzo(p), */ new FonsecaNelis(p)));
te.runExperiments(builder, tests, p, 100);
te.runExperiments(builder, tests, p, 100); // TODO: Change back to 500
}
}
}
......@@ -91,7 +91,7 @@ public class TestEnvironment {
abstractTestInstances.forEach(t -> resultMap.put(t, (long) 0));
for (double util = 1; util <= numberOfProcessors; util += 0.25) {
resultMap.replaceAll((k, v) -> (long) 0);
nextTry: for (int i = 0; i < numberOfTaskSetsPerUtil; ++i) {
for (int i = 0; i < numberOfTaskSetsPerUtil; ++i) {
final Set<DagTask> taskSet = builder.generateTaskSet(util);
System.out.print(Math.round((double) checkedTasksets / numberOfTaskSets * 100)
......@@ -102,14 +102,8 @@ public class TestEnvironment {
final SortedTaskSet<DagTask> sortedTaskSet =
new SortedTaskSet<>(priorityManager);
sortedTaskSet.addAll(taskSet);
final SchedulingInfo schedulingInfo;
try {
schedulingInfo = testInstance.runSchedulabilityCheck(sortedTaskSet);
} catch (Exception e) {
i--;
continue nextTry;
// TODO: remove this exception
}
final SchedulingInfo schedulingInfo =
testInstance.runSchedulabilityCheck(sortedTaskSet);
if (schedulingInfo.getFeasibility() == Feasiblity.SUCCEEDED) {
resultMap.computeIfPresent(testInstance, (k, v) -> v + 1);
......
......@@ -209,7 +209,7 @@ public class SystemSetup<T extends Task> {
private long maxNumberOfBranches = 5;
private long depth = 2;
private long p_par = 80;
private long p_add = 20;
private long p_add = 5; // TODO: Change back to 20
public DagTaskBuilder() {
}
......
......@@ -13,7 +13,6 @@ import java.util.Set;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.common.math.LongMath;
import org.jgrapht.Graphs;
import org.jgrapht.experimental.dag.DirectedAcyclicGraph;
import org.jgrapht.graph.DefaultEdge;
import mvd.jester.info.SchedulingInfo;
......@@ -35,13 +34,13 @@ public class FonsecaNelis extends AbstractTest<DagTask> {
private final Map<Task, TerminationInfo> responseTimes;
private final PriorityManager priorityManager;
private final Map<Task, Set<Segment>> sortedSegments;
private final Map<Task, Set<Segment>> carryOutSegments;
public FonsecaNelis(final long numberOfProcessors) {
super(numberOfProcessors);
this.responseTimes = new HashMap<>();
this.priorityManager = new RateMonotonic();
this.sortedSegments = new HashMap<>();
this.carryOutSegments = new HashMap<>();
}
@Override
......@@ -51,7 +50,7 @@ public class FonsecaNelis extends AbstractTest<DagTask> {
@Override
public SchedulingInfo runSchedulabilityCheck(final SortedTaskSet<DagTask> tasks) {
sortedSegments.clear();
carryOutSegments.clear();
responseTimes.clear();
createNFJandDecompositionTree(tasks);
for (final DagTask t : tasks) {
......@@ -69,80 +68,11 @@ public class FonsecaNelis extends AbstractTest<DagTask> {
final DirectedAcyclicGraph<Job, DefaultEdge> nfjJobDag =
DagUtils.createNFJGraph(jobDag);
final BinaryDecompositionTree<Job> tree = DagUtils.createDecompositionTree(nfjJobDag);
// TODO: remove this
if (!DagUtils.checkNFJProperty(nfjJobDag) || !checkTree(nfjJobDag, tree)) {
throw new RuntimeException("Nicht NFJ in Test!");
}
sortedSegments.put(t, constructCarryOutDistribution(nfjJobDag, tree));
}
}
// TODO: Remove this function
private boolean checkTree(DirectedAcyclicGraph<Job, DefaultEdge> nfjJobDag,
BinaryDecompositionTree<Job> tree) {
DirectedAcyclicGraph<Job, DefaultEdge> jobDagFromTree =
DagUtils.createNFJfromDecompositionTree(tree);
if (nfjJobDag.vertexSet().size() != jobDagFromTree.vertexSet().size()) {
return false;
}
if (jobDagFromTree.edgeSet().size() != nfjJobDag.edgeSet().size()) {
return false;
}
for (DefaultEdge e : nfjJobDag.edgeSet()) {
Job target = nfjJobDag.getEdgeTarget(e);
Job source = nfjJobDag.getEdgeSource(e);
if (!jobDagFromTree.containsEdge(source, target)) {
return false;
carryOutSegments.put(t, constructCarryOutDistribution(nfjJobDag, tree));
}
}
for (Job j : nfjJobDag) {
for (Job n : nfjJobDag) {
if (n == j) {
continue;
}
if (nfjJobDag.containsEdge(n, j) && !jobDagFromTree.containsEdge(n, j)) {
return false;
}
}
if (nfjJobDag.inDegreeOf(j) != jobDagFromTree.inDegreeOf(j))
return false;
if (nfjJobDag.outDegreeOf(j) != jobDagFromTree.outDegreeOf(j))
return false;
for (Job p : Graphs.predecessorListOf(nfjJobDag, j)) {
if (!Graphs.predecessorListOf(jobDagFromTree, j).contains(p)) {
return false;
}
}
for (Job s : Graphs.successorListOf(nfjJobDag, j)) {
if (!Graphs.successorListOf(jobDagFromTree, j).contains(s)) {
return false;
}
}
for (Job a : nfjJobDag.getAncestors(nfjJobDag, j)) {
if (!jobDagFromTree.getAncestors(jobDagFromTree, j).contains(a)) {
return false;
}
}
for (Job d : nfjJobDag.getDescendants(nfjJobDag, j)) {
if (!jobDagFromTree.getDescendants(jobDagFromTree, j).contains(d)) {
return false;
}
}
}
return true;
}
private Set<Segment> constructCarryOutDistribution(
final DirectedAcyclicGraph<Job, DefaultEdge> nfjDag,
final BinaryDecompositionTree<Job> tree) {
......@@ -182,7 +112,7 @@ public class FonsecaNelis extends AbstractTest<DagTask> {
if (node.getNodeType().equals(NodeType.LEAF)) {
return new Node<TreeJob>(parent, new TreeJob(node.getObject()));
} else {
final Node<TreeJob> modifiedNode = new Node<TreeJob>(null, node.getNodeType());
final Node<TreeJob> modifiedNode = new Node<TreeJob>(parent, node.getNodeType());
modifiedNode.setLeftNode(transformNode(modifiedNode, node.getLeftNode()));
modifiedNode.setRightNode(transformNode(modifiedNode, node.getRightNode()));
return modifiedNode;
......@@ -233,10 +163,6 @@ public class FonsecaNelis extends AbstractTest<DagTask> {
final long totalInterference = (long) Math.floor(taskInterference + selfInterference);
responseTime = criticalPath + totalInterference;
// TODO: remove check of deadline if bug is found
if (responseTime > task.getDeadline()) {
return responseTime;
}
} while (responseTime != previousResponseTime);
return responseTime;
......@@ -245,9 +171,9 @@ public class FonsecaNelis extends AbstractTest<DagTask> {
private double getTaskInterference(final DagTask task, final long interval) {
final long period = task.getPeriod();
final long criticalPath = task.getCriticalPath();
final long numberOfIntervals =
final long numberOfPeriods =
LongMath.divide(interval - criticalPath, period, RoundingMode.FLOOR);
final long carryInAndOutInterval = interval - Math.max(0, numberOfIntervals) * period;
final long carryInAndOutInterval = interval - Math.max(0, numberOfPeriods) * period;
final long numberOfBodyJobs =
LongMath.divide(interval - carryInAndOutInterval, period, RoundingMode.FLOOR);
......@@ -255,7 +181,7 @@ public class FonsecaNelis extends AbstractTest<DagTask> {
final long carryInAndOutWorkload = getCarryInAndOutWorkload(task,
task.getWorkloadDistribution(), sortedSegments.get(task), carryInAndOutInterval);
task.getWorkloadDistribution(), carryOutSegments.get(task), carryInAndOutInterval);
return carryInAndOutWorkload + bodyWorkload;
}
......@@ -299,8 +225,8 @@ public class FonsecaNelis extends AbstractTest<DagTask> {
private long getCarryOutWorkload(final DagTask task, final Set<Segment> carryOutDistribution,
final long carryOutPeriod) {
long workload = 0;
final long period = task.getPeriod();
final long responseTime = responseTimes.get(task).getResponseTime();
final long taskWorkload = task.getWorkload();
final long criticalPath = task.getCriticalPath();
final List<Segment> distributionList = Lists.newArrayList(carryOutDistribution);
for (int i = 0; i < distributionList.size(); ++i) {
......@@ -314,10 +240,12 @@ public class FonsecaNelis extends AbstractTest<DagTask> {
workload += Math.max(Math.min(width, s.getJobWcet()), 0) * s.getNumberOfJobs();
}
final long improvedWorkload =
Math.max(carryOutPeriod - (period - responseTime), 0) * numberOfProcessors;
final long improvedWorkloadFromTask =
taskWorkload - Math.max(0, criticalPath - carryOutPeriod);
final long improvedWorkloadFromProcessors = carryOutPeriod * numberOfProcessors;
return Math.min(improvedWorkload, workload);
return Math.min(Math.min(improvedWorkloadFromTask, improvedWorkloadFromProcessors),
workload);
}
private long getCarryInWorkload(final DagTask task, final Set<Segment> carryInDistribution,
......
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