use of com.dat3m.dartagnan.program.Thread 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;
}
use of com.dat3m.dartagnan.program.Thread 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;
}
use of com.dat3m.dartagnan.program.Thread in project Dat3M by hernanponcedeleon.
the class CoSymmetryBreaking method encode.
public BooleanFormula encode(SolverContext ctx) {
BooleanFormulaManager bmgr = ctx.getFormulaManager().getBooleanFormulaManager();
BooleanFormula enc = bmgr.makeTrue();
for (EquivalenceClass<Thread> symmClass : symm.getNonTrivialClasses()) {
enc = bmgr.and(enc, encode(symmClass, ctx));
}
return enc;
}
Aggregations