Ejemplo n.º 1
0
        public static void evaluate()
        {
            //Require 3x3 for assumptions in Coord labeling
            if (Config.network_nrX != 3 || Config.network_nrY != 3)
            {
                throw new Exception("Incorrect network size for router evaluation!");
            }

            Router     theRouter = Network.MakeRouter(new Coord(1, 1));
            SimpleNode node      = new SimpleNode(Simulator.network.nodes[0].mapping, theRouter.coord);

            theRouter.setNode(node);

            for (int i = 0; i < 4; i++)
            {
                Link inLink  = new Link(0);
                Link outLink = new Link(0);

                theRouter.linkIn[i]  = inLink;
                theRouter.linkOut[i] = outLink;
            }

            //FINISH CONFIGURING LINKS

            ExhaustiveSweep <int> s = new ExhaustiveSweep <int>();

            s.addParameter(possibleDests);
            s.addParameter(possibleDests);
            s.addParameter(possibleDests);
            s.addParameter(possibleDests);
            //s.addParameter("L", possibleDests);

            ulong timesToRunEach = 1;

            Console.WriteLine("iterating over {0}(*{1}) configurations", s.Count, timesToRunEach);
            for (ulong i = 0; i < Config.RouterEvaluationIterations * s.Count; i++)
            {
                if (i % 4096 == 0)
                {
                    Console.WriteLine("Completed {0} evalutations", i);
                }

                int[] nextConfig = s.GetConfig(i / Config.RouterEvaluationIterations);
#if EVAL_DEBUG
                Console.WriteLine("i{0} N{1} S{2} E{3} W{4}", i, nextConfig[0], nextConfig[1], nextConfig[2], nextConfig[3]);
#endif
                // assign each config direction to its link with a new packet/flit
                for (int j = 0; j < 4; j++)
                {
                    int  dest         = nextConfig[j];
                    Flit incomingFlit = null;
                    if (dest >= 0)
                    {
                        incomingFlit = new Packet(null, 0, 1, new Coord(1, 1), new Coord(nextConfig[j])).flits[0];
                        incomingFlit.packet.creationTime = (ulong)Simulator.rand.Next(4);
                    }
                    theRouter.linkIn[j].In = incomingFlit;
                    theRouter.linkIn[j].doStep();

                    simplePrint(j, incomingFlit);
                }
#if EVAL_DEBUG
                Console.WriteLine();
#endif
                theRouter.doStep();

                for (int j = 0; j < 4; j++)
                {
                    theRouter.linkOut[j].doStep();
                    simplePrint(j, theRouter.linkOut[j].Out);
                }
                simplePrint(4, node.getReceivedFlit());
#if EVAL_DEBUG
                Console.WriteLine();
#endif
            }
        }