Search in sources :

Example 16 with AliasAnalysis

use of com.dat3m.dartagnan.program.analysis.AliasAnalysis in project Dat3M by hernanponcedeleon.

the class AnalysisTest method program3.

private void program3(Alias method, Result... expect) throws InvalidConfigurationException {
    ProgramBuilder b = new ProgramBuilder(SourceLanguage.LITMUS);
    MemoryObject x = b.newObject("x", 3);
    x.setInitialValue(0, x);
    b.initThread(0);
    Register r0 = b.getOrCreateRegister(0, "r0", ARCH_PRECISION);
    Load e0 = newLoad(r0, x);
    b.addChild(0, e0);
    Store e1 = newStore(x, plus(r0, 1));
    b.addChild(0, e1);
    Store e2 = newStore(plus(x, 2));
    b.addChild(0, e2);
    Store e3 = newStore(r0);
    b.addChild(0, e3);
    AliasAnalysis a = analyze(b, method);
    assertAlias(expect[0], a, e0, e1);
    assertAlias(expect[1], a, e0, e2);
    assertAlias(expect[2], a, e1, e2);
    assertAlias(expect[3], a, e0, e3);
    assertAlias(expect[4], a, e1, e3);
    // precisely no
    assertAlias(expect[5], a, e2, e3);
}
Also used : Register(com.dat3m.dartagnan.program.Register) ProgramBuilder(com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder) MemoryObject(com.dat3m.dartagnan.program.memory.MemoryObject) AliasAnalysis(com.dat3m.dartagnan.program.analysis.AliasAnalysis)

Example 17 with AliasAnalysis

use of com.dat3m.dartagnan.program.analysis.AliasAnalysis in project Dat3M by hernanponcedeleon.

the class RelCo method getMaxTupleSet.

@Override
public TupleSet getMaxTupleSet() {
    if (maxTupleSet == null) {
        logger.info("Computing maxTupleSet for " + getName());
        AliasAnalysis alias = analysisContext.get(AliasAnalysis.class);
        WmmAnalysis wmmAnalysis = analysisContext.get(WmmAnalysis.class);
        maxTupleSet = new TupleSet();
        List<Event> eventsInit = task.getProgram().getCache().getEvents(FilterBasic.get(INIT));
        List<Event> eventsStore = task.getProgram().getCache().getEvents(FilterMinus.get(FilterBasic.get(WRITE), FilterBasic.get(INIT)));
        for (Event e1 : eventsInit) {
            for (Event e2 : eventsStore) {
                if (alias.mayAlias((MemEvent) e1, (MemEvent) e2)) {
                    maxTupleSet.add(new Tuple(e1, e2));
                }
            }
        }
        for (Event e1 : eventsStore) {
            for (Event e2 : eventsStore) {
                if (e1.getCId() != e2.getCId() && alias.mayAlias((MemEvent) e1, (MemEvent) e2)) {
                    maxTupleSet.add(new Tuple(e1, e2));
                }
            }
        }
        removeMutuallyExclusiveTuples(maxTupleSet);
        if (wmmAnalysis.isLocallyConsistent()) {
            applyLocalConsistencyMaxSet();
        }
        logger.info("maxTupleSet size for " + getName() + ": " + maxTupleSet.size());
    }
    return maxTupleSet;
}
Also used : TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) MemEvent(com.dat3m.dartagnan.program.event.core.MemEvent) WmmAnalysis(com.dat3m.dartagnan.wmm.analysis.WmmAnalysis) MemEvent(com.dat3m.dartagnan.program.event.core.MemEvent) Event(com.dat3m.dartagnan.program.event.core.Event) AliasAnalysis(com.dat3m.dartagnan.program.analysis.AliasAnalysis) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple)

Example 18 with AliasAnalysis

use of com.dat3m.dartagnan.program.analysis.AliasAnalysis in project Dat3M by hernanponcedeleon.

the class RelCo method applyLocalConsistencyMinSet.

private void applyLocalConsistencyMinSet() {
    for (Tuple t : getMaxTupleSet()) {
        AliasAnalysis alias = analysisContext.get(AliasAnalysis.class);
        MemEvent w1 = (MemEvent) t.getFirst();
        MemEvent w2 = (MemEvent) t.getSecond();
        if (!w1.is(INIT) && alias.mustAlias(w1, w2) && (w1.is(INIT) || t.isForward())) {
            minTupleSet.add(t);
        }
    }
}
Also used : MemEvent(com.dat3m.dartagnan.program.event.core.MemEvent) AliasAnalysis(com.dat3m.dartagnan.program.analysis.AliasAnalysis) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple)

Example 19 with AliasAnalysis

use of com.dat3m.dartagnan.program.analysis.AliasAnalysis in project Dat3M by hernanponcedeleon.

the class RelLoc method getMinTupleSet.

@Override
public TupleSet getMinTupleSet() {
    if (minTupleSet == null) {
        AliasAnalysis alias = analysisContext.get(AliasAnalysis.class);
        minTupleSet = new TupleSet();
        for (Tuple t : getMaxTupleSet()) {
            if (alias.mustAlias((MemEvent) t.getFirst(), (MemEvent) t.getSecond())) {
                minTupleSet.add(t);
            }
        }
    }
    return minTupleSet;
}
Also used : TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) AliasAnalysis(com.dat3m.dartagnan.program.analysis.AliasAnalysis) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple)

Example 20 with AliasAnalysis

use of com.dat3m.dartagnan.program.analysis.AliasAnalysis in project Dat3M by hernanponcedeleon.

the class RelRf method getMaxTupleSet.

@Override
public TupleSet getMaxTupleSet() {
    if (maxTupleSet == null) {
        AliasAnalysis alias = analysisContext.get(AliasAnalysis.class);
        WmmAnalysis wmmAnalysis = analysisContext.get(WmmAnalysis.class);
        logger.info("Computing maxTupleSet for " + getName());
        maxTupleSet = new TupleSet();
        List<Event> loadEvents = task.getProgram().getCache().getEvents(FilterBasic.get(READ));
        List<Event> storeEvents = task.getProgram().getCache().getEvents(FilterBasic.get(WRITE));
        for (Event e1 : storeEvents) {
            for (Event e2 : loadEvents) {
                if (alias.mayAlias((MemEvent) e1, (MemEvent) e2)) {
                    maxTupleSet.add(new Tuple(e1, e2));
                }
            }
        }
        removeMutuallyExclusiveTuples(maxTupleSet);
        if (wmmAnalysis.isLocallyConsistent()) {
            applyLocalConsistency();
        }
        if (wmmAnalysis.doesRespectAtomicBlocks()) {
            atomicBlockOptimization();
        }
        logger.info("maxTupleSet size for " + getName() + ": " + maxTupleSet.size());
    }
    return maxTupleSet;
}
Also used : TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) WmmAnalysis(com.dat3m.dartagnan.wmm.analysis.WmmAnalysis) MemEvent(com.dat3m.dartagnan.program.event.core.MemEvent) Event(com.dat3m.dartagnan.program.event.core.Event) AliasAnalysis(com.dat3m.dartagnan.program.analysis.AliasAnalysis) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple)

Aggregations

AliasAnalysis (com.dat3m.dartagnan.program.analysis.AliasAnalysis)20 ProgramBuilder (com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder)12 Register (com.dat3m.dartagnan.program.Register)12 MemoryObject (com.dat3m.dartagnan.program.memory.MemoryObject)12 MemEvent (com.dat3m.dartagnan.program.event.core.MemEvent)7 Tuple (com.dat3m.dartagnan.wmm.utils.Tuple)7 Event (com.dat3m.dartagnan.program.event.core.Event)6 TupleSet (com.dat3m.dartagnan.wmm.utils.TupleSet)5 WmmAnalysis (com.dat3m.dartagnan.wmm.analysis.WmmAnalysis)4 ExecutionAnalysis (com.dat3m.dartagnan.program.analysis.ExecutionAnalysis)2 Load (com.dat3m.dartagnan.program.event.core.Load)2 Store (com.dat3m.dartagnan.program.event.core.Store)2 EndAtomic (com.dat3m.dartagnan.program.event.lang.svcomp.EndAtomic)2 FilterAbstract (com.dat3m.dartagnan.program.filter.FilterAbstract)2 IExpr (com.dat3m.dartagnan.expression.IExpr)1 Utils (com.dat3m.dartagnan.expression.utils.Utils)1 Tag (com.dat3m.dartagnan.program.event.Tag)1 Init (com.dat3m.dartagnan.program.event.core.Init)1 FilterBasic (com.dat3m.dartagnan.program.filter.FilterBasic)1 FilterIntersection (com.dat3m.dartagnan.program.filter.FilterIntersection)1