Search in sources :

Example 6 with Event

use of com.dat3m.dartagnan.program.event.core.Event in project Dat3M by hernanponcedeleon.

the class VerificationTask method performStaticProgramAnalyses.

public void performStaticProgramAnalyses() throws InvalidConfigurationException {
    analysisContext.register(BranchEquivalence.class, BranchEquivalence.fromConfig(program, config));
    analysisContext.register(ExecutionAnalysis.class, ExecutionAnalysis.fromConfig(program, analysisContext, config));
    analysisContext.register(Dependency.class, Dependency.fromConfig(program, analysisContext, config));
    analysisContext.register(AliasAnalysis.class, AliasAnalysis.fromConfig(program, config));
    analysisContext.register(ThreadSymmetry.class, ThreadSymmetry.fromConfig(program, config));
    for (Thread thread : program.getThreads()) {
        for (Event e : thread.getEvents()) {
            // Some events perform static analyses by themselves (e.g. Svcomp's EndAtomic)
            // which may rely on previous "global" analyses
            e.runLocalAnalysis(program, analysisContext);
        }
    }
}
Also used : Event(com.dat3m.dartagnan.program.event.core.Event) Thread(com.dat3m.dartagnan.program.Thread)

Example 7 with Event

use of com.dat3m.dartagnan.program.event.core.Event in project Dat3M by hernanponcedeleon.

the class Printer method appendThread.

private void appendThread(Thread thread) {
    try {
        Integer.parseInt(thread.getName());
        result.append("\nthread_").append(thread.getName()).append("\n");
    } catch (Exception e) {
        result.append("\n").append(thread.getName()).append("\n");
    }
    for (Event e : thread.getCache().getEvents(FilterBasic.get(Tag.ANY))) {
        appendEvent(e);
    }
}
Also used : Event(com.dat3m.dartagnan.program.event.core.Event)

Example 8 with Event

use of com.dat3m.dartagnan.program.event.core.Event in project Dat3M by hernanponcedeleon.

the class CoSymmetryBreaking method encode.

public BooleanFormula encode(EquivalenceClass<Thread> symmClass, SolverContext ctx) {
    BooleanFormulaManager bmgr = ctx.getFormulaManager().getBooleanFormulaManager();
    BooleanFormula enc = bmgr.makeTrue();
    if (symmClass.getEquivalence() != symm) {
        return enc;
    }
    Info info = infoMap.get(symmClass);
    if (info == null) {
        logger.warn("Cannot encode co-symmetry because no information has been computed. " + "Make sure that <initialize> gets called before encoding.");
        return enc;
    }
    List<Thread> symmThreads = info.threads;
    // ============= Construct rows =============
    Thread t1 = symmThreads.get(0);
    List<Thread> otherThreads = symmThreads.subList(1, symmThreads.size());
    List<Tuple> r1Tuples = new ArrayList<>();
    for (Store w : info.writes) {
        for (Thread t2 : otherThreads) {
            r1Tuples.add(new Tuple(w, symm.map(w, t2)));
        }
    }
    // Starting row
    List<BooleanFormula> r1 = new ArrayList<>(r1Tuples.size() + 1);
    if (info.hasMustEdges) {
        r1.add(info.writes.get(0).exec());
    }
    r1.addAll(Lists.transform(r1Tuples, t -> co.getSMTVar(t, ctx)));
    // Construct symmetric rows
    Thread rep = symmClass.getRepresentative();
    for (int i = 1; i < symmThreads.size(); i++) {
        Thread t2 = symmThreads.get(i);
        Function<Event, Event> p = symm.createTransposition(t1, t2);
        List<Tuple> r2Tuples = r1Tuples.stream().map(t -> t.permute(p)).collect(Collectors.toList());
        List<BooleanFormula> r2 = new ArrayList<>(r2Tuples.size() + 1);
        if (info.hasMustEdges) {
            r2.add(symm.map(info.writes.get(0), t2).exec());
        }
        r2.addAll(Lists.transform(r2Tuples, t -> co.getSMTVar(t, ctx)));
        final String id = "_" + rep.getId() + "_" + i;
        // NOTE: We want to have r1 >= r2 but lexLeader encodes r1 <= r2, so we swap r1 and r2.
        enc = bmgr.and(enc, SymmetryEncoder.encodeLexLeader(id, r2, r1, ctx));
        t1 = t2;
        r1Tuples = r2Tuples;
        r1 = r2;
    }
    return enc;
}
Also used : SymmetryEncoder(com.dat3m.dartagnan.encoding.SymmetryEncoder) java.util(java.util) BooleanFormula(org.sosy_lab.java_smt.api.BooleanFormula) Thread(com.dat3m.dartagnan.program.Thread) Function(java.util.function.Function) Lists(com.google.common.collect.Lists) TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) SolverContext(org.sosy_lab.java_smt.api.SolverContext) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple) FilterBasic(com.dat3m.dartagnan.program.filter.FilterBasic) EquivalenceClass(com.dat3m.dartagnan.utils.equivalence.EquivalenceClass) AliasAnalysis(com.dat3m.dartagnan.program.analysis.AliasAnalysis) VerificationTask(com.dat3m.dartagnan.verification.VerificationTask) ThreadSymmetry(com.dat3m.dartagnan.program.analysis.ThreadSymmetry) Store(com.dat3m.dartagnan.program.event.core.Store) Relation(com.dat3m.dartagnan.wmm.relation.Relation) Collectors(java.util.stream.Collectors) Tag(com.dat3m.dartagnan.program.event.Tag) BooleanFormulaManager(org.sosy_lab.java_smt.api.BooleanFormulaManager) RelationNameRepository(com.dat3m.dartagnan.wmm.relation.RelationNameRepository) Logger(org.apache.logging.log4j.Logger) Event(com.dat3m.dartagnan.program.event.core.Event) Preconditions(com.google.common.base.Preconditions) LogManager(org.apache.logging.log4j.LogManager) Axiom(com.dat3m.dartagnan.wmm.axiom.Axiom) BooleanFormulaManager(org.sosy_lab.java_smt.api.BooleanFormulaManager) Store(com.dat3m.dartagnan.program.event.core.Store) Thread(com.dat3m.dartagnan.program.Thread) Event(com.dat3m.dartagnan.program.event.core.Event) BooleanFormula(org.sosy_lab.java_smt.api.BooleanFormula) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple)

Example 9 with Event

use of com.dat3m.dartagnan.program.event.core.Event in project Dat3M by hernanponcedeleon.

the class CoreReasoner method addExecReason.

private void addExecReason(Tuple edge, List<CoreLiteral> coreReasons) {
    Event e1 = edge.getFirst();
    Event e2 = edge.getSecond();
    if (e1.getCId() > e2.getCId()) {
        // Normalize edge direction
        Event temp = e1;
        e1 = e2;
        e2 = temp;
    }
    if (exec.isImplied(e1, e2)) {
        coreReasons.add(new ExecLiteral(e1));
    } else if (exec.isImplied(e2, e1)) {
        coreReasons.add(new ExecLiteral(e2));
    } else {
        coreReasons.add(new ExecLiteral(e1));
        coreReasons.add(new ExecLiteral(e2));
    }
}
Also used : Event(com.dat3m.dartagnan.program.event.core.Event)

Example 10 with Event

use of com.dat3m.dartagnan.program.event.core.Event in project Dat3M by hernanponcedeleon.

the class Acyclic method getEncodeTupleSet.

@Override
public TupleSet getEncodeTupleSet() {
    logger.info("Computing encodeTupleSet for " + this);
    // ====== Construct [Event -> Successor] mapping ======
    Map<Event, Collection<Event>> succMap = new HashMap<>();
    TupleSet relMaxTuple = rel.getMaxTupleSet();
    for (Tuple t : relMaxTuple) {
        succMap.computeIfAbsent(t.getFirst(), key -> new ArrayList<>()).add(t.getSecond());
    }
    // ====== Compute SCCs ======
    DependencyGraph<Event> depGraph = DependencyGraph.from(succMap.keySet(), succMap);
    TupleSet result = new TupleSet();
    for (Set<DependencyGraph<Event>.Node> scc : depGraph.getSCCs()) {
        for (DependencyGraph<Event>.Node node1 : scc) {
            for (DependencyGraph<Event>.Node node2 : scc) {
                Tuple t = new Tuple(node1.getContent(), node2.getContent());
                if (relMaxTuple.contains(t)) {
                    result.add(t);
                }
            }
        }
    }
    logger.info("encodeTupleSet size " + result.size());
    if (GlobalSettings.REDUCE_ACYCLICITY_ENCODE_SETS) {
        reduceWithMinSets(result);
        logger.info("reduced encodeTupleSet size " + result.size());
    }
    return result;
}
Also used : Utils(com.dat3m.dartagnan.wmm.utils.Utils) java.util(java.util) ExecutionAnalysis(com.dat3m.dartagnan.program.analysis.ExecutionAnalysis) org.sosy_lab.java_smt.api(org.sosy_lab.java_smt.api) Relation(com.dat3m.dartagnan.wmm.relation.Relation) Collectors(java.util.stream.Collectors) Tag(com.dat3m.dartagnan.program.event.Tag) DependencyGraph(com.dat3m.dartagnan.utils.dependable.DependencyGraph) Logger(org.apache.logging.log4j.Logger) TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) Event(com.dat3m.dartagnan.program.event.core.Event) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple) GlobalSettings(com.dat3m.dartagnan.GlobalSettings) LogManager(org.apache.logging.log4j.LogManager) TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) DependencyGraph(com.dat3m.dartagnan.utils.dependable.DependencyGraph) Event(com.dat3m.dartagnan.program.event.core.Event) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple)

Aggregations

Event (com.dat3m.dartagnan.program.event.core.Event)104 Tuple (com.dat3m.dartagnan.wmm.utils.Tuple)34 Thread (com.dat3m.dartagnan.program.Thread)32 Register (com.dat3m.dartagnan.program.Register)25 TupleSet (com.dat3m.dartagnan.wmm.utils.TupleSet)25 MemEvent (com.dat3m.dartagnan.program.event.core.MemEvent)20 Tag (com.dat3m.dartagnan.program.event.Tag)16 Label (com.dat3m.dartagnan.program.event.core.Label)16 Collectors (java.util.stream.Collectors)16 BooleanFormula (org.sosy_lab.java_smt.api.BooleanFormula)16 BooleanFormulaManager (org.sosy_lab.java_smt.api.BooleanFormulaManager)16 LogManager (org.apache.logging.log4j.LogManager)15 Logger (org.apache.logging.log4j.Logger)15 Program (com.dat3m.dartagnan.program.Program)12 ExecutionAnalysis (com.dat3m.dartagnan.program.analysis.ExecutionAnalysis)12 RegWriter (com.dat3m.dartagnan.program.event.core.utils.RegWriter)12 java.util (java.util)12 SolverContext (org.sosy_lab.java_smt.api.SolverContext)12 FilterBasic (com.dat3m.dartagnan.program.filter.FilterBasic)11 CondJump (com.dat3m.dartagnan.program.event.core.CondJump)10