use of com.dat3m.dartagnan.wmm.Wmm in project Dat3M by hernanponcedeleon.
the class PropertyEncoder method encodeDataRaces.
public BooleanFormula encodeDataRaces(SolverContext ctx) {
final String hb = "hb";
checkState(memoryModel.getAxioms().stream().anyMatch(ax -> ax.isAcyclicity() && ax.getRelation().getName().equals(hb)), "The provided WMM needs an 'acyclic(hb)' axiom to encode data races.");
logger.info("Encoding data-races");
BooleanFormulaManager bmgr = ctx.getFormulaManager().getBooleanFormulaManager();
IntegerFormulaManager imgr = ctx.getFormulaManager().getIntegerFormulaManager();
BooleanFormula enc = bmgr.makeFalse();
for (Thread t1 : program.getThreads()) {
for (Thread t2 : program.getThreads()) {
if (t1.getId() == t2.getId()) {
continue;
}
for (Event e1 : t1.getCache().getEvents(FilterMinus.get(FilterBasic.get(Tag.WRITE), FilterBasic.get(Tag.INIT)))) {
MemEvent w = (MemEvent) e1;
for (Event e2 : t2.getCache().getEvents(FilterMinus.get(FilterBasic.get(Tag.MEMORY), FilterBasic.get(Tag.INIT)))) {
MemEvent m = (MemEvent) e2;
if (w.hasFilter(Tag.RMW) && m.hasFilter(Tag.RMW)) {
continue;
}
if (w.canRace() && m.canRace() && alias.mayAlias(w, m)) {
BooleanFormula conflict = bmgr.and(m.exec(), w.exec(), edge(hb, m, w, ctx), generalEqual(w.getMemAddressExpr(), m.getMemAddressExpr(), ctx), imgr.equal(intVar(hb, w, ctx), imgr.add(intVar(hb, m, ctx), imgr.makeNumber(BigInteger.ONE))));
enc = bmgr.or(enc, conflict);
}
}
}
}
}
// We use the SMT variable to extract from the model if the property was violated
enc = bmgr.equivalence(RACES.getSMTVariable(ctx), enc);
return bmgr.and(RACES.getSMTVariable(ctx), enc);
}
use of com.dat3m.dartagnan.wmm.Wmm in project Dat3M by hernanponcedeleon.
the class Dat3M method runTest.
private void runTest() {
UiOptions options = optionsPane.getOptions();
testResult = null;
try {
Editor programEditor = editorsPane.getEditor(EditorCode.PROGRAM);
Program program = new ProgramParser().parse(programEditor.getEditorPane().getText(), programEditor.getLoadedFormat());
try {
Wmm targetModel = new ParserCat().parse(editorsPane.getEditor(EditorCode.TARGET_MM).getEditorPane().getText());
testResult = new ReachabilityResult(program, targetModel, options);
} catch (Exception e) {
String msg = e.getMessage() == null ? "Memory model cannot be parsed" : e.getMessage();
showError(msg, "Target memory model error");
}
} catch (Exception e) {
String msg = e.getMessage() == null ? "Program cannot be parsed" : e.getMessage();
Throwable cause = e.getCause();
if (cause instanceof InputMismatchException) {
Token token = ((InputMismatchException) cause).getOffendingToken();
msg = "Problem with \"" + token.getText() + "\" at line " + token.getLine();
}
showError(msg, "Program error");
}
}
use of com.dat3m.dartagnan.wmm.Wmm in project Dat3M by hernanponcedeleon.
the class BranchTest method data.
@Parameterized.Parameters(name = "{index}: {0}")
public static Iterable<Object[]> data() throws IOException {
ImmutableMap<String, Result> expected = readExpectedResults();
Wmm linuxWmm = new ParserCat().parse(new File(ResourceHelper.CAT_RESOURCE_PATH + "cat/linux-kernel.cat"));
Wmm aarch64Wmm = new ParserCat().parse(new File(ResourceHelper.CAT_RESOURCE_PATH + "cat/aarch64.cat"));
List<Object[]> data;
try (Stream<Path> fileStream = Files.walk(Paths.get(ResourceHelper.TEST_RESOURCE_PATH + "branch/C/"))) {
data = fileStream.filter(Files::isRegularFile).filter(f -> (f.toString().endsWith("litmus"))).map(f -> new Object[] { f.toString(), expected.get(f.getFileName().toString()), linuxWmm }).collect(Collectors.toList());
}
try (Stream<Path> fileStream = Files.walk(Paths.get(ResourceHelper.TEST_RESOURCE_PATH + "branch/AARCH64/"))) {
data.addAll(fileStream.filter(Files::isRegularFile).filter(f -> (f.toString().endsWith("litmus"))).map(f -> new Object[] { f.toString(), expected.get(f.getFileName().toString()), aarch64Wmm }).collect(Collectors.toList()));
}
return data;
}
use of com.dat3m.dartagnan.wmm.Wmm in project Dat3M by hernanponcedeleon.
the class RefinementTask method createDefaultWmm.
private Wmm createDefaultWmm() {
Wmm baseline = new Wmm();
RelationRepository repo = baseline.getRelationRepository();
Relation rf = repo.getRelation(RF);
if (baselines.contains(UNIPROC)) {
// ---- acyclic(po-loc | rf) ----
Relation poloc = repo.getRelation(POLOC);
Relation co = repo.getRelation(CO);
Relation fr = repo.getRelation(FR);
Relation porf = new RelUnion(poloc, rf);
repo.addRelation(porf);
Relation porfco = new RelUnion(porf, co);
repo.addRelation(porfco);
Relation porfcofr = new RelUnion(porfco, fr);
repo.addRelation(porfcofr);
baseline.addAxiom(new Acyclic(porfcofr));
}
if (baselines.contains(NO_OOTA)) {
// ---- acyclic (dep | rf) ----
Relation data = repo.getRelation(DATA);
Relation ctrl = repo.getRelation(CTRL);
Relation addr = repo.getRelation(ADDR);
Relation dep = new RelUnion(data, addr);
repo.addRelation(dep);
dep = new RelUnion(ctrl, dep);
repo.addRelation(dep);
Relation hb = new RelUnion(dep, rf);
repo.addRelation(hb);
baseline.addAxiom(new Acyclic(hb));
}
if (baselines.contains(ATOMIC_RMW)) {
// ---- empty (rmw & fre;coe) ----
Relation rmw = repo.getRelation(RMW);
Relation coe = repo.getRelation(COE);
Relation fre = repo.getRelation(FRE);
Relation frecoe = new RelComposition(fre, coe);
repo.addRelation(frecoe);
Relation rmwANDfrecoe = new RelIntersection(rmw, frecoe);
repo.addRelation(rmwANDfrecoe);
baseline.addAxiom(new Empty(rmwANDfrecoe));
}
return baseline;
}
Aggregations