Switch.cc (9508:dde110931867) Switch.cc (9858:f2417ecf5cc9)
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 29 unchanged lines hidden (view full) ---

38#include "mem/ruby/network/simple/Throttle.hh"
39
40using namespace std;
41using m5::stl_helpers::deletePointers;
42using m5::stl_helpers::operator<<;
43
44Switch::Switch(const Params *p) : BasicRouter(p)
45{
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 29 unchanged lines hidden (view full) ---

38#include "mem/ruby/network/simple/Throttle.hh"
39
40using namespace std;
41using m5::stl_helpers::deletePointers;
42using m5::stl_helpers::operator<<;
43
44Switch::Switch(const Params *p) : BasicRouter(p)
45{
46 m_perfect_switch_ptr = new PerfectSwitch(m_id, this, p->virt_nets);
46 m_perfect_switch = new PerfectSwitch(m_id, this, p->virt_nets);
47}
48
49Switch::~Switch()
50{
47}
48
49Switch::~Switch()
50{
51 delete m_perfect_switch_ptr;
51 delete m_perfect_switch;
52
53 // Delete throttles (one per output port)
54 deletePointers(m_throttles);
55
56 // Delete MessageBuffers
57 deletePointers(m_buffers_to_free);
58}
59
60void
61Switch::init()
62{
63 BasicRouter::init();
52
53 // Delete throttles (one per output port)
54 deletePointers(m_throttles);
55
56 // Delete MessageBuffers
57 deletePointers(m_buffers_to_free);
58}
59
60void
61Switch::init()
62{
63 BasicRouter::init();
64 m_perfect_switch_ptr->init(m_network_ptr);
64 m_perfect_switch->init(m_network_ptr);
65}
66
67void
68Switch::addInPort(const vector<MessageBuffer*>& in)
69{
65}
66
67void
68Switch::addInPort(const vector<MessageBuffer*>& in)
69{
70 m_perfect_switch_ptr->addInPort(in);
70 m_perfect_switch->addInPort(in);
71
72 for (int i = 0; i < in.size(); i++) {
73 in[i]->setReceiver(this);
74 }
75}
76
77void
78Switch::addOutPort(const vector<MessageBuffer*>& out,

--- 20 unchanged lines hidden (view full) ---

99 intermediateBuffers.push_back(buffer_ptr);
100 m_buffers_to_free.push_back(buffer_ptr);
101
102 buffer_ptr->setSender(this);
103 buffer_ptr->setReceiver(this);
104 }
105
106 // Hook the queues to the PerfectSwitch
71
72 for (int i = 0; i < in.size(); i++) {
73 in[i]->setReceiver(this);
74 }
75}
76
77void
78Switch::addOutPort(const vector<MessageBuffer*>& out,

--- 20 unchanged lines hidden (view full) ---

99 intermediateBuffers.push_back(buffer_ptr);
100 m_buffers_to_free.push_back(buffer_ptr);
101
102 buffer_ptr->setSender(this);
103 buffer_ptr->setReceiver(this);
104 }
105
106 // Hook the queues to the PerfectSwitch
107 m_perfect_switch_ptr->addOutPort(intermediateBuffers, routing_table_entry);
107 m_perfect_switch->addOutPort(intermediateBuffers, routing_table_entry);
108
109 // Hook the queues to the Throttle
110 throttle_ptr->addLinks(intermediateBuffers, out);
111}
112
113void
114Switch::clearRoutingTables()
115{
108
109 // Hook the queues to the Throttle
110 throttle_ptr->addLinks(intermediateBuffers, out);
111}
112
113void
114Switch::clearRoutingTables()
115{
116 m_perfect_switch_ptr->clearRoutingTables();
116 m_perfect_switch->clearRoutingTables();
117}
118
119void
120Switch::clearBuffers()
121{
117}
118
119void
120Switch::clearBuffers()
121{
122 m_perfect_switch_ptr->clearBuffers();
122 m_perfect_switch->clearBuffers();
123 for (int i = 0; i < m_throttles.size(); i++) {
124 if (m_throttles[i] != NULL) {
125 m_throttles[i]->clear();
126 }
127 }
128}
129
130void
131Switch::reconfigureOutPort(const NetDest& routing_table_entry)
132{
123 for (int i = 0; i < m_throttles.size(); i++) {
124 if (m_throttles[i] != NULL) {
125 m_throttles[i]->clear();
126 }
127 }
128}
129
130void
131Switch::reconfigureOutPort(const NetDest& routing_table_entry)
132{
133 m_perfect_switch_ptr->reconfigureOutPort(routing_table_entry);
133 m_perfect_switch->reconfigureOutPort(routing_table_entry);
134}
135
136const Throttle*
137Switch::getThrottle(LinkID link_number) const
138{
139 assert(m_throttles[link_number] != NULL);
140 return m_throttles[link_number];
141}
142
143const vector<Throttle*>*
144Switch::getThrottles() const
145{
146 return &m_throttles;
147}
148
149void
150Switch::printStats(std::ostream& out) const
151{
152 ccprintf(out, "switch_%d_inlinks: %d\n", m_id,
134}
135
136const Throttle*
137Switch::getThrottle(LinkID link_number) const
138{
139 assert(m_throttles[link_number] != NULL);
140 return m_throttles[link_number];
141}
142
143const vector<Throttle*>*
144Switch::getThrottles() const
145{
146 return &m_throttles;
147}
148
149void
150Switch::printStats(std::ostream& out) const
151{
152 ccprintf(out, "switch_%d_inlinks: %d\n", m_id,
153 m_perfect_switch_ptr->getInLinks());
153 m_perfect_switch->getInLinks());
154 ccprintf(out, "switch_%d_outlinks: %d\n", m_id,
154 ccprintf(out, "switch_%d_outlinks: %d\n", m_id,
155 m_perfect_switch_ptr->getOutLinks());
155 m_perfect_switch->getOutLinks());
156
157 // Average link utilizations
158 double average_utilization = 0.0;
159 int throttle_count = 0;
160
161 for (int i = 0; i < m_throttles.size(); i++) {
162 Throttle* throttle_ptr = m_throttles[i];
163 if (throttle_ptr) {

--- 45 unchanged lines hidden (view full) ---

209 }
210 }
211 out << endl;
212}
213
214void
215Switch::clearStats()
216{
156
157 // Average link utilizations
158 double average_utilization = 0.0;
159 int throttle_count = 0;
160
161 for (int i = 0; i < m_throttles.size(); i++) {
162 Throttle* throttle_ptr = m_throttles[i];
163 if (throttle_ptr) {

--- 45 unchanged lines hidden (view full) ---

209 }
210 }
211 out << endl;
212}
213
214void
215Switch::clearStats()
216{
217 m_perfect_switch_ptr->clearStats();
217 m_perfect_switch->clearStats();
218 for (int i = 0; i < m_throttles.size(); i++) {
219 if (m_throttles[i] != NULL)
220 m_throttles[i]->clearStats();
221 }
222}
223
224void
225Switch::print(std::ostream& out) const

--- 33 unchanged lines hidden ---
218 for (int i = 0; i < m_throttles.size(); i++) {
219 if (m_throttles[i] != NULL)
220 m_throttles[i]->clearStats();
221 }
222}
223
224void
225Switch::print(std::ostream& out) const

--- 33 unchanged lines hidden ---