class RubySystem;
extern RubySystem* g_system_ptr;
-// FIXME: this is required by the contructor of Directory_Entry.hh.
-// It can't go into slicc_util.hh because it opens a can of ugly worms
-extern inline int max_tokens()
-{
- return 1024;
-}
-
#endif // __MEM_RUBY_COMMON_GLOBAL_HH__
void
BaseGarnetNetwork::clearStats()
{
- m_ruby_start = g_system_ptr->getTime();
+ m_ruby_start = curCycle();
}
Time
for (int i = 0; i < m_link_ptr_vector.size(); i++) {
average_link_utilization +=
(double(m_link_ptr_vector[i]->getLinkUtilization())) /
- (double(g_system_ptr->getTime()-m_ruby_start));
+ (double(curCycle() - m_ruby_start));
vector<int> vc_load = m_link_ptr_vector[i]->getVcLoad();
for (int j = 0; j < vc_load.size(); j++) {
if (!m_in_use[i/m_vcs_per_vnet])
continue;
- average_vc_load[i] = (double(average_vc_load[i]) /
- (double(g_system_ptr->getTime()) - m_ruby_start));
+ average_vc_load[i] = (double(average_vc_load[i])) /
+ (double(curCycle() - m_ruby_start));
out << "Average VC Load [" << i << "] = " << average_vc_load[i]
<< " flits/cycle " << endl;
}
// Instantiating the virtual channels
m_vcs.resize(m_num_vcs);
for (int i=0; i < m_num_vcs; i++) {
- m_vcs[i] = new VirtualChannel_d(i);
+ m_vcs[i] = new VirtualChannel_d(i, m_router->curCycle());
}
}
InputUnit_d::wakeup()
{
flit_d *t_flit;
- if (m_in_link->isReady()) {
+ if (m_in_link->isReady(m_router->curCycle())) {
t_flit = m_in_link->consumeLink();
int vc = t_flit->get_vc();
// Do the route computation for this vc
m_router->route_req(t_flit, this, vc);
- m_vcs[vc]->set_enqueue_time(g_system_ptr->getTime());
+ m_vcs[vc]->set_enqueue_time(m_router->curCycle());
} else {
- t_flit->advance_stage(SA_);
+ t_flit->advance_stage(SA_, m_router->curCycle());
m_router->swarb_req();
}
// write flit into input buffer
inline int get_inlink_id() { return m_in_link->get_id(); }
inline void
- set_vc_state(VC_state_type state, int vc)
+ set_vc_state(VC_state_type state, int vc, Time curTime)
{
- m_vcs[vc]->set_state(state);
+ m_vcs[vc]->set_state(state, curTime);
}
inline void
}
inline void
- increment_credit(int in_vc, bool free_signal)
+ increment_credit(int in_vc, bool free_signal, Time curTime)
{
- flit_d *t_flit = new flit_d(in_vc, free_signal);
+ flit_d *t_flit = new flit_d(in_vc, free_signal, curTime);
creditQueue->insert(t_flit);
m_credit_link->scheduleEvent(1);
}
}
inline void
- updateRoute(int vc, int outport)
+ updateRoute(int vc, int outport, Time curTime)
{
m_vcs[vc]->set_outport(outport);
- m_vcs[vc]->set_state(VC_AB_);
+ m_vcs[vc]->set_state(VC_AB_, curTime);
}
inline void
- grant_vc(int in_vc, int out_vc)
+ grant_vc(int in_vc, int out_vc, Time curTime)
{
- m_vcs[in_vc]->grant_vc(out_vc);
+ m_vcs[in_vc]->grant_vc(out_vc, curTime);
}
inline flit_d*
}
inline bool
- need_stage(int vc, VC_state_type state, flit_stage stage)
+ need_stage(int vc, VC_state_type state, flit_stage stage, Time curTime)
{
- return m_vcs[vc]->need_stage(state, stage);
+ return m_vcs[vc]->need_stage(state, stage, curTime);
}
inline bool
- need_stage_nextcycle(int vc, VC_state_type state, flit_stage stage)
+ need_stage_nextcycle(int vc, VC_state_type state, flit_stage stage,
+ Time curTime)
{
- return m_vcs[vc]->need_stage_nextcycle(state, stage);
+ return m_vcs[vc]->need_stage_nextcycle(state, stage, curTime);
}
inline bool
- isReady(int invc)
+ isReady(int invc, Time curTime)
{
- return m_vcs[invc]->isReady();
+ return m_vcs[invc]->isReady(curTime);
}
inline int
for (int i = 0; i < m_num_vcs; i++) {
m_out_vc_state.push_back(new OutVcState_d(i, m_net_ptr));
- m_out_vc_state[i]->setState(IDLE_, g_system_ptr->getTime());
+ m_out_vc_state[i]->setState(IDLE_, m_net_ptr->curCycle());
}
}
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);
- fl->set_delay(g_system_ptr->getTime() - msg_ptr->getTime());
+ flit_d *fl = new flit_d(i, vc, vnet, num_flits, new_msg_ptr,
+ m_net_ptr->curCycle());
+
+ fl->set_delay(m_net_ptr->curCycle() - msg_ptr->getTime());
m_ni_buffers[vc]->insert(fl);
}
- m_ni_enqueue_time[vc] = g_system_ptr->getTime();
- m_out_vc_state[vc]->setState(ACTIVE_, g_system_ptr->getTime());
+
+ m_ni_enqueue_time[vc] = m_net_ptr->curCycle();
+ m_out_vc_state[vc]->setState(ACTIVE_, m_net_ptr->curCycle());
}
return true ;
}
m_vc_allocator[vnet] = 0;
if (m_out_vc_state[(vnet*m_vc_per_vnet) + delta]->isInState(
- IDLE_, g_system_ptr->getTime())) {
+ IDLE_, m_net_ptr->curCycle())) {
return ((vnet*m_vc_per_vnet) + delta);
}
}
NetworkInterface_d::wakeup()
{
DPRINTF(RubyNetwork, "m_id: %d woke up at time: %lld",
- m_id, g_system_ptr->getTime());
+ m_id, m_net_ptr->curCycle());
MsgPtr msg_ptr;
/*********** Picking messages destined for this NI **********/
- if (inNetLink->isReady()) {
+ if (inNetLink->isReady(m_net_ptr->curCycle())) {
flit_d *t_flit = inNetLink->consumeLink();
bool free_signal = false;
if (t_flit->get_type() == TAIL_ || t_flit->get_type() == HEAD_TAIL_) {
}
// 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);
+ flit_d *credit_flit = new flit_d(t_flit->get_vc(), free_signal,
+ m_net_ptr->curCycle());
creditQueue->insert(credit_flit);
m_ni_credit_link->scheduleEvent(1);
int vnet = t_flit->get_vnet();
m_net_ptr->increment_received_flits(vnet);
- int network_delay = g_system_ptr->getTime() -
+ int network_delay = m_net_ptr->curCycle() -
t_flit->get_enqueue_time();
int queueing_delay = t_flit->get_delay();
m_net_ptr->increment_network_latency(network_delay, vnet);
/****************** Checking for credit link *******/
- if (m_credit_link->isReady()) {
+ if (m_credit_link->isReady(m_net_ptr->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_,
- g_system_ptr->getTime());
+ m_net_ptr->curCycle());
}
delete t_flit;
}
vc = 0;
// model buffer backpressure
- if (m_ni_buffers[vc]->isReady() && m_out_vc_state[vc]->has_credits()) {
+ if (m_ni_buffers[vc]->isReady(m_net_ptr->curCycle()) &&
+ m_out_vc_state[vc]->has_credits()) {
+
bool is_candidate_vc = true;
int t_vnet = get_vnet(vc);
int vc_base = t_vnet * m_vc_per_vnet;
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()) {
+ if (m_ni_buffers[t_vc]->isReady(m_net_ptr->curCycle())) {
if (m_ni_enqueue_time[t_vc] < m_ni_enqueue_time[vc]) {
is_candidate_vc = false;
break;
m_out_vc_state[vc]->decrement_credit();
// Just removing the flit
flit_d *t_flit = m_ni_buffers[vc]->getTopFlit();
- t_flit->set_time(g_system_ptr->getTime() + 1);
+ t_flit->set_time(m_net_ptr->curCycle() + 1);
outSrcQueue->insert(t_flit);
// schedule the out link
outNetLink->scheduleEvent(1);
}
}
for (int vc = 0; vc < m_num_vcs; vc++) {
- if (m_ni_buffers[vc]->isReadyForNext()) {
+ if (m_ni_buffers[vc]->isReadyForNext(m_net_ptr->curCycle())) {
scheduleEvent(1);
return;
}
void
NetworkLink_d::wakeup()
{
- if (link_srcQueue->isReady()) {
+ if (link_srcQueue->isReady(curCycle())) {
flit_d *t_flit = link_srcQueue->getTopFlit();
- t_flit->set_time(g_system_ptr->getTime() + m_latency);
+ t_flit->set_time(curCycle() + m_latency);
linkBuffer->insert(t_flit);
link_consumer->scheduleEvent(m_latency);
m_link_utilized++;
double calculate_power();
- inline bool isReady() { return linkBuffer->isReady(); }
+ inline bool isReady(Time curTime) { return linkBuffer->isReady(curTime); }
inline flit_d* peekLink() { return linkBuffer->peekTopFlit(); }
inline flit_d* consumeLink() { return linkBuffer->getTopFlit(); }
void init_net_ptr(GarnetNetwork_d* net_ptr)
void
OutputUnit_d::wakeup()
{
- if (m_credit_link->isReady()) {
+ if (m_credit_link->isReady(m_router->curCycle())) {
flit_d *t_flit = m_credit_link->consumeLink();
int out_vc = t_flit->get_vc();
m_outvc_state[out_vc]->increment_credit();
m_outvc_state[out_vc]->get_credit_count());
if (t_flit->is_free_signal())
- set_vc_state(IDLE_, out_vc);
+ set_vc_state(IDLE_, out_vc, m_router->curCycle());
delete t_flit;
}
void
OutputUnit_d::update_vc(int vc, int in_port, int in_vc)
{
- m_outvc_state[vc]->setState(ACTIVE_, g_system_ptr->getTime() + 1);
+ m_outvc_state[vc]->setState(ACTIVE_, m_router->curCycle() + 1);
m_outvc_state[vc]->set_inport(in_port);
m_outvc_state[vc]->set_invc(in_vc);
m_router->update_incredit(in_port, in_vc,
}
inline void
- set_vc_state(VC_state_type state, int vc)
+ set_vc_state(VC_state_type state, int vc, Time curTime)
{
- m_outvc_state[vc]->setState(state, g_system_ptr->getTime() + 1);
+ m_outvc_state[vc]->setState(state, curTime + 1);
}
inline bool
- is_vc_idle(int vc)
+ is_vc_idle(int vc, Time curTime)
{
- return (m_outvc_state[vc]->isInState(IDLE_,
- g_system_ptr->getTime()));
+ return (m_outvc_state[vc]->isInState(IDLE_, curTime));
}
inline void
RoutingUnit_d::RC_stage(flit_d *t_flit, InputUnit_d *in_unit, int invc)
{
int outport = routeCompute(t_flit);
- in_unit->updateRoute(invc, outport);
- t_flit->advance_stage(VA_);
+ in_unit->updateRoute(invc, outport, m_router->curCycle());
+ t_flit->advance_stage(VA_, m_router->curCycle());
m_router->vcarb_req();
}
get_vnet(invc))))
continue;
- if (m_input_unit[inport]->need_stage(invc, ACTIVE_, SA_) &&
- m_input_unit[inport]->has_credits(invc)) {
+ if (m_input_unit[inport]->need_stage(invc, ACTIVE_, SA_,
+ m_router->curCycle()) &&
+ m_input_unit[inport]->has_credits(invc)) {
+
if (is_candidate_inport(inport, invc)) {
int outport = m_input_unit[inport]->get_route(invc);
m_local_arbiter_activity++;
if ((m_router->get_net_ptr())->isVNetOrdered(t_vnet)) {
for (int vc_offset = 0; vc_offset < m_vc_per_vnet; vc_offset++) {
int temp_vc = vc_base + vc_offset;
- if (m_input_unit[inport]->need_stage(temp_vc, ACTIVE_, SA_) &&
+ if (m_input_unit[inport]->need_stage(temp_vc, ACTIVE_, SA_,
+ m_router->curCycle()) &&
(m_input_unit[inport]->get_route(temp_vc) == outport) &&
(m_input_unit[inport]->get_enqueue_time(temp_vc) <
t_enqueue_time)) {
// remove flit from Input Unit
flit_d *t_flit = m_input_unit[inport]->getTopFlit(invc);
- t_flit->advance_stage(ST_);
+ t_flit->advance_stage(ST_, m_router->curCycle());
t_flit->set_vc(outvc);
t_flit->set_outport(outport);
- t_flit->set_time(g_system_ptr->getTime() + 1);
+ t_flit->set_time(m_router->curCycle() + 1);
m_output_unit[outport]->decrement_credit(outvc);
m_router->update_sw_winner(inport, t_flit);
m_global_arbiter_activity++;
if ((t_flit->get_type() == TAIL_) ||
t_flit->get_type() == HEAD_TAIL_) {
+
// Send a credit back
// along with the information that this VC is now idle
- m_input_unit[inport]->increment_credit(invc, true);
+ m_input_unit[inport]->increment_credit(invc, true,
+ m_router->curCycle());
+
// This Input VC should now be empty
- assert(m_input_unit[inport]->isReady(invc) == false);
+ assert(m_input_unit[inport]->isReady(invc,
+ m_router->curCycle()) == false);
- m_input_unit[inport]->set_vc_state(IDLE_, invc);
+ m_input_unit[inport]->set_vc_state(IDLE_, invc,
+ m_router->curCycle());
m_input_unit[inport]->set_enqueue_time(invc, INFINITE_);
} else {
// Send a credit back
// but do not indicate that the VC is idle
- m_input_unit[inport]->increment_credit(invc, false);
+ m_input_unit[inport]->increment_credit(invc, false,
+ m_router->curCycle());
}
break; // got a in request for this outport
}
{
for (int i = 0; i < m_num_inports; i++) {
for (int j = 0; j < m_num_vcs; j++) {
- if (m_input_unit[i]->need_stage_nextcycle(j, ACTIVE_, SA_)) {
+ if (m_input_unit[i]->need_stage_nextcycle(j, ACTIVE_, SA_,
+ m_router->curCycle())) {
scheduleEvent(1);
return;
}
Switch_d::wakeup()
{
DPRINTF(RubyNetwork, "Switch woke up at time: %lld\n",
- g_system_ptr->getTime());
+ m_router->curCycle());
for (int inport = 0; inport < m_num_inports; inport++) {
- if (!m_switch_buffer[inport]->isReady())
+ if (!m_switch_buffer[inport]->isReady(m_router->curCycle()))
continue;
flit_d *t_flit = m_switch_buffer[inport]->peekTopFlit();
- if (t_flit->is_stage(ST_)) {
+ if (t_flit->is_stage(ST_, m_router->curCycle())) {
int outport = t_flit->get_outport();
- t_flit->advance_stage(LT_);
- t_flit->set_time(g_system_ptr->getTime() + 1);
+ t_flit->advance_stage(LT_, m_router->curCycle());
+ t_flit->set_time(m_router->curCycle() + 1);
// This will take care of waking up the Network Link
m_output_unit[outport]->insert_flit(t_flit);
Switch_d::check_for_wakeup()
{
for (int inport = 0; inport < m_num_inports; inport++) {
- if (m_switch_buffer[inport]->isReadyForNext()) {
+ if (m_switch_buffer[inport]->isReadyForNext(m_router->curCycle())) {
scheduleEvent(1);
break;
}
if ((m_router->get_net_ptr())->isVNetOrdered(vnet)) {
for (int vc_offset = 0; vc_offset < m_vc_per_vnet; vc_offset++) {
int temp_vc = invc_base + vc_offset;
- if (m_input_unit[inport_iter]->need_stage(temp_vc, VC_AB_, VA_) &&
+ if (m_input_unit[inport_iter]->need_stage(temp_vc, VC_AB_, VA_,
+ m_router->curCycle()) &&
(m_input_unit[inport_iter]->get_route(temp_vc) == outport) &&
(m_input_unit[inport_iter]->get_enqueue_time(temp_vc) <
t_enqueue_time)) {
if (outvc_offset >= num_vcs_per_vnet)
outvc_offset = 0;
int outvc = outvc_base + outvc_offset;
- if (m_output_unit[outport]->is_vc_idle(outvc)) {
+ if (m_output_unit[outport]->is_vc_idle(outvc, m_router->curCycle())) {
m_local_arbiter_activity[vnet]++;
m_outvc_req[outport][outvc][inport_iter][invc_iter] = true;
if (!m_outvc_is_req[outport][outvc])
get_vnet(invc_iter))))
continue;
- if (m_input_unit[inport_iter]->need_stage(
- invc_iter, VC_AB_, VA_)) {
+ if (m_input_unit[inport_iter]->need_stage(invc_iter, VC_AB_,
+ VA_, m_router->curCycle())) {
if (!is_invc_candidate(inport_iter, invc_iter))
continue;
int invc = invc_base + invc_offset;
if (m_outvc_req[outport_iter][outvc_iter][inport][invc]) {
m_global_arbiter_activity[vnet]++;
- m_input_unit[inport]->grant_vc(invc, outvc_iter);
+ m_input_unit[inport]->grant_vc(invc, outvc_iter,
+ m_router->curCycle());
m_output_unit[outport_iter]->update_vc(
outvc_iter, inport, invc);
m_router->swarb_req();
{
for (int i = 0; i < m_num_inports; i++) {
for (int j = 0; j < m_num_vcs; j++) {
- if (m_input_unit[i]->need_stage_nextcycle(j, VC_AB_, VA_)) {
+ if (m_input_unit[i]->need_stage_nextcycle(j, VC_AB_, VA_,
+ m_router->curCycle())) {
scheduleEvent(1);
return;
}
#include "mem/ruby/network/garnet/fixed-pipeline/VirtualChannel_d.hh"
-VirtualChannel_d::VirtualChannel_d(int id)
+VirtualChannel_d::VirtualChannel_d(int id, Time curTime)
{
m_id = id;
m_input_buffer = new flitBuffer_d();
m_vc_state.first = IDLE_;
- m_vc_state.second = g_system_ptr->getTime();
+ m_vc_state.second = curTime;
m_enqueue_time = INFINITE_;
}
}
void
-VirtualChannel_d::grant_vc(int out_vc)
+VirtualChannel_d::grant_vc(int out_vc, Time curTime)
{
m_output_vc = out_vc;
m_vc_state.first = ACTIVE_;
- m_vc_state.second = g_system_ptr->getTime() + 1;
+ m_vc_state.second = curTime + 1;
flit_d *t_flit = m_input_buffer->peekTopFlit();
- t_flit->advance_stage(SA_);
+ t_flit->advance_stage(SA_, curTime);
}
bool
-VirtualChannel_d::need_stage(VC_state_type state, flit_stage stage)
+VirtualChannel_d::need_stage(VC_state_type state, flit_stage stage,
+ Time curTime)
{
- if ((m_vc_state.first == state) &&
- (g_system_ptr->getTime() >= m_vc_state.second)) {
- if (m_input_buffer->isReady()) {
+ if ((m_vc_state.first == state) && (curTime >= m_vc_state.second)) {
+ if (m_input_buffer->isReady(curTime)) {
flit_d *t_flit = m_input_buffer->peekTopFlit();
- return(t_flit->is_stage(stage)) ;
+ return(t_flit->is_stage(stage, curTime)) ;
}
}
return false;
-
}
bool
-VirtualChannel_d::need_stage_nextcycle(VC_state_type state, flit_stage stage)
+VirtualChannel_d::need_stage_nextcycle(VC_state_type state, flit_stage stage,
+ Time curTime)
{
- if ((m_vc_state.first == state) &&
- ((g_system_ptr->getTime()+1) >= m_vc_state.second)) {
- if (m_input_buffer->isReadyForNext()) {
+ if ((m_vc_state.first == state) && ((curTime + 1) >= m_vc_state.second)) {
+ if (m_input_buffer->isReadyForNext(curTime)) {
flit_d *t_flit = m_input_buffer->peekTopFlit();
- return(t_flit->is_next_stage(stage)) ;
+ return(t_flit->is_next_stage(stage, curTime)) ;
}
}
return false;
class VirtualChannel_d
{
public:
- VirtualChannel_d(int id);
+ VirtualChannel_d(int id, Time curTime);
~VirtualChannel_d();
- bool need_stage(VC_state_type state, flit_stage stage);
- bool need_stage_nextcycle(VC_state_type state, flit_stage stage);
+ bool need_stage(VC_state_type state, flit_stage stage, Time curTime);
+ bool need_stage_nextcycle(VC_state_type state, flit_stage stage,
+ Time curTime);
void set_outport(int outport);
- void grant_vc(int out_vc);
+ void grant_vc(int out_vc, Time curTime);
inline Time get_enqueue_time() { return m_enqueue_time; }
inline void set_enqueue_time(Time time) { m_enqueue_time = time; }
inline void update_credit(int credit) { m_credit_count = credit; }
inline void increment_credit() { m_credit_count++; }
- inline bool isReady() { return m_input_buffer->isReady(); }
+ inline bool isReady(Time curTime)
+ {
+ return m_input_buffer->isReady(curTime);
+ }
inline void
insertFlit(flit_d *t_flit)
}
inline void
- set_state(VC_state_type m_state)
+ set_state(VC_state_type m_state, Time curTime)
{
m_vc_state.first = m_state;
- m_vc_state.second = g_system_ptr->getTime() + 1;
+ m_vc_state.second = curTime + 1;
}
inline flit_d*
}
bool
-flitBuffer_d::isReady()
+flitBuffer_d::isReady(Time curTime)
{
if (m_buffer.size() != 0 ) {
flit_d *t_flit = peekTopFlit();
- if (t_flit->get_time() <= g_system_ptr->getTime())
+ if (t_flit->get_time() <= curTime)
return true;
}
return false;
}
bool
-flitBuffer_d::isReadyForNext()
+flitBuffer_d::isReadyForNext(Time curTime)
{
if (m_buffer.size() != 0 ) {
flit_d *t_flit = peekTopFlit();
- if (t_flit->get_time() <= (g_system_ptr->getTime() + 1))
+ if (t_flit->get_time() <= (curTime + 1))
return true;
}
return false;
flitBuffer_d();
flitBuffer_d(int maximum_size);
- bool isReady();
- bool isReadyForNext();
+ bool isReady(Time curTime);
+ bool isReadyForNext(Time curTime);
bool isEmpty();
void print(std::ostream& out) const;
bool isFull();
#include "mem/ruby/network/garnet/fixed-pipeline/flit_d.hh"
-flit_d::flit_d(int id, int vc, int vnet, int size, MsgPtr msg_ptr)
+flit_d::flit_d(int id, int vc, int vnet, int size, MsgPtr msg_ptr,
+ Time curTime)
{
m_size = size;
m_msg_ptr = msg_ptr;
- m_enqueue_time = g_system_ptr->getTime();
- m_time = g_system_ptr->getTime();
+ m_enqueue_time = curTime;
+ m_time = curTime;
m_id = id;
m_vnet = vnet;
m_vc = vc;
m_type = BODY_;
}
-flit_d::flit_d(int vc, bool is_free_signal)
+flit_d::flit_d(int vc, bool is_free_signal, Time curTime)
{
m_id = 0;
m_vc = vc;
m_is_free_signal = is_free_signal;
- m_time = g_system_ptr->getTime();
+ m_time = curTime;
}
void
class flit_d
{
public:
- flit_d(int id, int vc, int vnet, int size, MsgPtr msg_ptr);
- flit_d(int vc, bool is_free_signal);
+ flit_d(int id, int vc, int vnet, int size, MsgPtr msg_ptr, Time curTime);
+ flit_d(int vc, bool is_free_signal, Time curTime);
void set_outport(int port) { m_outport = port; }
int get_outport() {return m_outport; }
void print(std::ostream& out) const;
flit_type get_type() { return m_type; }
bool
- is_stage(flit_stage t_stage)
+ is_stage(flit_stage t_stage, Time curTime)
{
return (m_stage.first == t_stage &&
- g_system_ptr->getTime() >= m_stage.second);
+ curTime >= m_stage.second);
}
bool
- is_next_stage(flit_stage t_stage)
+ is_next_stage(flit_stage t_stage, Time curTime)
{
return (m_stage.first == t_stage &&
- (g_system_ptr->getTime() + 1) >= m_stage.second);
+ (curTime + 1) >= m_stage.second);
}
void
- advance_stage(flit_stage t_stage)
+ advance_stage(flit_stage t_stage, Time curTime)
{
m_stage.first = t_stage;
- m_stage.second = g_system_ptr->getTime() + 1;
+ m_stage.second = curTime + 1;
}
+
std::pair<flit_stage, Time>
get_stage()
{
for (int i = 0; i < m_link_ptr_vector.size(); i++) {
average_link_utilization +=
(double(m_link_ptr_vector[i]->getLinkUtilization())) /
- (double(g_system_ptr->getTime()-m_ruby_start));
+ (double(curCycle() - m_ruby_start));
vector<int> vc_load = m_link_ptr_vector[i]->getVcLoad();
for (int j = 0; j < vc_load.size(); j++) {
if (!m_in_use[i/m_vcs_per_vnet])
continue;
- average_vc_load[i] = (double(average_vc_load[i]) /
- (double(g_system_ptr->getTime()) - m_ruby_start));
+ average_vc_load[i] = double(average_vc_load[i]) /
+ (double(curCycle() - m_ruby_start));
out << "Average VC Load [" << i << "] = " << average_vc_load[i]
<< " flits/cycle " << endl;
}
for (int i = 0; i < m_num_vcs; i++) {
m_out_vc_state.push_back(new OutVcState(i));
- m_out_vc_state[i]->setState(IDLE_, g_system_ptr->getTime());
+ m_out_vc_state[i]->setState(IDLE_, m_net_ptr->curCycle());
}
}
}
for (int i = 0; i < num_flits; i++) {
m_net_ptr->increment_injected_flits(vnet);
- flit *fl = new flit(i, vc, vnet, num_flits, new_msg_ptr);
- fl->set_delay(g_system_ptr->getTime() - msg_ptr->getTime());
+ flit *fl = new flit(i, vc, vnet, num_flits, new_msg_ptr,
+ m_net_ptr->curCycle());
+ fl->set_delay(m_net_ptr->curCycle() - msg_ptr->getTime());
m_ni_buffers[vc]->insert(fl);
}
- m_out_vc_state[vc]->setState(VC_AB_, g_system_ptr->getTime());
+ m_out_vc_state[vc]->setState(VC_AB_, m_net_ptr->curCycle());
// setting an output vc request for the next hop.
// This flit will be ready to traverse the link and into the next hop
// only when an output vc is acquired at the next hop
outNetLink->request_vc_link(vc,
new_net_msg_ptr->getInternalDestination(),
- g_system_ptr->getTime());
+ m_net_ptr->curCycle());
}
return true ;
m_vc_allocator[vnet] = 0;
if (m_out_vc_state[(vnet*m_vc_per_vnet) + delta]->isInState(IDLE_,
- g_system_ptr->getTime())) {
+ m_net_ptr->curCycle())) {
return ((vnet*m_vc_per_vnet) + delta);
}
}
flit *t_flit = inNetLink->consumeLink();
if (t_flit->get_type() == TAIL_ || t_flit->get_type() == HEAD_TAIL_) {
DPRINTF(RubyNetwork, "m_id: %d, Message delivered at time: %lld\n",
- m_id, g_system_ptr->getTime());
+ m_id, m_net_ptr->curCycle());
outNode_ptr[t_flit->get_vnet()]->enqueue(
t_flit->get_msg_ptr(), 1);
// signal the upstream router that this vc can be freed now
inNetLink->release_vc_link(t_flit->get_vc(),
- g_system_ptr->getTime() + 1);
+ m_net_ptr->curCycle() + 1);
}
int vnet = t_flit->get_vnet();
m_net_ptr->increment_received_flits(vnet);
- int network_delay = g_system_ptr->getTime() -
+ int network_delay = m_net_ptr->curCycle() -
t_flit->get_enqueue_time();
int queueing_delay = t_flit->get_delay();
m_net_ptr->increment_network_latency(network_delay, vnet);
vc++;
if (vc == m_num_vcs)
vc = 0;
- if (m_ni_buffers[vc]->isReady()) {
+ if (m_ni_buffers[vc]->isReady(m_net_ptr->curCycle())) {
if (m_out_vc_state[vc]->isInState(ACTIVE_,
- g_system_ptr->getTime()) &&
+ m_net_ptr->curCycle()) &&
outNetLink->isBufferNotFull_link(vc)) { // buffer backpressure
// Just removing the flit
flit *t_flit = m_ni_buffers[vc]->getTopFlit();
- t_flit->set_time(g_system_ptr->getTime() + 1);
+ t_flit->set_time(m_net_ptr->curCycle() + 1);
outSrcQueue->insert(t_flit);
// schedule the out link
}
}
for (int vc = 0; vc < m_num_vcs; vc++) {
- if (m_ni_buffers[vc]->isReadyForNext()) {
+ if (m_ni_buffers[vc]->isReadyForNext(m_net_ptr->curCycle())) {
scheduleEvent(1);
return;
}
bool
NetworkLink::isReady()
{
- return linkBuffer->isReady();
+ return linkBuffer->isReady(curCycle());
}
void
void
NetworkLink::wakeup()
{
- if (!link_srcQueue->isReady())
+ if (!link_srcQueue->isReady(curCycle()))
return;
flit *t_flit = link_srcQueue->getTopFlit();
- t_flit->set_time(g_system_ptr->getTime() + m_latency);
+ t_flit->set_time(curCycle() + m_latency);
linkBuffer->insert(t_flit);
link_consumer->scheduleEvent(m_latency);
m_link_utilized++;
vector<InVcState *> in_vc_vector;
for (int i = 0; i < m_num_vcs; i++) {
in_vc_vector.push_back(new InVcState(i));
- in_vc_vector[i]->setState(IDLE_, g_system_ptr->getTime());
+ in_vc_vector[i]->setState(IDLE_, curCycle());
}
m_in_vc_state.push_back(in_vc_vector);
m_in_link.push_back(in_link);
vector<OutVcState *> out_vc_vector;
for (int i = 0; i < m_num_vcs; i++) {
out_vc_vector.push_back(new OutVcState(i));
- out_vc_vector[i]->setState(IDLE_, g_system_ptr->getTime());
+ out_vc_vector[i]->setState(IDLE_, curCycle());
}
m_out_vc_state.push_back(out_vc_vector);
m_link_weights.push_back(link_weight);
int outport = getRoute(destination);
m_in_vc_state[in_port][in_vc]->setRoute(outport);
m_in_vc_state[in_port][in_vc]->setState(VC_AB_, request_time);
- assert(request_time >= g_system_ptr->getTime());
- if (request_time > g_system_ptr->getTime())
+ assert(request_time >= curCycle());
+ if (request_time > curCycle())
m_vc_arbiter->scheduleEventAbsolute(request_time);
else
vc_arbitrate();
InVcState *in_vc_state = m_in_vc_state[inport][invc];
- if (in_vc_state->isInState(VC_AB_, g_system_ptr->getTime())) {
+ if (in_vc_state->isInState(VC_AB_, curCycle())) {
int outport = in_vc_state->get_outport();
vector<int> valid_vcs = get_valid_vcs(invc);
for (int valid_vc_iter = 0; valid_vc_iter < valid_vcs.size();
valid_vc_iter++) {
if (m_out_vc_state[outport][valid_vcs[valid_vc_iter]]
- ->isInState(IDLE_, g_system_ptr->getTime())) {
+ ->isInState(IDLE_, curCycle())) {
in_vc_state->grant_vc(valid_vcs[valid_vc_iter],
- g_system_ptr->getTime());
+ curCycle());
- m_in_link[inport]->grant_vc_link(invc,
- g_system_ptr->getTime());
+ m_in_link[inport]->grant_vc_link(invc, curCycle());
m_out_vc_state[outport][valid_vcs[valid_vc_iter]]
- ->setState(VC_AB_, g_system_ptr->getTime());
+ ->setState(VC_AB_, curCycle());
break;
}
}
assert(m_net_ptr->getNumPipeStages() >= 1);
// Subtract 1 as 1 cycle will be consumed in scheduling the output link
- m_flit->set_time(g_system_ptr->getTime() +
- (m_net_ptr->getNumPipeStages() - 1));
+ m_flit->set_time(curCycle() + (m_net_ptr->getNumPipeStages() - 1));
m_flit->set_vc(outvc);
m_router_buffers[outport][outvc]->insert(m_flit);
NetDest destination = nm->getInternalDestination();
if (m_net_ptr->getNumPipeStages() > 1) {
- m_out_vc_state[outport][outvc]->setState(VC_AB_,
- g_system_ptr->getTime() + 1);
-
+ m_out_vc_state[outport][outvc]->setState(VC_AB_, curCycle() + 1);
m_out_link[outport]->request_vc_link(outvc, destination,
- g_system_ptr->getTime() + 1);
+ curCycle() + 1);
} else {
- m_out_vc_state[outport][outvc]->setState(VC_AB_,
- g_system_ptr->getTime());
-
+ m_out_vc_state[outport][outvc]->setState(VC_AB_, curCycle());
m_out_link[outport]->request_vc_link(outvc, destination,
- g_system_ptr->getTime());
+ curCycle());
}
}
if ((m_flit->get_type() == TAIL_) || (m_flit->get_type() == HEAD_TAIL_)) {
- m_in_vc_state[inport][invc]->setState(IDLE_,
- g_system_ptr->getTime() + 1);
-
- m_in_link[inport]->release_vc_link(invc,
- g_system_ptr->getTime() + 1);
+ m_in_vc_state[inport][invc]->setState(IDLE_, curCycle() + 1);
+ m_in_link[inport]->release_vc_link(invc, curCycle() + 1);
}
}
// checking the incoming link
if (m_in_link[incoming_port]->isReady()) {
- DPRINTF(RubyNetwork, "m_id: %d, Time: %lld\n",
- m_id, g_system_ptr->getTime());
+ DPRINTF(RubyNetwork, "m_id: %d, Time: %lld\n", m_id, curCycle());
t_flit = m_in_link[incoming_port]->peekLink();
routeCompute(t_flit, incoming_port);
m_in_link[incoming_port]->consumeLink();
if (vc_tolookat == m_num_vcs)
vc_tolookat = 0;
- if (m_router_buffers[port][vc_tolookat]->isReady()) {
+ if (m_router_buffers[port][vc_tolookat]->isReady(curCycle())) {
// models buffer backpressure
if (m_out_vc_state[port][vc_tolookat]->isInState(ACTIVE_,
- g_system_ptr->getTime()) &&
+ curCycle()) &&
m_out_link[port]->isBufferNotFull_link(vc_tolookat)) {
flit *t_flit =
m_router_buffers[port][vc_tolookat]->getTopFlit();
- t_flit->set_time(g_system_ptr->getTime() + 1 );
+ t_flit->set_time(curCycle() + 1 );
m_out_src_queue[port]->insert(t_flit);
m_out_link[port]->scheduleEvent(1);
break; // done for this port
{
for (int port = 0; port < m_out_link.size(); port++) {
for (int vc = 0; vc < m_num_vcs; vc++) {
- if (m_router_buffers[port][vc]->isReadyForNext()) {
+ if (m_router_buffers[port][vc]->isReadyForNext(curCycle())) {
scheduleEvent(1);
return;
}
{
for (int port = 0; port < m_in_link.size(); port++) {
for (int vc = 0; vc < m_num_vcs; vc++) {
- if (m_in_vc_state[port][vc]->isInState(VC_AB_,
- g_system_ptr->getTime() + 1)) {
-
+ if (m_in_vc_state[port][vc]->isInState(VC_AB_, curCycle() + 1)) {
m_vc_arbiter->scheduleEvent(1);
return;
}
#include "mem/ruby/network/garnet/flexible-pipeline/flit.hh"
-flit::flit(int id, int vc, int vnet, int size, MsgPtr msg_ptr)
+flit::flit(int id, int vc, int vnet, int size, MsgPtr msg_ptr, Time curTime)
{
m_size = size;
m_msg_ptr = msg_ptr;
- m_enqueue_time = g_system_ptr->getTime();
- m_time = g_system_ptr->getTime();
+ m_enqueue_time = curTime;
+ m_time = curTime;
m_id = id;
m_vnet = vnet;
m_vc = vc;
class flit
{
public:
- flit(int id, int vc, int vnet, int size, MsgPtr msg_ptr);
+ flit(int id, int vc, int vnet, int size, MsgPtr msg_ptr, Time curTime);
int get_size();
int get_id();
}
bool
-flitBuffer::isReady()
+flitBuffer::isReady(Time curTime)
{
if (m_buffer.size() != 0 ) {
flit *t_flit = m_buffer.front();
- if (t_flit->get_time() <= g_system_ptr->getTime())
+ if (t_flit->get_time() <= curTime)
return true;
}
return false;
}
bool
-flitBuffer::isReadyForNext()
+flitBuffer::isReadyForNext(Time curTime)
{
if (m_buffer.size() != 0 ) {
flit *t_flit = m_buffer.front();
- if (t_flit->get_time() <= (g_system_ptr->getTime() + 1))
+ if (t_flit->get_time() <= (curTime + 1))
return true;
}
return false;
flitBuffer();
flitBuffer(int maximum_size);
- bool isReady();
- bool isReadyForNext();
+ bool isReady(Time curTime);
+ bool isReadyForNext(Time curTime);
bool isFull();
bool isEmpty();
void setMaxSize(int maximum);
{
//Network Activities from garnet
calculate_performance_numbers();
- double sim_cycles;
- sim_cycles =
- g_system_ptr->getTime() - m_network_ptr->getRubyStartTime();
+ double sim_cycles = curCycle() - m_network_ptr->getRubyStartTime();
// Number of virtual networks/message classes declared in Ruby
// maybe greater than active virtual networks.
orion_cfg_ptr);
double sim_cycles =
- (double)(g_system_ptr->getTime() - m_net_ptr->getRubyStartTime());
+ (double)(m_net_ptr->curCycle() - m_net_ptr->getRubyStartTime());
// Dynamic Power
// Assume half the bits flipped on every link activity
#include <iostream>
#include "base/refcnt.hh"
-#include "mem/ruby/common/Global.hh"
#include "mem/ruby/common/TypeDefines.hh"
-#include "mem/ruby/system/System.hh"
+#include "mem/packet.hh"
class Message;
typedef RefCountingPtr<Message> MsgPtr;
class Message : public RefCounted
{
public:
- Message()
- : m_time(g_system_ptr->getTime()),
- m_LastEnqueueTime(g_system_ptr->getTime()),
+ Message(Time curTime)
+ : m_time(curTime),
+ m_LastEnqueueTime(curTime),
m_DelayedCycles(0)
{ }
#include "mem/ruby/common/NetDest.hh"
#include "mem/ruby/slicc_interface/Message.hh"
-class Address;
-
class NetworkMessage;
typedef RefCountingPtr<NetworkMessage> NetMsgPtr;
class NetworkMessage : public Message
{
public:
- NetworkMessage()
- : m_internal_dest_valid(false)
+ NetworkMessage(Time curTime)
+ : Message(curTime), m_internal_dest_valid(false)
{ }
NetworkMessage(const NetworkMessage &other)
#include "mem/protocol/RubyAccessMode.hh"
#include "mem/protocol/RubyRequestType.hh"
#include "mem/ruby/common/Address.hh"
-#include "mem/packet.hh"
class RubyRequest : public Message
{
PacketPtr pkt;
unsigned m_contextId;
- RubyRequest() {}
- RubyRequest(uint64_t _paddr, uint8_t* _data, int _len, uint64_t _pc,
- RubyRequestType _type, RubyAccessMode _access_mode,
- PacketPtr _pkt, PrefetchBit _pb = PrefetchBit_No,
- unsigned _proc_id = 100)
- : m_PhysicalAddress(_paddr),
+ RubyRequest(Time curTime, uint64_t _paddr, uint8_t* _data, int _len,
+ uint64_t _pc, RubyRequestType _type, RubyAccessMode _access_mode,
+ PacketPtr _pkt, PrefetchBit _pb = PrefetchBit_No,
+ unsigned _proc_id = 100)
+ : Message(curTime),
+ m_PhysicalAddress(_paddr),
m_Type(_type),
m_ProgramCounter(_pc),
m_AccessMode(_access_mode),
m_LineAddress.makeLineAddress();
}
- static RubyRequest*
- create()
+ RubyRequest(Time curTime) : Message(curTime)
{
- return new RubyRequest();
}
RubyRequest*
return val % mod;
}
+inline int max_tokens()
+{
+ return 1024;
+}
+
/**
* This function accepts an address, a data block and a packet. If the address
* range for the data block contains the address which the packet needs to
#include "base/statistics.hh"
#include "mem/ruby/buffers/MessageBuffer.hh"
#include "mem/ruby/common/Address.hh"
-#include "mem/ruby/common/Global.hh"
#include "mem/ruby/slicc_interface/AbstractController.hh"
#include "mem/ruby/slicc_interface/RubyRequest.hh"
+#include "mem/ruby/system/System.hh"
#include "params/Prefetcher.hh"
#include "sim/sim_object.hh"
active_request.bytes_issued = 0;
active_request.pkt = pkt;
- SequencerMsg *msg = new SequencerMsg;
+ SequencerMsg *msg = new SequencerMsg(curCycle());
msg->getPhysicalAddress() = Address(paddr);
msg->getLineAddress() = line_address(msg->getPhysicalAddress());
msg->getType() = write ? SequencerRequestType_ST : SequencerRequestType_LD;
return;
}
- SequencerMsg *msg = new SequencerMsg;
+ SequencerMsg *msg = new SequencerMsg(curCycle());
msg->getPhysicalAddress() = Address(active_request.start_paddr +
active_request.bytes_completed);
pc = pkt->req->getPC();
}
- RubyRequest *msg = new RubyRequest(pkt->getAddr(),
+ RubyRequest *msg = new RubyRequest(curCycle(), pkt->getAddr(),
pkt->getPtr<uint8_t>(true),
pkt->getSize(), pc, secondary_type,
RubyAccessMode_Supervisor, pkt,
#include "base/cprintf.hh"
#include "base/stl_helpers.hh"
+#include "mem/ruby/common/Global.hh"
+#include "mem/ruby/system/System.hh"
#include "mem/ruby/system/WireBuffer.hh"
using namespace std;
self.symtab.newSymbol(v)
# Declare message
- code("${{msg_type.ident}} *out_msg = new ${{msg_type.ident}};")
+ code("${{msg_type.ident}} *out_msg = \
+ new ${{msg_type.ident}}(curCycle());")
# The other statements
t = self.statements.generate(code, None)
#include <iostream>
-#include "mem/ruby/common/Global.hh"
+#include "mem/ruby/slicc_interface/RubySlicc_Util.hh"
''')
for dm in self.data_members.values():
$klass ${{self.c_ident}}$parent
{
public:
- ${{self.c_ident}}()
- {
+ ${{self.c_ident}}
''', klass="class")
+ if self.isMessage:
+ code('(Time curTime) : %s(curTime) {' % self["interface"])
+ else:
+ code('()\n\t\t{')
+
code.indent()
if not self.isGlobal:
code.indent()
if not self.isGlobal:
params = [ 'const %s& local_%s' % (dm.type.c_ident, dm.ident) \
for dm in self.data_members.itervalues() ]
-
params = ', '.join(params)
+
+ if self.isMessage:
+ params = "const Time curTime, " + params
+
code('${{self.c_ident}}($params)')
# Call superclass constructor
if "interface" in self:
- code(' : ${{self["interface"]}}()')
+ if self.isMessage:
+ code(' : ${{self["interface"]}}(curTime)')
+ else:
+ code(' : ${{self["interface"]}}()')
code('{')
code.indent()
code.dedent()
code('}')
- # create a static factory method and a clone member
+ # create a clone member
code('''
-static ${{self.c_ident}}*
-create()
-{
- return new ${{self.c_ident}}();
-}
-
${{self.c_ident}}*
clone() const
{
#include <iostream>
#include "mem/protocol/${{self.c_ident}}.hh"
-#include "mem/ruby/slicc_interface/RubySlicc_Util.hh"
using namespace std;
''')