Ejemplo n.º 1
0
        public override void setup()
        {
			if (Config.network_nrX != 4 && Config.network_nrY != 4)
				throw new Exception("buffered hierarchical ring only support 4x4 network");
			nics = new Router_NIC[Config.N];
			iris = new Router_IRI[4];
            nodes = new Node[Config.N];
            links = new List<Link>();
            cache = new CmpCache();

            ParseFinish(Config.finish);

            workload = new Workload(Config.traceFilenames);

            mapping = new NodeMapping_AllCPU_SharedCache();

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
            {
                Coord c = new Coord(n);
                nodes[n] = new Node(mapping, c);
				nics[n] = new Router_NIC(c);
                nodes[n].setRouter(nics[n]);
                nics[n].setNode(nodes[n]);
            }
			for (int n = 0; n < 4; n++)
			{
				iris[n] = new Router_IRI(n);
			}

			for (int group = 0; group < 4; group ++)
			{
				for (int i = 0; i < 4; i++)
				{
					if (i == 3) continue;
					int node = group * 4 + i;
					Link dirA = new Link(Config.router.switchLinkLatency - 1);
					links.Add(dirA);
					nics[node].linkOut[0] = dirA;
					nics[node+1].linkIn[0] = dirA;
				}

				Link dirD = new Link(Config.router.switchLinkLatency - 1);
				Link dirB = new Link(Config.router.switchLinkLatency - 1);
				links.Add(dirB);
				links.Add(dirD);
				nics[group*4 + 3].linkOut[0] = dirD;
				iris[group].LLinkIn[0] = dirD;	
				nics[group*4].linkIn[0] = dirB;
				iris[group].LLinkOut[0] = dirB;
				int next = (group + 1) % 4;
				Link dirC = new Link(Config.router.level1RingLinkLatency - 1);
				links.Add(dirC);
				iris[group].GLinkOut[0] = dirC;
				iris[next].GLinkIn[0] = dirC;
			}
       	} 
Ejemplo n.º 2
0
        public override void setup()
        {
            if (Config.bBufferedRing)
            {
                nodeRouters = new Router_Node_Buffer[Config.N];
            }
            else
            {
                nodeRouters = new Router_Node[Config.N];
            }

            nodes = new Node[Config.N];
            links = new List <Link>();
            cache = new CmpCache();

            ParseFinish(Config.finish);

            workload = new Workload(Config.traceFilenames);

            mapping = new NodeMapping_AllCPU_SharedCache();

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
            {
                Coord    c    = new Coord(n);
                RC_Coord RC_c = new RC_Coord(n);

                nodes[n] = new Node(mapping, c);
                if (Config.bBufferedRing)
                {
                    nodeRouters[n] = new Router_Node_Buffer(RC_c, c);
                }
                else
                {
                    nodeRouters[n] = new Router_Node(RC_c, c);
                }
                nodes[n].setRouter(nodeRouters[n]);
                nodeRouters[n].setNode(nodes[n]);
            }
            // connect the network with Links
            for (int n = 0; n < Config.N; n++)
            {
                int  next = (n + 1) % Config.N;
                Link dirA = new Link(Config.router.switchLinkLatency - 1);
                Link dirB = new Link(Config.router.switchLinkLatency - 1);
                links.Add(dirA);
                links.Add(dirB);
                nodeRouters[n].linkOut[CW]     = dirA;
                nodeRouters[next].linkIn[CW]   = dirA;
                nodeRouters[n].linkIn[CCW]     = dirB;
                nodeRouters[next].linkOut[CCW] = dirB;
            }
        }
Ejemplo n.º 3
0
        public void setup_TorusSingleRing()
        {
            nodeRouters    = new Router_TorusRingNode[Config.N];
            connectRouters = new Router_TorusRingConnect[8];
            nodes          = new Node[Config.N];
            links          = new List <Link>();
            cache          = new CmpCache();

            ParseFinish(Config.finish);
            workload = new Workload(Config.traceFilenames);
            mapping  = new NodeMapping_AllCPU_SharedCache();

            for (int n = 0; n < Config.N; n++)
            {
                Coord c = new Coord(n);
                nodes[n]       = new Node(mapping, c);
                nodeRouters[n] = new Router_TorusRingNode(c);
                nodes[n].setRouter(nodeRouters[n]);
                nodeRouters[n].setNode(nodes[n]);
            }
            for (int n = 0; n < 8; n++)
            {
                connectRouters[n] = new Router_TorusRingConnect(n);
            }

            int[] CW_Connect = new int[16] {
                7, 0, 6, 1, 3, 1, 2, 0, 2, 5, 3, 4, 6, 4, 7, 5
            };
            int[] CCW_Connect = new int[16] {
                1, 7, 0, 6, 0, 3, 1, 2, 4, 2, 5, 3, 5, 6, 4, 7
            };
            int[] dirCW = new int[16] {
                1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1
            };
            int[] dirCCW = new int[16] {
                1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0
            };
            for (int n = 0; n < Config.N; n++)
            {
                Link dirA = new Link(Config.router.linkLatency - 1);
                Link dirB = new Link(Config.router.linkLatency - 1);
                links.Add(dirA);
                links.Add(dirB);
                nodeRouters[n].linkOut[0] = dirA;
                nodeRouters[n].linkIn[0]  = dirB;
                connectRouters[CW_Connect[n]].linkIn[dirCW[n]]    = dirA;
                connectRouters[CCW_Connect[n]].linkOut[dirCCW[n]] = dirB;
            }
        }
Ejemplo n.º 4
0
      	public override void setup()
       	{
            if (Config.bBufferedRing)
                nodeRouters = new Router_Node_Buffer[Config.N];
            else
                nodeRouters = new Router_Node[Config.N];

            nodes = new Node[Config.N];
            links = new List<Link>();
            cache = new CmpCache();

            ParseFinish(Config.finish);

            workload = new Workload(Config.traceFilenames);

            mapping = new NodeMapping_AllCPU_SharedCache();

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
           	{
                Coord c = new Coord(n);
                RC_Coord RC_c = new RC_Coord(n);

                nodes[n] = new Node(mapping, c);
                if (Config.bBufferedRing)
                    nodeRouters[n] = new Router_Node_Buffer(RC_c, c);
                else
                    nodeRouters[n] = new Router_Node(RC_c, c);
                nodes[n].setRouter(nodeRouters[n]);
                nodeRouters[n].setNode(nodes[n]);
            }
            // connect the network with Links
            for (int n = 0; n < Config.N; n++)
            {
				int next = (n + 1) % Config.N;
				Link dirA = new Link(Config.router.switchLinkLatency - 1);
				Link dirB = new Link(Config.router.switchLinkLatency - 1);
				links.Add(dirA);
				links.Add(dirB);
				nodeRouters[n].linkOut[CW] = dirA;
				nodeRouters[next].linkIn[CW] = dirA;
				nodeRouters[n].linkIn[CCW] = dirB;
				nodeRouters[next].linkOut[CCW] = dirB;
			}
       	}
Ejemplo n.º 5
0
        public override void setup()
        {
            // boilerplate
            nodes = new Node[Config.N];
            cache = new CmpCache();
            ParseFinish(Config.finish);
            workload = new Workload(Config.traceFilenames);
            mapping  = new NodeMapping_AllCPU_SharedCache();

            _nics = new List <BufRingMultiNetwork_NIC>();
            _iris = new List <BufRingMultiNetwork_IRI>();

            links    = new List <Link>();
            _routers = new BufRingMultiNetwork_Router[Config.N];

            //Console.WriteLine("setup: N = {0}", Config.N);

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
            {
                Coord c = new Coord(n);
                nodes[n]    = new Node(mapping, c);
                _routers[n] = new BufRingMultiNetwork_Router(c);
                _routers[n].setNode(nodes[n]);
                nodes[n].setRouter(_routers[n]);
            }

            // for each copy of the network...
            for (int copy = 0; copy < Config.bufrings_n; copy++)
            {
                BufRingMultiNetwork_Coord c = new BufRingMultiNetwork_Coord(0, 0);
                BufRingMultiNetwork_IRI   iri;
                int count;
                setup_ring(c, 0, out iri, out count);
            }
        }
Ejemplo n.º 6
0
		public override void setup()
		{
			if (Config.sub_net <= 0) 
				throw new Exception ("No subnetwork is configured (sub_net <= 0)!");

			_routers = new MultiMeshRouter [Config.N];
			nodes = new Node[Config.N];
			links = new List<Link>();
			cache = new CmpCache();

			endOfTraceBarrier = new bool[Config.N];
			canRewind = false;

			ParseFinish(Config.finish);

			workload = new Workload(Config.traceFilenames);

			mapping = new NodeMapping_AllCPU_SharedCache();

			// create routers and nodes
			// each node contains router [sub_net * node, ... ,  sub_net*(node+1)-1]
			for (int n = 0; n < Config.N; n++)
			{
				Coord c = new Coord(n);
				nodes[n] = new Node(mapping, c);
				_routers [n] = new MultiMeshRouter (c);
				nodes [n].setRouter (_routers [n]);
				_routers [n].setNode (nodes [n]);
				endOfTraceBarrier[n] = false;
			}


			// create the Golden manager
			// NOT sure if needed
			golden = new Golden();

			// connect the network with Links
			for (int n = 0; n < Config.N; n++)
			{
				int x, y;
				Coord.getXYfromID(n, out x, out y);

				// inter-router links
				for (int dir = 0; dir < 4; dir++)
				{

					// Clockwise 0->3 map to N->E->S->W
					/* Coordinate Mapping (e.g. 16 nodes)
					 * (0,3) (1,3) .....     |||||    3  7 ...
					 * ...					 |||||	  2  6 ...
					 * ...					 |||||    1  5 ...
					 * (0,0) (1,0) ......	 |||||    0  4 ...
					 * */

					int oppDir = (dir + 2) % 4; // direction from neighbor's perspective

					// determine neighbor's coordinates
					int x_, y_;
					switch (dir)
					{
						case Simulator.DIR_UP: x_ = x; y_ = y + 1; break;
						case Simulator.DIR_DOWN: x_ = x; y_ = y - 1; break;
						case Simulator.DIR_RIGHT: x_ = x + 1; y_ = y; break;
						case Simulator.DIR_LEFT: x_ = x - 1; y_ = y; break;
						default: continue;
					}

					// If we are a torus, we manipulate x_ and y_
					if(Config.torus)
					{
						if(x_ < 0)
							x_ += X;
						else if(x_ >= X)
							x_ -= X;

						if(y_ < 0)
							y_ += Y;
						else if(y_ >= Y)
							y_ -= Y;
					}
					// mesh, not torus: detect edge
					else if (x_ < 0 || x_ >= X || y_ < 0 || y_ >= Y)
						continue;

					// ensure no duplication by handling a link at the lexicographically
					// first router
					if (x_ < x || (x_ == x && y_ < y)) continue;

					int ID, ID_neighbor; 
					ID = Coord.getIDfromXY(x, y);
					ID_neighbor = Coord.getIDfromXY(x_, y_);

					for (int m = 0; m < Config.sub_net; m++)
					{
						// Link param is *extra* latency (over the standard 1 cycle)
						Link dirA = new Link(Config.router.linkLatency - 1);
						Link dirB = new Link(Config.router.linkLatency - 1);
						links.Add(dirA);
						links.Add(dirB);

						_routers [ID].subrouter [m].linkOut [dir] = dirA;
						_routers [ID_neighbor].subrouter [m].linkIn [oppDir] = dirA;
						_routers [ID].subrouter [m].linkIn [dir] = dirB;
						_routers [ID_neighbor].subrouter [m].linkOut [oppDir] = dirB;
						_routers [ID].subrouter [m].neighbors++;
						_routers [ID_neighbor].subrouter [m].neighbors++;
						_routers [ID].subrouter [m].neigh [dir] = _routers [ID_neighbor].subrouter [m];
						_routers [ID_neighbor].subrouter [m].neigh [oppDir] = _routers [ID].subrouter [m];

					}
				}

				// connect the subrouters

				if (Config.bypass_enable && Config.bridge_subnet)
					for (int pi = 0; pi < Config.num_bypass; pi++)
						for (int m = 0; m < Config.sub_net; m++)
						{
							Link bypass = new Link(0);
							links.Add(bypass);
							_routers[n].subrouter[m].bypassLinkOut[pi] = bypass;
							_routers[n].subrouter[(m+1)%Config.sub_net].bypassLinkIn[pi] = bypass;
							_routers [n].subrouter[m].neighbors++;
							//_routers [n].subrouter [m].neigh [pi] = _routers [n].subrouter [(m+1)%Config.sub_net];
						}

				
			}

			if (Config.bypass_enable == true && Config.bridge_subnet == false)
				for (int i = 0; i < Config.sub_net; i++)
					for (int k = 0; k < Config.network_nrY; k++)
						for (int j = 0; j < Config.network_nrX; j++)
					{
						Link bypass = new Link(0);
						links.Add(bypass);
						_routers[k * Config.network_nrX+j%Config.network_nrX].subrouter[i].bypassLinkOut[0] = bypass;
						_routers[k * Config.network_nrX+(j+1)%Config.network_nrX].subrouter[i].bypassLinkIn[0] = bypass;
						_routers[k * Config.network_nrX+j%Config.network_nrX].subrouter [i].neighbors++;
					}


			// TORUS: be careful about the number of neighbors, which is based on if bypass is enabled. NOT tested.
			if (Config.torus)
				for (int i = 0; i < Config.N; i++)
					for (int j = 0; j < Config.sub_net; j++)
						if (_routers[i].subrouter [j].neighbors < 4)
							throw new Exception("torus construction not successful!");
		}
Ejemplo n.º 7
0
        public override void setup()
        {
            if (Config.N != 1024)
            {
                throw new Exception("HR_16_8drop only suport 8x8 network");
            }
            nodeRouters     = new Router_Node[Config.N];
            L1bridgeRouters = new Router_Bridge[512];
            L2bridgeRouters = new Router_Bridge[128];
            L3bridgeRouters = new Router_Bridge[32];
            L4bridgeRouters = new Router_Bridge[8];
            nodes           = new Node[Config.N];
            links           = new List <Link>();
            cache           = new CmpCache();

            ParseFinish(Config.finish);

            workload = new Workload(Config.traceFilenames);

            mapping = new NodeMapping_AllCPU_SharedCache();

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
            {
                Coord    c    = new Coord(n);
                RC_Coord RC_c = new RC_Coord(n);

                nodes[n]       = new Node(mapping, c);
                nodeRouters[n] = new Router_Node(RC_c, c);
                nodes[n].setRouter(nodeRouters[n]);
                nodeRouters[n].setNode(nodes[n]);
            }
            for (int n = 0; n < 512; n++)
            {
                L1bridgeRouters[n] = new Router_Bridge(n, 2, 1);
            }
            for (int n = 0; n < 128; n++)
            {
                L2bridgeRouters[n] = new Router_Bridge(n, 4, 2, 2, 8);
            }
            for (int n = 0; n < 32; n++)
            {
                L3bridgeRouters[n] = new Router_Bridge(n, 8, 4, 4, 16);
            }
            for (int n = 0; n < 8; n++)
            {
                L4bridgeRouters[n] = new Router_Bridge(n, 16, 8, 8, 32);
            }
            // connect the network with Links
            for (int n = 0; n < 256; n++)
            {
                for (int i = 0; i < 4; i++)
                {
                    int ID = n * 4 + i;
                    if (ID % 2 == 0)
                    {
                        continue;
                    }
                    int  next = (i + 1) % 4 + n * 4;
                    Link dirA = new Link(Config.router.switchLinkLatency - 1);
                    Link dirB = new Link(Config.router.switchLinkLatency - 1);
                    links.Add(dirA);
                    links.Add(dirB);
                    nodeRouters[ID].linkOut[CW]    = dirA;
                    nodeRouters[next].linkIn[CW]   = dirA;
                    nodeRouters[ID].linkIn[CCW]    = dirB;
                    nodeRouters[next].linkOut[CCW] = dirB;
                }
            }

            // connect L1 bridge Routers
            for (int n = 0; n < 512; n++)
            {
                int ID = n;
                int next, pre;
                if (ID % 8 == 0 || ID % 8 == 6)
                {
                    next = ID * 2 + 3; pre = ID * 2 + 2;
                }
                else if (ID % 8 == 1 || ID % 8 == 7)
                {
                    next = ID * 2 - 1; pre = ID * 2 - 2;
                }
                else
                {
                    next = ID * 2 + 1; pre = ID * 2;
                }

                Link dirA = new Link(Config.router.switchLinkLatency - 1);
                Link dirB = new Link(Config.router.switchLinkLatency - 1);
                Link dirC = new Link(Config.router.switchLinkLatency - 1);
                Link dirD = new Link(Config.router.switchLinkLatency - 1);
                links.Add(dirA);
                links.Add(dirB);
                links.Add(dirC);
                links.Add(dirD);
                L1bridgeRouters[n].LLinkOut[CW] = dirA;
                nodeRouters[next].linkIn[CW]    = dirA;
                L1bridgeRouters[n].LLinkIn[CCW] = dirB;
                nodeRouters[next].linkOut[CCW]  = dirB;

                L1bridgeRouters[n].LLinkOut[CCW] = dirC;
                nodeRouters[pre].linkIn[CCW]     = dirC;
                L1bridgeRouters[n].LLinkIn[CW]   = dirD;
                nodeRouters[pre].linkOut[CW]     = dirD;

                int nextL1 = (n + 1) % 8 + n / 8 * 8;
                if (ID % 8 == 1 || ID % 8 == 5)
                {
                    continue;
                }
                for (int i = 0; i < 2; i++)
                {
                    dirA = new Link(Config.router.level1RingLinkLatency - 1);
                    dirB = new Link(Config.router.level1RingLinkLatency - 1);
                    links.Add(dirA);
                    links.Add(dirB);
                    L1bridgeRouters[n].GLinkIn[i * 2 + 1]       = dirA;
                    L1bridgeRouters[nextL1].GLinkOut[i * 2 + 1] = dirA;
                    L1bridgeRouters[n].GLinkOut[i * 2]          = dirB;
                    L1bridgeRouters[nextL1].GLinkIn[i * 2]      = dirB;
                }
            }
            // connect L2 bridge Routers
            for (int n = 0; n < 128; n++)
            {
                int next, pre;
                if (n % 8 == 0 || n % 8 == 6)
                {
                    next = n * 4 + 6; pre = next - 1;
                }
                else if (n % 8 == 1 || n % 8 == 7)
                {
                    next = n * 4 - 2; pre = next - 1;
                }
                else
                {
                    next = n * 4 + 2; pre = next - 1;
                }

                for (int i = 0; i < 2; i++)
                {
                    Link dirA = new Link(Config.router.level1RingLinkLatency - 1);
                    Link dirB = new Link(Config.router.level1RingLinkLatency - 1);
                    Link dirC = new Link(Config.router.level1RingLinkLatency - 1);
                    Link dirD = new Link(Config.router.level1RingLinkLatency - 1);
                    links.Add(dirA);
                    links.Add(dirB);
                    links.Add(dirC);
                    links.Add(dirD);

                    L2bridgeRouters[n].LLinkOut[i * 2]        = dirA;
                    L1bridgeRouters[next].GLinkIn[i * 2]      = dirA;
                    L2bridgeRouters[n].LLinkIn[i * 2 + 1]     = dirB;
                    L1bridgeRouters[next].GLinkOut[i * 2 + 1] = dirB;

                    L2bridgeRouters[n].LLinkOut[i * 2 + 1]  = dirC;
                    L1bridgeRouters[pre].GLinkIn[i * 2 + 1] = dirC;
                    L2bridgeRouters[n].LLinkIn[i * 2]       = dirD;
                    L1bridgeRouters[pre].GLinkOut[i * 2]    = dirD;
                }
                int nextL2 = (n + 1) % 8 + n / 8 * 8;
                if (n % 8 == 1 || n % 8 == 5)
                {
                    continue;
                }
                for (int i = 0; i < 4; i++)
                {
                    Link dirA = new Link(Config.router.level2RingLinkLatency - 1);
                    Link dirB = new Link(Config.router.level2RingLinkLatency - 1);
                    links.Add(dirA);
                    links.Add(dirB);
                    L2bridgeRouters[n].GLinkIn[i * 2 + 1]       = dirA;
                    L2bridgeRouters[nextL2].GLinkOut[i * 2 + 1] = dirA;
                    L2bridgeRouters[n].GLinkOut[i * 2]          = dirB;
                    L2bridgeRouters[nextL2].GLinkIn[i * 2]      = dirB;
                }
            }
            //connect L3 bridge Routers
            for (int n = 0; n < 32; n++)
            {
                int next, pre;
                if (n % 8 == 0 || n % 8 == 6)
                {
                    next = n * 4 + 6; pre = next - 1;
                }
                else if (n % 8 == 1 || n % 8 == 7)
                {
                    next = n * 4 - 2; pre = next - 1;
                }
                else
                {
                    next = n * 4 + 2; pre = next - 1;
                }

                for (int i = 0; i < 4; i++)
                {
                    Link dirA = new Link(Config.router.level2RingLinkLatency - 1);
                    Link dirB = new Link(Config.router.level2RingLinkLatency - 1);
                    Link dirC = new Link(Config.router.level2RingLinkLatency - 1);
                    Link dirD = new Link(Config.router.level2RingLinkLatency - 1);
                    links.Add(dirA);
                    links.Add(dirB);
                    links.Add(dirC);
                    links.Add(dirD);

                    L3bridgeRouters[n].LLinkOut[i * 2]        = dirA;
                    L2bridgeRouters[next].GLinkIn[i * 2]      = dirA;
                    L3bridgeRouters[n].LLinkIn[i * 2 + 1]     = dirB;
                    L2bridgeRouters[next].GLinkOut[i * 2 + 1] = dirB;

                    L3bridgeRouters[n].LLinkOut[i * 2 + 1]  = dirC;
                    L2bridgeRouters[pre].GLinkIn[i * 2 + 1] = dirC;
                    L3bridgeRouters[n].LLinkIn[i * 2]       = dirD;
                    L2bridgeRouters[pre].GLinkOut[i * 2]    = dirD;
                }
                int nextL3 = (n + 1) % 8 + n / 8 * 8;
                if (n % 8 == 1 || n % 8 == 5)
                {
                    continue;
                }
                for (int i = 0; i < 8; i++)
                {
                    Link dirA = new Link(Config.router.level3RingLinkLatency - 1);
                    Link dirB = new Link(Config.router.level3RingLinkLatency - 1);
                    links.Add(dirA);
                    links.Add(dirB);
                    L3bridgeRouters[n].GLinkIn[i * 2 + 1]       = dirA;
                    L3bridgeRouters[nextL3].GLinkOut[i * 2 + 1] = dirA;
                    L3bridgeRouters[n].GLinkOut[i * 2]          = dirB;
                    L3bridgeRouters[nextL3].GLinkIn[i * 2]      = dirB;
                }
            }
            //connect L4 bridge Routers
            for (int n = 0; n < 8; n++)
            {
                int next, pre;
                if (n % 8 == 0 || n % 8 == 6)
                {
                    next = n * 4 + 6; pre = next - 1;
                }
                else if (n % 8 == 1 || n % 8 == 7)
                {
                    next = n * 4 - 2; pre = next - 1;
                }
                else
                {
                    next = n * 4 + 2; pre = next - 1;
                }

                for (int i = 0; i < 8; i++)
                {
                    Link dirA = new Link(Config.router.level3RingLinkLatency - 1);
                    Link dirB = new Link(Config.router.level3RingLinkLatency - 1);
                    Link dirC = new Link(Config.router.level3RingLinkLatency - 1);
                    Link dirD = new Link(Config.router.level3RingLinkLatency - 1);
                    links.Add(dirA);
                    links.Add(dirB);
                    links.Add(dirC);
                    links.Add(dirD);

                    L4bridgeRouters[n].LLinkOut[i * 2]        = dirA;
                    L3bridgeRouters[next].GLinkIn[i * 2]      = dirA;
                    L4bridgeRouters[n].LLinkIn[i * 2 + 1]     = dirB;
                    L3bridgeRouters[next].GLinkOut[i * 2 + 1] = dirB;

                    L4bridgeRouters[n].LLinkOut[i * 2 + 1]  = dirC;
                    L3bridgeRouters[pre].GLinkIn[i * 2 + 1] = dirC;
                    L4bridgeRouters[n].LLinkIn[i * 2]       = dirD;
                    L3bridgeRouters[pre].GLinkOut[i * 2]    = dirD;
                }
                int nextL4 = (n + 1) % 8 + n / 8 * 8;
                for (int i = 0; i < 16; i++)
                {
                    Link dirA = new Link(Config.router.level4RingLinkLatency - 1);
                    Link dirB = new Link(Config.router.level4RingLinkLatency - 1);
                    links.Add(dirA);
                    links.Add(dirB);
                    L4bridgeRouters[n].GLinkIn[i * 2 + 1]       = dirA;
                    L4bridgeRouters[nextL4].GLinkOut[i * 2 + 1] = dirA;
                    L4bridgeRouters[n].GLinkOut[i * 2]          = dirB;
                    L4bridgeRouters[nextL4].GLinkIn[i * 2]      = dirB;
                }
            }
        }
Ejemplo n.º 8
0
        public override void setup()
        {
            nodeRouters   = new Router_Node[Config.N];
            switchRouters = new Router_Switch[Config.N];
            nodes         = new Node[Config.N];
            links         = new List <Link>();
            cache         = new CmpCache();

            ParseFinish(Config.finish);

            workload = new Workload(Config.traceFilenames);

            mapping = new NodeMapping_AllCPU_SharedCache();

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
            {
                Coord    c    = new Coord(n);
                RC_Coord RC_c = new RC_Coord(n);

                nodes[n]       = new Node(mapping, c);
                nodeRouters[n] = new Router_Node(RC_c, c);
                nodes[n].setRouter(nodeRouters[n]);
                nodeRouters[n].setNode(nodes[n]);
            }
            for (int n = 0; n < Config.N; n++)
            {
                switchRouters[n] = new Router_Switch(n);
            }

            if (Config.RouterEvaluation)
            {
                return;
            }

            // connect the network with Links
            for (int y = 0; y < Y / 2; y++)
            {
                for (int x = 0; x < X / 2; x++)
                {
                    for (int z = 0; z < 4; z++)
                    {
                        Link dirA = new Link(Config.router.switchLinkLatency - 1);
                        Link dirB = new Link(Config.router.switchLinkLatency - 1);
                        Link dirC = new Link(Config.router.switchLinkLatency - 1);
                        Link dirD = new Link(Config.router.switchLinkLatency - 1);
                        links.Add(dirA);
                        links.Add(dirB);
                        links.Add(dirC);
                        links.Add(dirD);
                        int next = (RC_Coord.getIDfromXYZ(x, y, z) + 1) % 4 + RC_Coord.getIDfromXYZ(x, y, z) / 4 * 4;
                        //Console.WriteLine("Net/HR_Network. ID:{0}", RC_Coord.getIDfromXYZ(x, y, z));
                        nodeRouters[RC_Coord.getIDfromXYZ(x, y, z)].linkOut[CW] = dirA;
                        switchRouters[next].linkIn[Local_CW] = dirA;
                        nodeRouters[RC_Coord.getIDfromXYZ(x, y, z)].linkIn[CCW] = dirB;
                        switchRouters[next].linkOut[Local_CCW] = dirB;

                        nodeRouters[RC_Coord.getIDfromXYZ(x, y, z)].linkOut[CCW]        = dirC;
                        switchRouters[RC_Coord.getIDfromXYZ(x, y, z)].linkIn[Local_CCW] = dirC;
                        nodeRouters[RC_Coord.getIDfromXYZ(x, y, z)].linkIn[CW]          = dirD;
                        switchRouters[RC_Coord.getIDfromXYZ(x, y, z)].linkOut[Local_CW] = dirD;
                    }
                }
            }
            int [] xRingIndex = { 1, 3, 9, 11, 15, 13, 7, 5 };
            int [] yRingIndex = { 0, 8, 10, 12, 14, 6, 4, 2 };
            for (int n = 0; n < 8; n++)
            {
                Link dirA = new Link(Config.router.level1RingLinkLatency - 1);
                Link dirB = new Link(Config.router.level1RingLinkLatency - 1);
                switchRouters[xRingIndex[n]].linkOut[GL_CCW]          = dirA;
                switchRouters[xRingIndex[(n + 1) % 8]].linkIn[GL_CCW] = dirA;
                switchRouters[xRingIndex[n]].linkIn[GL_CW]            = dirB;
                switchRouters[xRingIndex[(n + 1) % 8]].linkOut[GL_CW] = dirB;

                Link dirC = new Link(Config.router.level1RingLinkLatency - 1);
                Link dirD = new Link(Config.router.level1RingLinkLatency - 1);
                switchRouters[yRingIndex[n]].linkOut[GL_CCW]          = dirC;
                switchRouters[yRingIndex[(n + 1) % 8]].linkIn[GL_CCW] = dirC;
                switchRouters[yRingIndex[n]].linkIn[GL_CW]            = dirD;
                switchRouters[yRingIndex[(n + 1) % 8]].linkOut[GL_CW] = dirD;
                links.Add(dirA);
                links.Add(dirB);
                links.Add(dirC);
                links.Add(dirD);
            }
        }
Ejemplo n.º 9
0
        public virtual void setup()
        {
            routers = new Router[Config.N];
            nodes = new Node[Config.N];
            links = new List<Link>();
            cache = new CmpCache();

            endOfTraceBarrier = new bool[Config.N];
			hsReqPerNode = new int[Config.N];
            canRewind = false;
			hotSpotNode = -1;
			hotSpotGenCount = 0;
			hsFlowID = 0;

            ParseFinish(Config.finish);

            workload = new Workload(Config.traceFilenames);

            mapping = new NodeMapping_AllCPU_SharedCache();

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
            {
                Coord c = new Coord(n);
                nodes[n] = new Node(mapping, c);
                routers[n] = MakeRouter(c);
                nodes[n].setRouter(routers[n]);
                routers[n].setNode(nodes[n]);
                endOfTraceBarrier[n] = false;
				hsReqPerNode [n] = 0;
				#if DEBUG
				Console.WriteLine ("*******This is Node {0} **********", n);
				((Router_BLESS_MC)nodes [n].router).PrintMask ();
				#endif
            }


			//Console.WriteLine ("Exit Normally!");
			//System.Environment.Exit (1);

            // create the Golden manager
            golden = new Golden();

            if (Config.RouterEvaluation)
                return;

            // connect the network with Links
            for (int n = 0; n < Config.N; n++)
            {
                int x, y;
                Coord.getXYfromID(n, out x, out y);

                // inter-router links
                for (int dir = 0; dir < 4; dir++)
                {

					// Clockwise 0->3 map to N->E->S->W
					/* Coordinate Mapping (e.g. 16 nodes)
					 * (0,3) (1,3) .....     |||||    3  7 ...
					 * ...					 |||||	  2  6 ...
					 * ...					 |||||    1  5 ...
					 * (0,0) (1,0) ......	 |||||    0  4 ...
					 * */

                    int oppDir = (dir + 2) % 4; // direction from neighbor's perspective

                    // determine neighbor's coordinates
                    int x_, y_;
                    switch (dir)
                    {
                        case Simulator.DIR_UP: x_ = x; y_ = y + 1; break;
                        case Simulator.DIR_DOWN: x_ = x; y_ = y - 1; break;
                        case Simulator.DIR_RIGHT: x_ = x + 1; y_ = y; break;
                        case Simulator.DIR_LEFT: x_ = x - 1; y_ = y; break;
                        default: continue;
                    }

                    // If we are a torus, we manipulate x_ and y_
                    if(Config.torus)
                    {
                      if(x_ < 0)
                        x_ += X;
                      else if(x_ >= X)
                        x_ -= X;

                      if(y_ < 0)
                        y_ += Y;
                      else if(y_ >= Y)
                        y_ -= Y;
                    }
                    // mesh, not torus: detect edge
                    else if (x_ < 0 || x_ >= X || y_ < 0 || y_ >= Y)
                    {
                        if (Config.edge_loop)
                        {
                            Link edgeL = new Link(Config.router.linkLatency - 1);
                            links.Add(edgeL);

                            routers[Coord.getIDfromXY(x, y)].linkOut[dir] = edgeL;
                            routers[Coord.getIDfromXY(x, y)].linkIn[dir] = edgeL;
                            routers[Coord.getIDfromXY(x, y)].neighbors++;
                            routers[Coord.getIDfromXY(x, y)].neigh[dir] =
                                routers[Coord.getIDfromXY(x, y)];
                        }

                        continue;
                    }

                    // ensure no duplication by handling a link at the lexicographically
                    // first router
                    if (x_ < x || (x_ == x && y_ < y)) continue;

                    // Link param is *extra* latency (over the standard 1 cycle)
                    Link dirA = new Link(Config.router.linkLatency - 1);
                    Link dirB = new Link(Config.router.linkLatency - 1);
                    links.Add(dirA);
                    links.Add(dirB);

                    // link 'em up
                    routers[Coord.getIDfromXY(x, y)].linkOut[dir] = dirA;
                    routers[Coord.getIDfromXY(x_, y_)].linkIn[oppDir] = dirA;

                    routers[Coord.getIDfromXY(x, y)].linkIn[dir] = dirB;
                    routers[Coord.getIDfromXY(x_, y_)].linkOut[oppDir] = dirB;

                    routers[Coord.getIDfromXY(x, y)].neighbors++;
                    routers[Coord.getIDfromXY(x_, y_)].neighbors++;

                    routers[Coord.getIDfromXY(x, y)].neigh[dir] = routers[Coord.getIDfromXY(x_, y_)];
                    routers[Coord.getIDfromXY(x_, y_)].neigh[oppDir] = routers[Coord.getIDfromXY(x, y)];

                    if (Config.router.algorithm == RouterAlgorithm.DR_SCARAB)
                    {
                        for (int wireNr = 0; wireNr < Config.nack_nr; wireNr++)
                        {
                            Link nackA = new Link(Config.nack_linkLatency - 1);
                            Link nackB = new Link(Config.nack_linkLatency - 1);
                            links.Add(nackA);
                            links.Add(nackB);
                            ((Router_SCARAB)routers[Coord.getIDfromXY(x, y)]).nackOut[dir * Config.nack_nr + wireNr] = nackA;
                            ((Router_SCARAB)routers[Coord.getIDfromXY(x_, y_)]).nackIn[oppDir * Config.nack_nr + wireNr] = nackA;

                            ((Router_SCARAB)routers[Coord.getIDfromXY(x, y)]).nackIn[dir * Config.nack_nr + wireNr] = nackB;
                            ((Router_SCARAB)routers[Coord.getIDfromXY(x_, y_)]).nackOut[oppDir * Config.nack_nr + wireNr] = nackB;
                        }
                    }
                }
            }

			// Just to verify the formed topology
			//for ( int i=0; i<16; i++) {
			//	Console.WriteLine ("Router {0} has {1} neighbors", i, routers[i].neighbors);
			//}

            if (Config.torus)
                for (int i = 0; i < Config.N; i++)
                    if (routers[i].neighbors < 4)
                        throw new Exception("torus construction not successful!");
        }
Ejemplo n.º 10
0
        public override void setup()
        {
            // boilerplate
            nodes = new Node[Config.N];
            cache = new CmpCache();
            ParseFinish(Config.finish);
            workload = new Workload(Config.traceFilenames);
            mapping  = new NodeMapping_AllCPU_SharedCache();

            links    = new List <Link>();
            _routers = new BufRingNetwork_Router[Config.N];

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
            {
                Coord c = new Coord(n);
                nodes[n]    = new Node(mapping, c);
                _routers[n] = new BufRingNetwork_Router(c);
                _routers[n].setNode(nodes[n]);
                nodes[n].setRouter(_routers[n]);
            }

            int B = Config.bufrings_branching;

            // create the NICs and IRIs
            _nics = new BufRingNetwork_NIC[Config.N * Config.bufrings_n];
            _iris = new BufRingNetwork_IRI[B * Config.bufrings_n];

            // for each copy of the network...
            for (int copy = 0; copy < Config.bufrings_n; copy++)
            {
                // for each local ring...
                for (int ring = 0; ring < B; ring++)
                {
                    // create global ring interface
                    _iris[copy * B + ring] = new BufRingNetwork_IRI(ring);

                    // create local NICs (ring stops)
                    for (int local = 0; local < B; local++)
                    {
                        _nics[copy * Config.N + ring * B + local] = new BufRingNetwork_NIC(ring, local);
                    }
                    // connect with links
                    for (int local = 1; local < B; local++)
                    {
                        Link l = new Link(Config.bufrings_locallat - 1);
                        links.Add(l);
                        _nics[copy * Config.N + ring * B + local - 1].setOutput(l,
                                                                                _nics[copy * Config.N + ring * B + local]);
                        _nics[copy * Config.N + ring * B + local].setInput(l);
                    }
                    Link iriIn = new Link(Config.bufrings_locallat - 1), iriOut = new Link(Config.bufrings_locallat - 1);
                    links.Add(iriIn);
                    links.Add(iriOut);
                    _nics[copy * Config.N + ring * B + B - 1].setOutput(iriIn,
                                                                        _iris[copy * B + ring]);
                    _nics[copy * Config.N + ring * B + 0].setInput(iriOut);

                    _iris[copy * B + ring].setLocalInput(iriIn);
                    _iris[copy * B + ring].setLocalOutput(iriOut,
                                                          _nics[copy * Config.N + ring * B + 0]);
                }

                // connect IRIs with links to make up global ring
                for (int ring = 0; ring < B; ring++)
                {
                    Link globalLink = new Link(Config.bufrings_globallat - 1);
                    links.Add(globalLink);
                    _iris[copy * B + ring].setGlobalOutput(globalLink,
                                                           _iris[copy * B + (ring + 1) % B]);
                    _iris[copy * B + (ring + 1) % B].setGlobalInput(globalLink);
                }

                // add the corresponding NIC to each node/router
                for (int id = 0; id < Config.N; id++)
                {
                    int ring, local;
                    BufRingNetwork_NIC.Map(id, out ring, out local);

                    _routers[id].addNIC(_nics[copy * Config.N + ring * B + local]);
                    _nics[copy * Config.N + ring * B + local].setRouter(_routers[id]);
                }
            }
        }
Ejemplo n.º 11
0
        public virtual void setup()
        {
            routers = new Router[Config.N];
            nodes   = new Node[Config.N];
            links   = new List <Link>();
            cache   = new CmpCache();

            endOfTraceBarrier = new bool[Config.N];
            canRewind         = false;

            ParseFinish(Config.finish);

            workload = new Workload(Config.traceFilenames);

            mapping = new NodeMapping_AllCPU_SharedCache();

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
            {
                Coord c = new Coord(n);
                nodes[n]   = new Node(mapping, c);
                routers[n] = MakeRouter(c);
                nodes[n].setRouter(routers[n]);
                routers[n].setNode(nodes[n]);
                endOfTraceBarrier[n] = false;
            }

            // create the Golden manager
            golden = new Golden();

            if (Config.RouterEvaluation)
            {
                return;
            }

            // connect the network with Links
            for (int n = 0; n < Config.N; n++)
            {
                int x, y;
                Coord.getXYfromID(n, out x, out y);

                // inter-router links
                for (int dir = 0; dir < 4; dir++)
                {
                    int oppDir = (dir + 2) % 4; // direction from neighbor's perspective

                    // determine neighbor's coordinates
                    int x_, y_;
                    switch (dir)
                    {
                    case Simulator.DIR_UP: x_ = x; y_ = y + 1; break;

                    case Simulator.DIR_DOWN: x_ = x; y_ = y - 1; break;

                    case Simulator.DIR_RIGHT: x_ = x + 1; y_ = y; break;

                    case Simulator.DIR_LEFT: x_ = x - 1; y_ = y; break;

                    default: continue;
                    }

                    // If we are a torus, we manipulate x_ and y_
                    if (Config.torus)
                    {
                        if (x_ < 0)
                        {
                            x_ += X;
                        }
                        else if (x_ >= X)
                        {
                            x_ -= X;
                        }

                        if (y_ < 0)
                        {
                            y_ += Y;
                        }
                        else if (y_ >= Y)
                        {
                            y_ -= Y;
                        }
                    }
                    // mesh, not torus: detect edge
                    else if (x_ < 0 || x_ >= X || y_ < 0 || y_ >= Y)
                    {
                        if (Config.edge_loop)
                        {
                            Link edgeL = new Link(Config.router.linkLatency - 1);
                            links.Add(edgeL);

                            routers[Coord.getIDfromXY(x, y)].linkOut[dir] = edgeL;
                            routers[Coord.getIDfromXY(x, y)].linkIn[dir]  = edgeL;
                            routers[Coord.getIDfromXY(x, y)].neighbors++;
                            routers[Coord.getIDfromXY(x, y)].neigh[dir] =
                                routers[Coord.getIDfromXY(x, y)];
                        }

                        continue;
                    }

                    // ensure no duplication by handling a link at the lexicographically
                    // first router
                    if (x_ < x || (x_ == x && y_ < y))
                    {
                        continue;
                    }

                    // Link param is *extra* latency (over the standard 1 cycle)
                    Link dirA = new Link(Config.router.linkLatency - 1);
                    Link dirB = new Link(Config.router.linkLatency - 1);
                    links.Add(dirA);
                    links.Add(dirB);

                    // link 'em up
                    routers[Coord.getIDfromXY(x, y)].linkOut[dir]     = dirA;
                    routers[Coord.getIDfromXY(x_, y_)].linkIn[oppDir] = dirA;

                    routers[Coord.getIDfromXY(x, y)].linkIn[dir]       = dirB;
                    routers[Coord.getIDfromXY(x_, y_)].linkOut[oppDir] = dirB;

                    routers[Coord.getIDfromXY(x, y)].neighbors++;
                    routers[Coord.getIDfromXY(x_, y_)].neighbors++;

                    routers[Coord.getIDfromXY(x, y)].neigh[dir]      = routers[Coord.getIDfromXY(x_, y_)];
                    routers[Coord.getIDfromXY(x_, y_)].neigh[oppDir] = routers[Coord.getIDfromXY(x, y)];

                    if (Config.router.algorithm == RouterAlgorithm.DR_SCARAB)
                    {
                        for (int wireNr = 0; wireNr < Config.nack_nr; wireNr++)
                        {
                            Link nackA = new Link(Config.nack_linkLatency - 1);
                            Link nackB = new Link(Config.nack_linkLatency - 1);
                            links.Add(nackA);
                            links.Add(nackB);
                            ((Router_SCARAB)routers[Coord.getIDfromXY(x, y)]).nackOut[dir * Config.nack_nr + wireNr]     = nackA;
                            ((Router_SCARAB)routers[Coord.getIDfromXY(x_, y_)]).nackIn[oppDir * Config.nack_nr + wireNr] = nackA;

                            ((Router_SCARAB)routers[Coord.getIDfromXY(x, y)]).nackIn[dir * Config.nack_nr + wireNr]       = nackB;
                            ((Router_SCARAB)routers[Coord.getIDfromXY(x_, y_)]).nackOut[oppDir * Config.nack_nr + wireNr] = nackB;
                        }
                    }
                }
            }

            if (Config.torus)
            {
                for (int i = 0; i < Config.N; i++)
                {
                    if (routers[i].neighbors < 4)
                    {
                        throw new Exception("torus construction not successful!");
                    }
                }
            }
        }
Ejemplo n.º 12
0
      	public override void setup()
       	{
			if (Config.N != 16)
				throw new Exception("HR_Simple only suport 4x4 network");
            nodeRouters = new Router_Node[Config.N];
           	bridgeRouters = new Router_Bridge[4]; 
            nodes = new Node[Config.N];
            links = new List<Link>();
            cache = new CmpCache();

            ParseFinish(Config.finish);

            workload = new Workload(Config.traceFilenames);

            mapping = new NodeMapping_AllCPU_SharedCache();

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
           	{
                Coord c = new Coord(n);
                RC_Coord RC_c = new RC_Coord(n);

                nodes[n] = new Node(mapping, c);
                nodeRouters[n] = new Router_Node(RC_c, c);
                nodes[n].setRouter(nodeRouters[n]);
                nodeRouters[n].setNode(nodes[n]);
            }
            for (int n = 0; n < 4; n++)
            	bridgeRouters[n] = new Router_Bridge(n, Config.GlobalRingWidth);
            // connect the network with Links
            for (int n = 0; n < 4; n++)
            {
				for (int i = 0; i < 4; i++)
				{
					int ID = n * 4 + i;
					if (ID == 2 || ID == 6 || ID == 8 || ID == 12)
						continue;
					int next = (i + 1) % 4 + n * 4;
					Link dirA = new Link(Config.router.switchLinkLatency - 1);
					Link dirB = new Link(Config.router.switchLinkLatency - 1);
					links.Add(dirA);
					links.Add(dirB);
					nodeRouters[ID].linkOut[CW] = dirA;
					nodeRouters[next].linkIn[CW] = dirA;
					nodeRouters[ID].linkIn[CCW] = dirB;
					nodeRouters[next].linkOut[CCW] = dirB;
				}
			}
			for (int n = 0; n < 4; n++)
			{
				Link dirA = new Link(Config.router.switchLinkLatency - 1);
				Link dirB = new Link(Config.router.switchLinkLatency - 1);
				Link dirC = new Link(Config.router.switchLinkLatency - 1);
				Link dirD = new Link(Config.router.switchLinkLatency - 1);
				links.Add(dirA);
				links.Add(dirB);
				links.Add(dirC);
				links.Add(dirD);
				bridgeRouters[n].LLinkOut[CW] = dirA;
				nodeRouters[CWnext[n]].linkIn[CW] = dirA;
				bridgeRouters[n].LLinkIn[CCW] = dirB;
				nodeRouters[CWnext[n]].linkOut[CCW] = dirB;

				bridgeRouters[n].LLinkOut[CCW] = dirC;
				nodeRouters[CCWnext[n]].linkIn[CCW] = dirC;
				bridgeRouters[n].LLinkIn[CW] = dirD;
				nodeRouters[CCWnext[n]].linkOut[CW] = dirD;
				
				int next = (n + 1) % 4;

				for (int i = 0 ; i < Config.GlobalRingWidth; i++)
				{
					dirA = new Link(2 - 1);
					dirB = new Link(2 - 1);
					links.Add(dirA);
					links.Add(dirB);
					bridgeRouters[n].GLinkIn[i*2+1] = dirA;
					bridgeRouters[next].GLinkOut[i*2+1] = dirA;
					bridgeRouters[n].GLinkOut[i*2] = dirB;
					bridgeRouters[next].GLinkIn[i*2] = dirB;
				}
			}
       	}
Ejemplo n.º 13
0
        public virtual void setup()
        {
            routers = new Router[Config.N];
            nodes = new Node[Config.N];
            links = new List<Link>();
            cache = new CmpCache();

            endOfTraceBarrier = new bool[Config.N];
            canRewind = false;

            ParseFinish(Config.finish);

            workload = new Workload(Config.traceFilenames);

            mapping = new NodeMapping_AllCPU_SharedCache();

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
            {
                Coord c = new Coord(n);
                nodes[n] = new Node(mapping, c);
                routers[n] = MakeRouter(c);
                nodes[n].setRouter(routers[n]);
                routers[n].setNode(nodes[n]);
                endOfTraceBarrier[n] = false;
            }

            // create the Golden manager
            golden = new Golden();

            if (Config.RouterEvaluation)
                return;

            // connect the network with Links
            for (int n = 0; n < Config.N; n++)
            {
                int x, y;
                Coord.getXYfromID(n, out x, out y);

                // inter-router links
                for (int dir = 0; dir < 4; dir++)
                {
                    int oppDir = (dir + 2) % 4; // direction from neighbor's perspective

                    // determine neighbor's coordinates
                    int x_, y_;
                    switch (dir)
                    {
                        case Simulator.DIR_UP: x_ = x; y_ = y + 1; break;
                        case Simulator.DIR_DOWN: x_ = x; y_ = y - 1; break;
                        case Simulator.DIR_RIGHT: x_ = x + 1; y_ = y; break;
                        case Simulator.DIR_LEFT: x_ = x - 1; y_ = y; break;
                        default: continue;
                    }

                    // If we are a torus, we manipulate x_ and y_
                    if(Config.torus)
                    {
                      if(x_ < 0)
                        x_ += X;
                      else if(x_ >= X)
                        x_ -= X;

                      if(y_ < 0)
                        y_ += Y;
                      else if(y_ >= Y)
                        y_ -= Y;
                    }
                    // mesh, not torus: detect edge
                    else if (x_ < 0 || x_ >= X || y_ < 0 || y_ >= Y)
                    {
                        if (Config.edge_loop)
                        {
                            Link edgeL = new Link(Config.router.linkLatency - 1);
                            links.Add(edgeL);

                            routers[Coord.getIDfromXY(x, y)].linkOut[dir] = edgeL;
                            routers[Coord.getIDfromXY(x, y)].linkIn[dir] = edgeL;
                            routers[Coord.getIDfromXY(x, y)].neighbors++;
                            routers[Coord.getIDfromXY(x, y)].neigh[dir] =
                                routers[Coord.getIDfromXY(x, y)];
                        }

                        continue;
                    }

                    // ensure no duplication by handling a link at the lexicographically
                    // first router
                    if (x_ < x || (x_ == x && y_ < y)) continue;

                    // Link param is *extra* latency (over the standard 1 cycle)
                    Link dirA = new Link(Config.router.linkLatency - 1);
                    Link dirB = new Link(Config.router.linkLatency - 1);
                    links.Add(dirA);
                    links.Add(dirB);

                    // link 'em up
                    routers[Coord.getIDfromXY(x, y)].linkOut[dir] = dirA;
                    routers[Coord.getIDfromXY(x_, y_)].linkIn[oppDir] = dirA;

                    routers[Coord.getIDfromXY(x, y)].linkIn[dir] = dirB;
                    routers[Coord.getIDfromXY(x_, y_)].linkOut[oppDir] = dirB;

                    routers[Coord.getIDfromXY(x, y)].neighbors++;
                    routers[Coord.getIDfromXY(x_, y_)].neighbors++;

                    routers[Coord.getIDfromXY(x, y)].neigh[dir] = routers[Coord.getIDfromXY(x_, y_)];
                    routers[Coord.getIDfromXY(x_, y_)].neigh[oppDir] = routers[Coord.getIDfromXY(x, y)];

                    if (Config.router.algorithm == RouterAlgorithm.DR_SCARAB)
                    {
                        for (int wireNr = 0; wireNr < Config.nack_nr; wireNr++)
                        {
                            Link nackA = new Link(Config.nack_linkLatency - 1);
                            Link nackB = new Link(Config.nack_linkLatency - 1);
                            links.Add(nackA);
                            links.Add(nackB);
                            ((Router_SCARAB)routers[Coord.getIDfromXY(x, y)]).nackOut[dir * Config.nack_nr + wireNr] = nackA;
                            ((Router_SCARAB)routers[Coord.getIDfromXY(x_, y_)]).nackIn[oppDir * Config.nack_nr + wireNr] = nackA;

                            ((Router_SCARAB)routers[Coord.getIDfromXY(x, y)]).nackIn[dir * Config.nack_nr + wireNr] = nackB;
                            ((Router_SCARAB)routers[Coord.getIDfromXY(x_, y_)]).nackOut[oppDir * Config.nack_nr + wireNr] = nackB;
                        }
                    }
                }
            }

            if (Config.torus)
                for (int i = 0; i < Config.N; i++)
                    if (routers[i].neighbors < 4)
                        throw new Exception("torus construction not successful!");
        }
Ejemplo n.º 14
0
        public void ftflySetup()
        {
            if (Config.router.algorithm != RouterAlgorithm.DR_FLIT_SWITCHED_OLDEST_FIRST
                    && Config.router.algorithm != RouterAlgorithm.DR_AFC
                    && Config.router.algorithm != RouterAlgorithm.DR_FLIT_SWITCHED_CALF)
                throw new Exception(String.Format("Flattened butteryfly network does not support {0}", Config.router.algorithm));

            routers = new Router[Config.N];
            nodes = new Node[Config.N];
            links = new List<Link>();
            cache = new CmpCache();

            ParseFinish(Config.finish);

            workload = new Workload(Config.traceFilenames);

            mapping = new NodeMapping_AllCPU_SharedCache();

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
            {
                Coord c = new Coord(n);
                nodes[n] = new Node(mapping, c);
                routers[n] = MakeRouter(c);
                nodes[n].setRouter(routers[n]);
                routers[n].setNode(nodes[n]);
            }

            // create the Golden manager
            golden = new Golden();

            if (Config.RouterEvaluation)
                return;

            // connect the network with Links
            for (int n = 0; n < Config.N; n++)
            {
                int x, y;
                Coord.getXYfromID(n, out x, out y);
#if DEBUG
                Console.WriteLine("NETWORK SETUP: coord ({0},{1}) ID {2}",x,y,n);
#endif
                // inter-router links
                for (int dir = 0; dir < 8; dir++)
                {
                    //if same coordinates
                    if(dir==x)
                        continue;
                    if(dir>=4 && dir%4==y)
                        continue;

                    int oppDir = (dir<4)?(x):(4+y);// direction from neighbor's perspective

                    // determine neighbor's coordinates
                    int x_, y_;
                    switch (dir)
                    {
                        case Simulator.DIR_Y_0: x_ = x; y_ = 0;break;
                        case Simulator.DIR_Y_1: x_ = x; y_ = 1; break;
                        case Simulator.DIR_Y_2: x_ = x; y_ = 2; break;
                        case Simulator.DIR_Y_3: x_ = x; y_ = 3; break;
                        case Simulator.DIR_X_0: x_ = 0; y_ = y; break;
                        case Simulator.DIR_X_1: x_ = 1; y_ = y; break;
                        case Simulator.DIR_X_2: x_ = 2; y_ = y; break;
                        case Simulator.DIR_X_3: x_ = 3; y_ = y; break;
                        default: continue;
                    }
                    // mesh, not torus: detect edge
                    // This part is for torus setup
                    if (x_ < 0 || x_ >= X || y_ < 0 || y_ >= Y)
                    {
                        if (Config.edge_loop)
                        {
                            Link edgeL = new Link(Config.router.linkLatency - 1, n, dir);
                            links.Add(edgeL);

                            routers[Coord.getIDfromXY(x, y)].linkOut[dir] = edgeL;
                            routers[Coord.getIDfromXY(x, y)].linkIn[dir] = edgeL;
                            routers[Coord.getIDfromXY(x, y)].neighbors++;
                            throw new Exception("FTFLY shouldn't hit a torus network setup(edge_loop=true).");
                        }

                        continue;
                    }

                    // ensure no duplication by handling a link at the lexicographically
                    // first router
                    // for flattened butterfly, it's fine cuz it's going to overwrite it
                    if (x_ < x || (x_ == x && y_ < y)) continue;

                    //Console.WriteLine("dst ({0},{1})",x_,y_);

                    /* The setup is row wise going upward */
                    int link_lat=Config.router.linkLatency-1;

                    // Extra latency to links that have longer hops.
                    if(Math.Abs(x-x_)>1)
                        link_lat+=Math.Abs(x-x_);
                    if(Math.Abs(y-y_)>1)
                        link_lat+=Math.Abs(y-y_);

                    // an extra cycle on router b/c of higher radix routers
                    // for bless. However, this extra cycle is modeled in
                    // chipper by having a larger sorting network.
                    if (Config.router.algorithm != RouterAlgorithm.DR_FLIT_SWITCHED_CALF)
                        link_lat++;

                    Link dirA = new Link(link_lat, n, dir);
                    Link dirB = new Link(link_lat, n, dir);
                    links.Add(dirA);
                    links.Add(dirB);

                    // link 'em up
                    routers[Coord.getIDfromXY(x, y)].linkOut[dir] = dirA;
                    routers[Coord.getIDfromXY(x_, y_)].linkIn[oppDir] = dirA;

                    routers[Coord.getIDfromXY(x, y)].linkIn[dir] = dirB;
                    routers[Coord.getIDfromXY(x_, y_)].linkOut[oppDir] = dirB;

                    routers[Coord.getIDfromXY(x, y)].neighbors++;
                    routers[Coord.getIDfromXY(x_, y_)].neighbors++;

                    routers[Coord.getIDfromXY(x, y)].neigh[dir] = routers[Coord.getIDfromXY(x_, y_)];
                    routers[Coord.getIDfromXY(x_, y_)].neigh[oppDir] = routers[Coord.getIDfromXY(x, y)];
    
                    // DONE CARE for ftfly
                    if (Config.router.algorithm == RouterAlgorithm.DR_SCARAB)
                    {
                        for (int wireNr = 0; wireNr < Config.nack_nr; wireNr++)
                        {
                            Link nackA = new Link(Config.nack_linkLatency - 1, n, dir);
                            Link nackB = new Link(Config.nack_linkLatency - 1, n, dir);
                            links.Add(nackA);
                            links.Add(nackB);
                            ((Router_SCARAB)routers[Coord.getIDfromXY(x, y)]).nackOut[dir * Config.nack_nr + wireNr] = nackA;
                            ((Router_SCARAB)routers[Coord.getIDfromXY(x_, y_)]).nackIn[oppDir * Config.nack_nr + wireNr] = nackA;

                            ((Router_SCARAB)routers[Coord.getIDfromXY(x, y)]).nackIn[dir * Config.nack_nr + wireNr] = nackB;
                            ((Router_SCARAB)routers[Coord.getIDfromXY(x_, y_)]).nackOut[oppDir * Config.nack_nr + wireNr] = nackB;
                        }
                    }
                }
            }
            for (int n = 0; n < Config.N; n++)
            {
               int x, y;
               Coord.getXYfromID(n, out x, out y);
               //Console.WriteLine("router {0}-({1},{2}):{3}",n,x,y,routers[n].neighbors); 
            }
        }
Ejemplo n.º 15
0
        public override void setup()
        {
            if (Config.N != 64)
            {
                throw new Exception("HR_8_16drop only suport 8x8 network");
            }
            nodeRouters   = new Router_Node[Config.N];
            bridgeRouters = new Router_Bridge[16];
            nodes         = new Node[Config.N];
            links         = new List <Link>();
            cache         = new CmpCache();

            ParseFinish(Config.finish);

            workload = new Workload(Config.traceFilenames);

            mapping = new NodeMapping_AllCPU_SharedCache();

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
            {
                Coord    c    = new Coord(n);
                RC_Coord RC_c = new RC_Coord(n);

                nodes[n]       = new Node(mapping, c);
                nodeRouters[n] = new Router_Node(RC_c, c);
                nodes[n].setRouter(nodeRouters[n]);
                nodeRouters[n].setNode(nodes[n]);
            }
            for (int n = 0; n < 16; n++)
            {
                bridgeRouters[n] = new Router_Bridge(n, Config.GlobalRingWidth);
            }
            // connect the network with Links
            for (int n = 0; n < 4; n++)
            {
                for (int i = 0; i < 8; i++)
                {
                    int ID = n * 8 + i;
                    if (ID % 2 == 1)
                    {
                        continue;
                    }
                    int  next = ID + 1;
                    Link dirA = new Link(Config.router.switchLinkLatency - 1);
                    Link dirB = new Link(Config.router.switchLinkLatency - 1);
                    links.Add(dirA);
                    links.Add(dirB);
                    nodeRouters[ID].linkOut[CW]    = dirA;
                    nodeRouters[next].linkIn[CW]   = dirA;
                    nodeRouters[ID].linkIn[CCW]    = dirB;
                    nodeRouters[next].linkOut[CCW] = dirB;
                }
            }
            int [] Gnext = { 2, 5, 4, 1, 6, 7, 10, 9, 14, 11, 8, 15, 0, 3, 12, 13 };
            for (int n = 0; n < 16; n++)
            {
                int  next = n * 2;
                int  pre  = (next - 1 + 8) % 8 + n / 4 * 8;
                Link dirA = new Link(Config.router.switchLinkLatency - 1);
                Link dirB = new Link(Config.router.switchLinkLatency - 1);
                Link dirC = new Link(Config.router.switchLinkLatency - 1);
                Link dirD = new Link(Config.router.switchLinkLatency - 1);
                links.Add(dirA);
                links.Add(dirB);
                links.Add(dirC);
                links.Add(dirD);
                bridgeRouters[n].LLinkOut[CW]  = dirA;
                nodeRouters[next].linkIn[CW]   = dirA;
                bridgeRouters[n].LLinkIn[CCW]  = dirB;
                nodeRouters[next].linkOut[CCW] = dirB;

                bridgeRouters[n].LLinkOut[CCW] = dirC;
                nodeRouters[pre].linkIn[CCW]   = dirC;
                bridgeRouters[n].LLinkIn[CW]   = dirD;
                nodeRouters[pre].linkOut[CW]   = dirD;

                for (int i = 0; i < Config.GlobalRingWidth; i++)
                {
                    dirA = new Link(2 - 1);
                    dirB = new Link(2 - 1);
                    links.Add(dirA);
                    links.Add(dirB);
                    bridgeRouters[n].GLinkIn[i * 2 + 1]         = dirA;
                    bridgeRouters[Gnext[n]].GLinkOut[i * 2 + 1] = dirA;
                    bridgeRouters[n].GLinkOut[i * 2]            = dirB;
                    bridgeRouters[Gnext[n]].GLinkIn[i * 2]      = dirB;
                }
            }
        }
Ejemplo n.º 16
0
       	public void setup_RingCluster_4()
       	{
       		nodeRouters = new Router_Node[Config.N];
       		connectRouters = new Router_Connect[6];
            nodes = new Node[Config.N];
            links = new List<Link>();
            cache = new CmpCache();

            ParseFinish(Config.finish);

            workload = new Workload(Config.traceFilenames);

            mapping = new NodeMapping_AllCPU_SharedCache();

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
            {
                Coord c = new Coord(n);
                nodes[n] = new Node(mapping, c);
                 
                nodeRouters[n] = new Router_Node(c); 
                nodes[n].setRouter(nodeRouters[n]);                                
                nodeRouters[n].setNode(nodes[n]);
            }
            for (int n = 0; n < 6; n++)
            	connectRouters[n] = new Router_Connect(n);
            
            for (int n = 0; n < Config.N / 4; n++)  // n is the cluster number
            {
            	for (int i = 0; i < 4; i++)  // for each node in the same cluster
            	{
            		if (n == 0 && i == 3 || n == 1 && i == 1 || n == 2 && i == 1 || n == 3 && i == 3)
            		{
	            		Link dirA = new Link(0);   
    	                Link dirB = new Link(0);                  	
    	                links.Add(dirA);                    	
    	                links.Add(dirB);
    	                int next = (i + 1 == 4)? n * 4 : n * 4 + i + 1;                    
    	        		nodeRouters[n * 4 + i].linkOut[CW] = dirA;
    	        		nodeRouters[next].linkIn[CW] = dirA;
    	        		nodeRouters[next].linkOut[CCW] = dirB;
    	        		nodeRouters[n * 4 + i].linkIn[CCW] = dirB;            		
            		}
            	}
            }
            for (int n = 0; n < 6; n++)
            {
            	Link dirA = new Link(Config.router.linkLatency - 1);	            	
            	Link dirB = new Link(Config.router.linkLatency - 1);	            	
            	links.Add(dirA);
            	links.Add(dirB);
            	int[] node1 = new int[6] {1, 6, 11, 12, 0, 4};
            	nodeRouters[node1[n]].linkOut[CW] = dirA;
            	nodeRouters[node1[n]].linkIn[CCW] = dirB;
            	connectRouters[n].linkIn[L0] = dirA;
            	connectRouters[n].linkOut[L0] = dirB;
            	
            	dirA = new Link(Config.router.linkLatency - 1);
            	dirB = new Link(Config.router.linkLatency - 1);	            	            	
            	links.Add(dirA);
            	links.Add(dirB);
            	int[] node2 = new int[6] {2, 7, 8, 13, 1, 5};
            	nodeRouters[node2[n]].linkOut[CCW] = dirA;
            	nodeRouters[node2[n]].linkIn[CW] = dirB;
            	connectRouters[n].linkIn[L3] = dirA;
            	connectRouters[n].linkOut[L3] = dirB;
            	
            	dirA = new Link(Config.router.linkLatency - 1);
            	dirB = new Link(Config.router.linkLatency - 1);	            	            	
            	links.Add(dirA);
            	links.Add(dirB);
            	int[] node3 = new int[6] {4, 9, 14, 3, 15, 11};
            	nodeRouters[node3[n]].linkOut[CCW] = dirA;
            	nodeRouters[node3[n]].linkIn[CW] = dirB;
            	connectRouters[n].linkIn[L1] = dirA;
            	connectRouters[n].linkOut[L1] = dirB;
            	
            	dirA = new Link(Config.router.linkLatency - 1);
            	dirB = new Link(Config.router.linkLatency - 1);	            	            	
            	links.Add(dirA);
            	links.Add(dirB);
            	int[] node4 = new int[6] {7, 8, 13, 2, 14, 10};
            	nodeRouters[node4[n]].linkOut[CW] = dirA;
            	nodeRouters[node4[n]].linkIn[CCW] = dirB;
            	connectRouters[n].linkIn[L2] = dirA;
            	connectRouters[n].linkOut[L2] = dirB;
            }  
                    
       	}
Ejemplo n.º 17
0
        public void ftflySetup()
        {
            if (Config.router.algorithm != RouterAlgorithm.DR_FLIT_SWITCHED_OLDEST_FIRST &&
                Config.router.algorithm != RouterAlgorithm.DR_AFC &&
                Config.router.algorithm != RouterAlgorithm.DR_FLIT_SWITCHED_CALF)
            {
                throw new Exception(String.Format("Flattened butteryfly network does not support {0}", Config.router.algorithm));
            }

            routers = new Router[Config.N];
            nodes   = new Node[Config.N];
            links   = new List <Link>();
            cache   = new CmpCache();

            ParseFinish(Config.finish);

            workload = new Workload(Config.traceFilenames);

            mapping = new NodeMapping_AllCPU_SharedCache();

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
            {
                Coord c = new Coord(n);
                nodes[n]   = new Node(mapping, c);
                routers[n] = MakeRouter(c);
                nodes[n].setRouter(routers[n]);
                routers[n].setNode(nodes[n]);
            }

            // create the Golden manager
            golden = new Golden();

            if (Config.RouterEvaluation)
            {
                return;
            }

            // connect the network with Links
            for (int n = 0; n < Config.N; n++)
            {
                int x, y;
                Coord.getXYfromID(n, out x, out y);
#if DEBUG
                Console.WriteLine("NETWORK SETUP: coord ({0},{1}) ID {2}", x, y, n);
#endif
                // inter-router links
                for (int dir = 0; dir < 8; dir++)
                {
                    //if same coordinates
                    if (dir == x)
                    {
                        continue;
                    }
                    if (dir >= 4 && dir % 4 == y)
                    {
                        continue;
                    }

                    int oppDir = (dir < 4)?(x):(4 + y);// direction from neighbor's perspective

                    // determine neighbor's coordinates
                    int x_, y_;
                    switch (dir)
                    {
                    case Simulator.DIR_Y_0: x_ = x; y_ = 0; break;

                    case Simulator.DIR_Y_1: x_ = x; y_ = 1; break;

                    case Simulator.DIR_Y_2: x_ = x; y_ = 2; break;

                    case Simulator.DIR_Y_3: x_ = x; y_ = 3; break;

                    case Simulator.DIR_X_0: x_ = 0; y_ = y; break;

                    case Simulator.DIR_X_1: x_ = 1; y_ = y; break;

                    case Simulator.DIR_X_2: x_ = 2; y_ = y; break;

                    case Simulator.DIR_X_3: x_ = 3; y_ = y; break;

                    default: continue;
                    }
                    // mesh, not torus: detect edge
                    // This part is for torus setup
                    if (x_ < 0 || x_ >= X || y_ < 0 || y_ >= Y)
                    {
                        if (Config.edge_loop)
                        {
                            Link edgeL = new Link(Config.router.linkLatency - 1, n, dir);
                            links.Add(edgeL);

                            routers[Coord.getIDfromXY(x, y)].linkOut[dir] = edgeL;
                            routers[Coord.getIDfromXY(x, y)].linkIn[dir]  = edgeL;
                            routers[Coord.getIDfromXY(x, y)].neighbors++;
                            throw new Exception("FTFLY shouldn't hit a torus network setup(edge_loop=true).");
                        }

                        continue;
                    }

                    // ensure no duplication by handling a link at the lexicographically
                    // first router
                    // for flattened butterfly, it's fine cuz it's going to overwrite it
                    if (x_ < x || (x_ == x && y_ < y))
                    {
                        continue;
                    }

                    //Console.WriteLine("dst ({0},{1})",x_,y_);

                    /* The setup is row wise going upward */
                    int link_lat = Config.router.linkLatency - 1;

                    // Extra latency to links that have longer hops.
                    if (Math.Abs(x - x_) > 1)
                    {
                        link_lat += Math.Abs(x - x_);
                    }
                    if (Math.Abs(y - y_) > 1)
                    {
                        link_lat += Math.Abs(y - y_);
                    }

                    // an extra cycle on router b/c of higher radix routers
                    // for bless. However, this extra cycle is modeled in
                    // chipper by having a larger sorting network.
                    if (Config.router.algorithm != RouterAlgorithm.DR_FLIT_SWITCHED_CALF)
                    {
                        link_lat++;
                    }

                    Link dirA = new Link(link_lat, n, dir);
                    Link dirB = new Link(link_lat, n, dir);
                    links.Add(dirA);
                    links.Add(dirB);

                    // link 'em up
                    routers[Coord.getIDfromXY(x, y)].linkOut[dir]     = dirA;
                    routers[Coord.getIDfromXY(x_, y_)].linkIn[oppDir] = dirA;

                    routers[Coord.getIDfromXY(x, y)].linkIn[dir]       = dirB;
                    routers[Coord.getIDfromXY(x_, y_)].linkOut[oppDir] = dirB;

                    routers[Coord.getIDfromXY(x, y)].neighbors++;
                    routers[Coord.getIDfromXY(x_, y_)].neighbors++;

                    routers[Coord.getIDfromXY(x, y)].neigh[dir]      = routers[Coord.getIDfromXY(x_, y_)];
                    routers[Coord.getIDfromXY(x_, y_)].neigh[oppDir] = routers[Coord.getIDfromXY(x, y)];

                    // DONE CARE for ftfly
                    if (Config.router.algorithm == RouterAlgorithm.DR_SCARAB)
                    {
                        for (int wireNr = 0; wireNr < Config.nack_nr; wireNr++)
                        {
                            Link nackA = new Link(Config.nack_linkLatency - 1, n, dir);
                            Link nackB = new Link(Config.nack_linkLatency - 1, n, dir);
                            links.Add(nackA);
                            links.Add(nackB);
                            ((Router_SCARAB)routers[Coord.getIDfromXY(x, y)]).nackOut[dir * Config.nack_nr + wireNr]     = nackA;
                            ((Router_SCARAB)routers[Coord.getIDfromXY(x_, y_)]).nackIn[oppDir * Config.nack_nr + wireNr] = nackA;

                            ((Router_SCARAB)routers[Coord.getIDfromXY(x, y)]).nackIn[dir * Config.nack_nr + wireNr]       = nackB;
                            ((Router_SCARAB)routers[Coord.getIDfromXY(x_, y_)]).nackOut[oppDir * Config.nack_nr + wireNr] = nackB;
                        }
                    }
                }
            }
            for (int n = 0; n < Config.N; n++)
            {
                int x, y;
                Coord.getXYfromID(n, out x, out y);
                //Console.WriteLine("router {0}-({1},{2}):{3}",n,x,y,routers[n].neighbors);
            }
        }
Ejemplo n.º 18
0
        public void setup()
        {
            routers = new Router[Config.N * (1 + ((Config.RingRouter) ? Config.nrConnections : 0))];
            nodes = new Node[Config.N];
            links = new List<Link>();
            cache = new CmpCache();
            
            ringRouter = new RingRouter[Config.N * (1 + Config.nrConnections)];

            /*if(Config.disjointRings)
            {
            	bool ignoreCase = true;
            	if (String.Compare(Config.disjointConnection, "mesh", ignoreCase) == 0)
            		connector = new RingRouter[Config.N]; // Fix later
            	else if (String.Compare(Config.disjointConnection, "torus", ignoreCase) == 0)
            		connector = new RingRouter[Config.N];
            	else if (String.Compare(Config.disjointConnection, "ring", ignoreCase) == 0)
            		connector = new RingRouter[Config.N]; // Fix later
            }*/

            ParseFinish(Config.finish);

            workload = new Workload(Config.traceFilenames);

            mapping = new NodeMapping_AllCPU_SharedCache();

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
            {
                Coord c = new Coord(n);
                nodes[n] = new Node(mapping, c);
                
                if (!Config.RingRouter)
                {
                	routers[n] = MakeRouter(c);
                	nodes[n].setRouter(routers[n]);
                	routers[n].setNode(nodes[n]);
                }
            }
            /*if (Config.disjointRings)
	            for (int n = 0; n < 8; n++)
	            {
	              	connectors[n] = MakeConnector(n);
	            }
			*/
            // create the Golden manager
            golden = new Golden();

            if (Config.RouterEvaluation)
                return;
			
            /*
             * Ring width = node width of each ring
             * Ring height = node height of each ring
             * NrConnections = number of connections routers per node
             * 
             */
            if (Config.RingRouter)
            {
            	int nrPlaceholdersPerNetwork = Config.nrPlaceholders / 2;
                int nrNodesPerRing = (Config.ringWidth * 2 + Config.ringHeight * 2 - 4);
                int nrConnectPerRing = nrNodesPerRing * Config.nrConnections;
                int nrItemInRing = nrConnectPerRing + nrNodesPerRing;
                
                #if DEBUG
                	Console.WriteLine("NrNodesPerRing = {0}, NrConectPerRing = {1}, NrItemInRing = {2}", nrNodesPerRing, nrConnectPerRing, nrItemInRing);
                #endif
                int prevID = -1;
                
                // TODO: Check edge conditions of for loops.  Currently only using for 2x2 ring.
				bool clockwise = false;
                for (int y = 0; y < Config.network_nrY / Config.ringHeight; y++) {
                    for (int x = 0; x < Config.network_nrX / Config.ringWidth; x++) {
                    	if (Config.alternateDir)
                    	{
                    		clockwise = !clockwise;
                    	}
                    	else
                    	{
                    		clockwise = true;
                    	}
                    	prevID = -1;
                    	
                        for (int z = 0; z < nrItemInRing; z++)
                        {
                            int ringID = RingCoord.getIDfromXYZ(x, y, z);
                            int nodeID = RingCoord.getIDfromRingID(ringID);
                            RingCoord rc = new RingCoord(ringID);
                            
                            #if DEBUG
                            	Console.WriteLine("ringID = {0}, nodeID = {1}, prevID = {2}", ringID, nodeID, prevID);
                            #endif
                            
                            ringRouter[ringID] = makeNodeRouter(rc); 
                            
							ringRouter[ringID].clockwise = clockwise;
							
													                            
							routers[nodeID] = ringRouter[ringID];
							nodes[nodeID].setRouter(ringRouter[ringID]);
							ringRouter[ringID].setNode(nodes[nodeID]);

                            // Link them up if its not the first node in the loop
                            if (prevID != -1)
                            {
                            	Link prev = new Link(Config.router.linkLatency - 1);
                            	links.Add(prev);
                            	
                            	#if DEBUG
                            		Console.WriteLine("Connecting prev{0} & current{1} with link {2}", prevID, ringID, prev);
                            	#endif
                            	
                            	if (clockwise)
                            	{
                            		ringRouter[prevID].linkOut[Simulator.DIR_CW] = prev;
                            		ringRouter[ringID].linkIn[Simulator.DIR_CCW] = prev;
                            	}
                            	else
                            	{
                            		ringRouter[prevID].linkIn[Simulator.DIR_CW]   = prev;
                            		ringRouter[ringID].linkOut[Simulator.DIR_CCW] = prev;
                            	}
                            }
                            
                            prevID = ringID;
                            
                            // Connection routers
                            for (int i = 0; i < Config.nrConnections; i++)
                            {
                                z++;
                                int connectID = RingCoord.getIDfromXYZ(x, y, z);
                                int connect2ID = RingCoord.getIDfromRingID(connectID);
                                RingCoord connectRC = new RingCoord(connectID);
                                
                                ringRouter[connectID] = makeConnection(connectRC);
								ringRouter[connectID].clockwise = clockwise;
								
								
								routers[connect2ID] = ringRouter[connectID];
								
                                Link prev_link = new Link(Config.router.linkLatency - 1);
                                links.Add(prev_link);
                                
                                #if DEBUG
                            		Console.WriteLine("Connecting prev{0} & connect{1} with link {2}", prevID, connectID, prev_link);
                                #endif
                                
                                if (clockwise)
                            	{
                            		ringRouter[prevID].linkOut[Simulator.DIR_CW] = prev_link;
                            		ringRouter[connectID].linkIn[Simulator.DIR_CCW] = prev_link;
                            	}
                            	else
                            	{
                            		ringRouter[prevID].linkIn[Simulator.DIR_CW]   = prev_link;
                            		ringRouter[connectID].linkOut[Simulator.DIR_CCW] = prev_link;
                            	}
                                
                                prevID = connectID;
                            }
                        }
                        
                        // Finish ring
                        int startID = RingCoord.getIDfromXYZ(x, y, 0);
                       	Link finish_link = new Link(Config.router.linkLatency - 1); 
                       	links.Add(finish_link);
                        
                        #if DEBUG
                        Console.WriteLine("Finishing connecting prev{0} & start{1} with link {2}", prevID, startID, finish_link);
                        #endif
                        
                        if (clockwise)
                    	{
                    		ringRouter[prevID].linkOut[Simulator.DIR_CW]  = finish_link;
                    		ringRouter[startID].linkIn[Simulator.DIR_CCW] = finish_link;
                    	}
                    	else
                    	{
                    		ringRouter[prevID].linkIn[Simulator.DIR_CW]    = finish_link;
                    		ringRouter[startID].linkOut[Simulator.DIR_CCW] = finish_link;
                    	} 
                    }
                }
				
                
                if (Config.nrConnections > 1)
                	throw new Exception("Check the rest of the code before you continue making more connections");
				
				#if DEBUG
					Console.WriteLine("Starting connections....");
				#endif
				
                int connectionDir, oppDir;
                int oppX;
                int oppY;
                int oppZ;
               	int currentID, oppID;
                
                for (int y = 0; y < Config.network_nrY / Config.ringHeight; y++) {
					for (int x = 0; x < Config.network_nrX / Config.ringWidth; x++) {
                	 	for (int z = 0; z < nrItemInRing; z++) {
                	 		for (int i = 0; i < Config.nrConnections; i++) {
                	 			//TODO: reconfigure for more than a 4x4 network and/or more connections
                	 			
                	 			z++;
                	 			connectionDir = -1;
                	 			oppDir = -1;
                	 			currentID = -1;
                	 			oppID = -1;
                	 			oppX = x;
                	 			oppY = y;
                	 			oppZ = z + 4;
                	 			
                	 			if(oppZ > nrItemInRing)
                	 				oppZ -= nrItemInRing;
 								
                	 			currentID  = RingCoord.getIDfromXYZ(x, y, z);
	 							
                    			
                    			#if DEBUG
                	 				Console.WriteLine("Current Coord ({0},{1},{2})", x, y, z);
                	 			#endif
                	 			
                	 			int switchNum = (z - 1) / 2;
                	 			switch (switchNum)
                	 			{
                	 				case 0: connectionDir = Simulator.DIR_UP;
                	 						oppDir = Simulator.DIR_DOWN;
                	 						oppY = y - 1;
                	 						
                	 						#if DEBUG
                	 							Console.WriteLine("0");
                	 						#endif
                	 						
                	 						if (oppY < 0)
                	 						{
                	 							oppY = Config.network_nrY / Config.ringHeight - 1;
                	 							
                	 							// ensure no duplication by handling a link at the lexicographically
                    							// first router
                    							if (oppX < x || (oppX == x && oppY < y)) continue;
                	 							
                	 							if (!Config.torus)
                	 							{
                	 								//Lower the link latency because this router is not being used
                	 								oppID = RingCoord.getIDfromXYZ(oppX, oppY, oppZ);
													int nextZ = ((z + 1) > nrItemInRing - 1) ? 0 : z+1;
													int prevZ = ((z - 1) < 0) ? nrItemInRing - 1 : z-1;
													int nextID = RingCoord.getIDfromXYZ(x, y, nextZ);
													int previousID = RingCoord.getIDfromXYZ(x, y, prevZ);
													
													#if DEBUG
														Console.WriteLine("opp({0},{1},{2})\tnextID {3}, currentID {4}, previousID {5}", oppX, oppY, oppZ, nextID, currentID, previousID);
													#endif
													
													if (ringRouter[nextID].clockwise) {
														ringRouter[nextID].linkIn[Simulator.DIR_CCW] = ringRouter[previousID].linkOut[Simulator.DIR_CW];
														ringRouter[currentID].linkIn[Simulator.DIR_CCW] = ringRouter[currentID].linkOut[Simulator.DIR_CW];
													}
													else {
														ringRouter[previousID].linkIn[Simulator.DIR_CW] = ringRouter[nextID].linkOut[Simulator.DIR_CCW];
														ringRouter[currentID].linkIn[Simulator.DIR_CW] = ringRouter[currentID].linkOut[Simulator.DIR_CCW];
													}
													
													nextZ = ((oppZ + 1) > nrItemInRing - 1) ? 0 : oppZ+1;
													prevZ = ((oppZ - 1) < 0) ? nrItemInRing - 1 : oppZ-1;
													nextID = RingCoord.getIDfromXYZ(oppX, oppY, nextZ);
													previousID = RingCoord.getIDfromXYZ(oppX, oppY, prevZ);
															
													#if DEBUG
														Console.WriteLine("opp({0},{1},{2})\tnextID {3}, oppID {4}, previousID {5}", oppX, oppY, oppZ, nextID, oppID, previousID);
													#endif
													
													if (ringRouter[nextID].clockwise) {													
														ringRouter[nextID].linkIn[Simulator.DIR_CCW] = ringRouter[previousID].linkOut[Simulator.DIR_CW];
														ringRouter[oppID].linkIn[Simulator.DIR_CCW] = ringRouter[oppID].linkOut[Simulator.DIR_CW];
													}
													else {
														ringRouter[previousID].linkIn[Simulator.DIR_CW] = ringRouter[nextID].linkOut[Simulator.DIR_CCW];
														ringRouter[oppID].linkIn[Simulator.DIR_CW] = ringRouter[oppID].linkOut[Simulator.DIR_CCW];
													}
													ringRouter[currentID] = null;
													ringRouter[oppID] = null;
       	 								    		continue;
                	 							}
                	 						}
                	 							
                	 						break;
                	 						
                	 				case 1: connectionDir = Simulator.DIR_RIGHT;
                	 						oppDir = Simulator.DIR_LEFT;
                	 						oppX = x + 1;
                	 						
                	 						#if DEBUG
                	 							Console.WriteLine("1");
                	 						#endif
                	 						
                	 						if (oppX >= Config.network_nrX / Config.ringWidth)
                	 						{
                	 							oppX = 0;
                	 							
                	 							// ensure no duplication by handling a link at the lexicographically
                    							// first router
                    							if (oppX < x || (oppX == x && oppY < y)) continue;
                    							
                	 							if (!Config.torus)
                	 							{
                	 								//Lower the link latency because this router is not being used
                	 								oppID = RingCoord.getIDfromXYZ(oppX, oppY, oppZ);
													int nextZ = ((z + 1) > nrItemInRing - 1) ? 0 : z+1;
													int prevZ = ((z - 1) < 0) ? nrItemInRing - 1 : z-1;
													int nextID = RingCoord.getIDfromXYZ(x, y, nextZ);
													int previousID = RingCoord.getIDfromXYZ(x, y, prevZ);
													
													#if DEBUG
														Console.WriteLine("opp({0},{1},{2})\tnextID {3}, currentID {4}, previousID {5}", oppX, oppY, oppZ, nextID, currentID, previousID);
													#endif
													
													if (ringRouter[nextID].clockwise) {
														ringRouter[nextID].linkIn[Simulator.DIR_CCW] = ringRouter[previousID].linkOut[Simulator.DIR_CW];
														ringRouter[currentID].linkIn[Simulator.DIR_CCW] = ringRouter[currentID].linkOut[Simulator.DIR_CW];
													}
													else {
														ringRouter[previousID].linkIn[Simulator.DIR_CW] = ringRouter[nextID].linkOut[Simulator.DIR_CCW];
														ringRouter[currentID].linkIn[Simulator.DIR_CW] = ringRouter[currentID].linkOut[Simulator.DIR_CCW];
													}
													
													nextZ = ((oppZ + 1) > nrItemInRing - 1) ? 0 : oppZ+1;
													prevZ = ((oppZ - 1) < 0) ? nrItemInRing - 1 : oppZ-1;
													nextID = RingCoord.getIDfromXYZ(oppX, oppY, nextZ);
													previousID = RingCoord.getIDfromXYZ(oppX, oppY, prevZ);
													
													#if DEBUG
														Console.WriteLine("opp({0},{1},{2})\tnextID {3}, oppID {4}, previousID {5}", oppX, oppY, oppZ, nextID, oppID, previousID);
													#endif
													
													if (ringRouter[nextID].clockwise) {
														ringRouter[nextID].linkIn[Simulator.DIR_CCW] = ringRouter[previousID].linkOut[Simulator.DIR_CW];
														ringRouter[oppID].linkIn[Simulator.DIR_CCW] = ringRouter[oppID].linkOut[Simulator.DIR_CW];
													}
													else {
														ringRouter[previousID].linkIn[Simulator.DIR_CW] = ringRouter[nextID].linkOut[Simulator.DIR_CCW];
														ringRouter[oppID].linkIn[Simulator.DIR_CW] = ringRouter[oppID].linkOut[Simulator.DIR_CCW];
													}
													ringRouter[currentID] = null;
													ringRouter[oppID] = null;
       	 								    		continue;
                	 							}
                	 						}
                	 							
                	 						break;	

                	 				case 2: connectionDir = Simulator.DIR_DOWN;
                	 						oppDir = Simulator.DIR_UP;
                	 						oppY = y + 1;
                	 						
                	 						#if DEBUG
                	 							Console.WriteLine("2");
                	 						#endif
                	 						
                	 						if (oppY >= Config.network_nrY / Config.ringHeight)
                	 						{
                	 							oppY = 0;
                	 							
                	 							// ensure no duplication by handling a link at the lexicographically
                    							// first router
                    							if (oppX < x || (oppX == x && oppY < y)) continue;
                	 							
                	 							if (!Config.torus)
                	 							{
                	 								//Lower the link latency because this router is not being used
                	 								oppID = RingCoord.getIDfromXYZ(oppX, oppY, oppZ);
													int nextZ = ((z + 1) > nrItemInRing - 1) ? 0 : z+1;
													int prevZ = ((z - 1) < 0) ? nrItemInRing - 1 : z-1;
													int nextID = RingCoord.getIDfromXYZ(x, y, nextZ);
													int previousID = RingCoord.getIDfromXYZ(x, y, prevZ);
													
													#if DEBUG
														Console.WriteLine("opp({0},{1},{2})\tnextID {3}, currentID {4}, previousID {5}", oppX, oppY, oppZ, nextID, currentID, previousID);
													#endif
													
													if (ringRouter[nextID].clockwise) {
														ringRouter[nextID].linkIn[Simulator.DIR_CCW] = ringRouter[previousID].linkOut[Simulator.DIR_CW];
														ringRouter[currentID].linkIn[Simulator.DIR_CCW] = ringRouter[currentID].linkOut[Simulator.DIR_CW];
													}
													else {
														ringRouter[previousID].linkIn[Simulator.DIR_CW] = ringRouter[nextID].linkOut[Simulator.DIR_CCW];
														ringRouter[currentID].linkIn[Simulator.DIR_CW] = ringRouter[currentID].linkOut[Simulator.DIR_CCW];
													}
													
													nextZ = ((oppZ + 1) > nrItemInRing - 1) ? 0 : oppZ+1;
													prevZ = ((oppZ - 1) < 0) ? nrItemInRing - 1 : oppZ-1;
													nextID = RingCoord.getIDfromXYZ(oppX, oppY, nextZ);
													previousID = RingCoord.getIDfromXYZ(oppX, oppY, prevZ);
													
													#if DEBUG
														Console.WriteLine("opp({0},{1},{2})\tnextID {3}, oppID {4}, previousID {5}", oppX, oppY, oppZ, nextID, oppID, previousID);
													#endif
													
													if (ringRouter[nextID].clockwise) {
														ringRouter[nextID].linkIn[Simulator.DIR_CCW] = ringRouter[previousID].linkOut[Simulator.DIR_CW];
														ringRouter[oppID].linkIn[Simulator.DIR_CCW] = ringRouter[oppID].linkOut[Simulator.DIR_CW];
													}
													else {
														ringRouter[previousID].linkIn[Simulator.DIR_CW] = ringRouter[nextID].linkOut[Simulator.DIR_CCW];
														ringRouter[oppID].linkIn[Simulator.DIR_CW] = ringRouter[oppID].linkOut[Simulator.DIR_CCW];
													}
													ringRouter[currentID] = null;
													ringRouter[oppID] = null;
       	 								    		continue;
                	 							}
                	 						}
                	 							
                	 						break;

                	 				case 3: connectionDir = Simulator.DIR_LEFT;
                	 				
                	 						#if DEBUG
                	 							Console.WriteLine("3");
                	 						#endif
                	 						
                	 						oppDir = Simulator.DIR_RIGHT;
                	 						oppX = x - 1;
                	 				        if (oppX < 0)
                	 						{
                	 							oppX = Config.network_nrX / Config.ringWidth - 1;
										
        										// ensure no duplication by handling a link at the lexicographically
                    							// first router
                    							if (oppX < x || (oppX == x && oppY < y)) continue;
                    							
                    							if (!Config.torus)
                	 							{
                	 								//Lower the link latency because this router is not being used
                	 								oppID = RingCoord.getIDfromXYZ(oppX, oppY, oppZ);
													int nextZ = ((z + 1) > nrItemInRing - 1) ? 0 : z+1;
													int prevZ = ((z - 1) < 0) ? nrItemInRing - 1 : z-1;
													int nextID = RingCoord.getIDfromXYZ(x, y, nextZ);
													int previousID = RingCoord.getIDfromXYZ(x, y, prevZ);
													
													#if DEBUG
														Console.WriteLine("opp({0},{1},{2})\tnextID {3}, currentID {4}, previousID {5}", oppX, oppY, oppZ, nextID, currentID, previousID);
													#endif
													
													if (ringRouter[nextID].clockwise) {
														ringRouter[nextID].linkIn[Simulator.DIR_CCW] = ringRouter[previousID].linkOut[Simulator.DIR_CW];
														ringRouter[currentID].linkIn[Simulator.DIR_CCW] = ringRouter[currentID].linkOut[Simulator.DIR_CW];
													}
													else {
														ringRouter[previousID].linkIn[Simulator.DIR_CW] = ringRouter[nextID].linkOut[Simulator.DIR_CCW];
														ringRouter[currentID].linkIn[Simulator.DIR_CW] = ringRouter[currentID].linkOut[Simulator.DIR_CCW];
													}
													
													nextZ = ((oppZ + 1) > nrItemInRing - 1) ? 0 : oppZ+1;
													prevZ = ((oppZ - 1) < 0) ? nrItemInRing - 1 : oppZ-1;
													nextID = RingCoord.getIDfromXYZ(oppX, oppY, nextZ);
													previousID = RingCoord.getIDfromXYZ(oppX, oppY, prevZ);
													
													#if DEBUG
														Console.WriteLine("opp({0},{1},{2})\tnextID {3}, oppID {4}, previousID {5}", oppX, oppY, oppZ, nextID, oppID, previousID);
													#endif	
																
													if (ringRouter[nextID].clockwise) {
														ringRouter[nextID].linkIn[Simulator.DIR_CCW] = ringRouter[previousID].linkOut[Simulator.DIR_CW];
														ringRouter[oppID].linkIn[Simulator.DIR_CCW] = ringRouter[oppID].linkOut[Simulator.DIR_CW];
													}
													else {
														ringRouter[previousID].linkIn[Simulator.DIR_CW] = ringRouter[nextID].linkOut[Simulator.DIR_CCW];
														ringRouter[oppID].linkIn[Simulator.DIR_CW] = ringRouter[oppID].linkOut[Simulator.DIR_CCW];
													}
													ringRouter[currentID] = null;
													ringRouter[oppID] = null;
       	 								    		continue;
                	 							}
                	 						}
                	 						break;	
                	 						
                	 				default: throw new Exception("Ring too big for current system");
                	 			}
                	 			
								oppID = RingCoord.getIDfromXYZ(oppX, oppY, oppZ);
								
								// ensure no duplication by handling a link at the lexicographically
                    			// first router
                    			if (oppX < x || (oppX == x && oppY < y)) continue;													
								#if DEBUG
									Console.WriteLine("Creating normal link\topp({0},{1},{2})\toppID {3} dir {4} : oppdir {5}", oppX, oppY, oppZ, oppID, connectionDir, oppDir);
								#endif	
								
								Link linkA = new Link(Config.router.linkLatency - 1);
								Link linkB = new Link(Config.router.linkLatency - 1);
								links.Add(linkA);
								links.Add(linkB);
								
								#if DEBUG
                	 				Console.WriteLine("-------------------------------------------current{0} opp{1}", currentID, oppID);
								#endif
								
								((Connector)ringRouter[currentID]).connectionDirection    = connectionDir;
								((Connector)ringRouter[oppID]).connectionDirection        = oppDir;
								
								ringRouter[currentID].linkOut[connectionDir] = linkA;
								ringRouter[oppID].linkIn[oppDir]             = linkA;
								 
								ringRouter[currentID].linkIn[connectionDir]  = linkB;
								ringRouter[oppID].linkOut[oppDir]            = linkB;		
								
								if (nrPlaceholdersPerNetwork > 0) {
									((Connector)ringRouter[currentID]).injectPlaceholder = 2;
									nrPlaceholdersPerNetwork--;
								}
                	 		}
                	 	}
                	 			
                	}
                }
                #if DEBUG
				//Verification
				for (int y = 0; y < Config.network_nrY / Config.ringHeight; y++) {
					for (int x = 0; x < Config.network_nrX / Config.ringWidth; x++) {
						Console.WriteLine("");
						for (int z = 0; z < nrItemInRing; z++) {
							int tempID = RingCoord.getIDfromXYZ(x, y, z);
							if (ringRouter[tempID] == null) continue;
							if(z % 2 == 0) Console.WriteLine("Node with clockwise = {0}", ringRouter[tempID].clockwise);
							if(z % 2 == 1) Console.WriteLine("Connector with direction {0}", ((Connector)ringRouter[tempID]).connectionDirection);
							
							if (ringRouter[tempID].clockwise) {
								for (int dir = 5; dir >= 0; dir--) {
									if(ringRouter[tempID].linkIn[dir] != null)
										Console.WriteLine("{0} | ID:{1},  \tLinkIn  Direction {2}, \tLink: {3}\t|", ringRouter[tempID], tempID, dir, ringRouter[tempID].linkIn[dir]);
								}	
								for (int dir = 0; dir < 6; dir++) {
									if(ringRouter[tempID].linkOut[dir] != null)
										Console.WriteLine("{0} | ID:{1},  \tLinkOut Direction {2}, \tLink: {3}\t|", ringRouter[tempID], tempID, dir, ringRouter[tempID].linkOut[dir]);
								}
							}
							else {
								for (int dir = 5; dir >= 0; dir--) {
									if(ringRouter[tempID].linkOut[dir] != null)
										Console.WriteLine("{0} | ID:{1},  \tLinkOut Direction {2}, \tLink: {3}\t|", ringRouter[tempID], tempID, dir, ringRouter[tempID].linkOut[dir]);
								}
								for (int dir = 0; dir < 6; dir++) {
									if(ringRouter[tempID].linkIn[dir] != null)
										Console.WriteLine("{0} | ID:{1},  \tLinkIn  Direction {2}, \tLink: {3}\t|", ringRouter[tempID], tempID, dir, ringRouter[tempID].linkIn[dir]);
								}	
							}
						}
					}
				}
				#endif
                return;
            }

            /*
			if (Config.DisjointRings)
			{
				if (Config.SeperateConnect)
				{
					if (Config.network_nrX != Config.network_nrY)
						throw new Exception("Only works with square networks");
					
					// Designed for ringSize of 2
					// And square network
					// TODO: work on different dimensions
					
					int ringLength = Config.ringSize;
					int netXLength = Config.network_nrX;
					int netYLength = Config.network_nrY;
					
					int numRings = (netYLength / ringLength) * (netXLength / ringLength);
					int numRingNodes = (ringLength * ringLength);
					
					int dirOut    = 1;
					int dirIn     = 0;
					int dirInject = 2;
					int dirEject  = 3;
					
					Link A_B   = new Link(Config.router.linkLatency - 1);
					Link B_Z1A = new Link(Config.router.linkLatency - 1);
					Link Z1A_C = new Link(Config.router.linkLatency - 1); 
					Link C_Z4B = new Link(Config.router.linkLatency - 1);
					Link Z4B_D = new Link(Config.router.linkLatency - 1);
					Link D_A   = new Link(Config.router.linkLatency - 1);
					
					Link E_F   = new Link(Config.router.linkLatency - 1);
					Link F_G   = new Link(Config.router.linkLatency - 1);
					Link G_Z2A = new Link(Config.router.linkLatency - 1);
					Link Z2A_H = new Link(Config.router.linkLatency - 1);
					Link H_Z1B = new Link(Config.router.linkLatency - 1);
					Link Z1B_E = new Link(Config.router.linkLatency - 1);
					
					Link M_Z2B = new Link(Config.router.linkLatency - 1);
					Link Z2B_N = new Link(Config.router.linkLatency - 1);
					Link N_O   = new Link(Config.router.linkLatency - 1);
					Link O_P   = new Link(Config.router.linkLatency - 1);
					Link P_Z3A = new Link(Config.router.linkLatency - 1);
					Link Z3A_M = new Link(Config.router.linkLatency - 1);
					
					Link I_Z4A = new Link(Config.router.linkLatency - 1);
					Link Z4A_J = new Link(Config.router.linkLatency - 1);
					Link J_Z3B = new Link(Config.router.linkLatency - 1);
					Link Z3B_K = new Link(Config.router.linkLatency - 1);
					Link K_L   = new Link(Config.router.linkLatency - 1);
					Link L_I   = new Link(Config.router.linkLatency - 1);
					
					Link A_B1 = new Link(Config.router.linkLatency - 1);
					Link B_A1 = new Link(Config.router.linkLatency - 1);
					
					Link A_B2 = new Link(Config.router.linkLatency - 1);
					Link B_A2 = new Link(Config.router.linkLatency - 1);
					
					Link A_B3 = new Link(Config.router.linkLatency - 1);
					Link B_A3 = new Link(Config.router.linkLatency - 1);
					
					Link A_B4 = new Link(Config.router.linkLatency - 1);
					Link B_A4 = new Link(Config.router.linkLatency - 1);
					
					links.Add(A_B);
					links.Add(B_Z1A);
					links.Add(Z1A_C);
					links.Add(C_Z4B);
					links.Add(Z4B_D);
					links.Add(D_A);
					
					links.Add(E_F);
					links.Add(F_G); 
					links.Add(G_Z2A); 
					links.Add(Z2A_H);
					links.Add(H_Z1B);
					links.Add(Z1B_E);
					
					links.Add(M_Z2B);
					links.Add(Z2B_N);
					links.Add(N_O);
					links.Add(O_P);   
					links.Add(P_Z3A);
					links.Add(Z3A_M);
					
					links.Add(I_Z4A);
					links.Add(Z4A_J);
					links.Add(J_Z3B);
					links.Add(Z3B_K);
					links.Add(K_L);
					links.Add(L_I); 
					
					links.Add(A_B1);
					links.Add(B_A1);
					
					links.Add(A_B2);
					links.Add(B_A2);
					
					links.Add(A_B3);
					links.Add(B_A3); 
					
					links.Add(A_B4);
					links.Add(B_A4);
					
					int A = Coord.getIDfromXY(0, 0);
					int B = Coord.getIDfromXY(1, 0); 
					int C = Coord.getIDfromXY(1, 1);
					int D = Coord.getIDfromXY(0, 1);
					int E = Coord.getIDfromXY(2, 0);
					int F = Coord.getIDfromXY(3, 0);
					int G = Coord.getIDfromXY(3, 1);
					int H = Coord.getIDfromXY(2, 1);
					int I = Coord.getIDfromXY(0, 2);
					int J = Coord.getIDfromXY(1, 2);
					int K = Coord.getIDfromXY(1, 3);
					int L = Coord.getIDfromXY(0, 3);
					int M = Coord.getIDfromXY(2, 2);
					int N = Coord.getIDfromXY(3, 2);
					int O = Coord.getIDfromXY(3, 3);
					int P = Coord.getIDfromXY(2, 3);
					
					int Z1A = 0;
					int Z1B = 1;
					int Z2A = 2;
					int Z2B = 3;
					int Z3A = 4;
					int Z3B = 5;
					int Z4A = 6;
					int Z4B = 7;
					
					routers[A].linkIn[dirIn]   = D_A;
					routers[A].linkOut[dirOut] = A_B;
					routers[A].neigh[dirIn]    = routers[D];
					routers[A].neigh[dirOut]   = routers[B];
					routers[A].neighbors = 2;

					routers[B].linkIn[dirIn]   = A_B;
					routers[B].linkOut[dirOut] = B_Z1A;
					routers[B].neigh[dirIn]    = routers[A];
					routers[B].neigh[dirOut]   = connectors[Z1A];
					routers[B].neighbors = 2;

					routers[C].linkIn[dirIn]   = Z1A_C;
					routers[C].linkOut[dirOut] = C_Z4B;
					routers[C].neigh[dirIn]    = connectors[Z1A];
					routers[C].neigh[dirOut]   = connectors[Z4B];
					routers[C].neighbors = 2;	
					
					routers[D].linkIn[dirIn]   = Z4B_D;
					routers[D].linkOut[dirOut] = D_A;	
					routers[D].neigh[dirIn]    = connectors[Z4B];
					routers[D].neigh[dirOut]   = routers[A];
					routers[D].neighbors = 2;
				    
				    if (Config.sameDir)
				    {
					    routers[E].linkIn[dirIn]   = Z1B_E;
						routers[E].linkOut[dirOut] = E_F;
						routers[E].neigh[dirIn]    = connectors[Z1B];
						routers[E].neigh[dirOut]   = routers[F];
						routers[E].neighbors = 2;	
						
						routers[F].linkIn[dirIn]   = E_F;
						routers[F].linkOut[dirOut] = F_G;
						routers[F].neigh[dirIn]    = routers[E];
						routers[F].neigh[dirOut]   = routers[G];
						routers[F].neighbors = 2;	
						
						routers[G].linkIn[dirIn]   = F_G;
						routers[G].linkOut[dirOut] = G_Z2A;
						routers[G].neigh[dirIn]    = routers[F];
						routers[G].neigh[dirOut]   = connectors[Z2A];
						routers[G].neighbors = 2;	
						
						routers[H].linkIn[dirIn]   = Z2A_H;
						routers[H].linkOut[dirOut] = H_Z1B;
						routers[H].neigh[dirIn]    = connectors[Z2A];
						routers[H].neigh[dirOut]   = connectors[Z1B];
						routers[H].neighbors = 2;	
						
						routers[I].linkIn[dirIn]   = L_I;
						routers[I].linkOut[dirOut] = I_Z4A;
						routers[I].neigh[dirIn]    = routers[L];
						routers[I].neigh[dirOut]   = connectors[Z4A];
						routers[I].neighbors = 2;	
						
						routers[J].linkIn[dirIn]   = Z4A_J;
						routers[J].linkOut[dirOut] = J_Z3B;
						routers[J].neigh[dirIn]    = connectors[Z4A];
						routers[J].neigh[dirOut]   = connectors[Z3B];
						routers[J].neighbors = 2;	

						routers[K].linkIn[dirIn]   = Z3B_K;
						routers[K].linkOut[dirOut] = K_L;
						routers[K].neigh[dirIn]    = connectors[Z3B];
						routers[K].neigh[dirOut]   = routers[L];
						routers[K].neighbors = 2;	
						
						routers[L].linkIn[dirIn]   = K_L;
						routers[L].linkOut[dirOut] = L_I;
						routers[L].neigh[dirIn]    = routers[K];
						routers[L].neigh[dirOut]   = routers[I];
						routers[L].neighbors = 2;
					}
					else
					{
						routers[E].linkIn[dirIn]   = E_F;
						routers[E].linkOut[dirOut] = Z1B_E;	
						routers[E].neigh[dirIn]    = routers[F]; 
						routers[E].neigh[dirOut]   = connectors[Z1B];
						routers[E].neighbors = 2;	
						
						routers[F].linkIn[dirIn]   = F_G;
						routers[F].linkOut[dirOut] = E_F;
						routers[F].neigh[dirIn]    = routers[G];
						routers[F].neigh[dirOut]   = routers[E];
						routers[F].neighbors = 2;	
						
						routers[G].linkIn[dirIn]   = G_Z2A;
						routers[G].linkOut[dirOut] = F_G;	
						routers[G].neigh[dirIn]    = connectors[Z2A];
						routers[G].neigh[dirOut]   = routers[F];
						routers[G].neighbors = 2;	
						
						routers[H].linkIn[dirIn]   = H_Z1B;
						routers[H].linkOut[dirOut] = Z2A_H;	
						routers[H].neigh[dirIn]    = connectors[Z1B];
						routers[H].neigh[dirOut]   = connectors[Z2A];
						routers[H].neighbors = 2;	
						
						routers[I].linkIn[dirIn]   = I_Z4A;
						routers[I].linkOut[dirOut] = L_I;	
						routers[I].neigh[dirIn]    = connectors[Z4A];
						routers[I].neigh[dirOut]   = routers[L];
						routers[I].neighbors = 2;
						
						routers[J].linkIn[dirIn]   = J_Z3B;
						routers[J].linkOut[dirOut] = Z4A_J;
						routers[J].neigh[dirIn]    = connectors[Z3B];
						routers[J].neigh[dirOut]   = connectors[Z4A];
						routers[J].neighbors = 2;		

						routers[K].linkIn[dirIn]   = K_L;
						routers[K].linkOut[dirOut] = Z3B_K;	
						routers[K].neigh[dirIn]    = routers[L];
						routers[K].neigh[dirOut]   = connectors[Z3B];
						routers[K].neighbors = 2;
						
						routers[L].linkIn[dirIn]   = L_I;
						routers[L].linkOut[dirOut] = K_L;	
						routers[L].neigh[dirIn]    = routers[I]; 
						routers[L].neigh[dirOut]   = routers[K];
						routers[L].neighbors = 2;
					}
					
					routers[M].linkIn[dirIn]   = Z3A_M;
					routers[M].linkOut[dirOut] = M_Z2B;	
					routers[M].neigh[dirIn]    = connectors[Z3A];
					routers[M].neigh[dirOut]   = connectors[Z2B];
					routers[M].neighbors = 2;
					
					
					routers[N].linkIn[dirIn]   = Z2B_N;
					routers[N].linkOut[dirOut] = N_O;	
					routers[N].neigh[dirIn]    = connectors[Z2B];
					routers[N].neigh[dirOut]   = routers[O];
					routers[N].neighbors = 2;
					
					routers[O].linkIn[dirIn]   = N_O;
					routers[O].linkOut[dirOut] = O_P;	
					routers[O].neigh[dirIn]    = routers[N];
					routers[O].neigh[dirOut]   = routers[P];
					routers[O].neighbors = 2;	
					
					routers[P].linkIn[dirIn]   = O_P;
					routers[P].linkOut[dirOut] = P_Z3A;	
					routers[P].neigh[dirIn]    = routers[O];
					routers[P].neigh[dirOut]   = connectors[Z3A];
					routers[P].neighbors = 2;	
					
					// Connectors
					connectors[Z1A].linkIn[dirIn]     = B_Z1A;
					connectors[Z1A].linkOut[dirOut]   = Z1A_C;
					connectors[Z1A].neigh[dirIn]      = routers[B];
					connectors[Z1A].neigh[dirOut]     = routers[C];
					connectors[Z1A].neighbors        += 2;
					
					connectors[Z2B].linkIn[dirIn]     = M_Z2B;
					connectors[Z2B].linkOut[dirOut]   = Z2B_N;
					connectors[Z2B].neigh[dirIn]      = routers[M];
					connectors[Z2B].neigh[dirOut]     = routers[N];
					connectors[Z2B].neighbors        += 2;
					
					connectors[Z3A].linkIn[dirIn]     = P_Z3A;
					connectors[Z3A].linkOut[dirOut]   = Z3A_M;
					connectors[Z3A].neigh[dirIn]      = routers[P];
					connectors[Z3A].neigh[dirOut]     = routers[M];
					connectors[Z3A].neighbors        += 2;	
						
					connectors[Z4B].linkIn[dirIn]     = C_Z4B;
					connectors[Z4B].linkOut[dirOut]   = Z4B_D;
					connectors[Z4B].neigh[dirIn]      = routers[C];
					connectors[Z4B].neigh[dirOut]     = routers[D];
					connectors[Z4B].neighbors        += 2;	
					
					if (Config.sameDir)
					{
						connectors[Z1B].linkIn[dirIn]     = H_Z1B;
						connectors[Z1B].linkOut[dirOut]   = Z1B_E;
						connectors[Z1B].neigh[dirIn]      = routers[H];
						connectors[Z1B].neigh[dirOut]     = routers[E];
						connectors[Z1B].neighbors        += 2;	
					
						connectors[Z2A].linkIn[dirIn]     = G_Z2A;
						connectors[Z2A].linkOut[dirOut]   = Z2A_H;
						connectors[Z2A].neigh[dirIn]      = routers[G];
						connectors[Z2A].neigh[dirOut]     = routers[H];
						connectors[Z2A].neighbors        += 2;	
						
						connectors[Z4A].linkIn[dirIn]     = I_Z4A;
						connectors[Z4A].linkOut[dirOut]   = Z4A_J;
						connectors[Z4A].neigh[dirIn]      = routers[I];
						connectors[Z4A].neigh[dirOut]     = routers[J];
						connectors[Z4A].neighbors        += 2;	
					
						connectors[Z3B].linkIn[dirIn]     = J_Z3B;
						connectors[Z3B].linkOut[dirOut]   = Z3B_K;	
						connectors[Z3B].neigh[dirIn]      = routers[J];
						connectors[Z3B].neigh[dirOut]     = routers[K];
						connectors[Z3B].neighbors        += 2;
					}
					else
					{
						connectors[Z1B].linkIn[dirIn]     = Z1B_E;
						connectors[Z1B].linkOut[dirOut]   = H_Z1B;
						connectors[Z1B].neigh[dirIn]      = routers[E];
						connectors[Z1B].neigh[dirOut]     = routers[H];
						connectors[Z1B].neighbors        += 2;		
					
						connectors[Z2A].linkIn[dirIn]     = Z2A_H;
						connectors[Z2A].linkOut[dirOut]   = G_Z2A;
						connectors[Z2A].neigh[dirIn]      = routers[H];
						connectors[Z2A].neigh[dirOut]     = routers[G];
						connectors[Z2A].neighbors        += 2;		
					
						connectors[Z4A].linkIn[dirIn]     = Z4A_J;
						connectors[Z4A].linkOut[dirOut]   = I_Z4A;
						connectors[Z4A].neigh[dirIn]      = routers[J];
						connectors[Z4A].neigh[dirOut]     = routers[I];
						connectors[Z4A].neighbors        += 2;		
					
						connectors[Z3B].linkIn[dirIn]     = Z3B_K;
						connectors[Z3B].linkOut[dirOut]   = J_Z3B;	
						connectors[Z3B].neigh[dirIn]      = routers[K];
						connectors[Z3B].neigh[dirOut]     = routers[J];
						connectors[Z3B].neighbors        += 2;	
					}
					
					connectors[Z1A].linkIn[dirInject] = B_A1;
					connectors[Z1A].linkOut[dirEject] = A_B1;
					connectors[Z1A].neigh[dirIn]      = connectors[Z1B];
					connectors[Z1A].neigh[dirOut]     = connectors[Z1B];
					connectors[Z1A].neighbors        += 2;	
						
					connectors[Z1B].linkIn[dirInject] = A_B1;
					connectors[Z1B].linkOut[dirEject] = B_A1;	
					connectors[Z1B].neigh[dirIn]      = connectors[Z1A];
					connectors[Z1B].neigh[dirOut]     = connectors[Z1A];
					connectors[Z1B].neighbors        += 2;	
					
					connectors[Z2A].linkIn[dirInject] = B_A2;
					connectors[Z2A].linkOut[dirEject] = A_B2;	
					connectors[Z2A].neigh[dirIn]      = connectors[Z2B];
					connectors[Z2A].neigh[dirOut]     = connectors[Z2B];
					connectors[Z2A].neighbors        += 2;	
					
					connectors[Z2B].linkIn[dirInject] = A_B2;
					connectors[Z2B].linkOut[dirEject] = B_A2;
					connectors[Z2B].neigh[dirIn]      = connectors[Z2A];
					connectors[Z2B].neigh[dirOut]     = connectors[Z2A];
					connectors[Z2B].neighbors        += 2;		
					
					connectors[Z3A].linkIn[dirInject] = B_A3;
					connectors[Z3A].linkOut[dirEject] = A_B3;
					connectors[Z3A].neigh[dirIn]      = connectors[Z3B];
					connectors[Z3A].neigh[dirOut]     = connectors[Z3B];
					connectors[Z3A].neighbors        += 2;	
						
					connectors[Z3B].linkIn[dirInject] = A_B3;
					connectors[Z3B].linkOut[dirEject] = B_A3;	
					connectors[Z3B].neigh[dirIn]      = connectors[Z3A];
					connectors[Z3B].neigh[dirOut]     = connectors[Z3A];
					connectors[Z3B].neighbors        += 2;		
					
					connectors[Z4A].linkIn[dirInject] = B_A4;
					connectors[Z4A].linkOut[dirEject] = A_B4;
					connectors[Z4A].neigh[dirIn]      = connectors[Z4B];
					connectors[Z4A].neigh[dirOut]     = connectors[Z4B];
					connectors[Z4A].neighbors        += 2;			
					
					connectors[Z4B].linkIn[dirInject] = A_B4;
					connectors[Z4B].linkOut[dirEject] = B_A4;
					connectors[Z4B].neigh[dirIn]      = connectors[Z4A];
					connectors[Z4B].neigh[dirOut]     = connectors[Z4A];
					connectors[Z4B].neighbors        += 2;		
						
					return;
				}
			}
			
			/*
			if (Config.StreetRings)
			{
				// connect the network with Links
	            for (int n = 0; n < Config.N; n++)
	            {
	                int x, y;
	                Coord.getXYfromID(n, out x, out y);
	
	                // inter-router links
	                for (int dir = 0; dir < 2; dir++)
	                {
	                    int oppDir = (dir + 2) % 4; // direction from neighbor's perspective
	
	                    // determine neighbor's coordinates
	                    int x_, y_;
	                    switch (x % 2)
	                    {
		                    case 0:
				            	switch (dir)
				                {
				                    case 0:    x_ = x;     y_ = y + 1; break;
				                    case 1:    x_ = x;     y_ = y - 1; break;
				                    default: continue;
				                }
				                break;
		                    
		                    case 1:
			                    switch (dir)
			                    {
			                        case 0:    x_ = x;     y_ = y - 1; break;
			                        case 1:    x_ = x;     y_ = y + 1; break;
			                        default: continue;
			                    }
		                    break;
						}
				
	
	                    // ensure no duplication by handling a link at the lexicographically
	                    // first router
	                    if (x_ < x || (x_ == x && y_ < y)) continue;
	
	                    // Link param is *extra* latency (over the standard 1 cycle)
	                    Link dirA = new Link(Config.router.linkLatency - 1);
	                    Link dirB = new Link(Config.router.linkLatency - 1);
	                    links.Add(dirA);
	                    links.Add(dirB);
	
	                    // link 'em up
	                    routers[Coord.getIDfromXY(x,  y)].linkOut[dir]    = dirA;
	                    routers[Coord.getIDfromXY(x_, y_)].linkIn[oppDir] = dirA;
	
	                    routers[Coord.getIDfromXY(x,  y)].linkIn[dir]      = dirB;
	                    routers[Coord.getIDfromXY(x_, y_)].linkOut[oppDir] = dirB;
	
	                    routers[Coord.getIDfromXY(x,  y)].neighbors++;
	                    routers[Coord.getIDfromXY(x_, y_)].neighbors++;
	
	                    routers[Coord.getIDfromXY(x,  y)].neigh[dir]     = routers[Coord.getIDfromXY(x_, y_)];
	                    routers[Coord.getIDfromXY(x_, y_)].neigh[oppDir] = routers[Coord.getIDfromXY(x,  y)];
	
	                }
	            }
			}
			*/

            // connect the network with Links
            for (int n = 0; n < Config.N; n++)
            {
                int x, y;
                Coord.getXYfromID(n, out x, out y);
				int ID = n;
                // inter-router links
                for (int dir = 0; dir < 4; dir++)
                {
                    int oppDir = (dir + 2) % 4; // direction from neighbor's perspective

                    // determine neighbor's coordinates
                    int x_, y_;
                    switch (dir)
                    {
                        case Simulator.DIR_UP:    x_ = x;     y_ = y + 1; break;
                        case Simulator.DIR_DOWN:  x_ = x;     y_ = y - 1; break;
                        case Simulator.DIR_RIGHT: x_ = x + 1; y_ = y;     break;
                        case Simulator.DIR_LEFT:  x_ = x - 1; y_ = y;     break;
                        default: continue;
                    }

                    // If we are a torus, we manipulate x_ and y_
                    if(Config.torus)
                    {
                      if(x_ < 0)
                        x_ += X;
                      else if(x_ >= X)
                        x_ -= X;

                      if(y_ < 0)
                        y_ += Y;
                      else if(y_ >= Y)
                        y_ -= Y;
                    }
                    // mesh, not torus: detect edge
                    else if (x_ < 0 || x_ >= X || y_ < 0 || y_ >= Y)
                    {
                        if (Config.edge_loop)
                        {
                            Link edgeL = new Link(Config.router.linkLatency - 1);
                            links.Add(edgeL);
                            routers[ID].linkOut[dir] = edgeL;
                            routers[ID].linkIn[dir]  = edgeL;
                            routers[ID].neighbors++;
                            routers[ID].neigh[dir] =
                                routers[ID];
                        }

                        continue;
                    }

                    // ensure no duplication by handling a link at the lexicographically
                    // first router
                    if (x_ < x || (x_ == x && y_ < y)) continue;

                    // Link param is *extra* latency (over the standard 1 cycle)
                    Link dirA = new Link(Config.router.linkLatency - 1);
                    Link dirB = new Link(Config.router.linkLatency - 1);
                    links.Add(dirA);
                    links.Add(dirB);

					int oppID = Coord.getIDfromXY(x_, y_);

                    // link 'em up
                    routers[ID].linkOut[dir]    = dirA;
                    routers[oppID].linkIn[oppDir] = dirA;

                    routers[ID].linkIn[dir]      = dirB;
                    routers[oppID].linkOut[oppDir] = dirB;

                    routers[ID].neighbors++;
                    routers[oppID].neighbors++;

                    routers[ID].neigh[dir]     = routers[oppID];
                    routers[oppID].neigh[oppDir] = routers[ID];


                    if (Config.router.algorithm == RouterAlgorithm.DR_SCARAB)
                    {
                        for (int wireNr = 0; wireNr < Config.nack_nr; wireNr++)
                        {
                            Link nackA = new Link(Config.nack_linkLatency - 1);
                            Link nackB = new Link(Config.nack_linkLatency - 1);
                            links.Add(nackA);
                            links.Add(nackB);
                            ((Router_SCARAB)routers[Coord.getIDfromXY(x,  y)]).nackOut[dir    * Config.nack_nr + wireNr] = nackA;
                            ((Router_SCARAB)routers[Coord.getIDfromXY(x_, y_)]).nackIn[oppDir * Config.nack_nr + wireNr] = nackA;

                            ((Router_SCARAB)routers[Coord.getIDfromXY(x,  y)]).nackIn[dir      * Config.nack_nr + wireNr] = nackB;
                            ((Router_SCARAB)routers[Coord.getIDfromXY(x_, y_)]).nackOut[oppDir * Config.nack_nr + wireNr] = nackB;
                        }
                    }
                }
            }

            if (Config.torus)
                for (int i = 0; i < Config.N; i++)
                    if (routers[i].neighbors < 4)
                        throw new Exception("torus construction not successful!");
        }
Ejemplo n.º 19
0
        public override void setup()
        {
            if (Config.network_nrX != 4 && Config.network_nrY != 4)
            {
                throw new Exception("buffered hierarchical ring only support 4x4 network");
            }
            nics  = new Router_NIC[Config.N];
            iris  = new Router_IRI[4];
            nodes = new Node[Config.N];
            links = new List <Link>();
            cache = new CmpCache();

            ParseFinish(Config.finish);

            workload = new Workload(Config.traceFilenames);

            mapping = new NodeMapping_AllCPU_SharedCache();

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
            {
                Coord c = new Coord(n);
                nodes[n] = new Node(mapping, c);
                nics[n]  = new Router_NIC(c);
                nodes[n].setRouter(nics[n]);
                nics[n].setNode(nodes[n]);
            }
            for (int n = 0; n < 4; n++)
            {
                iris[n] = new Router_IRI(n);
            }

            for (int group = 0; group < 4; group++)
            {
                for (int i = 0; i < 4; i++)
                {
                    if (i == 3)
                    {
                        continue;
                    }
                    int  node = group * 4 + i;
                    Link dirA = new Link(Config.router.switchLinkLatency - 1);
                    links.Add(dirA);
                    nics[node].linkOut[0]    = dirA;
                    nics[node + 1].linkIn[0] = dirA;
                }

                Link dirD = new Link(Config.router.switchLinkLatency - 1);
                Link dirB = new Link(Config.router.switchLinkLatency - 1);
                links.Add(dirB);
                links.Add(dirD);
                nics[group * 4 + 3].linkOut[0] = dirD;
                iris[group].LLinkIn[0]         = dirD;
                nics[group * 4].linkIn[0]      = dirB;
                iris[group].LLinkOut[0]        = dirB;
                int  next = (group + 1) % 4;
                Link dirC = new Link(Config.router.level1RingLinkLatency - 1);
                links.Add(dirC);
                iris[group].GLinkOut[0] = dirC;
                iris[next].GLinkIn[0]   = dirC;
            }
        }
Ejemplo n.º 20
0
        public override void setup()
        {
            nodeRouters = new Router_Node[Config.N];
            connectRouters = new Router_Connect[Config.N / 2]; // some of the connectRouters may be disabled
            nodes = new Node[Config.N];
            links = new List<Link>();
            cache = new CmpCache();

            ParseFinish(Config.finish);

            workload = new Workload(Config.traceFilenames);

            mapping = new NodeMapping_AllCPU_SharedCache();

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
           {
                Coord c = new Coord(n);
                RC_Coord RC_c = new RC_Coord(n);

                nodes[n] = new Node(mapping, c);
                nodeRouters[n] = new Router_Node(RC_c, c);
                nodes[n].setRouter(nodeRouters[n]);
                nodeRouters[n].setNode(nodes[n]);
            }
            // connectRouters are numbered by sweeping x, with y increase in steps
            // disable the routers not needed here. Different topologies can be realised. (mesh, torus)
            for (int n = 0; n < Config.N / 2 ; n++)
            {
            	connectRouters[n] = new Router_Connect(n);
				/*if (n == 0 || n == 1 || n == 2 || n == 3 || 
            		n == 32 || n == 33 || n == 34 || n == 35)
            		connectRouters[n].enable = false;
            	if (n == 4 || n == 12 || n == 20 || n == 28)
            		connectRouters[n].enable = false;*/
            }
			if(Config.RC_mesh)
			{
				for (int i = 0; i < Config.network_nrX / 2; i++)
					connectRouters[i].enable = false;
				for (int i = 0; i < Config.network_nrY / 2; i++)
					connectRouters[Config.network_nrX * i + Config.network_nrX / 2].enable = false;
			}
			if(Config.RC_Torus)
			{
				// all connection Routers are enabled. Both horizontally and vertically. 
				; 
			}
			if (Config.RC_x_Torus)
			{
				for (int i = 0; i < Config.network_nrX / 2; i++)
					connectRouters[i].enable = false;
			}

//			Console.WriteLine("test");
            if (Config.RouterEvaluation)
                return;

            // connect the network with Links
            for (int y = 0; y < Y / 2; y++)
            {
            	for (int x = 0; x < X / 2; x++)
            	{
            		for (int z = 0; z < 4; z++)
            		{
            			int nextCRouter = -1;
						int preCRouter = -1;
            			switch (z)
            			{
            				case 0 : {nextCRouter = x + X*y + X/2; preCRouter = x + X*y; break;}
            				case 1 : {nextCRouter = (x + X*(y+1)) % (Config.N/2); preCRouter = x + X*y + X/2; break;}
            				case 2 : {nextCRouter = (x+1) % (X/2) + X*y + X/2; preCRouter = (x + X*(y+1)) % (Config.N/2); break;}
            				case 3 : {nextCRouter = x + X*y; preCRouter = (x+1) % (X/2) + X*y + X/2; break;}
            			}
						

		        		if (connectRouters[nextCRouter].enable) // clockwise: the connectRouter next to z = 0
		        		{	
		        			Link dirA = new Link(Config.router.linkLatency_N2R - 1);
		        			Link dirB = new Link(Config.router.linkLatency_N2R - 1);
		        			links.Add(dirA);
		        			links.Add(dirB);
							int port = ((z-1) < 0) ? z + 3 : z - 1;
						//	Console.WriteLine("x:{0},y:{1},z:{2}, ID:{3}", x, y, z, RC_Coord.getIDfromXYZ(x, y, z));
						//	Console.WriteLine("node:{0}, next_id:{1}, port{2}", RC_Coord.getIDfromXYZ(x, y, z), nextCRouter, port);
		        			nodeRouters[RC_Coord.getIDfromXYZ(x, y, z)].linkOut[CW] = dirA;							
		        			connectRouters[nextCRouter].linkIn[port] = dirA;
		        			nodeRouters[RC_Coord.getIDfromXYZ(x, y, z)].linkIn[CCW] = dirB;
		        			connectRouters[nextCRouter].linkOut[port] = dirB;
		        		}
		        		else  // the router is not enabled : does not exist
		        		{
		        			Link dirA = new Link(Config.router.linkLatency_N2N - 1);
		        			Link dirB = new Link(Config.router.linkLatency_N2N - 1);
		        			links.Add(dirA);
		        			links.Add(dirB);
		        			nodeRouters[RC_Coord.getIDfromXYZ(x, y, z)].linkOut[CW] = dirA;
		        			nodeRouters[RC_Coord.getIDfromXYZ(x, y, (z+1) % 4)].linkIn[CW] = dirA;
		        			nodeRouters[RC_Coord.getIDfromXYZ(x, y, z)].linkIn[CCW] = dirB;
		        			nodeRouters[RC_Coord.getIDfromXYZ(x, y, (z+1) % 4)].linkOut[CCW] = dirB;
							//Console.WriteLine("node:{0}, wire to node:{1}", RC_Coord.getIDfromXYZ(x, y, z), RC_Coord.getIDfromXYZ(x, y, (z+1) % 4));
		        		}		        		
		        		if (connectRouters[preCRouter].enable)
		        		{
		        			Link dirA = new Link(Config.router.linkLatency_N2R - 1);
		        			Link dirB = new Link(Config.router.linkLatency_N2R - 1);
		        			links.Add(dirA);
		        			links.Add(dirB);
		        			nodeRouters[RC_Coord.getIDfromXYZ(x, y, z)].linkOut[CCW] = dirA;
		        			connectRouters[preCRouter].linkIn[(z+1) % 4] = dirA;
		        			nodeRouters[RC_Coord.getIDfromXYZ(x, y, z)].linkIn[CW] = dirB;
		        			connectRouters[preCRouter].linkOut[(z+1) % 4] = dirB;
							//Console.WriteLine("node:{0}, pre_id:{1}, port{2}", RC_Coord.getIDfromXYZ(x, y, z), preCRouter, port);
		        		}
            		}
            	}
            }
			
        }
Ejemplo n.º 21
0
        public override void setup()
        {
            // boilerplate
            nodes = new Node[Config.N];
            cache = new CmpCache();
            ParseFinish(Config.finish);
            workload = new Workload(Config.traceFilenames);
            mapping = new NodeMapping_AllCPU_SharedCache();

            _nics = new List<BufRingMultiNetwork_NIC>();
            _iris = new List<BufRingMultiNetwork_IRI>();

            links = new List<Link>();
            _routers = new BufRingMultiNetwork_Router[Config.N];

            //Console.WriteLine("setup: N = {0}", Config.N);

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
            {
                Coord c = new Coord(n);
                nodes[n] = new Node(mapping, c);
                _routers[n] = new BufRingMultiNetwork_Router(c);
                _routers[n].setNode(nodes[n]);
                nodes[n].setRouter(_routers[n]);
            }

            // for each copy of the network...
            for (int copy = 0; copy < Config.bufrings_n; copy++) {
                BufRingMultiNetwork_Coord c = new BufRingMultiNetwork_Coord(0, 0);
                BufRingMultiNetwork_IRI iri;
                int count;
                setup_ring(c, 0, out iri, out count);
            }

        }
Ejemplo n.º 22
0
        public override void setup()
        {
            nodeRouters    = new Router_Node[Config.N];
            connectRouters = new Router_Connect[Config.N / 2]; // some of the connectRouters may be disabled
            nodes          = new Node[Config.N];
            links          = new List <Link>();
            cache          = new CmpCache();

            ParseFinish(Config.finish);

            workload = new Workload(Config.traceFilenames);

            mapping = new NodeMapping_AllCPU_SharedCache();

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
            {
                Coord    c    = new Coord(n);
                RC_Coord RC_c = new RC_Coord(n);

                nodes[n]       = new Node(mapping, c);
                nodeRouters[n] = new Router_Node(RC_c, c);
                nodes[n].setRouter(nodeRouters[n]);
                nodeRouters[n].setNode(nodes[n]);
            }
            // connectRouters are numbered by sweeping x, with y increase in steps
            // disable the routers not needed here. Different topologies can be realised. (mesh, torus)
            for (int n = 0; n < Config.N / 2; n++)
            {
                connectRouters[n] = new Router_Connect(n);

                /*if (n == 0 || n == 1 || n == 2 || n == 3 ||
                 * n == 32 || n == 33 || n == 34 || n == 35)
                 * connectRouters[n].enable = false;
                 * if (n == 4 || n == 12 || n == 20 || n == 28)
                 * connectRouters[n].enable = false;*/
            }
            if (Config.RC_mesh)
            {
                for (int i = 0; i < Config.network_nrX / 2; i++)
                {
                    connectRouters[i].enable = false;
                }
                for (int i = 0; i < Config.network_nrY / 2; i++)
                {
                    connectRouters[Config.network_nrX * i + Config.network_nrX / 2].enable = false;
                }
            }
            if (Config.RC_Torus)
            {
                // all connection Routers are enabled. Both horizontally and vertically.
                ;
            }
            if (Config.RC_x_Torus)
            {
                for (int i = 0; i < Config.network_nrX / 2; i++)
                {
                    connectRouters[i].enable = false;
                }
            }

//			Console.WriteLine("test");
            if (Config.RouterEvaluation)
            {
                return;
            }

            // connect the network with Links
            for (int y = 0; y < Y / 2; y++)
            {
                for (int x = 0; x < X / 2; x++)
                {
                    for (int z = 0; z < 4; z++)
                    {
                        int nextCRouter = -1;
                        int preCRouter  = -1;
                        switch (z)
                        {
                        case 0: { nextCRouter = x + X * y + X / 2; preCRouter = x + X * y; break; }

                        case 1: { nextCRouter = (x + X * (y + 1)) % (Config.N / 2); preCRouter = x + X * y + X / 2; break; }

                        case 2: { nextCRouter = (x + 1) % (X / 2) + X * y + X / 2; preCRouter = (x + X * (y + 1)) % (Config.N / 2); break; }

                        case 3: { nextCRouter = x + X * y; preCRouter = (x + 1) % (X / 2) + X * y + X / 2; break; }
                        }


                        if (connectRouters[nextCRouter].enable)                 // clockwise: the connectRouter next to z = 0
                        {
                            Link dirA = new Link(Config.router.linkLatency_N2R - 1);
                            Link dirB = new Link(Config.router.linkLatency_N2R - 1);
                            links.Add(dirA);
                            links.Add(dirB);
                            int port = ((z - 1) < 0) ? z + 3 : z - 1;
                            //	Console.WriteLine("x:{0},y:{1},z:{2}, ID:{3}", x, y, z, RC_Coord.getIDfromXYZ(x, y, z));
                            //	Console.WriteLine("node:{0}, next_id:{1}, port{2}", RC_Coord.getIDfromXYZ(x, y, z), nextCRouter, port);
                            nodeRouters[RC_Coord.getIDfromXYZ(x, y, z)].linkOut[CW] = dirA;
                            connectRouters[nextCRouter].linkIn[port] = dirA;
                            nodeRouters[RC_Coord.getIDfromXYZ(x, y, z)].linkIn[CCW] = dirB;
                            connectRouters[nextCRouter].linkOut[port] = dirB;
                        }
                        else                  // the router is not enabled : does not exist
                        {
                            Link dirA = new Link(Config.router.linkLatency_N2N - 1);
                            Link dirB = new Link(Config.router.linkLatency_N2N - 1);
                            links.Add(dirA);
                            links.Add(dirB);
                            nodeRouters[RC_Coord.getIDfromXYZ(x, y, z)].linkOut[CW]            = dirA;
                            nodeRouters[RC_Coord.getIDfromXYZ(x, y, (z + 1) % 4)].linkIn[CW]   = dirA;
                            nodeRouters[RC_Coord.getIDfromXYZ(x, y, z)].linkIn[CCW]            = dirB;
                            nodeRouters[RC_Coord.getIDfromXYZ(x, y, (z + 1) % 4)].linkOut[CCW] = dirB;
                            //Console.WriteLine("node:{0}, wire to node:{1}", RC_Coord.getIDfromXYZ(x, y, z), RC_Coord.getIDfromXYZ(x, y, (z+1) % 4));
                        }
                        if (connectRouters[preCRouter].enable)
                        {
                            Link dirA = new Link(Config.router.linkLatency_N2R - 1);
                            Link dirB = new Link(Config.router.linkLatency_N2R - 1);
                            links.Add(dirA);
                            links.Add(dirB);
                            nodeRouters[RC_Coord.getIDfromXYZ(x, y, z)].linkOut[CCW] = dirA;
                            connectRouters[preCRouter].linkIn[(z + 1) % 4]           = dirA;
                            nodeRouters[RC_Coord.getIDfromXYZ(x, y, z)].linkIn[CW]   = dirB;
                            connectRouters[preCRouter].linkOut[(z + 1) % 4]          = dirB;
                            //Console.WriteLine("node:{0}, pre_id:{1}, port{2}", RC_Coord.getIDfromXYZ(x, y, z), preCRouter, port);
                        }
                    }
                }
            }
            int PHnumber = Config.PlaceHolderNum;

            while (PHnumber > 0)
            {
                PHnumber--;
                Flit f1 = new Flit(null, 0);                  // generate a placeholder flit
                Flit f2 = new Flit(null, 0);
                f1.state = Flit.State.Placeholder;
                f2.state = Flit.State.Placeholder;
                nodeRouters[PHnumber].linkOut[0].In = f1;
                nodeRouters[PHnumber].linkOut[1].In = f2;
            }
        }
Ejemplo n.º 23
0
        public void setup_RingCluster_4()
        {
            nodeRouters    = new Router_Node[Config.N];
            connectRouters = new Router_Connect[6];
            nodes          = new Node[Config.N];
            links          = new List <Link>();
            cache          = new CmpCache();

            ParseFinish(Config.finish);

            workload = new Workload(Config.traceFilenames);

            mapping = new NodeMapping_AllCPU_SharedCache();

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
            {
                Coord c = new Coord(n);
                nodes[n] = new Node(mapping, c);

                nodeRouters[n] = new Router_Node(c);
                nodes[n].setRouter(nodeRouters[n]);
                nodeRouters[n].setNode(nodes[n]);
            }
            for (int n = 0; n < 6; n++)
            {
                connectRouters[n] = new Router_Connect(n);
            }

            for (int n = 0; n < Config.N / 4; n++) // n is the cluster number
            {
                for (int i = 0; i < 4; i++)        // for each node in the same cluster
                {
                    if (n == 0 && i == 3 || n == 1 && i == 1 || n == 2 && i == 1 || n == 3 && i == 3)
                    {
                        Link dirA = new Link(0);
                        Link dirB = new Link(0);
                        links.Add(dirA);
                        links.Add(dirB);
                        int next = (i + 1 == 4)? n * 4 : n * 4 + i + 1;
                        nodeRouters[n * 4 + i].linkOut[CW] = dirA;
                        nodeRouters[next].linkIn[CW]       = dirA;
                        nodeRouters[next].linkOut[CCW]     = dirB;
                        nodeRouters[n * 4 + i].linkIn[CCW] = dirB;
                    }
                }
            }
            for (int n = 0; n < 6; n++)
            {
                Link dirA = new Link(Config.router.linkLatency - 1);
                Link dirB = new Link(Config.router.linkLatency - 1);
                links.Add(dirA);
                links.Add(dirB);
                int[] node1 = new int[6] {
                    1, 6, 11, 12, 0, 4
                };
                nodeRouters[node1[n]].linkOut[CW] = dirA;
                nodeRouters[node1[n]].linkIn[CCW] = dirB;
                connectRouters[n].linkIn[L0]      = dirA;
                connectRouters[n].linkOut[L0]     = dirB;

                dirA = new Link(Config.router.linkLatency - 1);
                dirB = new Link(Config.router.linkLatency - 1);
                links.Add(dirA);
                links.Add(dirB);
                int[] node2 = new int[6] {
                    2, 7, 8, 13, 1, 5
                };
                nodeRouters[node2[n]].linkOut[CCW] = dirA;
                nodeRouters[node2[n]].linkIn[CW]   = dirB;
                connectRouters[n].linkIn[L3]       = dirA;
                connectRouters[n].linkOut[L3]      = dirB;

                dirA = new Link(Config.router.linkLatency - 1);
                dirB = new Link(Config.router.linkLatency - 1);
                links.Add(dirA);
                links.Add(dirB);
                int[] node3 = new int[6] {
                    4, 9, 14, 3, 15, 11
                };
                nodeRouters[node3[n]].linkOut[CCW] = dirA;
                nodeRouters[node3[n]].linkIn[CW]   = dirB;
                connectRouters[n].linkIn[L1]       = dirA;
                connectRouters[n].linkOut[L1]      = dirB;

                dirA = new Link(Config.router.linkLatency - 1);
                dirB = new Link(Config.router.linkLatency - 1);
                links.Add(dirA);
                links.Add(dirB);
                int[] node4 = new int[6] {
                    7, 8, 13, 2, 14, 10
                };
                nodeRouters[node4[n]].linkOut[CW] = dirA;
                nodeRouters[node4[n]].linkIn[CCW] = dirB;
                connectRouters[n].linkIn[L2]      = dirA;
                connectRouters[n].linkOut[L2]     = dirB;
            }
        }
Ejemplo n.º 24
0
       	public void setup_TorusSingleRing()
       	{
       		nodeRouters = new Router_TorusRingNode[Config.N];
       		connectRouters = new Router_TorusRingConnect[8];
            nodes = new Node[Config.N];
            links = new List<Link>();
            cache = new CmpCache();

            ParseFinish(Config.finish);
            workload = new Workload(Config.traceFilenames);
            mapping = new NodeMapping_AllCPU_SharedCache();
            
            for (int n = 0; n < Config.N; n++)
            {
                Coord c = new Coord(n);
                nodes[n] = new Node(mapping, c);                 
                nodeRouters[n] = new Router_TorusRingNode(c); 
                nodes[n].setRouter(nodeRouters[n]);                                
                nodeRouters[n].setNode(nodes[n]);
            }
            for (int n = 0; n < 8; n++)
            	connectRouters[n] = new Router_TorusRingConnect(n);

       		int[] CW_Connect = new int[16] {7,0,6,1,3,1,2,0,2,5,3,4,6,4,7,5};
       		int[] CCW_Connect = new int[16] {1,7,0,6,0,3,1,2,4,2,5,3,5,6,4,7};	
       		int[] dirCW = new int[16] {1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1};
       		int[] dirCCW = new int[16] {1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0};
       		for (int n = 0; n < Config.N; n++)
       		{
       			Link dirA = new Link(Config.router.linkLatency - 1);	            	
            	Link dirB = new Link(Config.router.linkLatency - 1);
            	links.Add(dirA);
            	links.Add(dirB);
            	nodeRouters[n].linkOut[0] = dirA;
            	nodeRouters[n].linkIn[0] = dirB;
            	connectRouters[CW_Connect[n]].linkIn[dirCW[n]] = dirA;
            	connectRouters[CCW_Connect[n]].linkOut[dirCCW[n]] = dirB;
       		}
       	}
Ejemplo n.º 25
0
        public override void setup()
        {
            if (Config.N != 16)
            {
                throw new Exception("HR_8drop only suport 4x4 network");
            }
            nodeRouters   = new Router_Node[Config.N];
            bridgeRouters = new Router_Bridge[8];
            nodes         = new Node[Config.N];
            links         = new List <Link>();
            cache         = new CmpCache();

            ParseFinish(Config.finish);

            workload = new Workload(Config.traceFilenames);

            mapping = new NodeMapping_AllCPU_SharedCache();

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
            {
                Coord    c    = new Coord(n);
                RC_Coord RC_c = new RC_Coord(n);

                nodes[n]       = new Node(mapping, c);
                nodeRouters[n] = new Router_Node(RC_c, c);
                nodes[n].setRouter(nodeRouters[n]);
                nodeRouters[n].setNode(nodes[n]);
            }
            for (int n = 0; n < 8; n++)
            {
                bridgeRouters[n] = new Router_Bridge(n, Config.GlobalRingWidth);
            }
            // connect the network with Links
            for (int n = 0; n < 4; n++)
            {
                for (int i = 0; i < 4; i++)
                {
                    int ID = n * 4 + i;
                    if (ID % 2 == 0)
                    {
                        continue;
                    }
                    int  next = (i + 1) % 4 + n * 4;
                    Link dirA = new Link(Config.router.switchLinkLatency - 1);
                    Link dirB = new Link(Config.router.switchLinkLatency - 1);
                    links.Add(dirA);
                    links.Add(dirB);
                    nodeRouters[ID].linkOut[CW]    = dirA;
                    nodeRouters[next].linkIn[CW]   = dirA;
                    nodeRouters[ID].linkIn[CCW]    = dirB;
                    nodeRouters[next].linkOut[CCW] = dirB;
                }
            }
            int [] CWnext  = { 3, 1, 5, 7, 9, 11, 15, 13 };
            int [] CCWnext = { 2, 0, 4, 6, 8, 10, 14, 12 };
            for (int n = 0; n < 8; n++)
            {
                Link dirA = new Link(Config.router.switchLinkLatency - 1);
                Link dirB = new Link(Config.router.switchLinkLatency - 1);
                Link dirC = new Link(Config.router.switchLinkLatency - 1);
                Link dirD = new Link(Config.router.switchLinkLatency - 1);
                links.Add(dirA);
                links.Add(dirB);
                links.Add(dirC);
                links.Add(dirD);
                bridgeRouters[n].LLinkOut[CW]       = dirA;
                nodeRouters[CWnext[n]].linkIn[CW]   = dirA;
                bridgeRouters[n].LLinkIn[CCW]       = dirB;
                nodeRouters[CWnext[n]].linkOut[CCW] = dirB;

                bridgeRouters[n].LLinkOut[CCW]      = dirC;
                nodeRouters[CCWnext[n]].linkIn[CCW] = dirC;
                bridgeRouters[n].LLinkIn[CW]        = dirD;
                nodeRouters[CCWnext[n]].linkOut[CW] = dirD;

                int next = (n + 1) % 8;

                for (int i = 0; i < Config.GlobalRingWidth; i++)
                {
                    dirA = new Link(Config.router.level1RingLinkLatency - 1);
                    dirB = new Link(Config.router.level1RingLinkLatency - 1);
                    links.Add(dirA);
                    links.Add(dirB);
                    bridgeRouters[n].GLinkIn[i * 2 + 1]     = dirA;
                    bridgeRouters[next].GLinkOut[i * 2 + 1] = dirA;
                    bridgeRouters[n].GLinkOut[i * 2]        = dirB;
                    bridgeRouters[next].GLinkIn[i * 2]      = dirB;
                }
            }
        }
Ejemplo n.º 26
0
      	public override void setup()
       	{
			if (Config.N != 1024)
				throw new Exception("HR_16_8drop only suport 8x8 network");
            nodeRouters = new Router_Node[Config.N];
           	L1bridgeRouters = new Router_Bridge[512];
			L2bridgeRouters = new Router_Bridge[128];
			L3bridgeRouters = new Router_Bridge[32];
			L4bridgeRouters = new Router_Bridge[8];
            nodes = new Node[Config.N];
            links = new List<Link>();
            cache = new CmpCache();

            ParseFinish(Config.finish);

            workload = new Workload(Config.traceFilenames);

            mapping = new NodeMapping_AllCPU_SharedCache();

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
           	{
                Coord c = new Coord(n);
                RC_Coord RC_c = new RC_Coord(n);

                nodes[n] = new Node(mapping, c);
                nodeRouters[n] = new Router_Node(RC_c, c);
                nodes[n].setRouter(nodeRouters[n]);
                nodeRouters[n].setNode(nodes[n]);
            }
            for (int n = 0; n < 512; n++)
            	L1bridgeRouters[n] = new Router_Bridge(n, 2, 1);
			for (int n = 0; n < 128; n++)
				L2bridgeRouters[n] = new Router_Bridge(n, 4, 2, 2, 8);
			for (int n = 0; n < 32; n++)
				L3bridgeRouters[n] = new Router_Bridge(n, 8, 4, 4, 16);
			for (int n = 0; n < 8; n++)
				L4bridgeRouters[n] = new Router_Bridge(n, 16, 8, 8, 32);
            // connect the network with Links
            for (int n = 0; n < 256; n++)
            {
				for (int i = 0; i < 4; i++)
				{
					int ID = n * 4 + i;
					if (ID % 2 == 0) 
						continue;
					int next = (i + 1) % 4 + n * 4;
					Link dirA = new Link(Config.router.switchLinkLatency - 1);
					Link dirB = new Link(Config.router.switchLinkLatency - 1);
					links.Add(dirA);
					links.Add(dirB);
					nodeRouters[ID].linkOut[CW] = dirA;
					nodeRouters[next].linkIn[CW] = dirA;
					nodeRouters[ID].linkIn[CCW] = dirB;
					nodeRouters[next].linkOut[CCW] = dirB;
				}
			}

			// connect L1 bridge Routers
			for (int n = 0; n < 512; n++)
			{
				int ID = n;
				int next, pre;
				if (ID % 8 == 0 || ID % 8 == 6) { next = ID * 2 + 3; pre = ID * 2 + 2; }
				else if (ID % 8 == 1 || ID % 8 == 7) {next = ID * 2 - 1; pre = ID * 2 - 2; }
				else { next = ID * 2 + 1; pre = ID * 2;}

				Link dirA = new Link(Config.router.switchLinkLatency - 1);
				Link dirB = new Link(Config.router.switchLinkLatency - 1);
				Link dirC = new Link(Config.router.switchLinkLatency - 1);
				Link dirD = new Link(Config.router.switchLinkLatency - 1);
				links.Add(dirA);
				links.Add(dirB);
				links.Add(dirC);
				links.Add(dirD);
				L1bridgeRouters[n].LLinkOut[CW] = dirA;
				nodeRouters[next].linkIn[CW] = dirA;
				L1bridgeRouters[n].LLinkIn[CCW] = dirB;
				nodeRouters[next].linkOut[CCW] = dirB;

				L1bridgeRouters[n].LLinkOut[CCW] = dirC;
				nodeRouters[pre].linkIn[CCW] = dirC;
				L1bridgeRouters[n].LLinkIn[CW] = dirD;
				nodeRouters[pre].linkOut[CW] = dirD;
				
				int nextL1 = (n + 1) % 8 + n / 8 * 8;
				if (ID % 8 == 1 || ID % 8 == 5)
					continue;
				for (int i = 0 ; i < 2; i++)
				{
					dirA = new Link(Config.router.level1RingLinkLatency - 1);
					dirB = new Link(Config.router.level1RingLinkLatency - 1);
					links.Add(dirA);
					links.Add(dirB);
					L1bridgeRouters[n].GLinkIn[i*2+1] = dirA;
					L1bridgeRouters[nextL1].GLinkOut[i*2+1] = dirA;
					L1bridgeRouters[n].GLinkOut[i*2] = dirB;
					L1bridgeRouters[nextL1].GLinkIn[i*2] = dirB;
				}
			}			
			// connect L2 bridge Routers
			for (int n = 0; n < 128; n++)
			{
				int next, pre;
				if (n % 8 == 0 || n % 8 == 6) {next = n * 4 + 6; pre = next - 1; }
				else if (n % 8 == 1 || n % 8 == 7) {next = n * 4 - 2; pre = next - 1;}
				else {next = n * 4 + 2; pre = next - 1;}
				
				for (int i = 0; i < 2; i++)
				{
					Link dirA = new Link(Config.router.level1RingLinkLatency - 1);
					Link dirB = new Link(Config.router.level1RingLinkLatency - 1);
					Link dirC = new Link(Config.router.level1RingLinkLatency - 1);
					Link dirD = new Link(Config.router.level1RingLinkLatency - 1);
					links.Add(dirA);
					links.Add(dirB);
					links.Add(dirC);
					links.Add(dirD);
	
					L2bridgeRouters[n].LLinkOut[i * 2] = dirA;
					L1bridgeRouters[next].GLinkIn[i * 2] = dirA;
					L2bridgeRouters[n].LLinkIn[i * 2 + 1] = dirB;
					L1bridgeRouters[next].GLinkOut[i * 2 + 1] = dirB;

					L2bridgeRouters[n].LLinkOut[i * 2 + 1] = dirC;
					L1bridgeRouters[pre].GLinkIn[i * 2 + 1] = dirC;
					L2bridgeRouters[n].LLinkIn[i * 2] = dirD;
					L1bridgeRouters[pre].GLinkOut[i * 2] = dirD;
				}
				int nextL2 = (n + 1) % 8 + n / 8 * 8;
				if (n % 8 == 1 || n % 8 == 5)
					continue;
				for (int i = 0; i < 4; i++)
				{
					Link dirA = new Link(Config.router.level2RingLinkLatency - 1);
					Link dirB = new Link(Config.router.level2RingLinkLatency - 1);
					links.Add(dirA);
					links.Add(dirB);
					L2bridgeRouters[n].GLinkIn[i*2+1] = dirA;
					L2bridgeRouters[nextL2].GLinkOut[i*2+1] = dirA;
					L2bridgeRouters[n].GLinkOut[i*2] = dirB;
					L2bridgeRouters[nextL2].GLinkIn[i*2] = dirB;
				}
			}			
			//connect L3 bridge Routers
			for (int n = 0; n < 32; n++)
			{
				int next, pre;
				if (n % 8 == 0 || n % 8 == 6) {next = n * 4 + 6; pre = next - 1;}
				else if (n % 8 == 1 || n % 8 == 7) {next = n * 4 - 2; pre = next - 1;}
				else {next = n * 4 + 2; pre = next - 1;}

				for (int i = 0; i < 4; i++)
				{	
					Link dirA = new Link(Config.router.level2RingLinkLatency - 1);
					Link dirB = new Link(Config.router.level2RingLinkLatency - 1);
					Link dirC = new Link(Config.router.level2RingLinkLatency - 1);
					Link dirD = new Link(Config.router.level2RingLinkLatency - 1);
					links.Add(dirA);
					links.Add(dirB);
					links.Add(dirC);
					links.Add(dirD);

					L3bridgeRouters[n].LLinkOut[i*2] = dirA;
					L2bridgeRouters[next].GLinkIn[i*2] = dirA;
					L3bridgeRouters[n].LLinkIn[i*2+1] = dirB;
					L2bridgeRouters[next].GLinkOut[i*2+1] = dirB;

					L3bridgeRouters[n].LLinkOut[i * 2 + 1] = dirC;
					L2bridgeRouters[pre].GLinkIn[i * 2 + 1] = dirC;
					L3bridgeRouters[n].LLinkIn[i * 2] = dirD;
					L2bridgeRouters[pre].GLinkOut[i * 2] = dirD;
				}				
				int nextL3 = (n+1) % 8 + n / 8 * 8;
				if (n % 8 == 1 || n % 8 == 5)
					continue;
				for (int i = 0; i < 8; i++)
				{
					Link dirA = new Link(Config.router.level3RingLinkLatency - 1);
					Link dirB = new Link(Config.router.level3RingLinkLatency - 1);
					links.Add(dirA);
					links.Add(dirB);
					L3bridgeRouters[n].GLinkIn[i*2+1] = dirA;
					L3bridgeRouters[nextL3].GLinkOut[i*2+1] = dirA;
					L3bridgeRouters[n].GLinkOut[i*2] = dirB;
					L3bridgeRouters[nextL3].GLinkIn[i*2] = dirB;
				}
			}
			//connect L4 bridge Routers
			for (int n = 0; n < 8; n++)
			{
				int next, pre;
				if (n % 8 == 0 || n % 8 == 6) {next = n * 4 + 6; pre = next - 1;}
				else if (n % 8 == 1 || n % 8 == 7) {next = n * 4 - 2; pre = next - 1;}
				else {next = n * 4 + 2; pre = next - 1;}

				for (int i = 0; i < 8; i++)
				{	
					Link dirA = new Link(Config.router.level3RingLinkLatency - 1);
					Link dirB = new Link(Config.router.level3RingLinkLatency - 1);
					Link dirC = new Link(Config.router.level3RingLinkLatency - 1);
					Link dirD = new Link(Config.router.level3RingLinkLatency - 1);
					links.Add(dirA);
					links.Add(dirB);
					links.Add(dirC);
					links.Add(dirD);

					L4bridgeRouters[n].LLinkOut[i*2] = dirA;
					L3bridgeRouters[next].GLinkIn[i*2] = dirA;
					L4bridgeRouters[n].LLinkIn[i*2+1] = dirB;
					L3bridgeRouters[next].GLinkOut[i*2+1] = dirB;

					L4bridgeRouters[n].LLinkOut[i * 2 + 1] = dirC;
					L3bridgeRouters[pre].GLinkIn[i * 2 + 1] = dirC;
					L4bridgeRouters[n].LLinkIn[i * 2] = dirD;
					L3bridgeRouters[pre].GLinkOut[i * 2] = dirD;
				}				
				int nextL4 = (n+1) % 8 + n / 8 * 8;
				for (int i = 0; i < 16; i++)
				{
					Link dirA = new Link(Config.router.level4RingLinkLatency - 1);
					Link dirB = new Link(Config.router.level4RingLinkLatency - 1);
					links.Add(dirA);
					links.Add(dirB);
					L4bridgeRouters[n].GLinkIn[i*2+1] = dirA;
					L4bridgeRouters[nextL4].GLinkOut[i*2+1] = dirA;
					L4bridgeRouters[n].GLinkOut[i*2] = dirB;
					L4bridgeRouters[nextL4].GLinkIn[i*2] = dirB;
				}
			}

       	}
Ejemplo n.º 27
0
        public override void setup()
        {
            // boilerplate
            nodes = new Node[Config.N];
            cache = new CmpCache();
            ParseFinish(Config.finish);
            workload = new Workload(Config.traceFilenames);
            mapping = new NodeMapping_AllCPU_SharedCache();

            links = new List<Link>();
            _routers = new BufRingNetwork_Router[Config.N];

            // create routers and nodes
            for (int n = 0; n < Config.N; n++)
            {
                Coord c = new Coord(n);
                nodes[n] = new Node(mapping, c);
                _routers[n] = new BufRingNetwork_Router(c);
                _routers[n].setNode(nodes[n]);
                nodes[n].setRouter(_routers[n]);
            }

            int B = Config.bufrings_branching;

            // create the NICs and IRIs
            _nics = new BufRingNetwork_NIC[Config.N * Config.bufrings_n];
            _iris = new BufRingNetwork_IRI[B * Config.bufrings_n];

            // for each copy of the network...
            for (int copy = 0; copy < Config.bufrings_n; copy++) {

                // for each local ring...
                for (int ring = 0; ring < B; ring++) {

                    // create global ring interface
                    _iris[copy*B + ring] = new BufRingNetwork_IRI(ring);

                    // create local NICs (ring stops)
                    for (int local = 0; local < B; local++)
                        _nics[copy*Config.N + ring*B + local] = new BufRingNetwork_NIC(ring, local);
                    // connect with links
                    for (int local = 1; local < B; local++)
                    {
                        Link l = new Link(Config.bufrings_locallat - 1);
                        links.Add(l);
                        _nics[copy*Config.N + ring*B + local - 1].setOutput(l,
                                _nics[copy*Config.N + ring*B + local]);
                        _nics[copy*Config.N + ring*B + local].setInput(l);
                    }
                    Link iriIn = new Link(Config.bufrings_locallat - 1), iriOut = new Link(Config.bufrings_locallat - 1);
                    links.Add(iriIn);
                    links.Add(iriOut);
                    _nics[copy*Config.N + ring*B + B-1].setOutput(iriIn,
                            _iris[copy*B + ring]);
                    _nics[copy*Config.N + ring*B + 0].setInput(iriOut);

                    _iris[copy*B + ring].setLocalInput(iriIn);
                    _iris[copy*B + ring].setLocalOutput(iriOut,
                            _nics[copy*Config.N + ring*B + 0]);

                }

                // connect IRIs with links to make up global ring
                for (int ring = 0; ring < B; ring++) {
                    Link globalLink = new Link(Config.bufrings_globallat - 1);
                    links.Add(globalLink);
                    _iris[copy*B + ring].setGlobalOutput(globalLink,
                            _iris[copy*B + (ring+1)%B]);
                    _iris[copy*B + (ring+1)%B].setGlobalInput(globalLink);
                }

                // add the corresponding NIC to each node/router
                for (int id = 0; id < Config.N; id++) {
                    int ring, local;
                    BufRingNetwork_NIC.Map(id, out ring, out local);

                    _routers[id].addNIC(_nics[copy * Config.N + ring*B + local]);
                    _nics[copy * Config.N + ring*B + local].setRouter(_routers[id]);
                }
            }

        }