Search in sources :

Example 11 with MemEvent

use of com.dat3m.dartagnan.program.event.core.MemEvent 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 12 with MemEvent

use of com.dat3m.dartagnan.program.event.core.MemEvent in project Dat3M by hernanponcedeleon.

the class RelCo method getSMTVar.

@Override
public BooleanFormula getSMTVar(Tuple edge, SolverContext ctx) {
    if (!antisymmetry) {
        return super.getSMTVar(edge, ctx);
    }
    FormulaManager fmgr = ctx.getFormulaManager();
    BooleanFormulaManager bmgr = fmgr.getBooleanFormulaManager();
    MemEvent first = (MemEvent) edge.getFirst();
    MemEvent second = (MemEvent) edge.getSecond();
    // Doing the check at the java level seems to slightly improve  performance
    BooleanFormula eqAdd = first.getAddress().equals(second.getAddress()) ? bmgr.makeTrue() : generalEqual(first.getMemAddressExpr(), second.getMemAddressExpr(), ctx);
    return !getMaxTupleSet().contains(edge) ? bmgr.makeFalse() : first.getCId() <= second.getCId() ? edge(getName(), first, second, ctx) : bmgr.ifThenElse(bmgr.and(getExecPair(edge, ctx), eqAdd), bmgr.not(getSMTVar(edge.getInverse(), ctx)), bmgr.makeFalse());
}
Also used : MemEvent(com.dat3m.dartagnan.program.event.core.MemEvent)

Example 13 with MemEvent

use of com.dat3m.dartagnan.program.event.core.MemEvent 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 14 with MemEvent

use of com.dat3m.dartagnan.program.event.core.MemEvent in project Dat3M by hernanponcedeleon.

the class RelRf method encodeApprox.

@Override
protected BooleanFormula encodeApprox(SolverContext ctx) {
    FormulaManager fmgr = ctx.getFormulaManager();
    BooleanFormulaManager bmgr = fmgr.getBooleanFormulaManager();
    BooleanFormula enc = bmgr.makeTrue();
    Map<MemEvent, List<BooleanFormula>> edgeMap = new HashMap<>();
    for (Tuple tuple : maxTupleSet) {
        MemEvent w = (MemEvent) tuple.getFirst();
        MemEvent r = (MemEvent) tuple.getSecond();
        BooleanFormula edge = this.getSMTVar(tuple, ctx);
        // The boogie file might have a different type (Ints vs BVs) that the imposed by ARCH_PRECISION
        // In such cases we perform the transformation
        Formula a1 = w.getMemAddressExpr();
        Formula a2 = r.getMemAddressExpr();
        BooleanFormula sameAddress = generalEqual(a1, a2, ctx);
        Formula v1 = w.getMemValueExpr();
        Formula v2 = r.getMemValueExpr();
        BooleanFormula sameValue = generalEqual(v1, v2, ctx);
        edgeMap.computeIfAbsent(r, key -> new ArrayList<>()).add(edge);
        enc = bmgr.and(enc, bmgr.implication(edge, bmgr.and(getExecPair(w, r, ctx), sameAddress, sameValue)));
    }
    for (MemEvent r : edgeMap.keySet()) {
        enc = bmgr.and(enc, encodeEdgeSeq(r, edgeMap.get(r), ctx));
    }
    return enc;
}
Also used : AliasAnalysis(com.dat3m.dartagnan.program.analysis.AliasAnalysis) java.util(java.util) BooleanType(org.sosy_lab.java_smt.api.FormulaType.BooleanType) Store(com.dat3m.dartagnan.program.event.core.Store) ExecutionAnalysis(com.dat3m.dartagnan.program.analysis.ExecutionAnalysis) org.sosy_lab.java_smt.api(org.sosy_lab.java_smt.api) Relation(com.dat3m.dartagnan.wmm.relation.Relation) Utils(com.dat3m.dartagnan.expression.utils.Utils) RF(com.dat3m.dartagnan.wmm.relation.RelationNameRepository.RF) Collectors(java.util.stream.Collectors) MemEvent(com.dat3m.dartagnan.program.event.core.MemEvent) FilterAbstract(com.dat3m.dartagnan.program.filter.FilterAbstract) Tag(com.dat3m.dartagnan.program.event.Tag) EndAtomic(com.dat3m.dartagnan.program.event.lang.svcomp.EndAtomic) WmmAnalysis(com.dat3m.dartagnan.wmm.analysis.WmmAnalysis) Logger(org.apache.logging.log4j.Logger) TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) FilterIntersection(com.dat3m.dartagnan.program.filter.FilterIntersection) Event(com.dat3m.dartagnan.program.event.core.Event) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple) Load(com.dat3m.dartagnan.program.event.core.Load) LogManager(org.apache.logging.log4j.LogManager) FilterBasic(com.dat3m.dartagnan.program.filter.FilterBasic) MemEvent(com.dat3m.dartagnan.program.event.core.MemEvent) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple)

Example 15 with MemEvent

use of com.dat3m.dartagnan.program.event.core.MemEvent 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

MemEvent (com.dat3m.dartagnan.program.event.core.MemEvent)17 Event (com.dat3m.dartagnan.program.event.core.Event)12 AliasAnalysis (com.dat3m.dartagnan.program.analysis.AliasAnalysis)8 Tuple (com.dat3m.dartagnan.wmm.utils.Tuple)8 TupleSet (com.dat3m.dartagnan.wmm.utils.TupleSet)6 Thread (com.dat3m.dartagnan.program.Thread)5 Tag (com.dat3m.dartagnan.program.event.Tag)5 FilterBasic (com.dat3m.dartagnan.program.filter.FilterBasic)5 WmmAnalysis (com.dat3m.dartagnan.wmm.analysis.WmmAnalysis)5 Collectors (java.util.stream.Collectors)5 Program (com.dat3m.dartagnan.program.Program)4 Register (com.dat3m.dartagnan.program.Register)4 Load (com.dat3m.dartagnan.program.event.core.Load)4 RegWriter (com.dat3m.dartagnan.program.event.core.utils.RegWriter)4 java.util (java.util)4 LogManager (org.apache.logging.log4j.LogManager)4 Logger (org.apache.logging.log4j.Logger)4 Store (com.dat3m.dartagnan.program.event.core.Store)3 RegReaderData (com.dat3m.dartagnan.program.event.core.utils.RegReaderData)3 EndAtomic (com.dat3m.dartagnan.program.event.lang.svcomp.EndAtomic)3