Example #1
0
        public override bool TryProcessNodeChildren(PatternNodePPA nodePpa)
        {
            List <PatternNodePPA> children;

            if (nodePpa.TryGetChildren(out children))
            {
                ProcessNodes(children);
                return(true);
            }

            return(false);
        }
Example #2
0
        protected void ComputeNonParallel(PatternNodePPA node, ResultPPA result)
        {
            if (depthComputed > node.Permutation.Length + descendantsDepth)
            {
                List <PatternNodePPA> children;
                node.TryGetChildren(out children);
                foreach (var child in children)
                {
                    ComputeStep(child, result);

                    ComputeNonParallel(child, result);
                }

                node.DisposeChildren();
                node.DisposeDescendants();
            }
        }
Example #3
0
        protected void ComputeParallelUnSufficientThreads(PatternNodePPA node,
                                                          ResultPPA result, int numThreads)
        {
            int[]    childrenPerThread = DivideThreadsChildren(node.CountChildren, numThreads);
            Thread[] threads           = new Thread[childrenPerThread.Length - 1];
            List <PatternNodePPA> children;

            node.TryGetChildren(out children);

            int index = 0;


            for (int i = 0; i < threads.Length; i++)
            {
                int       startIndex       = index;
                ResultPPA clone            = result.GetClone();
                int       childrenToThread = childrenPerThread[i];
                threads[i] = new Thread(() => ComputeParallelUnSufficientThreadsChildrenProcessing(children,
                                                                                                   startIndex, childrenToThread, clone));

                index += childrenPerThread[i];
            }

            foreach (var thread in threads)
            {
                thread.Start();
            }

            ComputeParallelUnSufficientThreadsChildrenProcessing(children,
                                                                 index, childrenPerThread[childrenPerThread.Length - 1],
                                                                 result.GetClone());

            foreach (var thread in threads)
            {
                thread.Join();
            }

            result.FetchDataAllClones();
            result.DisposeClones();
        }
Example #4
0
        protected void ComputeParallelSufficientThreads(PatternNodePPA node,
                                                        ResultPPA result, int numThreads)
        {
            int[]    numThreadsChildren = ComputeThreadsCountChildren(node.CountChildren, numThreads);
            Thread[] threads            = new Thread[node.CountChildren - 1];
            List <PatternNodePPA> children;

            node.TryGetChildren(out children);


            for (int i = 0; i < threads.Length; i++)
            {
                ResultPPA      clone           = result.GetClone();
                PatternNodePPA child           = children[i];
                int            numThreadsChild = numThreadsChildren[i];
                threads[i] = new Thread(() => ComputeParallel(child,
                                                              clone, numThreadsChild));
            }

            foreach (var thread in threads)
            {
                thread.Start();
            }


            ComputeParallel(children[children.Count - 1],
                            result.GetClone(), numThreadsChildren[children.Count - 1]);

            foreach (var thread in threads)
            {
                thread.Join();
            }

            result.FetchDataAllClones();
            result.DisposeClones();
        }