Search in sources :

Example 26 with TupleSet

use of com.dat3m.dartagnan.wmm.utils.TupleSet in project Dat3M by hernanponcedeleon.

the class RelCartesian method getMaxTupleSet.

@Override
public TupleSet getMaxTupleSet() {
    if (maxTupleSet == null) {
        maxTupleSet = new TupleSet();
        List<Event> l1 = task.getProgram().getCache().getEvents(filter1);
        List<Event> l2 = task.getProgram().getCache().getEvents(filter2);
        ExecutionAnalysis exec = analysisContext.get(ExecutionAnalysis.class);
        for (Event e1 : l1) {
            for (Event e2 : l2) {
                if (!exec.areMutuallyExclusive(e1, e2)) {
                    maxTupleSet.add(new Tuple(e1, e2));
                }
            }
        }
    }
    return maxTupleSet;
}
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)

Example 27 with TupleSet

use of com.dat3m.dartagnan.wmm.utils.TupleSet in project Dat3M by hernanponcedeleon.

the class RelCtrlDirect method getMaxTupleSet.

@Override
public TupleSet getMaxTupleSet() {
    if (maxTupleSet == null) {
        maxTupleSet = new TupleSet();
        // NOTE: If's (under Linux) have different notion of ctrl dependency than conditional jumps!
        for (Thread thread : task.getProgram().getThreads()) {
            for (Event e1 : thread.getCache().getEvents(FilterBasic.get(Tag.CMP))) {
                for (Event e2 : ((IfAsJump) e1).getBranchesEvents()) {
                    maxTupleSet.add(new Tuple(e1, e2));
                }
            }
            // Relates jumps (except those implementing Ifs and their internal jump to end) with all later events
            List<Event> condJumps = thread.getCache().getEvents(FilterMinus.get(FilterBasic.get(Tag.JUMP), FilterUnion.get(FilterBasic.get(Tag.CMP), FilterBasic.get(Tag.IFI))));
            if (!condJumps.isEmpty()) {
                for (Event e2 : thread.getCache().getEvents(FilterBasic.get(Tag.ANY))) {
                    for (Event e1 : condJumps) {
                        if (e1.getCId() < e2.getCId()) {
                            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) IfAsJump(com.dat3m.dartagnan.program.event.core.IfAsJump) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple) Thread(com.dat3m.dartagnan.program.Thread)

Example 28 with TupleSet

use of com.dat3m.dartagnan.wmm.utils.TupleSet in project Dat3M by hernanponcedeleon.

the class RelUnion method encodeApprox.

@Override
protected BooleanFormula encodeApprox(SolverContext ctx) {
    BooleanFormulaManager bmgr = ctx.getFormulaManager().getBooleanFormulaManager();
    BooleanFormula enc = bmgr.makeTrue();
    TupleSet min = getMinTupleSet();
    for (Tuple tuple : encodeTupleSet) {
        if (min.contains(tuple)) {
            enc = bmgr.and(enc, bmgr.equivalence(this.getSMTVar(tuple, ctx), getExecPair(tuple, ctx)));
            continue;
        }
        BooleanFormula opt1 = r1.getSMTVar(tuple, ctx);
        BooleanFormula opt2 = r2.getSMTVar(tuple, ctx);
        if (Relation.PostFixApprox) {
            enc = bmgr.and(enc, bmgr.implication(bmgr.or(opt1, opt2), this.getSMTVar(tuple, ctx)));
        } else {
            enc = bmgr.and(enc, bmgr.equivalence(this.getSMTVar(tuple, ctx), bmgr.or(opt1, opt2)));
        }
    }
    return enc;
}
Also used : TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) BooleanFormulaManager(org.sosy_lab.java_smt.api.BooleanFormulaManager) BooleanFormula(org.sosy_lab.java_smt.api.BooleanFormula) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple)

Example 29 with TupleSet

use of com.dat3m.dartagnan.wmm.utils.TupleSet in project Dat3M by hernanponcedeleon.

the class RelDomainIdentity method addEncodeTupleSet.

@Override
public void addEncodeTupleSet(TupleSet tuples) {
    TupleSet activeSet = new TupleSet(Sets.intersection(Sets.difference(tuples, encodeTupleSet), maxTupleSet));
    encodeTupleSet.addAll(activeSet);
    activeSet.removeAll(getMinTupleSet());
    // TODO: Optimize using minSets (but no CAT uses this anyway)
    if (!activeSet.isEmpty()) {
        TupleSet r1Set = new TupleSet();
        for (Tuple tuple : activeSet) {
            r1Set.addAll(r1.getMaxTupleSet().getByFirst(tuple.getFirst()));
        }
        r1.addEncodeTupleSet(r1Set);
    }
}
Also used : TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple)

Example 30 with TupleSet

use of com.dat3m.dartagnan.wmm.utils.TupleSet in project Dat3M by hernanponcedeleon.

the class RelInverse method addEncodeTupleSet.

@Override
public void addEncodeTupleSet(TupleSet tuples) {
    TupleSet activeSet = new TupleSet(Sets.intersection(Sets.difference(tuples, encodeTupleSet), maxTupleSet));
    encodeTupleSet.addAll(activeSet);
    activeSet.removeAll(getMinTupleSet());
    if (!activeSet.isEmpty()) {
        r1.addEncodeTupleSet(activeSet.inverse());
    }
}
Also used : TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet)

Aggregations

TupleSet (com.dat3m.dartagnan.wmm.utils.TupleSet)47 Tuple (com.dat3m.dartagnan.wmm.utils.Tuple)36 Event (com.dat3m.dartagnan.program.event.core.Event)27 BooleanFormula (org.sosy_lab.java_smt.api.BooleanFormula)16 BooleanFormulaManager (org.sosy_lab.java_smt.api.BooleanFormulaManager)16 ExecutionAnalysis (com.dat3m.dartagnan.program.analysis.ExecutionAnalysis)11 Thread (com.dat3m.dartagnan.program.Thread)10 Relation (com.dat3m.dartagnan.wmm.relation.Relation)8 SolverContext (org.sosy_lab.java_smt.api.SolverContext)8 Sets (com.google.common.collect.Sets)7 MemEvent (com.dat3m.dartagnan.program.event.core.MemEvent)5 Set (java.util.Set)5 AliasAnalysis (com.dat3m.dartagnan.program.analysis.AliasAnalysis)4 HashSet (java.util.HashSet)4 Collectors (java.util.stream.Collectors)4 Tag (com.dat3m.dartagnan.program.event.Tag)3 WmmAnalysis (com.dat3m.dartagnan.wmm.analysis.WmmAnalysis)3 LogManager (org.apache.logging.log4j.LogManager)3 Logger (org.apache.logging.log4j.Logger)3 GlobalSettings (com.dat3m.dartagnan.GlobalSettings)2