Example #1
0
        public void ComputeHeuristic(InstNode node)
        {
            if (node.StaticCost != 0)
            {
                ex++;
                return;
            }
            node.StaticCost = 0;
            foreach (var x in node.Content)
            {
                node.StaticCost += InstructionRuntime.GetInstructionRuntime(x);
            }
            var leftH  = 0u;
            var rightH = 0u;

            if (node.Left != null)
            {
                ComputeHeuristic(node.Left);
                leftH = node.Left.Heuristic + (uint)(node.Left.Content.Count * CacheMissOverhead);
            }
            if (node.Right != null)
            {
                ComputeHeuristic(node.Right);
                rightH = node.Right.Heuristic + (uint)(node.Right.Content.Count * CacheMissOverhead);
            }
            node.Heuristic = node.StaticCost + Math.Max(leftH, rightH);
        }
Example #2
0
 public GraphHeuristic()
 {
     InstructionRuntime = new InstructionRuntime();
     CacheMissOverhead  = 5;
 }