Search in sources :

Example 1 with WmmAnalysis

use of com.dat3m.dartagnan.wmm.analysis.WmmAnalysis in project Dat3M by hernanponcedeleon.

the class RelCo method getMinTupleSet.

@Override
public TupleSet getMinTupleSet() {
    if (minTupleSet == null) {
        minTupleSet = new TupleSet();
        WmmAnalysis wmmAnalysis = analysisContext.get(WmmAnalysis.class);
        if (wmmAnalysis.isLocallyConsistent()) {
            applyLocalConsistencyMinSet();
        }
    }
    return minTupleSet;
}
Also used : TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) WmmAnalysis(com.dat3m.dartagnan.wmm.analysis.WmmAnalysis)

Example 2 with WmmAnalysis

use of com.dat3m.dartagnan.wmm.analysis.WmmAnalysis in project Dat3M by hernanponcedeleon.

the class RelCo method encodeApprox.

@Override
protected BooleanFormula encodeApprox(SolverContext ctx) {
    AliasAnalysis alias = analysisContext.get(AliasAnalysis.class);
    WmmAnalysis wmmAnalysis = analysisContext.get(WmmAnalysis.class);
    FormulaManager fmgr = ctx.getFormulaManager();
    BooleanFormulaManager bmgr = fmgr.getBooleanFormulaManager();
    IntegerFormulaManager imgr = fmgr.getIntegerFormulaManager();
    BooleanFormula enc = bmgr.makeTrue();
    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 e : eventsInit) {
        enc = bmgr.and(enc, imgr.equal(getIntVar(e, ctx), imgr.makeNumber(BigInteger.ZERO)));
    }
    List<IntegerFormula> intVars = new ArrayList<>();
    for (Event w : eventsStore) {
        IntegerFormula coVar = getIntVar(w, ctx);
        enc = bmgr.and(enc, imgr.greaterThan(coVar, imgr.makeNumber(BigInteger.ZERO)));
        intVars.add(coVar);
    }
    BooleanFormula distinct = intVars.size() > 1 ? imgr.distinct(intVars) : bmgr.makeTrue();
    enc = bmgr.and(enc, distinct);
    for (Event w : task.getProgram().getCache().getEvents(FilterBasic.get(WRITE))) {
        MemEvent w1 = (MemEvent) w;
        BooleanFormula lastCo = w1.exec();
        for (Tuple t : maxTupleSet.getByFirst(w1)) {
            MemEvent w2 = (MemEvent) t.getSecond();
            BooleanFormula relation = getSMTVar(t, ctx);
            BooleanFormula execPair = getExecPair(t, ctx);
            lastCo = bmgr.and(lastCo, bmgr.not(relation));
            Formula a1 = w1.getMemAddressExpr();
            Formula a2 = w2.getMemAddressExpr();
            BooleanFormula sameAddress = generalEqual(a1, a2, ctx);
            enc = bmgr.and(enc, bmgr.equivalence(relation, bmgr.and(execPair, sameAddress, imgr.lessThan(getIntVar(w1, ctx), getIntVar(w2, ctx)))));
            // ============ Local consistency optimizations ============
            if (getMinTupleSet().contains(t)) {
                enc = bmgr.and(enc, bmgr.equivalence(relation, execPair));
            } else if (wmmAnalysis.isLocallyConsistent()) {
                if (w2.is(INIT) || t.isBackward()) {
                    enc = bmgr.and(enc, bmgr.equivalence(relation, bmgr.makeFalse()));
                }
                if (w1.is(INIT) || t.isForward()) {
                    enc = bmgr.and(enc, bmgr.implication(bmgr.and(execPair, sameAddress), relation));
                }
            }
        }
        if (task.getProgram().getFormat().equals(LITMUS) || task.getProperty().contains(LIVENESS)) {
            BooleanFormula lastCoExpr = getLastCoVar(w1, ctx);
            enc = bmgr.and(enc, bmgr.equivalence(lastCoExpr, lastCo));
            for (Event i : eventsInit) {
                Init init = (Init) i;
                if (!alias.mayAlias(w1, init)) {
                    continue;
                }
                IExpr address = init.getAddress();
                Formula a1 = w1.getMemAddressExpr();
                Formula a2 = address.toIntFormula(init, ctx);
                BooleanFormula sameAddress = generalEqual(a1, a2, ctx);
                Formula v1 = w1.getMemValueExpr();
                Formula v2 = init.getBase().getLastMemValueExpr(ctx, init.getOffset());
                BooleanFormula sameValue = generalEqual(v1, v2, ctx);
                enc = bmgr.and(enc, bmgr.implication(bmgr.and(lastCoExpr, sameAddress), sameValue));
            }
        }
    }
    return enc;
}
Also used : IntegerFormula(org.sosy_lab.java_smt.api.NumeralFormula.IntegerFormula) ArrayList(java.util.ArrayList) AliasAnalysis(com.dat3m.dartagnan.program.analysis.AliasAnalysis) IntegerFormula(org.sosy_lab.java_smt.api.NumeralFormula.IntegerFormula) Init(com.dat3m.dartagnan.program.event.core.Init) 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) IExpr(com.dat3m.dartagnan.expression.IExpr) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple)

Example 3 with WmmAnalysis

use of com.dat3m.dartagnan.wmm.analysis.WmmAnalysis 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 4 with WmmAnalysis

use of com.dat3m.dartagnan.wmm.analysis.WmmAnalysis 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

WmmAnalysis (com.dat3m.dartagnan.wmm.analysis.WmmAnalysis)4 AliasAnalysis (com.dat3m.dartagnan.program.analysis.AliasAnalysis)3 Event (com.dat3m.dartagnan.program.event.core.Event)3 MemEvent (com.dat3m.dartagnan.program.event.core.MemEvent)3 Tuple (com.dat3m.dartagnan.wmm.utils.Tuple)3 TupleSet (com.dat3m.dartagnan.wmm.utils.TupleSet)3 IExpr (com.dat3m.dartagnan.expression.IExpr)1 Init (com.dat3m.dartagnan.program.event.core.Init)1 ArrayList (java.util.ArrayList)1 IntegerFormula (org.sosy_lab.java_smt.api.NumeralFormula.IntegerFormula)1