Search in sources :

Example 6 with Axiom

use of com.dat3m.dartagnan.wmm.axiom.Axiom 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

Axiom (com.dat3m.dartagnan.wmm.axiom.Axiom)6 Relation (com.dat3m.dartagnan.wmm.relation.Relation)2 BooleanFormula (org.sosy_lab.java_smt.api.BooleanFormula)2 BooleanFormulaManager (org.sosy_lab.java_smt.api.BooleanFormulaManager)2 Thread (com.dat3m.dartagnan.program.Thread)1 Event (com.dat3m.dartagnan.program.event.core.Event)1 Store (com.dat3m.dartagnan.program.event.core.Store)1 AcyclicityConstraint (com.dat3m.dartagnan.solver.caat.constraints.AcyclicityConstraint)1 Constraint (com.dat3m.dartagnan.solver.caat.constraints.Constraint)1 EmptinessConstraint (com.dat3m.dartagnan.solver.caat.constraints.EmptinessConstraint)1 IrreflexivityConstraint (com.dat3m.dartagnan.solver.caat.constraints.IrreflexivityConstraint)1 RelationGraph (com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.RelationGraph)1 Wmm (com.dat3m.dartagnan.wmm.Wmm)1 RecursiveGroup (com.dat3m.dartagnan.wmm.utils.RecursiveGroup)1 Tuple (com.dat3m.dartagnan.wmm.utils.Tuple)1 TupleSet (com.dat3m.dartagnan.wmm.utils.TupleSet)1 HashSet (java.util.HashSet)1