Search in sources :

Example 16 with Thread

use of com.dat3m.dartagnan.program.Thread in project Dat3M by hernanponcedeleon.

the class Simplifier method run.

@Override
public void run(Program program) {
    Preconditions.checkArgument(!program.isUnrolled(), "Simplifying should be performed before unrolling.");
    logger.info("pre-simplification: " + program.getEvents().size() + " events");
    for (Thread t : program.getThreads()) {
        if (simplify(t)) {
            t.clearCache();
        }
    }
    program.clearCache(false);
    logger.info("post-simplification: " + program.getEvents().size() + " events");
    if (print) {
        System.out.println("===== Program after simplification =====");
        System.out.println(new Printer().print(program));
        System.out.println("========================================");
    }
}
Also used : Printer(com.dat3m.dartagnan.utils.printer.Printer) Thread(com.dat3m.dartagnan.program.Thread)

Example 17 with Thread

use of com.dat3m.dartagnan.program.Thread in project Dat3M by hernanponcedeleon.

the class BranchEquivalence method computeExclusiveClasses.

// ========================== Equivalence class computations =========================
private void computeExclusiveClasses(Map<Thread, Map<Event, Branch>> threadBranches) {
    for (Thread t : program.getThreads()) {
        computeReachableBranches(threadBranches.get(t).get(t.getEntry()));
    }
    Set<BranchClass> branchClasses = getAllTypedEqClasses();
    for (BranchClass c1 : branchClasses) {
        Set<BranchClass> excl = c1.exclusiveClasses;
        if (c1 == initialClass) {
            if (!unreachableClass.isEmpty()) {
                excl.add(unreachableClass);
            }
            continue;
        } else if (c1 == unreachableClass) {
            excl.addAll(branchClasses);
            excl.remove(unreachableClass);
            continue;
        }
        for (BranchClass c2 : branchClasses) {
            if (c2 == unreachableClass) {
                excl.add(unreachableClass);
                continue;
            } else if (c2 == initialClass || c2 == c1) {
                continue;
            }
            Event e1 = c1.getRepresentative();
            Event e2 = c2.getRepresentative();
            if (e1.getThread() == e2.getThread() && e1.getCId() < e2.getCId()) {
                if (!c1.reachableClasses.contains(c2)) {
                    excl.add(c2);
                    c2.exclusiveClasses.add(c1);
                }
            }
        }
    }
}
Also used : Event(com.dat3m.dartagnan.program.event.core.Event) Thread(com.dat3m.dartagnan.program.Thread)

Example 18 with Thread

use of com.dat3m.dartagnan.program.Thread in project Dat3M by hernanponcedeleon.

the class ThreadSymmetry method createMappings.

private void createMappings() {
    for (Thread thread : program.getThreads()) {
        Map<Integer, Event> mapping = symmMap.computeIfAbsent(thread, key -> new HashMap<>());
        thread.getEvents().forEach(e -> mapping.put(e.getFId(), e));
    }
    Set<? extends EquivalenceClass<Thread>> classes = getAllEquivalenceClasses();
    for (EquivalenceClass<Thread> clazz : classes) {
        int size = symmMap.get(clazz.getRepresentative()).size();
        for (Thread t : clazz) {
            if (symmMap.get(t).size() == size) {
                Verify.verify(symmMap.get(t).size() == size, "Symmetric threads T%s and T%s have different number of events: %s vs. %s", clazz.getRepresentative(), t, size, symmMap.get(t).size());
            }
        }
    }
}
Also used : Event(com.dat3m.dartagnan.program.event.core.Event) Thread(com.dat3m.dartagnan.program.Thread)

Example 19 with Thread

use of com.dat3m.dartagnan.program.Thread in project Dat3M by hernanponcedeleon.

the class AtomicAsLock method run.

@Override
public void run(Program program) {
    MemoryObject a = program.getMemory().allocate(1);
    for (Thread t : program.getThreads()) {
        run(a, t);
    }
    // TODO unmodifiable thread list?
    program.getThreads().add(new Thread(1 + program.getThreads().stream().mapToInt(Thread::getId).max().orElse(-1), newInit(a, 0)));
}
Also used : MemoryObject(com.dat3m.dartagnan.program.memory.MemoryObject) Thread(com.dat3m.dartagnan.program.Thread)

Example 20 with Thread

use of com.dat3m.dartagnan.program.Thread in project Dat3M by hernanponcedeleon.

the class LoopUnrolling method updateAssertions.

private void updateAssertions(Program program) {
    if (program.getAss() != null) {
        // but I was under the impression that assFilter was used for Litmus tests.
        return;
    }
    List<Event> assertions = new ArrayList<>();
    for (Thread t : program.getThreads()) {
        assertions.addAll(t.getCache().getEvents(FilterBasic.get(Tag.ASSERTION)));
    }
    AbstractAssert ass = new AssertTrue();
    if (!assertions.isEmpty()) {
        ass = new AssertInline((Local) assertions.get(0));
        for (int i = 1; i < assertions.size(); i++) {
            ass = new AssertCompositeOr(ass, new AssertInline((Local) assertions.get(i)));
        }
    }
    program.setAss(ass);
    logger.info("Updated assertions after unrolling.");
}
Also used : AssertTrue(com.dat3m.dartagnan.asserts.AssertTrue) ArrayList(java.util.ArrayList) Event(com.dat3m.dartagnan.program.event.core.Event) Local(com.dat3m.dartagnan.program.event.core.Local) AbstractAssert(com.dat3m.dartagnan.asserts.AbstractAssert) AssertCompositeOr(com.dat3m.dartagnan.asserts.AssertCompositeOr) Thread(com.dat3m.dartagnan.program.Thread) AssertInline(com.dat3m.dartagnan.asserts.AssertInline)

Aggregations

Thread (com.dat3m.dartagnan.program.Thread)48 Event (com.dat3m.dartagnan.program.event.core.Event)27 Tuple (com.dat3m.dartagnan.wmm.utils.Tuple)13 TupleSet (com.dat3m.dartagnan.wmm.utils.TupleSet)11 LogManager (org.apache.logging.log4j.LogManager)10 Logger (org.apache.logging.log4j.Logger)10 BooleanFormula (org.sosy_lab.java_smt.api.BooleanFormula)9 BooleanFormulaManager (org.sosy_lab.java_smt.api.BooleanFormulaManager)9 Program (com.dat3m.dartagnan.program.Program)8 Tag (com.dat3m.dartagnan.program.event.Tag)8 Configuration (org.sosy_lab.common.configuration.Configuration)8 InvalidConfigurationException (org.sosy_lab.common.configuration.InvalidConfigurationException)8 MemEvent (com.dat3m.dartagnan.program.event.core.MemEvent)7 Collectors (java.util.stream.Collectors)7 Context (com.dat3m.dartagnan.verification.Context)6 Preconditions (com.google.common.base.Preconditions)6 FilterBasic (com.dat3m.dartagnan.program.filter.FilterBasic)5 Options (org.sosy_lab.common.configuration.Options)5 Utils.generalEqual (com.dat3m.dartagnan.expression.utils.Utils.generalEqual)4 RegWriter (com.dat3m.dartagnan.program.event.core.utils.RegWriter)4