use of com.dat3m.dartagnan.program.event.core.Event 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.program.event.core.Event 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.program.event.core.Event in project Dat3M by hernanponcedeleon.
the class RelRMW method pairingCond.
private BooleanFormula pairingCond(Thread thread, Event load, Event store, SolverContext ctx) {
BooleanFormulaManager bmgr = ctx.getFormulaManager().getBooleanFormulaManager();
BooleanFormula pairingCond = bmgr.and(load.exec(), store.cf());
for (Event otherLoad : thread.getCache().getEvents(loadExclFilter)) {
if (otherLoad.getCId() > load.getCId() && otherLoad.getCId() < store.getCId()) {
pairingCond = bmgr.and(pairingCond, bmgr.not(otherLoad.exec()));
}
}
for (Event otherStore : thread.getCache().getEvents(storeExclFilter)) {
if (otherStore.getCId() > load.getCId() && otherStore.getCId() < store.getCId()) {
pairingCond = bmgr.and(pairingCond, bmgr.not(otherStore.cf()));
}
}
return pairingCond;
}
use of com.dat3m.dartagnan.program.event.core.Event 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;
}
use of com.dat3m.dartagnan.program.event.core.Event 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;
}
Aggregations