Exemple #1
0
        public ConcurrentNodeDictionary <ulong> ComputeAggregateCosts(ConcurrentNodeDictionary <ulong> durations)
        {
            ConcurrentNodeDictionary <ulong> aggregateCosts = new ConcurrentNodeDictionary <ulong>(true);

            List <NodeId> sortedNodes = new List <NodeId>();

            sortedNodes.AddRange(DataflowGraph.Nodes);
            sortedNodes.Sort((n1, n2) => - DataflowGraph.GetNodeHeight(n1).CompareTo(DataflowGraph.GetNodeHeight(n2)));
            foreach (var node in sortedNodes)
            {
                // int maxConeConcurrency = 0;
                ulong  aggregateCost = 0;
                NodeId maxChild      = NodeId.Invalid;
                foreach (var outgoing in DataflowGraph.GetOutgoingEdges(node))
                {
                    if (aggregateCosts[outgoing.OtherNode].Max(ref aggregateCost) || !maxChild.IsValid)
                    {
                        maxChild = outgoing.OtherNode;
                    }
                }

                aggregateCost       += durations[node];
                aggregateCosts[node] = aggregateCost;
            }

            return(aggregateCosts);
        }
Exemple #2
0
        public void ComputeAggregateCosts()
        {
            PipAndPriority maxPipAndPriority = default(PipAndPriority);
            List <NodeId>  sortedNodes       = new List <NodeId>();

            sortedNodes.AddRange(DataflowGraph.Nodes);
            sortedNodes.Sort((n1, n2) => DataflowGraph.GetNodeHeight(n1).CompareTo(DataflowGraph.GetNodeHeight(n2)));
            foreach (var node in sortedNodes)
            {
                ulong aggregateCost = 0;
                foreach (var incoming in DataflowGraph.GetIncomingEdges(node))
                {
                    BottomUpAggregateCosts[incoming.OtherNode].Max(ref aggregateCost);
                }

                aggregateCost += Durations[node];
                BottomUpAggregateCosts[node] = aggregateCost;
            }

            sortedNodes.Sort((n1, n2) => - DataflowGraph.GetNodeHeight(n1).CompareTo(DataflowGraph.GetNodeHeight(n2)));
            foreach (var node in sortedNodes)
            {
                // int maxConeConcurrency = 0;
                ulong  aggregateCost = 0, constrainedAggregateCost = 0;
                NodeId maxChild = NodeId.Invalid;
                foreach (var outgoing in DataflowGraph.GetOutgoingEdges(node))
                {
                    ConstrainedAggregateCosts[outgoing.OtherNode].Max(ref constrainedAggregateCost);

                    if (AggregateCosts[outgoing.OtherNode].Max(ref aggregateCost) || !maxChild.IsValid)
                    {
                        maxChild = outgoing.OtherNode;
                    }
                }

                FormattedSemistableHashes[node] = CachedGraph.PipTable.GetFormattedSemiStableHash(node.ToPipId());
                aggregateCost       += Durations[node];
                AggregateCosts[node] = aggregateCost;
                aggregateCost.Max(ref MaxAggregateCost);
                CriticalChain[node] = maxChild;

                new PipAndPriority
                {
                    Node     = node,
                    Priority = aggregateCost,
                }.Max(ref maxPipAndPriority);
            }

            CriticalPathHeadNode = maxPipAndPriority.Node;

            NodeId criticalChainNode = CriticalPathHeadNode;

            while (criticalChainNode.IsValid)
            {
                CriticalPath.Add(criticalChainNode);
                criticalChainNode = CriticalChain[criticalChainNode];
            }
        }