Search in sources :

Example 1 with EdgeDirection

use of com.dat3m.dartagnan.solver.caat.misc.EdgeDirection in project Dat3M by hernanponcedeleon.

the class ExternalGraph method edgeStream.

@Override
public Stream<Edge> edgeStream(int id, EdgeDirection dir) {
    EventData e = getEvent(id);
    Function<EventData, Edge> edgeMapping = dir == EdgeDirection.OUTGOING ? (x -> new Edge(id, x.getId())) : (x -> new Edge(x.getId(), id));
    return threadEventsMap.entrySet().stream().filter(x -> x.getKey() != e.getThread()).flatMap(x -> x.getValue().stream()).map(edgeMapping);
}
Also used : IntStream(java.util.stream.IntStream) List(java.util.List) Stream(java.util.stream.Stream) EventData(com.dat3m.dartagnan.verification.model.EventData) Map(java.util.Map) Thread(com.dat3m.dartagnan.program.Thread) Function(java.util.function.Function) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) 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 2 with EdgeDirection

use of com.dat3m.dartagnan.solver.caat.misc.EdgeDirection in project Dat3M by hernanponcedeleon.

the class FenceGraph method edgeStream.

@Override
public Stream<Edge> edgeStream(int id, EdgeDirection dir) {
    EventData e = getEvent(id);
    if (!e.isMemoryEvent()) {
        return Stream.empty();
    }
    List<EventData> threadEvents = model.getThreadEventsMap().get(e.getThread());
    if (dir == EdgeDirection.OUTGOING) {
        EventData fence = getNextFence(e);
        return fence == null ? Stream.empty() : threadEvents.subList(fence.getLocalId() + 1, threadEvents.size()).stream().filter(EventData::isMemoryEvent).map(x -> new Edge(id, x.getId()));
    } else {
        EventData fence = getPreviousFence(e);
        return fence == null ? Stream.empty() : threadEvents.subList(0, fence.getLocalId()).stream().filter(EventData::isMemoryEvent).map(x -> new Edge(x.getId(), id));
    }
}
Also used : java.util(java.util) Stream(java.util.stream.Stream) EventData(com.dat3m.dartagnan.verification.model.EventData) Thread(com.dat3m.dartagnan.program.Thread) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) 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 3 with EdgeDirection

use of com.dat3m.dartagnan.solver.caat.misc.EdgeDirection 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 4 with EdgeDirection

use of com.dat3m.dartagnan.solver.caat.misc.EdgeDirection 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 5 with EdgeDirection

use of com.dat3m.dartagnan.solver.caat.misc.EdgeDirection in project Dat3M by hernanponcedeleon.

the class InternalGraph method edgeStream.

@Override
public Stream<Edge> edgeStream(int id, EdgeDirection dir) {
    EventData e = getEvent(id);
    Function<EventData, Edge> edgeMapping = dir == EdgeDirection.OUTGOING ? (x -> new Edge(id, x.getId())) : (x -> new Edge(x.getId(), id));
    return threadEventsMap.get(e.getThread()).stream().map(edgeMapping);
}
Also used : IntStream(java.util.stream.IntStream) List(java.util.List) Stream(java.util.stream.Stream) EventData(com.dat3m.dartagnan.verification.model.EventData) Map(java.util.Map) Thread(com.dat3m.dartagnan.program.Thread) Function(java.util.function.Function) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) EdgeDirection(com.dat3m.dartagnan.solver.caat.misc.EdgeDirection) Edge(com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge) EventData(com.dat3m.dartagnan.verification.model.EventData)

Aggregations

EdgeDirection (com.dat3m.dartagnan.solver.caat.misc.EdgeDirection)6 Edge (com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge)6 EventData (com.dat3m.dartagnan.verification.model.EventData)6 Stream (java.util.stream.Stream)6 Function (java.util.function.Function)5 java.util (java.util)4 Thread (com.dat3m.dartagnan.program.Thread)3 BigInteger (java.math.BigInteger)3 Iterators (com.google.common.collect.Iterators)2 List (java.util.List)2 Map (java.util.Map)2 Spliterator (java.util.Spliterator)2 IntStream (java.util.stream.IntStream)2 StreamSupport (java.util.stream.StreamSupport)2