示例#1
0
 public void addNIC(BufRingNetwork_NIC nic)
 {
     _nics[_nic_count++] = nic;
 }
示例#2
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]);
                }
            }
        }
示例#3
0
        public bool getCredit(Flit f, object sender, int bubble)
        {
            int ring, localid;

            BufRingNetwork_NIC.Map(f.packet.dest.ID, out ring, out localid);

            if (sender is BufRingNetwork_IRI)   // on global ring
            {
                if (ring != _id)
                {
                    if (_creditG > bubble)
                    {
                        _creditG--;
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    if (_creditGL > bubble)
                    {
                        _creditGL--;
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else if (sender is BufRingNetwork_NIC)   // on local ring
            {
                if (ring != _id)
                {
                    if (_creditLG > bubble)
                    {
                        _creditLG--;
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    if (_creditL > bubble)
                    {
                        _creditL--;
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            return(false);
        }
示例#4
0
        public bool doStep()
        {
            bool somethingMoved = false;

            // handle inputs

            // global input
            if (_gin.Out != null)
            {
                Flit f = _gin.Out;
                _gin.Out = null;

                somethingMoved = true;

                int ring, localid;
                BufRingNetwork_NIC.Map(f.packet.dest.ID, out ring, out localid);
                if (ring == _id)
                {
                    _bufGL.Enqueue(f);
                    Simulator.stats.bufrings_iri_enqueue_gl[0].Add();
                }
                else
                {
                    _bufG.Enqueue(f);
                    Simulator.stats.bufrings_iri_enqueue_g[0].Add();
                }
            }

            // local input
            if (_lin.Out != null)
            {
                Flit f = _lin.Out;
                _lin.Out = null;

                somethingMoved = true;

                int ring, localid;
                BufRingNetwork_NIC.Map(f.packet.dest.ID, out ring, out localid);
                if (ring == _id)
                {
                    _bufL.Enqueue(f);
                    Simulator.stats.bufrings_iri_enqueue_l[0].Add();
                }
                else
                {
                    _bufLG.Enqueue(f);
                    Simulator.stats.bufrings_iri_enqueue_lg[0].Add();
                }
            }

            // handle outputs

            // global output (on-ring traffic)
            if (_gout.In == null && _bufG.Count > 0)
            {
                Flit f = _bufG.Peek();
                if (_downstreamG.getCredit(f, this, 0))
                {
                    _bufG.Dequeue();
                    Simulator.stats.bufrings_iri_dequeue_g[0].Add();
                    _creditG++;
                    _gout.In       = f;
                    somethingMoved = true;
                }
            }
            // global output (transfer traffic)
            if (_gout.In == null && _bufLG.Count > 0)
            {
                Flit f = _bufLG.Peek();
                if (_downstreamG.getCredit(f, this, 1))
                {
                    _bufLG.Dequeue();
                    Simulator.stats.bufrings_iri_dequeue_lg[0].Add();
                    _creditLG++;
                    _gout.In       = f;
                    somethingMoved = true;
                }
            }

            // local output (on-ring traffic)
            if (_lout.In == null && _bufL.Count > 0)
            {
                Flit f = _bufL.Peek();
                if (_downstreamL.getCredit(f, this, 0))
                {
                    _bufL.Dequeue();
                    Simulator.stats.bufrings_iri_dequeue_l[0].Add();
                    _creditL++;
                    _lout.In       = f;
                    somethingMoved = true;
                }
            }
            // local output (transfer traffic)
            if (_lout.In == null && _bufGL.Count > 0)
            {
                Flit f = _bufGL.Peek();
                if (_downstreamL.getCredit(f, this, 1))
                {
                    _bufGL.Dequeue();
                    Simulator.stats.bufrings_iri_dequeue_gl[0].Add();
                    _creditGL++;
                    _lout.In       = f;
                    somethingMoved = true;
                }
            }

            if (_gout.In != null)
            {
                Simulator.stats.bufrings_link_traverse[0].Add();
            }
            if (_lout.In != null)
            {
                Simulator.stats.bufrings_link_traverse[1].Add();
            }

            Simulator.stats.bufrings_iri_occupancy_g[0].Add(_bufG.Count);
            Simulator.stats.bufrings_iri_occupancy_l[0].Add(_bufL.Count);
            Simulator.stats.bufrings_iri_occupancy_gl[0].Add(_bufGL.Count);
            Simulator.stats.bufrings_iri_occupancy_lg[0].Add(_bufLG.Count);

            return(somethingMoved);
        }
示例#5
0
 public void addNIC(BufRingNetwork_NIC nic)
 {
     _nics[_nic_count++] = nic;
 }