Search in sources :

Example 46 with TupleSet

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

the class RelMinus method getMaxTupleSet.

@Override
public TupleSet getMaxTupleSet() {
    if (maxTupleSet == null) {
        maxTupleSet = new TupleSet(Sets.difference(r1.getMaxTupleSet(), r2.getMinTupleSet()));
        r2.getMaxTupleSet();
    }
    return maxTupleSet;
}
Also used : TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet)

Example 47 with TupleSet

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

the class CoSymmetryBreaking method initialize.

private void initialize(EquivalenceClass<Thread> symmClass) {
    Info info = new Info();
    infoMap.put(symmClass, info);
    // Get symmetric threads and order them by tid
    List<Thread> symmThreads = new ArrayList<>(symmClass);
    symmThreads.sort(Comparator.comparingInt(Thread::getId));
    info.threads = symmThreads;
    // Get stores of first thread
    List<Store> writes = symmThreads.get(0).getCache().getEvents(FilterBasic.get(Tag.WRITE)).stream().map(Store.class::cast).collect(Collectors.toList());
    // Symmetric writes that cannot alias are related to e.g. thread-creation
    // We do not want to break on those
    writes.removeIf(w -> !alias.mayAlias(w, (Store) symm.map(w, symmThreads.get(1))));
    // We compute the (overall) sync-degree of a write w as the maximal sync degree over all
    // axioms. The sync-degree of w for axiom(r) is computed via must(r).
    List<Axiom> axioms = task.getAxioms();
    Map<Store, Integer> syncDegreeMap = new HashMap<>(writes.size());
    for (Store w : writes) {
        int syncDeg = 0;
        for (Axiom ax : axioms) {
            TupleSet minSet = ax.getRelation().getMinTupleSet();
            syncDeg = Math.max(syncDeg, (1 + minSet.getBySecond(w).size()) * (1 + minSet.getByFirst(w).size()));
        }
        syncDegreeMap.put(w, syncDeg);
    }
    // Sort the writes by sync-degree (highest first).
    // This will be the order in which we break coherences!
    Comparator<Store> breakingOrder = Comparator.<Store>comparingInt(syncDegreeMap::get).reversed();
    writes.sort(breakingOrder);
    // first position.
    for (int i = 0; i < writes.size(); i++) {
        Store w = writes.get(i);
        boolean mustAlias = symmThreads.stream().allMatch(t -> alias.mustAlias(w, (Store) symm.map(w, t)));
        if (mustAlias) {
            info.hasMustEdges = true;
            // Move entry to front
            writes.add(0, writes.remove(i));
            break;
        }
    }
    info.writes = writes;
}
Also used : TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) Store(com.dat3m.dartagnan.program.event.core.Store) Thread(com.dat3m.dartagnan.program.Thread) Axiom(com.dat3m.dartagnan.wmm.axiom.Axiom)

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