Search in sources :

Example 1 with FilterAbstract

use of com.dat3m.dartagnan.program.filter.FilterAbstract in project Dat3M by hernanponcedeleon.

the class VisitorBase method visitLetDefinition.

@Override
public Object visitLetDefinition(CatParser.LetDefinitionContext ctx) {
    Relation r = ctx.e.accept(relationVisitor);
    if (r != null) {
        r.setName(ctx.n.getText());
        relationRepository.updateRelation(r);
    } else {
        FilterAbstract f = ctx.e.accept(filterVisitor);
        f.setName(ctx.n.getText());
        wmm.addFilter(f);
    }
    return null;
}
Also used : RecursiveRelation(com.dat3m.dartagnan.wmm.relation.RecursiveRelation) Relation(com.dat3m.dartagnan.wmm.relation.Relation) FilterAbstract(com.dat3m.dartagnan.program.filter.FilterAbstract)

Example 2 with FilterAbstract

use of com.dat3m.dartagnan.program.filter.FilterAbstract in project Dat3M by hernanponcedeleon.

the class VisitorRelation method visitExprCartesian.

@Override
public Relation visitExprCartesian(CatParser.ExprCartesianContext ctx) {
    boolean orig = base.recursiveDef;
    base.recursiveDef = false;
    FilterAbstract filter1 = ctx.e1.accept(base.filterVisitor);
    FilterAbstract filter2 = ctx.e2.accept(base.filterVisitor);
    Relation relation = base.relationRepository.getRelation(RelCartesian.class, filter1, filter2);
    base.recursiveDef = orig;
    return relation;
}
Also used : RecursiveRelation(com.dat3m.dartagnan.wmm.relation.RecursiveRelation) Relation(com.dat3m.dartagnan.wmm.relation.Relation) FilterAbstract(com.dat3m.dartagnan.program.filter.FilterAbstract)

Example 3 with FilterAbstract

use of com.dat3m.dartagnan.program.filter.FilterAbstract 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 4 with FilterAbstract

use of com.dat3m.dartagnan.program.filter.FilterAbstract in project Dat3M by hernanponcedeleon.

the class RelRf method atomicBlockOptimization.

private void atomicBlockOptimization() {
    // TODO: This function can not only reduce rf-edges
    // but we could also figure out implied coherences:
    // Assume w1 and w2 are aliasing in the same block and w1 is before w2,
    // then if w1 is co-before some external w3, then so is w2, i.e.
    // co(w1, w3) => co(w2, w3), but we also have co(w2, w3) => co(w1, w3)
    // so co(w1, w3) <=> co(w2, w3).
    // This information is not expressible in terms of min/must sets, but
    // we could still encode it.
    int sizeBefore = maxTupleSet.size();
    // Atomics blocks: BeginAtomic -> EndAtomic
    ExecutionAnalysis exec = analysisContext.get(ExecutionAnalysis.class);
    AliasAnalysis alias = analysisContext.get(AliasAnalysis.class);
    FilterAbstract filter = FilterIntersection.get(FilterBasic.get(RMW), FilterBasic.get(SVCOMP.SVCOMPATOMIC));
    for (Event end : task.getProgram().getCache().getEvents(filter)) {
        // Collect memEvents of the atomic block
        List<Store> writes = new ArrayList<>();
        List<Load> reads = new ArrayList<>();
        EndAtomic endAtomic = (EndAtomic) end;
        for (Event b : endAtomic.getBlock()) {
            if (b instanceof Load) {
                reads.add((Load) b);
            } else if (b instanceof Store) {
                writes.add((Store) b);
            }
        }
        for (Load r : reads) {
            // If there is any write w inside the atomic block that is guaranteed to
            // execute before the read and that aliases with it,
            // then the read won't be able to read any external writes
            boolean hasImpliedWrites = writes.stream().anyMatch(w -> w.getCId() < r.getCId() && exec.isImplied(r, w) && alias.mustAlias(r, w));
            if (hasImpliedWrites) {
                maxTupleSet.removeIf(t -> t.getSecond() == r && t.isCrossThread());
            }
        }
    }
    logger.info("Atomic block optimization eliminated " + (sizeBefore - maxTupleSet.size()) + " reads");
}
Also used : Load(com.dat3m.dartagnan.program.event.core.Load) EndAtomic(com.dat3m.dartagnan.program.event.lang.svcomp.EndAtomic) ExecutionAnalysis(com.dat3m.dartagnan.program.analysis.ExecutionAnalysis) FilterAbstract(com.dat3m.dartagnan.program.filter.FilterAbstract) MemEvent(com.dat3m.dartagnan.program.event.core.MemEvent) Event(com.dat3m.dartagnan.program.event.core.Event) Store(com.dat3m.dartagnan.program.event.core.Store) AliasAnalysis(com.dat3m.dartagnan.program.analysis.AliasAnalysis)

Example 5 with FilterAbstract

use of com.dat3m.dartagnan.program.filter.FilterAbstract in project Dat3M by hernanponcedeleon.

the class VisitorRelation method visitExprIdentity.

@Override
public Relation visitExprIdentity(CatParser.ExprIdentityContext ctx) {
    boolean orig = base.recursiveDef;
    base.recursiveDef = false;
    FilterAbstract filter = ctx.e.accept(base.filterVisitor);
    Relation relation = base.relationRepository.getRelation(RelSetIdentity.class, filter);
    base.recursiveDef = orig;
    return relation;
}
Also used : RecursiveRelation(com.dat3m.dartagnan.wmm.relation.RecursiveRelation) Relation(com.dat3m.dartagnan.wmm.relation.Relation) FilterAbstract(com.dat3m.dartagnan.program.filter.FilterAbstract)

Aggregations

FilterAbstract (com.dat3m.dartagnan.program.filter.FilterAbstract)5 RecursiveRelation (com.dat3m.dartagnan.wmm.relation.RecursiveRelation)3 Relation (com.dat3m.dartagnan.wmm.relation.Relation)3 Event (com.dat3m.dartagnan.program.event.core.Event)2 MemEvent (com.dat3m.dartagnan.program.event.core.MemEvent)2 EndAtomic (com.dat3m.dartagnan.program.event.lang.svcomp.EndAtomic)2 Utils.generalEqual (com.dat3m.dartagnan.expression.utils.Utils.generalEqual)1 Thread (com.dat3m.dartagnan.program.Thread)1 AliasAnalysis (com.dat3m.dartagnan.program.analysis.AliasAnalysis)1 ExecutionAnalysis (com.dat3m.dartagnan.program.analysis.ExecutionAnalysis)1 Tag (com.dat3m.dartagnan.program.event.Tag)1 SVCOMPATOMIC (com.dat3m.dartagnan.program.event.Tag.SVCOMP.SVCOMPATOMIC)1 Load (com.dat3m.dartagnan.program.event.core.Load)1 Store (com.dat3m.dartagnan.program.event.core.Store)1 RMWStore (com.dat3m.dartagnan.program.event.core.rmw.RMWStore)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 Context (com.dat3m.dartagnan.verification.Context)1 VerificationTask (com.dat3m.dartagnan.verification.VerificationTask)1