Search in sources :

Example 6 with Store

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

Store (com.dat3m.dartagnan.program.event.core.Store)6 Event (com.dat3m.dartagnan.program.event.core.Event)4 Thread (com.dat3m.dartagnan.program.Thread)3 Load (com.dat3m.dartagnan.program.event.core.Load)3 AliasAnalysis (com.dat3m.dartagnan.program.analysis.AliasAnalysis)2 Tag (com.dat3m.dartagnan.program.event.Tag)2 MemEvent (com.dat3m.dartagnan.program.event.core.MemEvent)2 FilterBasic (com.dat3m.dartagnan.program.filter.FilterBasic)2 Axiom (com.dat3m.dartagnan.wmm.axiom.Axiom)2 Tuple (com.dat3m.dartagnan.wmm.utils.Tuple)2 TupleSet (com.dat3m.dartagnan.wmm.utils.TupleSet)2 Lists (com.google.common.collect.Lists)2 java.util (java.util)2 Collectors (java.util.stream.Collectors)2 BooleanFormula (org.sosy_lab.java_smt.api.BooleanFormula)2 BooleanFormulaManager (org.sosy_lab.java_smt.api.BooleanFormulaManager)2 SolverContext (org.sosy_lab.java_smt.api.SolverContext)2 SymmetryEncoder (com.dat3m.dartagnan.encoding.SymmetryEncoder)1 Utils.generalEqual (com.dat3m.dartagnan.expression.utils.Utils.generalEqual)1 Program (com.dat3m.dartagnan.program.Program)1