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; --- 30 unchanged lines hidden (view full) --- 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 = new PerfectSwitch(m_id, this, p->virt_nets); |
47 m_msg_counts.resize(MessageSizeType_NUM); 48 m_msg_bytes.resize(MessageSizeType_NUM); |
49} 50 51Switch::~Switch() 52{ 53 delete m_perfect_switch; 54 55 // Delete throttles (one per output port) 56 deletePointers(m_throttles); --- 50 unchanged lines hidden (view full) --- 107 108 // Hook the queues to the PerfectSwitch 109 m_perfect_switch->addOutPort(intermediateBuffers, routing_table_entry); 110 111 // Hook the queues to the Throttle 112 throttle_ptr->addLinks(intermediateBuffers, out); 113} 114 |
115const Throttle* 116Switch::getThrottle(LinkID link_number) const 117{ 118 assert(m_throttles[link_number] != NULL); 119 return m_throttles[link_number]; 120} 121 122const vector<Throttle*>* 123Switch::getThrottles() const 124{ 125 return &m_throttles; 126} 127 128void |
129Switch::regStats() |
130{ |
131 for (int link = 0; link < m_throttles.size(); link++) { 132 m_throttles[link]->regStats(name()); |
133 } |
134 |
135 m_avg_utilization.name(name() + ".percent_links_utilized"); 136 for (unsigned int i = 0; i < m_throttles.size(); i++) { 137 m_avg_utilization += m_throttles[i]->getUtilization(); |
138 } |
139 m_avg_utilization /= Stats::constant(m_throttles.size()); |
140 |
141 for (unsigned int type = MessageSizeType_FIRST; 142 type < MessageSizeType_NUM; ++type) { 143 m_msg_counts[type] 144 .name(name() + ".msg_count." + 145 MessageSizeType_to_string(MessageSizeType(type))) 146 .flags(Stats::nozero) 147 ; 148 m_msg_bytes[type] 149 .name(name() + ".msg_bytes." + 150 MessageSizeType_to_string(MessageSizeType(type))) 151 .flags(Stats::nozero) 152 ; |
153 |
154 for (unsigned int i = 0; i < m_throttles.size(); i++) { 155 m_msg_counts[type] += m_throttles[i]->getMsgCount(type); |
156 } |
157 m_msg_bytes[type] = m_msg_counts[type] * Stats::constant( 158 Network::MessageSizeType_to_int(MessageSizeType(type))); |
159 } |
160} 161 162void |
163Switch::resetStats() |
164{ 165 m_perfect_switch->clearStats(); 166 for (int i = 0; i < m_throttles.size(); i++) { |
167 m_throttles[i]->clearStats(); |
168 } 169} 170 171void |
172Switch::collateStats() 173{ 174 m_perfect_switch->collateStats(); 175 for (int i = 0; i < m_throttles.size(); i++) { 176 m_throttles[i]->collateStats(); 177 } 178} 179 180void |
181Switch::print(std::ostream& out) const 182{ 183 // FIXME printing 184 out << "[Switch]"; 185} 186 187bool 188Switch::functionalRead(Packet *pkt) --- 26 unchanged lines hidden --- |