Search in sources :

Example 11 with EventData

use of com.dat3m.dartagnan.verification.model.EventData in project Dat3M by hernanponcedeleon.

the class RcuGraph method repopulate.

@Override
public void repopulate() {
    this.lockUnlockMap = HashBiMap.create();
    this.unlockLockMap = lockUnlockMap.inverse();
    Stack<EventData> lastLocks = new Stack<>();
    for (List<EventData> events : model.getThreadEventsMap().values()) {
        for (EventData e : events) {
            if (LOCK_FILTER.filter(e.getEvent())) {
                lastLocks.push(e);
            } else if (UNLOCK_FILTER.filter(e.getEvent())) {
                if (!lastLocks.isEmpty()) {
                    lockUnlockMap.put(lastLocks.pop(), e);
                } else {
                    throw new IllegalStateException("Unbalanced RCU-Locks: Unlock without preceding Lock");
                }
            }
        }
        if (!lastLocks.isEmpty()) {
            throw new IllegalStateException("Unbalanced RCU-Locks: Lock without subsequent Unlock");
        }
    }
    size = lockUnlockMap.size();
}
Also used : EventData(com.dat3m.dartagnan.verification.model.EventData) Stack(java.util.Stack)

Example 12 with EventData

use of com.dat3m.dartagnan.verification.model.EventData in project Dat3M by hernanponcedeleon.

the class CoherenceGraph method edgeIterator.

@Override
public Iterator<Edge> edgeIterator(int id, EdgeDirection dir) {
    EventData e = getEvent(id);
    if (!e.isWrite()) {
        return Collections.emptyIterator();
    }
    com.google.common.base.Function<EventData, Edge> mapping = dir == EdgeDirection.INGOING ? (event -> new Edge(event.getId(), id)) : (event -> new Edge(id, event.getId()));
    return Iterators.transform(getCoSuccessorList(e, dir).iterator(), mapping);
}
Also used : java.util(java.util) Stream(java.util.stream.Stream) EventData(com.dat3m.dartagnan.verification.model.EventData) BigInteger(java.math.BigInteger) StreamSupport(java.util.stream.StreamSupport) Function(java.util.function.Function) Spliterator(java.util.Spliterator) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) Iterators(com.google.common.collect.Iterators) EdgeDirection(com.dat3m.dartagnan.solver.caat.misc.EdgeDirection) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) EventData(com.dat3m.dartagnan.verification.model.EventData)

Example 13 with EventData

use of com.dat3m.dartagnan.verification.model.EventData in project Dat3M by hernanponcedeleon.

the class CoherenceGraph method edgeStream.

@Override
public Stream<Edge> edgeStream(int id, EdgeDirection dir) {
    EventData e = getEvent(id);
    if (!e.isWrite()) {
        return Stream.empty();
    }
    Function<EventData, Edge> mapping = dir == EdgeDirection.INGOING ? (event -> new Edge(event.getId(), id)) : (event -> new Edge(id, event.getId()));
    return getCoSuccessorList(e, dir).stream().map(mapping);
}
Also used : java.util(java.util) Stream(java.util.stream.Stream) EventData(com.dat3m.dartagnan.verification.model.EventData) BigInteger(java.math.BigInteger) StreamSupport(java.util.stream.StreamSupport) Function(java.util.function.Function) Spliterator(java.util.Spliterator) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) Iterators(com.google.common.collect.Iterators) EdgeDirection(com.dat3m.dartagnan.solver.caat.misc.EdgeDirection) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) EventData(com.dat3m.dartagnan.verification.model.EventData)

Example 14 with EventData

use of com.dat3m.dartagnan.verification.model.EventData in project Dat3M by hernanponcedeleon.

the class ExternalGraph method containsById.

@Override
public boolean containsById(int id1, int id2) {
    EventData a = getEvent(id1);
    EventData b = getEvent(id2);
    return a.getThread() != b.getThread();
}
Also used : EventData(com.dat3m.dartagnan.verification.model.EventData)

Example 15 with EventData

use of com.dat3m.dartagnan.verification.model.EventData in project Dat3M by hernanponcedeleon.

the class FenceGraph method size.

@Override
public int size(int id, EdgeDirection dir) {
    EventData e = getEvent(id);
    if (!e.isMemoryEvent()) {
        return 0;
    }
    int size = 0;
    if (dir == EdgeDirection.OUTGOING) {
        EventData closestFence = getNextFence(e);
        if (closestFence == null) {
            return 0;
        }
        List<EventData> eventsAfterFence = model.getThreadEventsMap().get(e.getThread());
        eventsAfterFence = eventsAfterFence.subList(closestFence.getLocalId() + 1, eventsAfterFence.size());
        return (int) eventsAfterFence.stream().filter(EventData::isMemoryEvent).count();
    } else if (dir == EdgeDirection.INGOING) {
        EventData closestFence = getPreviousFence(e);
        if (closestFence == null) {
            return 0;
        }
        List<EventData> eventsBeforeFence = model.getThreadEventsMap().get(e.getThread());
        eventsBeforeFence = eventsBeforeFence.subList(0, closestFence.getLocalId());
        return (int) eventsBeforeFence.stream().filter(EventData::isMemoryEvent).count();
    }
    return size;
}
Also used : 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