Search in sources :

Example 16 with MemEvent

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

the class RelRMW method encodeApprox.

@Override
protected BooleanFormula encodeApprox(SolverContext ctx) {
    FormulaManager fmgr = ctx.getFormulaManager();
    BooleanFormulaManager bmgr = fmgr.getBooleanFormulaManager();
    // Encode base (not exclusive pairs) RMW
    TupleSet origEncodeTupleSet = encodeTupleSet;
    encodeTupleSet = new TupleSet(Sets.intersection(encodeTupleSet, baseMaxTupleSet));
    BooleanFormula enc = super.encodeApprox(ctx);
    encodeTupleSet = origEncodeTupleSet;
    // Encode RMW for exclusive pairs
    BooleanFormula unpredictable = bmgr.makeFalse();
    for (Thread thread : task.getProgram().getThreads()) {
        for (Event store : thread.getCache().getEvents(storeExclFilter)) {
            BooleanFormula storeExec = bmgr.makeFalse();
            for (Event load : thread.getCache().getEvents(loadExclFilter)) {
                if (load.getCId() < store.getCId()) {
                    // Encode if load and store form an exclusive pair
                    BooleanFormula isPair = exclPair(load, store, ctx);
                    BooleanFormula isExecPair = bmgr.and(isPair, store.exec());
                    enc = bmgr.and(enc, bmgr.equivalence(isPair, pairingCond(thread, load, store, ctx)));
                    // If load and store have the same address
                    BooleanFormula sameAddress = generalEqual(((MemEvent) load).getMemAddressExpr(), ((MemEvent) store).getMemAddressExpr(), ctx);
                    unpredictable = bmgr.or(unpredictable, bmgr.and(isExecPair, bmgr.not(sameAddress)));
                    // Relation between exclusive load and store
                    enc = bmgr.and(enc, bmgr.equivalence(this.getSMTVar(load, store, ctx), bmgr.and(isExecPair, sameAddress)));
                    // Can be executed if addresses mismatch, but behaviour is "constrained unpredictable"
                    // The implementation does not include all possible unpredictable cases: in case of address
                    // mismatch, addresses of read and write are unknown, i.e. read and write can use any address
                    storeExec = bmgr.or(storeExec, isPair);
                }
            }
            enc = bmgr.and(enc, bmgr.implication(store.exec(), storeExec));
        }
    }
    return bmgr.and(enc, bmgr.equivalence(Flag.ARM_UNPREDICTABLE_BEHAVIOUR.repr(ctx), unpredictable));
}
Also used : TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) BooleanFormulaManager(org.sosy_lab.java_smt.api.BooleanFormulaManager) FormulaManager(org.sosy_lab.java_smt.api.FormulaManager) BooleanFormulaManager(org.sosy_lab.java_smt.api.BooleanFormulaManager) MemEvent(com.dat3m.dartagnan.program.event.core.MemEvent) Event(com.dat3m.dartagnan.program.event.core.Event) BooleanFormula(org.sosy_lab.java_smt.api.BooleanFormula) Thread(com.dat3m.dartagnan.program.Thread)

Example 17 with MemEvent

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

the class ExecutionGraphVisualizer method generateGraphOfExecutionModel.

public void generateGraphOfExecutionModel(Writer writer, String graphName, ExecutionModel model) throws IOException {
    for (EventData data : model.getThreadEventsMap().values().stream().collect(ArrayList<EventData>::new, List::addAll, List::addAll)) {
        if (data.isMemoryEvent()) {
            MemEvent m = (MemEvent) data.getEvent();
            if (!(m.getAddress() instanceof Register)) {
                addresses.putIfAbsent(data.getAccessedAddress(), m.getAddress());
            }
        }
    }
    graphviz.begin(graphName);
    graphviz.append(String.format("label=\"%s\" \n", graphName));
    addAllThreadPos(model);
    addReadFrom(model);
    addCoherence(model);
    graphviz.end();
    graphviz.generateOutput(writer);
}
Also used : Register(com.dat3m.dartagnan.program.Register) MemEvent(com.dat3m.dartagnan.program.event.core.MemEvent) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) EventData(com.dat3m.dartagnan.verification.model.EventData)

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