Commit 43947796 by Michael Schmid

Small changes, mostly renaming

parent 39635336
......@@ -20,4 +20,15 @@
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
<filteredResources>
<filter>
<id>1600851289823</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
......@@ -30,7 +30,7 @@ public class App {
// SchmidMottok sm = new SchmidMottok(new KnownStructure(), manager);
// JiangYi jy = new JiangYi(manager);
// Set<DagTask> set = builder.generateRenyiTaskSet(7.0);
// Set<DagTask> set = manager.getBuilder().generateRenyiTaskSet(7.0);
// final SortedTaskSet<DagTask> rmTasks = new SortedTaskSet<>(sm.getPriorityManager());
// rmTasks.addAll(set);
......@@ -45,10 +45,10 @@ public class App {
new SchmidMottok(new KnownStructureWithMaxThreads(manager), manager),
new SchmidMottok(new KnownStructure(), manager),
// new MelaniButtazzo(manager),
// new FonsecaNelis(manager),
new JiangYi(manager)));
new FonsecaNelis(manager)
/* new JiangYi(manager) */));
te.varyRenyiUtilization(manager, tests, 500);
te.varyRenyiUtilization(manager, tests, 100);
}
// {
// SystemManager manager = new SystemManager(8);
......@@ -65,16 +65,17 @@ public class App {
// te.varyUtilization(builder, tests, 8, 500);
// }
// {
// SystemManager manager = new SystemManager(8);
// DagTaskBuilder builder = new DagTaskBuilder();
// SystemManager<DagTaskBuilder> manager = new SystemManager<>(DagTaskBuilder.class);
// TestEnvironment te = new TestEnvironment();
// List<AbstractTest<DagTask>> tests =
// te.registerTests(Arrays.asList(new SchmidMottok(new UnkownStructure(), manager),
// new SchmidMottok(new KownStructure(), 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),
// new JiangYi(manager)));
// te.varyNumberOfProcessors(builder, tests, manager, 500);
// te.varyNumberOfProcessors(manager, tests, 500);
// }
// {
// SystemManager manager = new SystemManager(8);
......
......@@ -238,7 +238,8 @@ public class TestEnvironment {
long checkedTasksets = 0;
final long numberOfTaskSets = ((numberOfProcessors * 4) - 3) * numberOfTaskSetsPerUtil;
final ResultLogger resultLogger = new ResultLogger("utilization_" + numberOfProcessors);
final ResultLogger resultLogger =
new ResultLogger("renyi_utilization_" + numberOfProcessors);
final Map<AbstractTest<DagTask>, Long> resultMap = new LinkedHashMap<>();
abstractTestInstances.forEach(t -> resultMap.put(t, (long) 0));
resultLogger.logHeader(resultMap, "Utilization");
......
......@@ -54,8 +54,8 @@ public class DagTask extends Task {
public long getMaximumParallelism() {
long max = 0;
for (final Segment s : workloadDistribution) {
if (max < s.getNumberOfJobs()) {
max = s.getNumberOfJobs();
if (max < s.getHeight()) {
max = s.getHeight();
}
}
return max;
......
......@@ -3,26 +3,26 @@ package mvd.jester.model;
public class Segment {
private final long jobWcet;
private final long numberOfJobs;
private final long width;
private final long height;
public Segment(long jobWcet, long numberOfJobs) {
this.jobWcet = jobWcet;
this.numberOfJobs = numberOfJobs;
public Segment(long width, long height) {
this.width = width;
this.height = height;
}
/**
* @return the numberOfJobs
*/
public long getNumberOfJobs() {
return numberOfJobs;
public long getHeight() {
return height;
}
/**
* @return the jobWcet
*/
public long getJobWcet() {
return jobWcet;
public long getWidth() {
return width;
}
}
......@@ -64,8 +64,8 @@ public class SynchronousTask extends Task {
public long getMaximumParallelism() {
long max = 0;
for (final Segment s : segments) {
if (max < s.getNumberOfJobs()) {
max = s.getNumberOfJobs();
if (max < s.getHeight()) {
max = s.getHeight();
}
}
return max;
......@@ -80,7 +80,7 @@ public class SynchronousTask extends Task {
public static long calculateWorkload(final Set<Segment> segments) {
long workload = 0;
for (final Segment s : segments) {
workload += s.getJobWcet() * s.getNumberOfJobs();
workload += s.getWidth() * s.getHeight();
}
return workload;
}
......@@ -89,7 +89,7 @@ public class SynchronousTask extends Task {
public static long calculateCriticalPath(final Set<Segment> segments) {
long criticalPath = 0;
for (final Segment s : segments) {
criticalPath += s.getJobWcet();
criticalPath += s.getWidth();
}
return criticalPath;
......
......@@ -194,8 +194,8 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface
public Set<DagTask> generateRenyiTaskSet(final double totalUtilization) {
final LinkedHashSet<DagTask> taskSet = new LinkedHashSet<>();
double currentUtilization = 0;
while (currentUtilization <= totalUtilization) {
final DagTask dagTask = generateRenyiTask(totalUtilization);
......@@ -207,8 +207,8 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface
final long period =
(long) Math.ceil(dagTask.getWorkload() / remainingUtilization);
if (period >= dagTask.getCriticalPath()) {
final DagTask modifiedTask =
new DagTask(dagTask.getJobDag(), period, numberOfProcessors);
final DagTask modifiedTask = new DagTask(dagTask.getJobDag(), period,
dagTask.getNumberOfThreads());
taskSet.add(modifiedTask);
break;
}
......@@ -280,19 +280,14 @@ public class SystemManager<T extends Builder> implements SystemManagerInterface
final long criticalPath = DagUtils.calculateCriticalPath(jobDag);
final long period = randomRenyiPeriod(workload, criticalPath, totalUtilization);
final long minNumberOfThreads = LongMath.divide(workload - criticalPath,
period - criticalPath, RoundingMode.FLOOR);
// TODO: change back to following:
// final long numberOfThreads = randomNumberOfThreads(minNumberOfThreads);
final long numberOfThreads = randomNumberOfThreads(numberOfProcessors / 2);
return new DagTask(jobDag, period, minNumberOfThreads);
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;
......
......@@ -25,7 +25,7 @@ public class JobContext implements JobContextInterface {
this.currentTasklet = Optional.empty();
this.taskContext = taskContext;
this.segmentContext = segmentContext;
this.wcet = segmentContext.getSegment().getJobWcet();
this.wcet = segmentContext.getSegment().getWidth();
}
public Optional<TaskContextInterface> updateExecution(long time) {
......
......@@ -19,8 +19,8 @@ public class SegmentContext {
jobs = new HashSet<>();
tasklets = new HashSet<>();
long numberOfJobs = segment.getNumberOfJobs() > numberOfProcessors ? numberOfProcessors
: segment.getNumberOfJobs();
long numberOfJobs =
segment.getHeight() > numberOfProcessors ? numberOfProcessors : segment.getHeight();
for (int j = 0; j < numberOfJobs; ++j) {
jobs.add(new JobContext(taskContext, this));
......
......@@ -24,7 +24,7 @@ public class JobContext implements JobContextInterface {
this.currentProcessor = Optional.empty();
this.taskContext = taskContext;
this.segmentContext = segmentContext;
this.wcet = segmentContext.getSegment().getJobWcet();
this.wcet = segmentContext.getSegment().getWidth();
this.executionTime = wcet;
}
......
......@@ -17,7 +17,7 @@ public class SegmentContext {
this.segment = segment;
jobs = new HashSet<>();
for (int j = 0; j < segment.getNumberOfJobs(); ++j) {
for (int j = 0; j < segment.getHeight(); ++j) {
jobs.add(new JobContext(taskContext, this));
}
}
......@@ -38,6 +38,6 @@ public class SegmentContext {
@Override
public String toString() {
return "(nJobs=" + segment.getNumberOfJobs() + ", jobWcet=" + segment.getJobWcet() + ")";
return "(nJobs=" + segment.getHeight() + ", jobWcet=" + segment.getWidth() + ")";
}
}
......@@ -56,7 +56,7 @@ public class TaskContext implements TaskContextInterface {
public Optional<TaskContextInterface> acceptNotification(long time) {
segmentCounter++;
if (segmentCounter >= segments.get(currentSegment).getSegment().getNumberOfJobs()) {
if (segmentCounter >= segments.get(currentSegment).getSegment().getHeight()) {
currentSegment++;
segmentCounter = 0;
if (currentSegment >= segments.size()) {
......
......@@ -84,8 +84,8 @@ public class ChwaLee extends AbstractTest<SynchronousTask> {
long selfInterference = 0;
for (final Segment s : task.getWorkloadDistribution()) {
if (s.getNumberOfJobs() >= p + 1) {
selfInterference += s.getJobWcet();
if (s.getHeight() >= p + 1) {
selfInterference += s.getWidth();
}
}
return selfInterference;
......@@ -97,8 +97,8 @@ public class ChwaLee extends AbstractTest<SynchronousTask> {
long workloadOfBodyJobs = 0;
for (final Segment s : t.getWorkloadDistribution()) {
if (s.getNumberOfJobs() >= p) {
workloadOfBodyJobs += s.getJobWcet();
if (s.getHeight() >= p) {
workloadOfBodyJobs += s.getWidth();
}
}
......@@ -109,11 +109,11 @@ public class ChwaLee extends AbstractTest<SynchronousTask> {
final List<Segment> segmentList = new ArrayList<>(t.getWorkloadDistribution());
Collections.reverse(segmentList);
for (final Segment s : segmentList) {
carryInLength += s.getJobWcet();
if (s.getNumberOfJobs() >= p && remainingLength > carryInLength) {
boundedCarryInWorkload += s.getJobWcet();
} else if (s.getNumberOfJobs() >= p && remainingLength <= carryInLength) {
boundedCarryInWorkload += s.getJobWcet() - (carryInLength - remainingLength);
carryInLength += s.getWidth();
if (s.getHeight() >= p && remainingLength > carryInLength) {
boundedCarryInWorkload += s.getWidth();
} else if (s.getHeight() >= p && remainingLength <= carryInLength) {
boundedCarryInWorkload += s.getWidth() - (carryInLength - remainingLength);
}
if (carryInLength >= remainingLength) {
break;
......@@ -126,7 +126,7 @@ public class ChwaLee extends AbstractTest<SynchronousTask> {
private long getMinimumWcet(final SynchronousTask task) {
long minWcet = 0;
for (final Segment s : task.getWorkloadDistribution()) {
minWcet += s.getJobWcet();
minWcet += s.getWidth();
}
return minWcet;
......
......@@ -198,7 +198,7 @@ public class FonsecaNelis extends AbstractTest<DagTask> {
Collections.reverse(reverseCarryInList);
for (final Segment s : reverseCarryInList) {
carryInPeriod += s.getJobWcet();
carryInPeriod += s.getWidth();
carryOutPeriod = carryInAndOutPeriod - carryInPeriod;
final long carryInWorkload =
getCarryInWorkload(task, carryInDistribution, carryInPeriod);
......@@ -212,7 +212,7 @@ public class FonsecaNelis extends AbstractTest<DagTask> {
carryOutPeriod = 0;
for (final Segment s : carryOutDistribution) {
carryOutPeriod += s.getJobWcet();
carryOutPeriod += s.getWidth();
carryInPeriod = carryInAndOutPeriod - carryOutPeriod;
final long carryInWorkload =
getCarryInWorkload(task, carryInDistribution, carryInPeriod);
......@@ -235,11 +235,11 @@ public class FonsecaNelis extends AbstractTest<DagTask> {
final Segment s = distributionList.get(i);
long weightOfPreviousSegments = 0;
for (int j = 0; j < i; ++j) {
weightOfPreviousSegments += distributionList.get(j).getJobWcet();
weightOfPreviousSegments += distributionList.get(j).getWidth();
}
final long width = carryOutPeriod - weightOfPreviousSegments;
workload += Math.max(Math.min(width, s.getJobWcet()), 0) * s.getNumberOfJobs();
workload += Math.max(Math.min(width, s.getWidth()), 0) * s.getHeight();
}
final long improvedWorkloadFromTask =
......@@ -262,11 +262,11 @@ public class FonsecaNelis extends AbstractTest<DagTask> {
final Segment s = distributionList.get(b);
long weightOfRemainingSegments = 0;
for (int p = b + 1; p < carryInDistribution.size(); ++p) {
weightOfRemainingSegments += distributionList.get(p).getJobWcet();
weightOfRemainingSegments += distributionList.get(p).getWidth();
}
final long width = carryInPeriod - period + responseTime - weightOfRemainingSegments;
workload += Math.max(Math.min(width, s.getJobWcet()), 0) * s.getNumberOfJobs();
workload += Math.max(Math.min(width, s.getWidth()), 0) * s.getHeight();
}
final long improvedWorkload = Math.max(carryInPeriod - (period - responseTime), 0)
......
......@@ -91,8 +91,8 @@ public class MaiaBertogna extends AbstractTest<SynchronousTask> {
long interference = 0;
for (final Segment s : task.getWorkloadDistribution()) {
if (s.getNumberOfJobs() >= parallelism + 1) {
interference += s.getJobWcet();
if (s.getHeight() >= parallelism + 1) {
interference += s.getWidth();
}
}
......@@ -112,8 +112,8 @@ public class MaiaBertogna extends AbstractTest<SynchronousTask> {
long workload = 0;
for (final Segment s : task.getWorkloadDistribution()) {
if (s.getNumberOfJobs() >= parallelism) {
workload += s.getJobWcet();
if (s.getHeight() >= parallelism) {
workload += s.getWidth();
}
}
......@@ -128,7 +128,7 @@ public class MaiaBertogna extends AbstractTest<SynchronousTask> {
private long getMinimumWcet(final SynchronousTask task) {
long minWcet = 0;
for (final Segment s : task.getWorkloadDistribution()) {
minWcet += s.getJobWcet();
minWcet += s.getWidth();
}
return minWcet;
......
......@@ -11,6 +11,7 @@ import mvd.jester.model.SystemManagerInterface;
import mvd.jester.model.Task;
import mvd.jester.priority.PriorityManager;
import mvd.jester.priority.RateMonotonic;
import mvd.jester.tests.TypeFunction.KnownStructureWithMaxThreads;
/**
* SchmidMottok
......@@ -54,14 +55,6 @@ public class SchmidMottok extends AbstractTest<DagTask> {
long responseTime = minimumWcet;
long previousResponseTime = 0;
long occupiedProcessors = 0; // manager.getNumberOfProcessors() + 1;
for (final DagTask t : tasks) {
if (t.getPeriod() < task.getPeriod()) {
final long numberOfProcessors = structure.getNumberOfThreads(t);
occupiedProcessors += numberOfProcessors;
}
}
do {
previousResponseTime = responseTime;
double taskInterference = 0;
......@@ -69,13 +62,8 @@ public class SchmidMottok extends AbstractTest<DagTask> {
if (t.getPeriod() < task.getPeriod()) {
final long numberOfThreads = structure.getNumberOfThreads(t);
for (int p = 0; p < numberOfThreads; ++p) {
if (occupiedProcessors > manager.getNumberOfProcessors()) {
taskInterference +=
Math.min(
structure.getTaskInterference(t, responseTimes,
responseTime, p + 1),
responseTime - minimumWcet + 1);
}
taskInterference += Math.min(structure.getTaskInterference(t, responseTimes,
responseTime, p + 1), responseTime - minimumWcet + 1);
}
}
}
......
......@@ -44,10 +44,9 @@ public interface TypeFunction {
for (final Segment s : task.getWorkloadDistribution()) {
final long numberOfThreads =
s.getNumberOfJobs() > 1 ? manager.getNumberOfProcessors() : 1;
s.getHeight() > 1 ? manager.getNumberOfProcessors() : 1;
if (numberOfThreads >= parallelism) {
workload +=
(double) (s.getNumberOfJobs() * s.getJobWcet()) / numberOfThreads;
workload += (double) (s.getHeight() * s.getWidth()) / numberOfThreads;
}
}
......@@ -98,8 +97,7 @@ public interface TypeFunction {
for (final Segment s : task.getWorkloadDistribution()) {
final long numberOfThreads = task.getNumberOfThreads();
if (numberOfThreads >= parallelism) {
workload +=
(double) (s.getNumberOfJobs() * s.getJobWcet()) / numberOfThreads;
workload += (double) (s.getHeight() * s.getWidth()) / numberOfThreads;
}
}
......@@ -148,11 +146,9 @@ public interface TypeFunction {
double workload = 0;
for (final Segment s : task.getWorkloadDistribution()) {
final long numberOfThreads =
s.getNumberOfJobs() > 1 ? task.getNumberOfThreads() : 1;
final long numberOfThreads = s.getHeight() > 1 ? task.getNumberOfThreads() : 1;
if (numberOfThreads >= parallelism) {
workload +=
(double) (s.getNumberOfJobs() * s.getJobWcet()) / numberOfThreads;
workload += (double) (s.getHeight() * s.getWidth()) / numberOfThreads;
}
}
......
......@@ -15,10 +15,10 @@ public class TestSegment {
Segment s1 = new Segment(100, 10);
Segment s2 = new Segment(9, 10);
assertTrue(s1.getJobWcet() == 100);
assertTrue(s1.getNumberOfJobs() == 10);
assertTrue(s1.getWidth() == 100);
assertTrue(s1.getHeight() == 10);
assertTrue(s2.getJobWcet() == 9);
assertTrue(s2.getNumberOfJobs() == 10);
assertTrue(s2.getWidth() == 9);
assertTrue(s2.getHeight() == 10);
}
}
......@@ -39,10 +39,10 @@ public class TestSystemSetup {
long maxJobWcet = t.getPeriod() / t.getWorkloadDistribution().size();
for (Segment s : t.getWorkloadDistribution()) {
assertTrue(s.getJobWcet() >= 1);
assertTrue(s.getJobWcet() <= maxJobWcet);
assertTrue(s.getNumberOfJobs() >= 1);
assertTrue(s.getNumberOfJobs() <= 10);
assertTrue(s.getWidth() >= 1);
assertTrue(s.getWidth() <= maxJobWcet);
assertTrue(s.getHeight() >= 1);
assertTrue(s.getHeight() <= 10);
}
assertTrue(t.getWorkloadDistribution().size() >= 1);
......
......@@ -32,7 +32,7 @@ public class TestJobContext {
SegmentContext sc = mock(SegmentContext.class);
Segment s = mock(Segment.class);
when(sc.getSegment()).thenReturn(s);
when(s.getJobWcet()).thenReturn((long) 20);
when(s.getWidth()).thenReturn((long) 20);
when(sc.getNextTasklet()).thenReturn(Optional.of(tlc))
.thenReturn(Optional.ofNullable(null));
......@@ -53,7 +53,7 @@ public class TestJobContext {
SegmentContext sc = mock(SegmentContext.class);
Segment s = mock(Segment.class);
when(sc.getSegment()).thenReturn(s);
when(s.getJobWcet()).thenReturn((long) 20);
when(s.getWidth()).thenReturn((long) 20);
when(tlc.checkExecutionTime()).thenReturn(true, false);
JobContext jc = new JobContext(tc, sc);
......@@ -75,7 +75,7 @@ public class TestJobContext {
when(sc.getSegment()).thenReturn(s);
when(sc.getNextTasklet()).thenReturn(Optional.ofNullable(tlc))
.thenReturn(Optional.ofNullable(null));
when(s.getJobWcet()).thenReturn((long) 20);
when(s.getWidth()).thenReturn((long) 20);
when(tlc.checkExecutionTime()).thenReturn(true, false);
when(tlc.updateExecution(not(eq(0)))).thenReturn(true);
when(tlc.updateExecution(0)).thenReturn(false);
......
......@@ -31,7 +31,7 @@ public class TestJobContext {
long jobWcet = ThreadLocalRandom.current().nextLong(20, 50);
Segment s = mock(Segment.class);
when(s.getJobWcet()).thenReturn(jobWcet);
when(s.getWidth()).thenReturn(jobWcet);
SegmentContext sc = mock(SegmentContext.class);
when(sc.getSegment()).thenReturn(s);
TaskContext tc = mock(TaskContext.class);
......
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