Example #1
0
        /// <summary>
        /// find the max latency
        /// </summary>
        /// <param name="sort">sorted list of vertices</param>
        /// <param name="graph">delay graph</param>
        /// <param name="registered">hash table of registered vertices</param>
        /// <returns>number of cycles</returns>
        internal static long FindMaxLatencyCore(IEnumerable <DelayGraphVertex> sort, DelayGraph graph, HashSet <DelayGraphVertex> registered)
        {
            long maxLatencyCost = 0;
            var  table          = new WaveFrontDictionary <long>();

            foreach (var v in sort)
            {
                var inEdges    = graph.GetForwardInEdges(v);
                var outEdges   = graph.GetForwardOutEdges(v);
                int myRefCount = outEdges.Count();

                // first, consume predecessor's wavefront data, if any
                long myCost = 0;
                foreach (var e in inEdges)
                {
                    var p = e.Source;
                    var c = table.Use(p);   // default for long is 0
                    // copy data into myData
                    myCost = Math.Max(myCost, c);
                }

                // then add v's latency cost
                myCost += GetLatencyCost(v, registered);

                // register myCost into table
                table.Define(v, myRefCount, myCost);

                // update maxLatencyCost if v has no outEdges
                if (myRefCount == 0 && maxLatencyCost < myCost)
                {
                    maxLatencyCost = myCost;
                }
            }
            return(maxLatencyCost);
        }
Example #2
0
 /// <summary>
 /// if myData is null, create it and register it into table using table.Define() for vertex v
 /// </summary>
 /// <param name="table">the wavefront dictionary</param>
 /// <param name="v">a vertex</param>
 /// <param name="myRefCount">reference count </param>
 /// <param name="myData">original data, could be null</param>
 /// <returns></returns>
 private static Dictionary <DelayGraphVertex, long> GetOrMakeMyData(WaveFrontDictionary <Dictionary <DelayGraphVertex, long> > table,
                                                                    DelayGraphVertex v, int myRefCount, Dictionary <DelayGraphVertex, long> myData)
 {
     if (myData == null)
     {
         myData = new Dictionary <DelayGraphVertex, long>();
         table.Define(v, myRefCount, myData);
     }
     return(myData);
 }