Permalink
Browse files

[#130]: Mapping restrictions should allow task references

Adding some tests to verify the proper behaviour.

Closes #130

Task-Url: http://github.com/roberthilbrich/assist-public/issues/130
  • Loading branch information...
RobertHilbrich committed Jul 17, 2018
1 parent 407fb3d commit 874bd8e9460c337efac3da32db70bb9abf399924
@@ -70,18 +70,92 @@ Restrictions {
assistSolver.runSolutionSearch
assistSolver.createSolutions
Assert.assertEquals("There should only be 6 results, because there are only 3 cores", 6, assistSolver.results.size)
Assert.assertEquals("There should only be 6 results, because there are only 3 cores", 6,
assistSolver.results.size)
for (result : assistSolver.results) {
/* Check that in each result, all tasks are being placed on the same core */
val taskResults = assistModel.allTasks.map[result.getHardwareElementForTask(it, 0)]
Assert.assertEquals(2, taskResults.size)
Assert.assertNotEquals("The tasks should have been placed to different cores", taskResults.get(0), taskResults.get(1))
Assert.assertNotEquals("The tasks should have been placed to different cores", taskResults.get(0),
taskResults.get(1))
}
}
@Test
def void Test1bSimplePair() {
val assistModel = parser.parse('''
Global {
System = "Example System";
}
Hardware {
Compartment C1 {
Box C1_B1 {
Board C1_B1_B1 {
RAM = 0;
Processor C1_B1_B1_P1 {
Core C1_B1_B1_P1_C0 { }
}
}
}
@Test
Box C1_B2 {
Board C1_B2_B1 {
RAM = 4;
Processor C1_B2_B1_P1 {
Core C1_B2_B1_P1_C0 { }
}
}
}
}
Compartment C2 {
Box C2_B1 {
Board C2_B1_B1 {
RAM = 2;
Processor C2_B1_B1_P1 {
Core C2_B1_B1_P1_C0 { }
}
}
}
}
}
Software {
Application A1 { Task A1_T1 {} }
Application A2 { Task A2_T1 {} }
}
Restrictions {
A1, A2.A2_T1 dislocal up to Core;
}
''')
Assert.assertNotNull(assistModel)
Assert.assertTrue(assistModel.eResource.errors.isEmpty)
val assistSolver = new AssistMappingSolver(assistModel)
assistSolver.setSolverSearchStrategy(VariableSelectorTypes.^default, ValueSelectorTypes.^default)
assistSolver.solverMaxSolutions = 1000
assistSolver.runInitialization
assistSolver.runConstraintGeneration
assistSolver.runSolutionSearch
assistSolver.createSolutions
Assert.assertEquals("There should only be 6 results, because there are only 3 cores", 6,
assistSolver.results.size)
for (result : assistSolver.results) {
/* Check that in each result, all tasks are being placed on the same core */
val taskResults = assistModel.allTasks.map[result.getHardwareElementForTask(it, 0)]
Assert.assertEquals(2, taskResults.size)
Assert.assertNotEquals("The tasks should have been placed to different cores", taskResults.get(0),
taskResults.get(1))
}
}
@Test
def void Test2ComplexApplications() {
val assistModel = parser.parse('''
Global {
@@ -136,21 +210,26 @@ Restrictions {
assistSolver.runSolutionSearch
assistSolver.createSolutions
Assert.assertEquals("There should only be 2 results, because there are only 2 processors", 2, assistSolver.results.size)
Assert.assertEquals("There should only be 2 results, because there are only 2 processors", 2,
assistSolver.results.size)
for (result : assistSolver.results) {
// Get processors for Application A tasks
val applicationAResults = assistModel.allTasks.filter[application.getName.startsWith("A")].map[result.getHardwareElementForTask(it, 1)].toSet
val applicationAResults = assistModel.allTasks.filter[application.getName.startsWith("A")].map [
result.getHardwareElementForTask(it, 1)
].toSet
// Get processors for Application B tasks
val applicationBResults = assistModel.allTasks.filter[application.getName.startsWith("B")].map[result.getHardwareElementForTask(it, 1)].toSet
val applicationBResults = assistModel.allTasks.filter[application.getName.startsWith("B")].map [
result.getHardwareElementForTask(it, 1)
].toSet
/* Application A and B must not share a processor */
val intersect = new HashSet(applicationAResults)
intersect.retainAll(applicationBResults)
Assert.assertTrue(intersect.isNullOrEmpty)
}
}
}
}
@@ -80,6 +80,77 @@ Restrictions {
Assert.assertNotEquals(taskResults.get(0).manufacturer, taskResults.get(1).manufacturer)
}
}
@Test
def void testCompartmentManufacturerWithTaskReferences() {
val assistModel = parser.parse('''
Global {
System = "Example System";
}
Hardware {
Compartment C1 {
Manufacturer = "M1";
Box C1_B1 {
Board C1_B1_B1 {
Processor C1_B1_B1_P1 {
Core C1_B1_B1_P1_C0 { }
}
}
}
Box C1_B2 {
Board C1_B2_B1 {
Processor C1_B2_B1_P1 {
Core C1_B2_B1_P1_C0 { }
}
}
}
}
Compartment C2 {
Manufacturer = "M2";
Box C2_B1 {
Board C2_B1_B1 {
Processor C2_B1_B1_P1 {
Core C2_B1_B1_P1_C0 { }
}
}
}
}
}
Software {
Application A1 { Task A1_T1 {} }
Application A2 { Task A2_T1 {} }
}
Restrictions {
A1.A1_T1, A2.A2_T1 dissimilar based on Compartment.Manufacturer;
}
''')
Assert.assertNotNull(assistModel)
Assert.assertTrue(assistModel.eResource.errors.isEmpty)
val assistSolver = new AssistMappingSolver(assistModel)
assistSolver.setSolverSearchStrategy(VariableSelectorTypes.^default, ValueSelectorTypes.^default)
assistSolver.solverMaxSolutions = 1000
assistSolver.runInitialization
assistSolver.runConstraintGeneration
assistSolver.runSolutionSearch
assistSolver.createSolutions
Assert.assertEquals(4, assistSolver.results.size)
for (result : assistSolver.results) {
/* Check that in each result, all tasks are being placed on compartments from different manufacturers */
val taskResults = assistModel.allTasks.map[result.getHardwareElementForTask(it, 4)].toSet
Assert.assertEquals(2, taskResults.size)
Assert.assertNotEquals(taskResults.get(0).manufacturer, taskResults.get(1).manufacturer)
}
}
@Test
@@ -305,6 +376,84 @@ Restrictions {
}
}
@Test
def void testMultipleDissimilarityConstraintsWithTaskReferences() {
val assistModel = parser.parse('''
Global {
System = "Example System";
}
Hardware {
Compartment C1 {
Manufacturer = "M1";
Box C1_B1 {
Board C1_B1_B1 {
Manufacturer = "MA";
Processor C1_B1_B1_P1 {
Core C1_B1_B1_P1_C0 { }
}
}
}
Box C1_B2 {
Board C1_B2_B1 {
Manufacturer = "MB";
Processor C1_B2_B1_P1 {
Core C1_B2_B1_P1_C0 { }
}
}
}
}
Compartment C2 {
Manufacturer = "M2";
Box C2_B1 {
Board C2_B1_B1 {
Manufacturer = "MC";
Processor C2_B1_B1_P1 {
Core C2_B1_B1_P1_C0 { }
}
}
}
}
}
Software {
Application A1 { Task A1_T1 {} }
Application A2 { Task A2_T1 {} }
}
Restrictions {
A1.A1_T1, A2 dissimilar based on Board.Manufacturer;
A1, A2.A2_T1 dissimilar based on Compartment.Manufacturer;
}
''')
Assert.assertNotNull(assistModel)
Assert.assertTrue(assistModel.eResource.errors.isEmpty)
val assistSolver = new AssistMappingSolver(assistModel)
assistSolver.setSolverSearchStrategy(VariableSelectorTypes.^default, ValueSelectorTypes.^default)
assistSolver.solverMaxSolutions = 1000
assistSolver.runInitialization
assistSolver.runConstraintGeneration
assistSolver.runSolutionSearch
assistSolver.createSolutions
Assert.assertEquals(4, assistSolver.results.size)
for (result : assistSolver.results) {
/* Check that in each result, all tasks are being placed on boards from different manufacturers */
val taskResultsBoardLevel = assistModel.allTasks.map[result.getHardwareElementForTask(it, 2)].toSet
Assert.assertEquals(2, taskResultsBoardLevel.size)
Assert.assertNotEquals(taskResultsBoardLevel.get(0).manufacturer, taskResultsBoardLevel.get(1).manufacturer)
/* Check that in each result, all tasks are being placed on compartments from different manufacturers */
val taskResultsCompLevel = assistModel.allTasks.map[result.getHardwareElementForTask(it, 4)].toSet
Assert.assertEquals(2, taskResultsCompLevel.size)
Assert.assertNotEquals(taskResultsCompLevel.get(0).manufacturer, taskResultsCompLevel.get(1).manufacturer)
}
}
@Test
def void testMultipleTasks1() {

0 comments on commit 874bd8e

Please sign in to comment.