use of com.dat3m.dartagnan.wmm.utils.TupleSet in project Dat3M by hernanponcedeleon.
the class RelTransRef method addEncodeTupleSet.
// TODO: This is ugly code that produces encodeSets which are too large
// However, the encoding does not care about the encodeSet and instead encodes (transEncode + identityEncode)
// which is what the encodeSet of this relation should be
@Override
public void addEncodeTupleSet(TupleSet tuples) {
TupleSet activeSet = new TupleSet(Sets.intersection(Sets.difference(tuples, encodeTupleSet), maxTupleSet));
encodeTupleSet.addAll(activeSet);
for (Tuple tuple : activeSet) {
if (tuple.isLoop()) {
identityEncodeTupleSet.add(tuple);
}
}
activeSet.removeAll(identityEncodeTupleSet);
TupleSet temp = encodeTupleSet;
encodeTupleSet = transEncodeTupleSet;
super.addEncodeTupleSet(activeSet);
encodeTupleSet = temp;
}
use of com.dat3m.dartagnan.wmm.utils.TupleSet in project Dat3M by hernanponcedeleon.
the class RelTransRef method invokeEncode.
private BooleanFormula invokeEncode(Function<SolverContext, BooleanFormula> originalMethod, SolverContext ctx) {
BooleanFormulaManager bmgr = ctx.getFormulaManager().getBooleanFormulaManager();
TupleSet temp = encodeTupleSet;
encodeTupleSet = transEncodeTupleSet;
BooleanFormula enc = originalMethod.apply(ctx);
encodeTupleSet = temp;
for (Tuple tuple : identityEncodeTupleSet) {
enc = bmgr.and(enc, bmgr.equivalence(tuple.getFirst().exec(), this.getSMTVar(tuple, ctx)));
}
return enc;
}
use of com.dat3m.dartagnan.wmm.utils.TupleSet in project Dat3M by hernanponcedeleon.
the class RelCrit method getMaxTupleSet.
@Override
public TupleSet getMaxTupleSet() {
if (maxTupleSet == null) {
maxTupleSet = new TupleSet();
for (Thread thread : task.getProgram().getThreads()) {
for (Event lock : thread.getCache().getEvents(FilterBasic.get(Tag.Linux.RCU_LOCK))) {
for (Event unlock : thread.getCache().getEvents(FilterBasic.get(Tag.Linux.RCU_UNLOCK))) {
if (lock.getCId() < unlock.getCId()) {
maxTupleSet.add(new Tuple(lock, unlock));
}
}
}
}
removeMutuallyExclusiveTuples(maxTupleSet);
}
return maxTupleSet;
}
use of com.dat3m.dartagnan.wmm.utils.TupleSet in project Dat3M by hernanponcedeleon.
the class RelRMW method encodeApprox.
@Override
protected BooleanFormula encodeApprox(SolverContext ctx) {
FormulaManager fmgr = ctx.getFormulaManager();
BooleanFormulaManager bmgr = fmgr.getBooleanFormulaManager();
// Encode base (not exclusive pairs) RMW
TupleSet origEncodeTupleSet = encodeTupleSet;
encodeTupleSet = new TupleSet(Sets.intersection(encodeTupleSet, baseMaxTupleSet));
BooleanFormula enc = super.encodeApprox(ctx);
encodeTupleSet = origEncodeTupleSet;
// Encode RMW for exclusive pairs
BooleanFormula unpredictable = bmgr.makeFalse();
for (Thread thread : task.getProgram().getThreads()) {
for (Event store : thread.getCache().getEvents(storeExclFilter)) {
BooleanFormula storeExec = bmgr.makeFalse();
for (Event load : thread.getCache().getEvents(loadExclFilter)) {
if (load.getCId() < store.getCId()) {
// Encode if load and store form an exclusive pair
BooleanFormula isPair = exclPair(load, store, ctx);
BooleanFormula isExecPair = bmgr.and(isPair, store.exec());
enc = bmgr.and(enc, bmgr.equivalence(isPair, pairingCond(thread, load, store, ctx)));
// If load and store have the same address
BooleanFormula sameAddress = generalEqual(((MemEvent) load).getMemAddressExpr(), ((MemEvent) store).getMemAddressExpr(), ctx);
unpredictable = bmgr.or(unpredictable, bmgr.and(isExecPair, bmgr.not(sameAddress)));
// Relation between exclusive load and store
enc = bmgr.and(enc, bmgr.equivalence(this.getSMTVar(load, store, ctx), bmgr.and(isExecPair, sameAddress)));
// Can be executed if addresses mismatch, but behaviour is "constrained unpredictable"
// The implementation does not include all possible unpredictable cases: in case of address
// mismatch, addresses of read and write are unknown, i.e. read and write can use any address
storeExec = bmgr.or(storeExec, isPair);
}
}
enc = bmgr.and(enc, bmgr.implication(store.exec(), storeExec));
}
}
return bmgr.and(enc, bmgr.equivalence(Flag.ARM_UNPREDICTABLE_BEHAVIOUR.repr(ctx), unpredictable));
}
use of com.dat3m.dartagnan.wmm.utils.TupleSet in project Dat3M by hernanponcedeleon.
the class RelFencerel method getMinTupleSet.
@Override
public TupleSet getMinTupleSet() {
if (minTupleSet == null) {
ExecutionAnalysis exec = analysisContext.get(ExecutionAnalysis.class);
minTupleSet = 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) {
boolean isImpliedByE1 = exec.isImplied(e1, fence);
for (Event e2 : eventsAfter) {
if (isImpliedByE1 || exec.isImplied(e2, fence)) {
minTupleSet.add(new Tuple(e1, e2));
}
}
}
}
}
removeMutuallyExclusiveTuples(minTupleSet);
}
return minTupleSet;
}
Aggregations