Search in sources :

Example 96 with Event

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

the class RelCrit method getMaxTupleSet.

@Override
public TupleSet getMaxTupleSet() {
    if (maxTupleSet == null) {
        maxTupleSet = new TupleSet();
        for (Thread thread : task.getProgram().getThreads()) {
            for (Event lock : thread.getCache().getEvents(FilterBasic.get(Tag.Linux.RCU_LOCK))) {
                for (Event unlock : thread.getCache().getEvents(FilterBasic.get(Tag.Linux.RCU_UNLOCK))) {
                    if (lock.getCId() < unlock.getCId()) {
                        maxTupleSet.add(new Tuple(lock, unlock));
                    }
                }
            }
        }
        removeMutuallyExclusiveTuples(maxTupleSet);
    }
    return maxTupleSet;
}
Also used : TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) Event(com.dat3m.dartagnan.program.event.core.Event) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple) Thread(com.dat3m.dartagnan.program.Thread)

Example 97 with Event

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

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

the class RelRMW method pairingCond.

private BooleanFormula pairingCond(Thread thread, Event load, Event store, SolverContext ctx) {
    BooleanFormulaManager bmgr = ctx.getFormulaManager().getBooleanFormulaManager();
    BooleanFormula pairingCond = bmgr.and(load.exec(), store.cf());
    for (Event otherLoad : thread.getCache().getEvents(loadExclFilter)) {
        if (otherLoad.getCId() > load.getCId() && otherLoad.getCId() < store.getCId()) {
            pairingCond = bmgr.and(pairingCond, bmgr.not(otherLoad.exec()));
        }
    }
    for (Event otherStore : thread.getCache().getEvents(storeExclFilter)) {
        if (otherStore.getCId() > load.getCId() && otherStore.getCId() < store.getCId()) {
            pairingCond = bmgr.and(pairingCond, bmgr.not(otherStore.cf()));
        }
    }
    return pairingCond;
}
Also used : 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)

Example 99 with Event

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

the class RelFencerel method getMinTupleSet.

@Override
public TupleSet getMinTupleSet() {
    if (minTupleSet == null) {
        ExecutionAnalysis exec = analysisContext.get(ExecutionAnalysis.class);
        minTupleSet = new TupleSet();
        for (Thread t : task.getProgram().getThreads()) {
            List<Event> fences = t.getCache().getEvents(FilterBasic.get(fenceName));
            List<Event> memEvents = t.getCache().getEvents(FilterBasic.get(Tag.MEMORY));
            for (Event fence : fences) {
                int numEventsBeforeFence = (int) memEvents.stream().mapToInt(Event::getCId).filter(id -> id < fence.getCId()).count();
                List<Event> eventsBefore = memEvents.subList(0, numEventsBeforeFence);
                List<Event> eventsAfter = memEvents.subList(numEventsBeforeFence, memEvents.size());
                for (Event e1 : eventsBefore) {
                    boolean isImpliedByE1 = exec.isImplied(e1, fence);
                    for (Event e2 : eventsAfter) {
                        if (isImpliedByE1 || exec.isImplied(e2, fence)) {
                            minTupleSet.add(new Tuple(e1, e2));
                        }
                    }
                }
            }
        }
        removeMutuallyExclusiveTuples(minTupleSet);
    }
    return minTupleSet;
}
Also used : TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) ExecutionAnalysis(com.dat3m.dartagnan.program.analysis.ExecutionAnalysis) Event(com.dat3m.dartagnan.program.event.core.Event) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple) Thread(com.dat3m.dartagnan.program.Thread)

Example 100 with Event

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

the class RelFencerel method getMaxTupleSet.

@Override
public TupleSet getMaxTupleSet() {
    if (maxTupleSet == null) {
        maxTupleSet = new TupleSet();
        for (Thread t : task.getProgram().getThreads()) {
            List<Event> fences = t.getCache().getEvents(FilterBasic.get(fenceName));
            List<Event> memEvents = t.getCache().getEvents(FilterBasic.get(Tag.MEMORY));
            for (Event fence : fences) {
                int numEventsBeforeFence = (int) memEvents.stream().mapToInt(Event::getCId).filter(id -> id < fence.getCId()).count();
                List<Event> eventsBefore = memEvents.subList(0, numEventsBeforeFence);
                List<Event> eventsAfter = memEvents.subList(numEventsBeforeFence, memEvents.size());
                for (Event e1 : eventsBefore) {
                    for (Event e2 : eventsAfter) {
                        maxTupleSet.add(new Tuple(e1, e2));
                    }
                }
            }
        }
        removeMutuallyExclusiveTuples(maxTupleSet);
    }
    return maxTupleSet;
}
Also used : TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) Event(com.dat3m.dartagnan.program.event.core.Event) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple) Thread(com.dat3m.dartagnan.program.Thread)

Aggregations

Event (com.dat3m.dartagnan.program.event.core.Event)104 Tuple (com.dat3m.dartagnan.wmm.utils.Tuple)34 Thread (com.dat3m.dartagnan.program.Thread)32 Register (com.dat3m.dartagnan.program.Register)25 TupleSet (com.dat3m.dartagnan.wmm.utils.TupleSet)25 MemEvent (com.dat3m.dartagnan.program.event.core.MemEvent)20 Tag (com.dat3m.dartagnan.program.event.Tag)16 Label (com.dat3m.dartagnan.program.event.core.Label)16 Collectors (java.util.stream.Collectors)16 BooleanFormula (org.sosy_lab.java_smt.api.BooleanFormula)16 BooleanFormulaManager (org.sosy_lab.java_smt.api.BooleanFormulaManager)16 LogManager (org.apache.logging.log4j.LogManager)15 Logger (org.apache.logging.log4j.Logger)15 Program (com.dat3m.dartagnan.program.Program)12 ExecutionAnalysis (com.dat3m.dartagnan.program.analysis.ExecutionAnalysis)12 RegWriter (com.dat3m.dartagnan.program.event.core.utils.RegWriter)12 java.util (java.util)12 SolverContext (org.sosy_lab.java_smt.api.SolverContext)12 FilterBasic (com.dat3m.dartagnan.program.filter.FilterBasic)11 CondJump (com.dat3m.dartagnan.program.event.core.CondJump)10