Search in sources :

Example 36 with Tuple

use of com.dat3m.dartagnan.wmm.utils.Tuple 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)

Example 37 with Tuple

use of com.dat3m.dartagnan.wmm.utils.Tuple 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 38 with Tuple

use of com.dat3m.dartagnan.wmm.utils.Tuple 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 39 with Tuple

use of com.dat3m.dartagnan.wmm.utils.Tuple 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 40 with Tuple

use of com.dat3m.dartagnan.wmm.utils.Tuple 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)

Aggregations

Tuple (com.dat3m.dartagnan.wmm.utils.Tuple)52 TupleSet (com.dat3m.dartagnan.wmm.utils.TupleSet)37 Event (com.dat3m.dartagnan.program.event.core.Event)36 BooleanFormula (org.sosy_lab.java_smt.api.BooleanFormula)23 BooleanFormulaManager (org.sosy_lab.java_smt.api.BooleanFormulaManager)23 Thread (com.dat3m.dartagnan.program.Thread)13 ExecutionAnalysis (com.dat3m.dartagnan.program.analysis.ExecutionAnalysis)11 AliasAnalysis (com.dat3m.dartagnan.program.analysis.AliasAnalysis)10 Collectors (java.util.stream.Collectors)10 Tag (com.dat3m.dartagnan.program.event.Tag)9 MemEvent (com.dat3m.dartagnan.program.event.core.MemEvent)9 Relation (com.dat3m.dartagnan.wmm.relation.Relation)9 SolverContext (org.sosy_lab.java_smt.api.SolverContext)9 LogManager (org.apache.logging.log4j.LogManager)8 Logger (org.apache.logging.log4j.Logger)8 FilterBasic (com.dat3m.dartagnan.program.filter.FilterBasic)6 WmmAnalysis (com.dat3m.dartagnan.wmm.analysis.WmmAnalysis)5 java.util (java.util)5 Store (com.dat3m.dartagnan.program.event.core.Store)4 List (java.util.List)4