Search in sources :

Example 1 with RMWStore

use of com.dat3m.dartagnan.program.event.core.rmw.RMWStore in project Dat3M by hernanponcedeleon.

the class RelRMW method getMaxTupleSet.

@Override
public TupleSet getMaxTupleSet() {
    if (maxTupleSet == null) {
        logger.info("Computing maxTupleSet for " + getName());
        baseMaxTupleSet = new TupleSet();
        // RMWLoad -> RMWStore
        FilterAbstract filter = FilterIntersection.get(FilterBasic.get(Tag.RMW), FilterBasic.get(Tag.WRITE));
        for (Event store : task.getProgram().getCache().getEvents(filter)) {
            if (store instanceof RMWStore) {
                baseMaxTupleSet.add(new Tuple(((RMWStore) store).getLoadEvent(), store));
            }
        }
        // Locks: Load -> Assume/CondJump -> Store
        FilterAbstract locks = FilterUnion.get(FilterBasic.get(Tag.C11.LOCK), FilterBasic.get(Tag.Linux.LOCK_READ));
        filter = FilterIntersection.get(FilterBasic.get(Tag.RMW), locks);
        for (Event e : task.getProgram().getCache().getEvents(filter)) {
            // Connect Load to Store
            baseMaxTupleSet.add(new Tuple(e, e.getSuccessor().getSuccessor()));
        }
        // Atomics blocks: BeginAtomic -> EndAtomic
        filter = FilterIntersection.get(FilterBasic.get(Tag.RMW), FilterBasic.get(SVCOMPATOMIC));
        for (Event end : task.getProgram().getCache().getEvents(filter)) {
            List<Event> block = ((EndAtomic) end).getBlock().stream().filter(x -> x.is(Tag.VISIBLE)).collect(Collectors.toList());
            for (int i = 0; i < block.size(); i++) {
                for (int j = i + 1; j < block.size(); j++) {
                    baseMaxTupleSet.add(new Tuple(block.get(i), block.get(j)));
                }
            }
        }
        removeMutuallyExclusiveTuples(baseMaxTupleSet);
        maxTupleSet = new TupleSet();
        maxTupleSet.addAll(baseMaxTupleSet);
        // to find guaranteed pairs (the encoding can then also be improved)
        for (Thread thread : task.getProgram().getThreads()) {
            for (Event load : thread.getCache().getEvents(loadExclFilter)) {
                for (Event store : thread.getCache().getEvents(storeExclFilter)) {
                    if (load.getCId() < store.getCId()) {
                        maxTupleSet.add(new Tuple(load, store));
                    }
                }
            }
        }
        removeMutuallyExclusiveTuples(maxTupleSet);
        logger.info("maxTupleSet size for " + getName() + ": " + maxTupleSet.size());
    }
    return maxTupleSet;
}
Also used : SVCOMPATOMIC(com.dat3m.dartagnan.program.event.Tag.SVCOMP.SVCOMPATOMIC) BooleanType(org.sosy_lab.java_smt.api.FormulaType.BooleanType) FilterUnion(com.dat3m.dartagnan.program.filter.FilterUnion) BooleanFormula(org.sosy_lab.java_smt.api.BooleanFormula) Thread(com.dat3m.dartagnan.program.Thread) FilterAbstract(com.dat3m.dartagnan.program.filter.FilterAbstract) EndAtomic(com.dat3m.dartagnan.program.event.lang.svcomp.EndAtomic) TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) FilterIntersection(com.dat3m.dartagnan.program.filter.FilterIntersection) SolverContext(org.sosy_lab.java_smt.api.SolverContext) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple) RMW(com.dat3m.dartagnan.wmm.relation.RelationNameRepository.RMW) FilterBasic(com.dat3m.dartagnan.program.filter.FilterBasic) Utils.generalEqual(com.dat3m.dartagnan.expression.utils.Utils.generalEqual) VerificationTask(com.dat3m.dartagnan.verification.VerificationTask) FormulaManager(org.sosy_lab.java_smt.api.FormulaManager) Collectors(java.util.stream.Collectors) MemEvent(com.dat3m.dartagnan.program.event.core.MemEvent) Sets(com.google.common.collect.Sets) Tag(com.dat3m.dartagnan.program.event.Tag) BooleanFormulaManager(org.sosy_lab.java_smt.api.BooleanFormulaManager) RMWStore(com.dat3m.dartagnan.program.event.core.rmw.RMWStore) Context(com.dat3m.dartagnan.verification.Context) List(java.util.List) Logger(org.apache.logging.log4j.Logger) Event(com.dat3m.dartagnan.program.event.core.Event) StaticRelation(com.dat3m.dartagnan.wmm.relation.base.stat.StaticRelation) LogManager(org.apache.logging.log4j.LogManager) Flag(com.dat3m.dartagnan.wmm.utils.Flag) TupleSet(com.dat3m.dartagnan.wmm.utils.TupleSet) FilterAbstract(com.dat3m.dartagnan.program.filter.FilterAbstract) RMWStore(com.dat3m.dartagnan.program.event.core.rmw.RMWStore) MemEvent(com.dat3m.dartagnan.program.event.core.MemEvent) Event(com.dat3m.dartagnan.program.event.core.Event) Tuple(com.dat3m.dartagnan.wmm.utils.Tuple) Thread(com.dat3m.dartagnan.program.Thread)

Example 2 with RMWStore

use of com.dat3m.dartagnan.program.event.core.rmw.RMWStore in project Dat3M by hernanponcedeleon.

the class VisitorBase method visitRMW.

@Override
public List<Event> visitRMW(RMW e) {
    Register resultRegister = e.getResultRegister();
    IExpr address = e.getAddress();
    String mo = e.getMo();
    Register dummyReg = e.getThread().newRegister(resultRegister.getPrecision());
    Load load = newRMWLoad(dummyReg, address, mo);
    RMWStore store = newRMWStore(load, address, e.getMemValue(), mo);
    return eventSequence(load, store, newLocal(resultRegister, dummyReg));
}
Also used : Load(com.dat3m.dartagnan.program.event.core.Load) Register(com.dat3m.dartagnan.program.Register) RMWStore(com.dat3m.dartagnan.program.event.core.rmw.RMWStore) IExpr(com.dat3m.dartagnan.expression.IExpr)

Example 3 with RMWStore

use of com.dat3m.dartagnan.program.event.core.rmw.RMWStore in project Dat3M by hernanponcedeleon.

the class VisitorTso method visitXchg.

@Override
public List<Event> visitXchg(Xchg e) {
    Register resultRegister = e.getResultRegister();
    IExpr address = e.getAddress();
    Register dummyReg = e.getThread().newRegister(resultRegister.getPrecision());
    Load load = newRMWLoad(dummyReg, address, null);
    load.addFilters(Tag.TSO.ATOM);
    RMWStore store = newRMWStore(load, address, resultRegister, null);
    store.addFilters(Tag.TSO.ATOM);
    return eventSequence(load, store, newLocal(resultRegister, dummyReg));
}
Also used : Register(com.dat3m.dartagnan.program.Register) RMWStore(com.dat3m.dartagnan.program.event.core.rmw.RMWStore)

Example 4 with RMWStore

use of com.dat3m.dartagnan.program.event.core.rmw.RMWStore 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)

Aggregations

RMWStore (com.dat3m.dartagnan.program.event.core.rmw.RMWStore)4 Register (com.dat3m.dartagnan.program.Register)2 IExpr (com.dat3m.dartagnan.expression.IExpr)1 Utils.generalEqual (com.dat3m.dartagnan.expression.utils.Utils.generalEqual)1 Thread (com.dat3m.dartagnan.program.Thread)1 Tag (com.dat3m.dartagnan.program.event.Tag)1 SVCOMPATOMIC (com.dat3m.dartagnan.program.event.Tag.SVCOMP.SVCOMPATOMIC)1 Event (com.dat3m.dartagnan.program.event.core.Event)1 Load (com.dat3m.dartagnan.program.event.core.Load)1 MemEvent (com.dat3m.dartagnan.program.event.core.MemEvent)1 EndAtomic (com.dat3m.dartagnan.program.event.lang.svcomp.EndAtomic)1 FilterAbstract (com.dat3m.dartagnan.program.filter.FilterAbstract)1 FilterBasic (com.dat3m.dartagnan.program.filter.FilterBasic)1 FilterIntersection (com.dat3m.dartagnan.program.filter.FilterIntersection)1 FilterUnion (com.dat3m.dartagnan.program.filter.FilterUnion)1 Edge (com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.Edge)1 Context (com.dat3m.dartagnan.verification.Context)1 VerificationTask (com.dat3m.dartagnan.verification.VerificationTask)1 EventData (com.dat3m.dartagnan.verification.model.EventData)1 RMW (com.dat3m.dartagnan.wmm.relation.RelationNameRepository.RMW)1