Search in sources :

Example 1 with LowLevelBinPacker

use of EAnalysis.BinPacking.LowLevelBinPacker in project osate2 by osate.

the class Binpack method analyzeInstanceModel.

@Override
protected void analyzeInstanceModel(final IProgressMonitor monitor, final AnalysisErrorReporterManager errManager, final SystemInstance root, final SystemOperationMode som) {
    try {
        monitor.beginTask("Binding threads to processors in " + root.getName(), IProgressMonitor.UNKNOWN);
        logInfo("Binpacker Analysis Report\n");
        /*
			 * Verify that all the busses have a transmission time
			 */
        final ForAllElement addBuses = new ForAllElement(errManager) {

            @Override
            public void process(Element obj) {
                checkBuses((ComponentInstance) obj);
            }
        };
        addBuses.processPreOrderComponentInstance(root, ComponentCategory.BUS);
        /*
			 * Find and report all thread and device instances that don't have a
			 * period specified.
			 */
        EList<Element> incompletethreads = new ForAllElement() {

            @Override
            protected boolean suchThat(Element obj) {
                final ComponentCategory cat = ((ComponentInstance) obj).getCategory();
                if (cat == ComponentCategory.THREAD || cat == ComponentCategory.DEVICE) {
                    return org.osate.pluginsupport.properties.PropertyUtils.getScaled(TimingProperties::getPeriod, (ComponentInstance) obj, TimeUnits.MS).orElse(0.0) == 0.0;
                } else {
                    return false;
                }
            }
        }.processPreOrderComponentInstance(root);
        for (final Iterator<Element> i = incompletethreads.iterator(); i.hasNext(); ) {
            final ComponentInstance o = (ComponentInstance) i.next();
            logWarning((InstanceModelUtil.isThread(o) ? "Thread " : "Device ") + o.getComponentInstancePath() + " is missing period property. Using default of 1 ns");
        }
        /*
			 * Find and report all thread instances that don't have a
			 * compute execution time specified.
			 */
        incompletethreads = new ForAllElement() {

            @Override
            protected boolean suchThat(Element obj) {
                return GetProperties.getThreadExecutioninMilliSec((ComponentInstance) obj) == 0.0;
            }
        }.processPreOrderComponentInstance(root, ComponentCategory.THREAD);
        for (final Iterator<Element> i = incompletethreads.iterator(); i.hasNext(); ) {
            final ComponentInstance o = (ComponentInstance) i.next();
            logWarning("Thread " + o.getComponentInstancePath() + " is missing compute_execution_time or InstructionsPerDispatch property. Using default of 0 ns");
        }
        /*
			 * Find if all the port connections have data size
			 */
        final ForAllElement addThreadConnections = new ForAllElement(errManager) {

            @Override
            public void process(Element obj) {
                if (obj instanceof ConnectionInstance) {
                    final ConnectionInstance connInst = (ConnectionInstance) obj;
                    if (connInst.getKind() == ConnectionKind.PORT_CONNECTION) {
                        final FeatureInstance src = (FeatureInstance) connInst.getSource();
                        Feature srcAP = src.getFeature();
                        Classifier cl = srcAP.getClassifier();
                        if (cl instanceof DataClassifier) {
                            DataClassifier srcDC = (DataClassifier) cl;
                            if (AadlContribUtils.getDataSize(srcDC, SizeUnits.BYTES) == 0) {
                                logWarning("Data size of connection source port " + src.getComponentInstancePath() + " not specified");
                            }
                        }
                    }
                }
            }
        };
        addThreadConnections.processPreOrderAll(root);
        /* The partitionChoice is set in initializeANalysis() */
        NoExpansionExpansor expansor = new NoExpansionExpansor();
        LowLevelBinPacker packer = null;
        if (partitionChoice == IMMEDIATE_PARTITION) {
            packer = new BFCPBinPacker(expansor);
        } else if (partitionChoice == DEFER_EXEC_TIME) {
            packer = new DFCPBinPacker(expansor);
        } else if (partitionChoice == DEFER_BANDWIDTH) {
            packer = new DFBPBinPacker(expansor);
        }
        AssignmentResult result = binPackSystem(root, expansor, packer, errManager, som);
        reportResults(som, result);
        if (result.isSuccess()) {
            showResults(som, root, result);
        } else {
            showNoResults(som);
        }
    } catch (InvalidModelException e) {
        error(e.getElement(), e.getMessage());
    }
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) NoExpansionExpansor(EAnalysis.BinPacking.NoExpansionExpansor) BFCPBinPacker(EAnalysis.BinPacking.BFCPBinPacker) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) Element(org.osate.aadl2.Element) ForAllElement(org.osate.aadl2.modelsupport.modeltraversal.ForAllElement) NamedElement(org.osate.aadl2.NamedElement) AssignmentResult(EAnalysis.BinPacking.AssignmentResult) Classifier(org.osate.aadl2.Classifier) SystemClassifier(org.osate.aadl2.SystemClassifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) DataClassifier(org.osate.aadl2.DataClassifier) ProcessorClassifier(org.osate.aadl2.ProcessorClassifier) DataClassifier(org.osate.aadl2.DataClassifier) ComponentCategory(org.osate.aadl2.ComponentCategory) Feature(org.osate.aadl2.Feature) InvalidModelException(org.osate.aadl2.properties.InvalidModelException) ForAllElement(org.osate.aadl2.modelsupport.modeltraversal.ForAllElement) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) LowLevelBinPacker(EAnalysis.BinPacking.LowLevelBinPacker) DFCPBinPacker(EAnalysis.BinPacking.DFCPBinPacker) DFBPBinPacker(EAnalysis.BinPacking.DFBPBinPacker)

Aggregations

AssignmentResult (EAnalysis.BinPacking.AssignmentResult)1 BFCPBinPacker (EAnalysis.BinPacking.BFCPBinPacker)1 DFBPBinPacker (EAnalysis.BinPacking.DFBPBinPacker)1 DFCPBinPacker (EAnalysis.BinPacking.DFCPBinPacker)1 LowLevelBinPacker (EAnalysis.BinPacking.LowLevelBinPacker)1 NoExpansionExpansor (EAnalysis.BinPacking.NoExpansionExpansor)1 Classifier (org.osate.aadl2.Classifier)1 ComponentCategory (org.osate.aadl2.ComponentCategory)1 ComponentClassifier (org.osate.aadl2.ComponentClassifier)1 DataClassifier (org.osate.aadl2.DataClassifier)1 Element (org.osate.aadl2.Element)1 Feature (org.osate.aadl2.Feature)1 NamedElement (org.osate.aadl2.NamedElement)1 ProcessorClassifier (org.osate.aadl2.ProcessorClassifier)1 SystemClassifier (org.osate.aadl2.SystemClassifier)1 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)1 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)1 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)1 ForAllElement (org.osate.aadl2.modelsupport.modeltraversal.ForAllElement)1 InvalidModelException (org.osate.aadl2.properties.InvalidModelException)1