Search in sources :

Example 21 with EventData

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()));
                }
            }
        }
    }
}
Also used : RMWStore(com.dat3m.dartagnan.program.event.core.rmw.RMWStore) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) EventData(com.dat3m.dartagnan.verification.model.EventData)

Example 22 with EventData

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;
}
Also used : EventData(com.dat3m.dartagnan.verification.model.EventData)

Example 23 with EventData

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();
}
Also used : Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) EventData(com.dat3m.dartagnan.verification.model.EventData)

Example 24 with EventData

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;
}
Also used : Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) EventData(com.dat3m.dartagnan.verification.model.EventData)

Example 25 with EventData

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()));
    }
}
Also used : EventDomain(com.dat3m.dartagnan.solver.caat4wmm.EventDomain) FenceGraph(com.dat3m.dartagnan.solver.caat4wmm.basePredicates.FenceGraph) EventData(com.dat3m.dartagnan.verification.model.EventData)

Aggregations

EventData (com.dat3m.dartagnan.verification.model.EventData)28 Edge (com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge)10 EdgeDirection (com.dat3m.dartagnan.solver.caat.misc.EdgeDirection)6 Stream (java.util.stream.Stream)6 Function (java.util.function.Function)5 Thread (com.dat3m.dartagnan.program.Thread)4 BigInteger (java.math.BigInteger)4 java.util (java.util)4 List (java.util.List)3 Map (java.util.Map)3 Iterators (com.google.common.collect.Iterators)2 Spliterator (java.util.Spliterator)2 IntStream (java.util.stream.IntStream)2 StreamSupport (java.util.stream.StreamSupport)2 Register (com.dat3m.dartagnan.program.Register)1 MemEvent (com.dat3m.dartagnan.program.event.core.MemEvent)1 RMWStore (com.dat3m.dartagnan.program.event.core.rmw.RMWStore)1 EventDomain (com.dat3m.dartagnan.solver.caat4wmm.EventDomain)1 FenceGraph (com.dat3m.dartagnan.solver.caat4wmm.basePredicates.FenceGraph)1 ArrayList (java.util.ArrayList)1