use of com.dat3m.dartagnan.program.event.core.MemEvent 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.MemEvent in project Dat3M by hernanponcedeleon.
the class ExecutionGraphVisualizer method generateGraphOfExecutionModel.
public void generateGraphOfExecutionModel(Writer writer, String graphName, ExecutionModel model) throws IOException {
for (EventData data : model.getThreadEventsMap().values().stream().collect(ArrayList<EventData>::new, List::addAll, List::addAll)) {
if (data.isMemoryEvent()) {
MemEvent m = (MemEvent) data.getEvent();
if (!(m.getAddress() instanceof Register)) {
addresses.putIfAbsent(data.getAccessedAddress(), m.getAddress());
}
}
}
graphviz.begin(graphName);
graphviz.append(String.format("label=\"%s\" \n", graphName));
addAllThreadPos(model);
addReadFrom(model);
addCoherence(model);
graphviz.end();
graphviz.generateOutput(writer);
}
Aggregations