From 4b67ada89e2e47b26ad07562774ff65beb5633a5 Mon Sep 17 00:00:00 2001 From: Nilay Vaish Date: Thu, 20 Mar 2014 09:14:14 -0500 Subject: ruby: garnet: convert network interfaces into clocked objects This helps in configuring the network interfaces from the python script and these objects no longer rely on the network object for the timing information. --- .../garnet/fixed-pipeline/NetworkInterface_d.cc | 68 ++++++++++++---------- 1 file changed, 36 insertions(+), 32 deletions(-) (limited to 'src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc') diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc b/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc index c4c64b5ea..3e4088038 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc +++ b/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc @@ -42,14 +42,12 @@ using namespace std; using m5::stl_helpers::deletePointers; -NetworkInterface_d::NetworkInterface_d(int id, int virtual_networks, - GarnetNetwork_d *network_ptr) - : Consumer(network_ptr) +NetworkInterface_d::NetworkInterface_d(const Params *p) + : ClockedObject(p), Consumer(this) { - m_id = id; - m_net_ptr = network_ptr; - m_virtual_networks = virtual_networks; - m_vc_per_vnet = m_net_ptr->getVCsPerVnet(); + m_id = p->id; + m_virtual_networks = p->virt_nets; + m_vc_per_vnet = p->vcs_per_vnet; m_num_vcs = m_vc_per_vnet*m_virtual_networks; m_vc_round_robin = 0; @@ -64,11 +62,16 @@ NetworkInterface_d::NetworkInterface_d(int id, int virtual_networks, m_ni_buffers[i] = new flitBuffer_d(); m_ni_enqueue_time[i] = INFINITE_; } + m_vc_allocator.resize(m_virtual_networks); // 1 allocator per vnet for (int i = 0; i < m_virtual_networks; i++) { m_vc_allocator[i] = 0; } +} +void +NetworkInterface_d::init() +{ for (int i = 0; i < m_num_vcs; i++) { m_out_vc_state.push_back(new OutVcState_d(i, m_net_ptr)); } @@ -115,9 +118,8 @@ NetworkInterface_d::addNode(vector& in, // the protocol injects messages into the NI inNode_ptr[j]->setConsumer(this); - inNode_ptr[j]->setReceiver(m_net_ptr); - - outNode_ptr[j]->setSender(m_net_ptr); + inNode_ptr[j]->setReceiver(this); + outNode_ptr[j]->setSender(this); } } @@ -172,15 +174,14 @@ NetworkInterface_d::flitisizeMessage(MsgPtr msg_ptr, int vnet) for (int i = 0; i < num_flits; i++) { m_net_ptr->increment_injected_flits(vnet); flit_d *fl = new flit_d(i, vc, vnet, num_flits, new_msg_ptr, - m_net_ptr->curCycle()); + curCycle()); - fl->set_delay(m_net_ptr->curCycle() - - m_net_ptr->ticksToCycles(msg_ptr->getTime())); + fl->set_delay(curCycle() - ticksToCycles(msg_ptr->getTime())); m_ni_buffers[vc]->insert(fl); } - m_ni_enqueue_time[vc] = m_net_ptr->curCycle(); - m_out_vc_state[vc]->setState(ACTIVE_, m_net_ptr->curCycle()); + m_ni_enqueue_time[vc] = curCycle(); + m_out_vc_state[vc]->setState(ACTIVE_, curCycle()); } return true ; } @@ -196,7 +197,7 @@ NetworkInterface_d::calculateVC(int vnet) m_vc_allocator[vnet] = 0; if (m_out_vc_state[(vnet*m_vc_per_vnet) + delta]->isInState( - IDLE_, m_net_ptr->curCycle())) { + IDLE_, curCycle())) { return ((vnet*m_vc_per_vnet) + delta); } } @@ -216,8 +217,7 @@ NetworkInterface_d::calculateVC(int vnet) void NetworkInterface_d::wakeup() { - DPRINTF(RubyNetwork, "m_id: %d woke up at time: %lld", - m_id, m_net_ptr->curCycle()); + DPRINTF(RubyNetwork, "m_id: %d woke up at time: %lld", m_id, curCycle()); MsgPtr msg_ptr; @@ -239,7 +239,7 @@ NetworkInterface_d::wakeup() /*********** Picking messages destined for this NI **********/ - if (inNetLink->isReady(m_net_ptr->curCycle())) { + if (inNetLink->isReady(curCycle())) { flit_d *t_flit = inNetLink->consumeLink(); bool free_signal = false; if (t_flit->get_type() == TAIL_ || t_flit->get_type() == HEAD_TAIL_) { @@ -251,15 +251,14 @@ NetworkInterface_d::wakeup() // Simply send a credit back since we are not buffering // this flit in the NI flit_d *credit_flit = new flit_d(t_flit->get_vc(), free_signal, - m_net_ptr->curCycle()); + curCycle()); creditQueue->insert(credit_flit); m_ni_credit_link-> - scheduleEventAbsolute(m_net_ptr->clockEdge(Cycles(1))); + scheduleEventAbsolute(clockEdge(Cycles(1))); int vnet = t_flit->get_vnet(); m_net_ptr->increment_received_flits(vnet); - Cycles network_delay = m_net_ptr->curCycle() - - t_flit->get_enqueue_time(); + Cycles network_delay = curCycle() - t_flit->get_enqueue_time(); Cycles queueing_delay = t_flit->get_delay(); m_net_ptr->increment_network_latency(network_delay, vnet); @@ -269,12 +268,11 @@ NetworkInterface_d::wakeup() /****************** Checking for credit link *******/ - if (m_credit_link->isReady(m_net_ptr->curCycle())) { + if (m_credit_link->isReady(curCycle())) { flit_d *t_flit = m_credit_link->consumeLink(); m_out_vc_state[t_flit->get_vc()]->increment_credit(); if (t_flit->is_free_signal()) { - m_out_vc_state[t_flit->get_vc()]->setState(IDLE_, - m_net_ptr->curCycle()); + m_out_vc_state[t_flit->get_vc()]->setState(IDLE_, curCycle()); } delete t_flit; } @@ -300,7 +298,7 @@ NetworkInterface_d::scheduleOutputLink() vc = 0; // model buffer backpressure - if (m_ni_buffers[vc]->isReady(m_net_ptr->curCycle()) && + if (m_ni_buffers[vc]->isReady(curCycle()) && m_out_vc_state[vc]->has_credits()) { bool is_candidate_vc = true; @@ -311,7 +309,7 @@ NetworkInterface_d::scheduleOutputLink() for (int vc_offset = 0; vc_offset < m_vc_per_vnet; vc_offset++) { int t_vc = vc_base + vc_offset; - if (m_ni_buffers[t_vc]->isReady(m_net_ptr->curCycle())) { + if (m_ni_buffers[t_vc]->isReady(curCycle())) { if (m_ni_enqueue_time[t_vc] < m_ni_enqueue_time[vc]) { is_candidate_vc = false; break; @@ -325,11 +323,10 @@ NetworkInterface_d::scheduleOutputLink() m_out_vc_state[vc]->decrement_credit(); // Just removing the flit flit_d *t_flit = m_ni_buffers[vc]->getTopFlit(); - t_flit->set_time(m_net_ptr->curCycle() + Cycles(1)); + t_flit->set_time(curCycle() + Cycles(1)); outSrcQueue->insert(t_flit); // schedule the out link - outNetLink-> - scheduleEventAbsolute(m_net_ptr->clockEdge(Cycles(1))); + outNetLink->scheduleEventAbsolute(clockEdge(Cycles(1))); if (t_flit->get_type() == TAIL_ || t_flit->get_type() == HEAD_TAIL_) { @@ -361,7 +358,7 @@ NetworkInterface_d::checkReschedule() } } for (int vc = 0; vc < m_num_vcs; vc++) { - if (m_ni_buffers[vc]->isReady(m_net_ptr->curCycle() + Cycles(1))) { + if (m_ni_buffers[vc]->isReady(curCycle() + Cycles(1))) { scheduleEvent(Cycles(1)); return; } @@ -385,3 +382,10 @@ NetworkInterface_d::functionalWrite(Packet *pkt) num_functional_writes += outSrcQueue->functionalWrite(pkt); return num_functional_writes; } + +NetworkInterface_d * +GarnetNetworkInterface_dParams::create() +{ + return new NetworkInterface_d(this); +} + -- cgit v1.2.3