Commit 789d7a36 authored by Alexander Diewald's avatar Alexander Diewald

DSE-TCgen: Add DSE project

* A DSE project is added to the AF3 project.
* Flash Memory and Fix Allocation Constraints are added.
* Return Unmodifiable ELists from EOperation methods in the DSE
  process handling to avoid some stupid mistakes.

Issue-Ref: 4008
Issue-Url: https://af3-developer.fortiss.org/issues/4008Signed-off-by: Alexander Diewald's avatarAlexander Diewald <diewald@fortiss.org>
parent 423e7166
DSEStaticImpl.java ceaf5ecf8c77609d4ae13d40b88ac443fe6b09e9 GREEN
DSEStaticImpl.java 8dbcca69543c56dd6f646999de726fe7bb7575c1 YELLOW
InitialInputDefinitionStepStaticImpl.java 574a20551eff4745bb24b682edd616368321de46 GREEN
ModelSnapshotStaticImpl.java 6db72d06363209e53e2dae7e0e0834a8239d3e7c GREEN
ProcessStepStaticImpl.java 13b80bb1fc56e3ed73d3449d911ae52453365938 YELLOW
ProcessStepStaticImpl.java f8ba2886782505778fd0a16c895988d568d97491 YELLOW
SolutionSelectionStepStaticImpl.java f62112f9d033b45294155eb8f77edfd74a633b07 GREEN
......@@ -33,11 +33,10 @@ public class DSEStaticImpl {
// Register the first step
currentStep = additionalStep;
} else {
if(currentStep instanceof ExplorationStep) {
if(additionalStep instanceof ExplorationStep) {
// Subsequent exploration runs should be added as siblings
currentStep = currentStep.getParent();
}
if(currentStep instanceof ExplorationStep &&
additionalStep instanceof ExplorationStep) {
// Subsequent exploration runs should be added as siblings
currentStep = currentStep.getParent();
}
currentStep.getSuccessors().add(additionalStep);
......
......@@ -15,6 +15,7 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.model.project.impl;
import static org.eclipse.emf.common.util.ECollections.unmodifiableEList;
import static org.fortiss.af3.exploration.util.ExplorationModelElementFactory.createSuperSetMap;
import static org.fortiss.af3.exploration.util.ExplorationUtils.appendNonPresentSolutionSets;
import static org.fortiss.af3.exploration.util.ExplorationUtils.recursiveArtifactWalk;
......@@ -53,7 +54,7 @@ public class ProcessStepStaticImpl {
/** Static implementation of the method {@link ProcessStep#getInputArtifacts()}. */
public static EList<IInputArtifact> getInputArtifacts(ProcessStepImpl processStepImpl) {
EList<IInputArtifact> aggregateList = aggregateLatestSnapshots(processStepImpl);
return aggregateList;
return unmodifiableEList(aggregateList);
}
/** Static implementation of the method {@link ProcessStep#getParent()}. */
......@@ -145,7 +146,7 @@ public class ProcessStepStaticImpl {
};
EList<IExplorationTarget<?>> collectedTargets = new BasicEList<>();
recursiveTreeWalk(processStepImpl, collectExpTargets, collectedTargets);
return collectedTargets;
return unmodifiableEList(collectedTargets);
}
/**
......@@ -224,7 +225,7 @@ public class ProcessStepStaticImpl {
};
EList<RuleSet> collectedRuleSets = new BasicEList<>();
recursiveTreeWalk(processStepImpl, collectExpTargets, collectedRuleSets);
return collectedRuleSets;
return unmodifiableEList(collectedRuleSets);
}
/** Static implementation of {@link ProcessStep#getModelSnapshots()} */
......
ArchitectureGraph.java 4f1539b6997b7a71d744ef750aa2f102097f211d YELLOW
ExplorationTestCaseGenerator.java 6073ddd68470a1e6c6844b0df40f1443d81b0f0c YELLOW
ExplorationTestCaseGenerator.java 55de602c69f445a5a72c8a8a61b8ee9fada1c974 YELLOW
......@@ -17,7 +17,7 @@ package org.fortiss.af3.exploration.testgenerator;
import static org.fortiss.af3.exploration.testgenerator.util.AnnotationGenerationUtils.expandArchitecturesByAnnotations;
import static org.fortiss.af3.exploration.testgenerator.util.CompArchGeneratonUtil.generateLogicalArchitectures;
import static org.fortiss.af3.exploration.testgenerator.util.DseUtils.defineDSEProblems;
import static org.fortiss.af3.exploration.testgenerator.util.DseUtils.expandByDseProblems;
import static org.fortiss.af3.exploration.testgenerator.util.FileWriterUtil.write;
import static org.fortiss.af3.exploration.testgenerator.util.GraphUtil.getGraphMetrics;
import static org.fortiss.af3.exploration.testgenerator.util.ProjectUtils.createAF3Projects;
......@@ -82,7 +82,7 @@ public class ExplorationTestCaseGenerator {
createAF3Projects(genCompArchs, platformArchitectures, "DSE_Generated_TestCase");
fileProjects = expandArchitecturesByAnnotations(fileProjects);
defineDSEProblems(fileProjects);
fileProjects = expandByDseProblems(fileProjects);
info(AF3ExplorationActivator.getDefault(),
"Test cases are generated in the runtime Workspace.");
......
AnnotationGenerationUtils.java 7fdab0a64ce72636bc59262b889b62eed54980ee YELLOW
CompArchGeneratonUtil.java 2796a78ae842d0cb0f8851ad607df5d8fb51e3f8 RED
ConstraintUtil.java 229f48efcae173018b06514d9c20fe2a89421063 RED
DseUtils.java c143d8d122a2aa7c547ef53d43e46ccc20ac1ee6 RED
CompArchGeneratonUtil.java 8d02b63410de3c790672c49699559245a8a306ef RED
DseUtils.java d81af0b7f649d2453aada362fc50572fce31ebc8 YELLOW
FileWriterUtil.java 4a95559f571d41fa44e6236fc055ab5baac7c384 YELLOW
GraphGenerationUtilities.java 3be2143bf23befd2c9103c621ce31accf65b7cc6 YELLOW
GraphMetricUtils.java ce15ba42b7bd36ad2ae46ebd084911e69c815a5f YELLOW
GraphUtil.java afaec2934ff3038bdcf9d10f7b75c71f0dd2e036 YELLOW
ProjectUtil.java 169730c7438788f79faa4dd8d5a3017f5941c3d9 YELLOW
ProjectUtils.java fe0009a32f6aaa58fb3330e2b9e383e217afc0dd YELLOW
......@@ -72,7 +72,7 @@ public class CompArchGeneratonUtil {
Set<ComponentArchitecture> logicalArchitectures = new HashSet<ComponentArchitecture>();
for(ArchitectureGraph<Component> template : templates) {
logicalArchitectures.add(getComponentArchitecture(template,
logicalArchitectures.add(getComponentArchitecture(template, "ComponentArchitecture_" +
template.vertexSet().size() + "_" + template.edgeSet().size()));
}
......
/*-------------------------------------------------------------------------+
| Copyright 2018 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.testgenerator.util;
import static org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotationValue;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import org.fortiss.af3.exploration.model.ExplorationConstraint;
import org.fortiss.af3.exploration.model.project.DSE;
import org.fortiss.af3.exploration.model.project.RuleSet;
import org.fortiss.af3.exploration.util.DSEProjectModelElementFactory;
import org.fortiss.af3.platform.model.ExecutionUnit;
import org.fortiss.af3.platform.model.PlatformArchitecture;
import org.fortiss.af3.platform.model.annotation.FlashSize;
import org.fortiss.af3.platform.model.annotation.MemorySize;
import org.fortiss.af3.task.model.Task;
import org.fortiss.af3.task.model.TaskArchitecture;
/**
* Utility class used for creating rule sets representing constraints for the deployment problem.
*
* @author munaro
*/
public class ConstraintUtil {
/** Hiding constructor. */
private ConstraintUtil() {
// Prevent instantiation.
}
/**
* Creates a rule set limiting the number of tasks deployed to a hardware component by the
* amount of available memory.
*
* @param dse
* Current design space exploration
* @param platformArchitecture
* Technical architecture representing the hardware platform
* @param taskArchitecture
* Task architecture to be deployed on the hardware components
* @return A rule set containing all constraints required for taking into account memory
* limitations
*/
public static RuleSet createMemoryDeploymentConstraint(DSE dse,
PlatformArchitecture platformArchitecture, TaskArchitecture taskArchitecture) {
List<ExplorationConstraint<?>> constraints = new ArrayList<>();
List<ExecutionUnit> executionUnits = platformArchitecture.getContainedElements().stream()
.filter(e -> e instanceof ExecutionUnit).map(ExecutionUnit.class::cast)
.collect(Collectors.toList());
for(ExecutionUnit executionUnit : executionUnits) {
// TODO(AD): Call the memory constraint creation utility method here.
}
RuleSet ruleSet = DSEProjectModelElementFactory.createRuleSet();
ruleSet.setImplicit(false);
ruleSet.setName("Memory_Constraints");
ruleSet.getExplorationTargets().addAll(constraints);
return ruleSet;
}
/**
* Creates a rule set with pre-allocation constraints for a given ration of tasks.
*
* @param dse
* Current design space exploration
* @param taskArchitecture
* Task architecture to sample the tasks to pre-allocate from
* @param technicalArchitecture
* Hardware platform with the components to allocate the tasks to
* @param ratio
* Ratio of tasks to pre-allocate
* @return A rule set containing the pre-allocation constraints
*/
public static RuleSet createPreAllocationConstraints(DSE dse, TaskArchitecture taskArchitecture,
PlatformArchitecture technicalArchitecture, double ratio) {
// TODO(AD): Revisit this method for checking its correctness.
RuleSet ruleSet = DSEProjectModelElementFactory.createRuleSet();
ruleSet.setImplicit(false);
ruleSet.setName("Pre-alloc RuleSet");
List<ExecutionUnit> executionUnits = technicalArchitecture.getContainedElements().stream()
.filter(element -> element instanceof ExecutionUnit).map(ExecutionUnit.class::cast)
.collect(Collectors.toList());
int numberOfAllocations = (int)Math.floor(ratio * taskArchitecture.getTasks().size());
Set<Task> allocatedTasks = new HashSet<Task>();
Map<ExecutionUnit, Long> unallocatedMemory = new HashMap<ExecutionUnit, Long>();
for(ExecutionUnit executionUnit : executionUnits) {
long memory = getAnnotationValue(executionUnit, FlashSize.class, Long.class);
unallocatedMemory.put(executionUnit, memory);
}
while(allocatedTasks.size() < numberOfAllocations) {
Task task = taskArchitecture.getContainedElements().stream().map(Task.class::cast)
.filter(element -> !allocatedTasks.contains(element)).findAny().get();
long requiredMemory = getAnnotationValue(task, MemorySize.class, Long.class);
Optional<ExecutionUnit> optionalEcu = executionUnits.stream()
.filter(executionUnit -> unallocatedMemory.get(executionUnit) >= requiredMemory)
.findAny();
if(optionalEcu.isPresent()) {
ExecutionUnit ecu = optionalEcu.get();
ruleSet.getExplorationTargets().add(createAllocationConstraint(dse, task, ecu));
unallocatedMemory.put(ecu, unallocatedMemory.get(ecu) - requiredMemory);
}
allocatedTasks.add(task);
}
return ruleSet;
}
/**
* Create an SMT constraint allocating a given task to a specific execution unit.
*
* @param dse
* Current design space exploration
* @param task
* Task to be allocated
* @param ecu
* Execution unit to be allocated the task to
* @return An SMT constraint representing the allocation
*/
private static ExplorationConstraint<?> createAllocationConstraint(DSE dse, Task task,
ExecutionUnit ecu) {
// TODO(AD): Use ConstraintUtils from the std. util methods.
return null;
}
}
DSEProjectModelElementFactory.java a56e2cd564383726898336469ebc3203186e992f GREEN
DSEProjectModelElementFactory.java fcedc4eb7da9f08bd5682c23d5e29c0f81f9f0db YELLOW
DSESolutionConversionUtils.java a6ccbba92864c653d1518a92455e87c17f7cc72b GREEN
DSMLModelElementFactory.java 8081a2d7e2a1ee311b830305854bb60bb7572d91 GREEN
DSMLUtils.java c07eeef09787cea9db98533d346e3e384a232593 GREEN
......
......@@ -51,6 +51,7 @@ public class DSEProjectModelElementFactory {
ProjectFactory.eINSTANCE.createInitialInputDefinitionStep();
step.setName("Import of model \"" + fp.getName() + "\"");
dse.setInitialStep(step);
dse.setCurrentStep(step);
return dse;
}
......
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 to comment