Search in sources :

Example 41 with TupleSet

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

the class RelFencerel method getMaxTupleSet.

@Override
public TupleSet getMaxTupleSet() {
    if (maxTupleSet == null) {
        maxTupleSet = new TupleSet();
        for (Thread t : task.getProgram().getThreads()) {
            List<Event> fences = t.getCache().getEvents(FilterBasic.get(fenceName));
            List<Event> memEvents = t.getCache().getEvents(FilterBasic.get(Tag.MEMORY));
            for (Event fence : fences) {
                int numEventsBeforeFence = (int) memEvents.stream().mapToInt(Event::getCId).filter(id -> id < fence.getCId()).count();
                List<Event> eventsBefore = memEvents.subList(0, numEventsBeforeFence);
                List<Event> eventsAfter = memEvents.subList(numEventsBeforeFence, memEvents.size());
                for (Event e1 : eventsBefore) {
                    for (Event e2 : eventsAfter) {
                        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) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple) Thread(com.dat3m.dartagnan.program.Thread)

Example 42 with TupleSet

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

the class BinaryRelation method addEncodeTupleSet.

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

Example 43 with TupleSet

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

the class RelComposition method getMinTupleSet.

@Override
public TupleSet getMinTupleSet() {
    if (minTupleSet == null) {
        ExecutionAnalysis exec = analysisContext.get(ExecutionAnalysis.class);
        minTupleSet = r1.getMinTupleSet().postComposition(r2.getMinTupleSet(), (t1, t2) -> exec.isImplied(t1.getFirst(), t1.getSecond()) || exec.isImplied(t2.getSecond(), t1.getSecond()));
        removeMutuallyExclusiveTuples(minTupleSet);
    }
    return minTupleSet;
}
Also used : BooleanFormulaManager(org.sosy_lab.java_smt.api.BooleanFormulaManager) HashSet(java.util.HashSet) TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) ExecutionAnalysis(com.dat3m.dartagnan.program.analysis.ExecutionAnalysis) SolverContext(org.sosy_lab.java_smt.api.SolverContext) Event(com.dat3m.dartagnan.program.event.core.Event) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple) BooleanFormula(org.sosy_lab.java_smt.api.BooleanFormula) Set(java.util.Set) Relation(com.dat3m.dartagnan.wmm.relation.Relation) Sets(com.google.common.collect.Sets) ExecutionAnalysis(com.dat3m.dartagnan.program.analysis.ExecutionAnalysis)

Example 44 with TupleSet

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

the class RelComposition method getMaxTupleSetRecursive.

@Override
public TupleSet getMaxTupleSetRecursive() {
    if (recursiveGroupId > 0 && maxTupleSet != null) {
        ExecutionAnalysis exec = analysisContext.get(ExecutionAnalysis.class);
        maxTupleSet = r1.getMaxTupleSetRecursive().postComposition(r2.getMaxTupleSetRecursive(), (t1, t2) -> !exec.areMutuallyExclusive(t1.getFirst(), t2.getSecond()));
        return maxTupleSet;
    }
    return getMaxTupleSet();
}
Also used : BooleanFormulaManager(org.sosy_lab.java_smt.api.BooleanFormulaManager) HashSet(java.util.HashSet) TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) ExecutionAnalysis(com.dat3m.dartagnan.program.analysis.ExecutionAnalysis) SolverContext(org.sosy_lab.java_smt.api.SolverContext) Event(com.dat3m.dartagnan.program.event.core.Event) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple) BooleanFormula(org.sosy_lab.java_smt.api.BooleanFormula) Set(java.util.Set) Relation(com.dat3m.dartagnan.wmm.relation.Relation) Sets(com.google.common.collect.Sets) ExecutionAnalysis(com.dat3m.dartagnan.program.analysis.ExecutionAnalysis)

Example 45 with TupleSet

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

the class RelComposition method addEncodeTupleSet.

@Override
public void addEncodeTupleSet(TupleSet tuples) {
    Set<Tuple> activeSet = new HashSet<>(Sets.intersection(Sets.difference(tuples, encodeTupleSet), maxTupleSet));
    encodeTupleSet.addAll(activeSet);
    activeSet.removeAll(getMinTupleSet());
    if (!activeSet.isEmpty()) {
        TupleSet r1Set = new TupleSet();
        TupleSet r2Set = new TupleSet();
        TupleSet r1Max = r1.getMaxTupleSet();
        TupleSet r2Max = r2.getMaxTupleSet();
        for (Tuple t : activeSet) {
            Event e1 = t.getFirst();
            Event e3 = t.getSecond();
            for (Tuple t1 : r1Max.getByFirst(e1)) {
                Event e2 = t1.getSecond();
                Tuple t2 = new Tuple(e2, e3);
                if (r2Max.contains(t2)) {
                    r1Set.add(t1);
                    r2Set.add(t2);
                }
            }
        }
        r1.addEncodeTupleSet(r1Set);
        r2.addEncodeTupleSet(r2Set);
    }
}
Also used : TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) Event(com.dat3m.dartagnan.program.event.core.Event) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple) HashSet(java.util.HashSet)

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