use of com.dat3m.dartagnan.program.event.core.MemEvent in project Dat3M by hernanponcedeleon.
the class RelCo method getMaxTupleSet.
@Override
public TupleSet getMaxTupleSet() {
if (maxTupleSet == null) {
logger.info("Computing maxTupleSet for " + getName());
AliasAnalysis alias = analysisContext.get(AliasAnalysis.class);
WmmAnalysis wmmAnalysis = analysisContext.get(WmmAnalysis.class);
maxTupleSet = new TupleSet();
List<Event> eventsInit = task.getProgram().getCache().getEvents(FilterBasic.get(INIT));
List<Event> eventsStore = task.getProgram().getCache().getEvents(FilterMinus.get(FilterBasic.get(WRITE), FilterBasic.get(INIT)));
for (Event e1 : eventsInit) {
for (Event e2 : eventsStore) {
if (alias.mayAlias((MemEvent) e1, (MemEvent) e2)) {
maxTupleSet.add(new Tuple(e1, e2));
}
}
}
for (Event e1 : eventsStore) {
for (Event e2 : eventsStore) {
if (e1.getCId() != e2.getCId() && alias.mayAlias((MemEvent) e1, (MemEvent) e2)) {
maxTupleSet.add(new Tuple(e1, e2));
}
}
}
removeMutuallyExclusiveTuples(maxTupleSet);
if (wmmAnalysis.isLocallyConsistent()) {
applyLocalConsistencyMaxSet();
}
logger.info("maxTupleSet size for " + getName() + ": " + maxTupleSet.size());
}
return maxTupleSet;
}
use of com.dat3m.dartagnan.program.event.core.MemEvent in project Dat3M by hernanponcedeleon.
the class RelCo method getSMTVar.
@Override
public BooleanFormula getSMTVar(Tuple edge, SolverContext ctx) {
if (!antisymmetry) {
return super.getSMTVar(edge, ctx);
}
FormulaManager fmgr = ctx.getFormulaManager();
BooleanFormulaManager bmgr = fmgr.getBooleanFormulaManager();
MemEvent first = (MemEvent) edge.getFirst();
MemEvent second = (MemEvent) edge.getSecond();
// Doing the check at the java level seems to slightly improve performance
BooleanFormula eqAdd = first.getAddress().equals(second.getAddress()) ? bmgr.makeTrue() : generalEqual(first.getMemAddressExpr(), second.getMemAddressExpr(), ctx);
return !getMaxTupleSet().contains(edge) ? bmgr.makeFalse() : first.getCId() <= second.getCId() ? edge(getName(), first, second, ctx) : bmgr.ifThenElse(bmgr.and(getExecPair(edge, ctx), eqAdd), bmgr.not(getSMTVar(edge.getInverse(), ctx)), bmgr.makeFalse());
}
use of com.dat3m.dartagnan.program.event.core.MemEvent in project Dat3M by hernanponcedeleon.
the class RelCo method applyLocalConsistencyMinSet.
private void applyLocalConsistencyMinSet() {
for (Tuple t : getMaxTupleSet()) {
AliasAnalysis alias = analysisContext.get(AliasAnalysis.class);
MemEvent w1 = (MemEvent) t.getFirst();
MemEvent w2 = (MemEvent) t.getSecond();
if (!w1.is(INIT) && alias.mustAlias(w1, w2) && (w1.is(INIT) || t.isForward())) {
minTupleSet.add(t);
}
}
}
use of com.dat3m.dartagnan.program.event.core.MemEvent in project Dat3M by hernanponcedeleon.
the class RelRf method encodeApprox.
@Override
protected BooleanFormula encodeApprox(SolverContext ctx) {
FormulaManager fmgr = ctx.getFormulaManager();
BooleanFormulaManager bmgr = fmgr.getBooleanFormulaManager();
BooleanFormula enc = bmgr.makeTrue();
Map<MemEvent, List<BooleanFormula>> edgeMap = new HashMap<>();
for (Tuple tuple : maxTupleSet) {
MemEvent w = (MemEvent) tuple.getFirst();
MemEvent r = (MemEvent) tuple.getSecond();
BooleanFormula edge = this.getSMTVar(tuple, ctx);
// The boogie file might have a different type (Ints vs BVs) that the imposed by ARCH_PRECISION
// In such cases we perform the transformation
Formula a1 = w.getMemAddressExpr();
Formula a2 = r.getMemAddressExpr();
BooleanFormula sameAddress = generalEqual(a1, a2, ctx);
Formula v1 = w.getMemValueExpr();
Formula v2 = r.getMemValueExpr();
BooleanFormula sameValue = generalEqual(v1, v2, ctx);
edgeMap.computeIfAbsent(r, key -> new ArrayList<>()).add(edge);
enc = bmgr.and(enc, bmgr.implication(edge, bmgr.and(getExecPair(w, r, ctx), sameAddress, sameValue)));
}
for (MemEvent r : edgeMap.keySet()) {
enc = bmgr.and(enc, encodeEdgeSeq(r, edgeMap.get(r), ctx));
}
return enc;
}
use of com.dat3m.dartagnan.program.event.core.MemEvent in project Dat3M by hernanponcedeleon.
the class RelRf method getMaxTupleSet.
@Override
public TupleSet getMaxTupleSet() {
if (maxTupleSet == null) {
AliasAnalysis alias = analysisContext.get(AliasAnalysis.class);
WmmAnalysis wmmAnalysis = analysisContext.get(WmmAnalysis.class);
logger.info("Computing maxTupleSet for " + getName());
maxTupleSet = new TupleSet();
List<Event> loadEvents = task.getProgram().getCache().getEvents(FilterBasic.get(READ));
List<Event> storeEvents = task.getProgram().getCache().getEvents(FilterBasic.get(WRITE));
for (Event e1 : storeEvents) {
for (Event e2 : loadEvents) {
if (alias.mayAlias((MemEvent) e1, (MemEvent) e2)) {
maxTupleSet.add(new Tuple(e1, e2));
}
}
}
removeMutuallyExclusiveTuples(maxTupleSet);
if (wmmAnalysis.isLocallyConsistent()) {
applyLocalConsistency();
}
if (wmmAnalysis.doesRespectAtomicBlocks()) {
atomicBlockOptimization();
}
logger.info("maxTupleSet size for " + getName() + ": " + maxTupleSet.size());
}
return maxTupleSet;
}
Aggregations