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("========================================");
}
}
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);
}
}
}
}
}
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());
}
}
}
}
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)));
}
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.");
}
Aggregations