Example #1
0
        private ISet <ArrayAccess> _CollectAccesses(string body)
        {
            var code = TestCodeFactory.CreateCode(body);
            var cfg  = ControlFlowGraphFactory.Create(code);

            return(ArrayAccessCollector.Collect(cfg));
        }
        /// <summary>
        /// Checks that there are no conflicting read and write accesses to arrays.
        /// </summary>
        /// <param name="loopIndex">The loop index of the loop that is subject for parallelization.</param>
        /// <param name="controlFlowGraph">The control flow graph of the body of the loop.</param>
        /// <param name="aliasAnalysis">A prelimary applied alias analysis already fed with possible aliases outside of the loop.</param>
        /// <param name="callGraph">The graph identifying the calls of methods for interprocedural analysis.</param>
        /// <param name="procedures">The control flow graphs of the invoked methods.</param>
        /// <returns><code>True</code> if there are no conflicting accesses to arrays.</returns>
        public static bool HasConflictingAccesses(string loopIndex, ControlFlowGraph controlFlowGraph, AliasAnalysis aliasAnalysis, CallGraph callGraph, IEnumerable <ControlFlowGraph> procedures)
        {
            var loopDependenceAnalysis = LoopDependenceAnalysis.Analyze(controlFlowGraph, loopIndex, callGraph, procedures);
            var arrayAccesses          = ArrayAccessCollector.Collect(new[] { controlFlowGraph }.Concat(procedures).SelectMany(graph => graph.Nodes));
            var verifier = new ArrayAccessVerifier(loopDependenceAnalysis, aliasAnalysis, arrayAccesses);

            return(verifier._ContainsLoopCarriedDependencies());
        }
        /// <summary>
        /// Checks that there are no conflicting read and write accesses to arrays.
        /// </summary>
        /// <param name="loopIndex">The loop index of the loop that is subject for parallelization.</param>
        /// <param name="controlFlowGraph">The control flow graph of the body of the loop.</param>
        /// <param name="aliasAnalysis">A prelimary applied alias analysis already fed with possible aliases outside of the loop.</param>
        /// <returns><code>True</code> if there are no conflicting accesses to arrays.</returns>
        public static bool HasConflictingAccesses(string loopIndex, ControlFlowGraph controlFlowGraph, AliasAnalysis aliasAnalysis)
        {
            var loopDependenceAnalysis = LoopDependenceAnalysis.Analyze(controlFlowGraph, loopIndex);
            var arrayAccesses          = ArrayAccessCollector.Collect(controlFlowGraph);
            var verifier = new ArrayAccessVerifier(loopDependenceAnalysis, aliasAnalysis, arrayAccesses);

            return(verifier._ContainsLoopCarriedDependencies());
        }