use of com.dat3m.dartagnan.verification.model.EventData in project Dat3M by hernanponcedeleon.
the class RMWGraph method repopulate.
/* Right now there are four cases where the RMW-Relation is established:
(1) LOCK : Load -> CondJump -> Store
(2) RMW : RMWLoad -> RMWStore (completely static)
(3) ExclAccess : ExclLoad -> ExclStore (dependent on control flow)
(4) Atomic blocks: BeginAtomic -> Events* -> EndAtomic
We need to keep this in line with the implementation of RelRMW!
*/
@Override
public void repopulate() {
// Atomic blocks
model.getAtomicBlocksMap().values().stream().flatMap(Collection::stream).forEach(block -> {
for (int i = 0; i < block.size(); i++) {
for (int j = i + 1; j < block.size(); j++) {
simpleGraph.add(new Edge(block.get(i).getId(), block.get(j).getId()));
}
}
});
for (List<EventData> events : model.getThreadEventsMap().values()) {
EventData lastExclLoad = null;
for (int i = 0; i < events.size(); i++) {
EventData e = events.get(i);
if (e.isRead()) {
if (e.isLock()) {
// Locks ~ (Load -> CondJump -> Store)
if (i + 1 < events.size()) {
// The condition fails, if the lock was not obtained cause then
// it will be the last event of the thread (we terminate on failed locks)
EventData next = events.get(i + 1);
simpleGraph.add(new Edge(e.getId(), next.getId()));
}
} else if (e.isExclusive()) {
// LoadExcl
lastExclLoad = e;
}
} else if (e.isWrite()) {
if (e.isExclusive()) {
// StoreExcl
if (lastExclLoad == null) {
throw new IllegalStateException("Exclusive store was executed without preceding exclusive load.");
}
simpleGraph.add(new Edge(lastExclLoad.getId(), e.getId()));
lastExclLoad = null;
} else if (e.getEvent() instanceof RMWStore) {
// RMWStore
EventData load = model.getData(((RMWStore) e.getEvent()).getLoadEvent()).get();
simpleGraph.add(new Edge(load.getId(), e.getId()));
}
}
}
}
}
use of com.dat3m.dartagnan.verification.model.EventData in project Dat3M by hernanponcedeleon.
the class RcuGraph method size.
@Override
public int size(int id, EdgeDirection dir) {
EventData e = getEvent(id);
BiMap<EventData, EventData> map = dir == EdgeDirection.OUTGOING ? lockUnlockMap : unlockLockMap;
return map.containsKey(e) ? 1 : 0;
}
use of com.dat3m.dartagnan.verification.model.EventData in project Dat3M by hernanponcedeleon.
the class RcuGraph method edgeStream.
@Override
public Stream<Edge> edgeStream(int id, EdgeDirection dir) {
EventData e = getEvent(id);
BiMap<EventData, EventData> map = (dir == EdgeDirection.OUTGOING ? lockUnlockMap : unlockLockMap);
EventData a = (dir == EdgeDirection.OUTGOING ? e : map.get(e));
EventData b = (a == e ? map.get(e) : e);
return (a != null && b != null) ? Stream.of(new Edge(a.getId(), b.getId())) : Stream.empty();
}
use of com.dat3m.dartagnan.verification.model.EventData in project Dat3M by hernanponcedeleon.
the class StaticDefaultWMMGraph method getEdgeFromTuple.
private Edge getEdgeFromTuple(Tuple t) {
Optional<EventData> e1 = model.getData(t.getFirst());
Optional<EventData> e2 = model.getData(t.getSecond());
return (e1.isPresent() && e2.isPresent()) ? new Edge(e1.get().getId(), e2.get().getId()) : null;
}
use of com.dat3m.dartagnan.verification.model.EventData in project Dat3M by hernanponcedeleon.
the class CoreReasoner method addFenceReason.
private void addFenceReason(Relation rel, Edge edge, List<CoreLiteral> coreReasons) {
FenceGraph fenceGraph = (FenceGraph) executionGraph.getRelationGraph(rel);
EventDomain domain = executionGraph.getDomain();
EventData e1 = domain.getObjectById(edge.getFirst());
EventData e2 = domain.getObjectById(edge.getSecond());
EventData f = fenceGraph.getNextFence(e1);
coreReasons.add(new ExecLiteral(f.getEvent()));
if (!exec.isImplied(f.getEvent(), e1.getEvent())) {
coreReasons.add(new ExecLiteral(e1.getEvent()));
}
if (!exec.isImplied(f.getEvent(), e2.getEvent())) {
coreReasons.add(new ExecLiteral(e2.getEvent()));
}
}
Aggregations