1/* 2 * Copyright (c) 2016 Georgia Institute of Technology 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; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Tushar Krishna 29 */ 30 31#include "cpu/testers/garnet_synthetic_traffic/GarnetSyntheticTraffic.hh" 32 33#include <cmath> 34#include <iomanip> 35#include <set> 36#include <string> 37#include <vector> 38 39#include "base/logging.hh" 40#include "base/random.hh" 41#include "base/statistics.hh" 42#include "debug/GarnetSyntheticTraffic.hh"
| 1/* 2 * Copyright (c) 2016 Georgia Institute of Technology 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; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Tushar Krishna 29 */ 30 31#include "cpu/testers/garnet_synthetic_traffic/GarnetSyntheticTraffic.hh" 32 33#include <cmath> 34#include <iomanip> 35#include <set> 36#include <string> 37#include <vector> 38 39#include "base/logging.hh" 40#include "base/random.hh" 41#include "base/statistics.hh" 42#include "debug/GarnetSyntheticTraffic.hh"
|
43#include "mem/mem_object.hh"
| |
44#include "mem/packet.hh" 45#include "mem/port.hh" 46#include "mem/request.hh" 47#include "sim/sim_events.hh" 48#include "sim/stats.hh" 49#include "sim/system.hh" 50 51using namespace std; 52 53int TESTER_NETWORK=0; 54 55bool 56GarnetSyntheticTraffic::CpuPort::recvTimingResp(PacketPtr pkt) 57{ 58 tester->completeRequest(pkt); 59 return true; 60} 61 62void 63GarnetSyntheticTraffic::CpuPort::recvReqRetry() 64{ 65 tester->doRetry(); 66} 67 68void 69GarnetSyntheticTraffic::sendPkt(PacketPtr pkt) 70{ 71 if (!cachePort.sendTimingReq(pkt)) { 72 retryPkt = pkt; // RubyPort will retry sending 73 } 74 numPacketsSent++; 75} 76 77GarnetSyntheticTraffic::GarnetSyntheticTraffic(const Params *p)
| 43#include "mem/packet.hh" 44#include "mem/port.hh" 45#include "mem/request.hh" 46#include "sim/sim_events.hh" 47#include "sim/stats.hh" 48#include "sim/system.hh" 49 50using namespace std; 51 52int TESTER_NETWORK=0; 53 54bool 55GarnetSyntheticTraffic::CpuPort::recvTimingResp(PacketPtr pkt) 56{ 57 tester->completeRequest(pkt); 58 return true; 59} 60 61void 62GarnetSyntheticTraffic::CpuPort::recvReqRetry() 63{ 64 tester->doRetry(); 65} 66 67void 68GarnetSyntheticTraffic::sendPkt(PacketPtr pkt) 69{ 70 if (!cachePort.sendTimingReq(pkt)) { 71 retryPkt = pkt; // RubyPort will retry sending 72 } 73 numPacketsSent++; 74} 75 76GarnetSyntheticTraffic::GarnetSyntheticTraffic(const Params *p)
|
78 : MemObject(p),
| 77 : ClockedObject(p),
|
79 tickEvent([this]{ tick(); }, "GarnetSyntheticTraffic tick", 80 false, Event::CPU_Tick_Pri), 81 cachePort("GarnetSyntheticTraffic", this), 82 retryPkt(NULL), 83 size(p->memory_size), 84 blockSizeBits(p->block_offset), 85 numDestinations(p->num_dest), 86 simCycles(p->sim_cycles), 87 numPacketsMax(p->num_packets_max), 88 numPacketsSent(0), 89 singleSender(p->single_sender), 90 singleDest(p->single_dest), 91 trafficType(p->traffic_type), 92 injRate(p->inj_rate), 93 injVnet(p->inj_vnet), 94 precision(p->precision), 95 responseLimit(p->response_limit), 96 masterId(p->system->getMasterId(this)) 97{ 98 // set up counters 99 noResponseCycles = 0; 100 schedule(tickEvent, 0); 101 102 initTrafficType(); 103 if (trafficStringToEnum.count(trafficType) == 0) { 104 fatal("Unknown Traffic Type: %s!\n", traffic); 105 } 106 traffic = trafficStringToEnum[trafficType]; 107 108 id = TESTER_NETWORK++; 109 DPRINTF(GarnetSyntheticTraffic,"Config Created: Name = %s , and id = %d\n", 110 name(), id); 111} 112 113Port & 114GarnetSyntheticTraffic::getPort(const std::string &if_name, PortID idx) 115{ 116 if (if_name == "test") 117 return cachePort; 118 else
| 78 tickEvent([this]{ tick(); }, "GarnetSyntheticTraffic tick", 79 false, Event::CPU_Tick_Pri), 80 cachePort("GarnetSyntheticTraffic", this), 81 retryPkt(NULL), 82 size(p->memory_size), 83 blockSizeBits(p->block_offset), 84 numDestinations(p->num_dest), 85 simCycles(p->sim_cycles), 86 numPacketsMax(p->num_packets_max), 87 numPacketsSent(0), 88 singleSender(p->single_sender), 89 singleDest(p->single_dest), 90 trafficType(p->traffic_type), 91 injRate(p->inj_rate), 92 injVnet(p->inj_vnet), 93 precision(p->precision), 94 responseLimit(p->response_limit), 95 masterId(p->system->getMasterId(this)) 96{ 97 // set up counters 98 noResponseCycles = 0; 99 schedule(tickEvent, 0); 100 101 initTrafficType(); 102 if (trafficStringToEnum.count(trafficType) == 0) { 103 fatal("Unknown Traffic Type: %s!\n", traffic); 104 } 105 traffic = trafficStringToEnum[trafficType]; 106 107 id = TESTER_NETWORK++; 108 DPRINTF(GarnetSyntheticTraffic,"Config Created: Name = %s , and id = %d\n", 109 name(), id); 110} 111 112Port & 113GarnetSyntheticTraffic::getPort(const std::string &if_name, PortID idx) 114{ 115 if (if_name == "test") 116 return cachePort; 117 else
|
119 return MemObject::getPort(if_name, idx);
| 118 return ClockedObject::getPort(if_name, idx);
|
120} 121 122void 123GarnetSyntheticTraffic::init() 124{ 125 numPacketsSent = 0; 126} 127 128 129void 130GarnetSyntheticTraffic::completeRequest(PacketPtr pkt) 131{ 132 DPRINTF(GarnetSyntheticTraffic, 133 "Completed injection of %s packet for address %x\n", 134 pkt->isWrite() ? "write" : "read\n", 135 pkt->req->getPaddr()); 136 137 assert(pkt->isResponse()); 138 noResponseCycles = 0; 139 delete pkt; 140} 141 142 143void 144GarnetSyntheticTraffic::tick() 145{ 146 if (++noResponseCycles >= responseLimit) { 147 fatal("%s deadlocked at cycle %d\n", name(), curTick()); 148 } 149 150 // make new request based on injection rate 151 // (injection rate's range depends on precision) 152 // - generate a random number between 0 and 10^precision 153 // - send pkt if this number is < injRate*(10^precision) 154 bool sendAllowedThisCycle; 155 double injRange = pow((double) 10, (double) precision); 156 unsigned trySending = random_mt.random<unsigned>(0, (int) injRange); 157 if (trySending < injRate*injRange) 158 sendAllowedThisCycle = true; 159 else 160 sendAllowedThisCycle = false; 161 162 // always generatePkt unless fixedPkts or singleSender is enabled 163 if (sendAllowedThisCycle) { 164 bool senderEnable = true; 165 166 if (numPacketsMax >= 0 && numPacketsSent >= numPacketsMax) 167 senderEnable = false; 168 169 if (singleSender >= 0 && id != singleSender) 170 senderEnable = false; 171 172 if (senderEnable) 173 generatePkt(); 174 } 175 176 // Schedule wakeup 177 if (curTick() >= simCycles) 178 exitSimLoop("Network Tester completed simCycles"); 179 else { 180 if (!tickEvent.scheduled()) 181 schedule(tickEvent, clockEdge(Cycles(1))); 182 } 183} 184 185void 186GarnetSyntheticTraffic::generatePkt() 187{ 188 int num_destinations = numDestinations; 189 int radix = (int) sqrt(num_destinations); 190 unsigned destination = id; 191 int dest_x = -1; 192 int dest_y = -1; 193 int source = id; 194 int src_x = id%radix; 195 int src_y = id/radix; 196 197 if (singleDest >= 0) 198 { 199 destination = singleDest; 200 } else if (traffic == UNIFORM_RANDOM_) { 201 destination = random_mt.random<unsigned>(0, num_destinations - 1); 202 } else if (traffic == BIT_COMPLEMENT_) { 203 dest_x = radix - src_x - 1; 204 dest_y = radix - src_y - 1; 205 destination = dest_y*radix + dest_x; 206 } else if (traffic == BIT_REVERSE_) { 207 unsigned int straight = source; 208 unsigned int reverse = source & 1; // LSB 209 210 int num_bits = (int) log2(num_destinations); 211 212 for (int i = 1; i < num_bits; i++) 213 { 214 reverse <<= 1; 215 straight >>= 1; 216 reverse |= (straight & 1); // LSB 217 } 218 destination = reverse; 219 } else if (traffic == BIT_ROTATION_) { 220 if (source%2 == 0) 221 destination = source/2; 222 else // (source%2 == 1) 223 destination = ((source/2) + (num_destinations/2)); 224 } else if (traffic == NEIGHBOR_) { 225 dest_x = (src_x + 1) % radix; 226 dest_y = src_y; 227 destination = dest_y*radix + dest_x; 228 } else if (traffic == SHUFFLE_) { 229 if (source < num_destinations/2) 230 destination = source*2; 231 else 232 destination = (source*2 - num_destinations + 1); 233 } else if (traffic == TRANSPOSE_) { 234 dest_x = src_y; 235 dest_y = src_x; 236 destination = dest_y*radix + dest_x; 237 } else if (traffic == TORNADO_) { 238 dest_x = (src_x + (int) ceil(radix/2) - 1) % radix; 239 dest_y = src_y; 240 destination = dest_y*radix + dest_x; 241 } 242 else { 243 fatal("Unknown Traffic Type: %s!\n", traffic); 244 } 245 246 // The source of the packets is a cache. 247 // The destination of the packets is a directory. 248 // The destination bits are embedded in the address after byte-offset. 249 Addr paddr = destination; 250 paddr <<= blockSizeBits; 251 unsigned access_size = 1; // Does not affect Ruby simulation 252 253 // Modeling different coherence msg types over different msg classes. 254 // 255 // GarnetSyntheticTraffic assumes the Garnet_standalone coherence protocol 256 // which models three message classes/virtual networks. 257 // These are: request, forward, response. 258 // requests and forwards are "control" packets (typically 8 bytes), 259 // while responses are "data" packets (typically 72 bytes). 260 // 261 // Life of a packet from the tester into the network: 262 // (1) This function generatePkt() generates packets of one of the 263 // following 3 types (randomly) : ReadReq, INST_FETCH, WriteReq 264 // (2) mem/ruby/system/RubyPort.cc converts these to RubyRequestType_LD, 265 // RubyRequestType_IFETCH, RubyRequestType_ST respectively 266 // (3) mem/ruby/system/Sequencer.cc sends these to the cache controllers 267 // in the coherence protocol. 268 // (4) Network_test-cache.sm tags RubyRequestType:LD, 269 // RubyRequestType:IFETCH and RubyRequestType:ST as 270 // Request, Forward, and Response events respectively; 271 // and injects them into virtual networks 0, 1 and 2 respectively. 272 // It immediately calls back the sequencer. 273 // (5) The packet traverses the network (simple/garnet) and reaches its 274 // destination (Directory), and network stats are updated. 275 // (6) Network_test-dir.sm simply drops the packet. 276 // 277 MemCmd::Command requestType; 278 279 RequestPtr req = nullptr; 280 Request::Flags flags; 281 282 // Inject in specific Vnet 283 // Vnet 0 and 1 are for control packets (1-flit) 284 // Vnet 2 is for data packets (5-flit) 285 int injReqType = injVnet; 286 287 if (injReqType < 0 || injReqType > 2) 288 { 289 // randomly inject in any vnet 290 injReqType = random_mt.random(0, 2); 291 } 292 293 if (injReqType == 0) { 294 // generate packet for virtual network 0 295 requestType = MemCmd::ReadReq; 296 req = std::make_shared<Request>(paddr, access_size, flags, masterId); 297 } else if (injReqType == 1) { 298 // generate packet for virtual network 1 299 requestType = MemCmd::ReadReq; 300 flags.set(Request::INST_FETCH); 301 req = std::make_shared<Request>( 302 0, 0x0, access_size, flags, masterId, 0x0, 0); 303 req->setPaddr(paddr); 304 } else { // if (injReqType == 2) 305 // generate packet for virtual network 2 306 requestType = MemCmd::WriteReq; 307 req = std::make_shared<Request>(paddr, access_size, flags, masterId); 308 } 309 310 req->setContext(id); 311 312 //No need to do functional simulation 313 //We just do timing simulation of the network 314 315 DPRINTF(GarnetSyntheticTraffic, 316 "Generated packet with destination %d, embedded in address %x\n", 317 destination, req->getPaddr()); 318 319 PacketPtr pkt = new Packet(req, requestType); 320 pkt->dataDynamic(new uint8_t[req->getSize()]); 321 pkt->senderState = NULL; 322 323 sendPkt(pkt); 324} 325 326void 327GarnetSyntheticTraffic::initTrafficType() 328{ 329 trafficStringToEnum["bit_complement"] = BIT_COMPLEMENT_; 330 trafficStringToEnum["bit_reverse"] = BIT_REVERSE_; 331 trafficStringToEnum["bit_rotation"] = BIT_ROTATION_; 332 trafficStringToEnum["neighbor"] = NEIGHBOR_; 333 trafficStringToEnum["shuffle"] = SHUFFLE_; 334 trafficStringToEnum["tornado"] = TORNADO_; 335 trafficStringToEnum["transpose"] = TRANSPOSE_; 336 trafficStringToEnum["uniform_random"] = UNIFORM_RANDOM_; 337} 338 339void 340GarnetSyntheticTraffic::doRetry() 341{ 342 if (cachePort.sendTimingReq(retryPkt)) { 343 retryPkt = NULL; 344 } 345} 346 347void 348GarnetSyntheticTraffic::printAddr(Addr a) 349{ 350 cachePort.printAddr(a); 351} 352 353 354GarnetSyntheticTraffic * 355GarnetSyntheticTrafficParams::create() 356{ 357 return new GarnetSyntheticTraffic(this); 358}
| 119} 120 121void 122GarnetSyntheticTraffic::init() 123{ 124 numPacketsSent = 0; 125} 126 127 128void 129GarnetSyntheticTraffic::completeRequest(PacketPtr pkt) 130{ 131 DPRINTF(GarnetSyntheticTraffic, 132 "Completed injection of %s packet for address %x\n", 133 pkt->isWrite() ? "write" : "read\n", 134 pkt->req->getPaddr()); 135 136 assert(pkt->isResponse()); 137 noResponseCycles = 0; 138 delete pkt; 139} 140 141 142void 143GarnetSyntheticTraffic::tick() 144{ 145 if (++noResponseCycles >= responseLimit) { 146 fatal("%s deadlocked at cycle %d\n", name(), curTick()); 147 } 148 149 // make new request based on injection rate 150 // (injection rate's range depends on precision) 151 // - generate a random number between 0 and 10^precision 152 // - send pkt if this number is < injRate*(10^precision) 153 bool sendAllowedThisCycle; 154 double injRange = pow((double) 10, (double) precision); 155 unsigned trySending = random_mt.random<unsigned>(0, (int) injRange); 156 if (trySending < injRate*injRange) 157 sendAllowedThisCycle = true; 158 else 159 sendAllowedThisCycle = false; 160 161 // always generatePkt unless fixedPkts or singleSender is enabled 162 if (sendAllowedThisCycle) { 163 bool senderEnable = true; 164 165 if (numPacketsMax >= 0 && numPacketsSent >= numPacketsMax) 166 senderEnable = false; 167 168 if (singleSender >= 0 && id != singleSender) 169 senderEnable = false; 170 171 if (senderEnable) 172 generatePkt(); 173 } 174 175 // Schedule wakeup 176 if (curTick() >= simCycles) 177 exitSimLoop("Network Tester completed simCycles"); 178 else { 179 if (!tickEvent.scheduled()) 180 schedule(tickEvent, clockEdge(Cycles(1))); 181 } 182} 183 184void 185GarnetSyntheticTraffic::generatePkt() 186{ 187 int num_destinations = numDestinations; 188 int radix = (int) sqrt(num_destinations); 189 unsigned destination = id; 190 int dest_x = -1; 191 int dest_y = -1; 192 int source = id; 193 int src_x = id%radix; 194 int src_y = id/radix; 195 196 if (singleDest >= 0) 197 { 198 destination = singleDest; 199 } else if (traffic == UNIFORM_RANDOM_) { 200 destination = random_mt.random<unsigned>(0, num_destinations - 1); 201 } else if (traffic == BIT_COMPLEMENT_) { 202 dest_x = radix - src_x - 1; 203 dest_y = radix - src_y - 1; 204 destination = dest_y*radix + dest_x; 205 } else if (traffic == BIT_REVERSE_) { 206 unsigned int straight = source; 207 unsigned int reverse = source & 1; // LSB 208 209 int num_bits = (int) log2(num_destinations); 210 211 for (int i = 1; i < num_bits; i++) 212 { 213 reverse <<= 1; 214 straight >>= 1; 215 reverse |= (straight & 1); // LSB 216 } 217 destination = reverse; 218 } else if (traffic == BIT_ROTATION_) { 219 if (source%2 == 0) 220 destination = source/2; 221 else // (source%2 == 1) 222 destination = ((source/2) + (num_destinations/2)); 223 } else if (traffic == NEIGHBOR_) { 224 dest_x = (src_x + 1) % radix; 225 dest_y = src_y; 226 destination = dest_y*radix + dest_x; 227 } else if (traffic == SHUFFLE_) { 228 if (source < num_destinations/2) 229 destination = source*2; 230 else 231 destination = (source*2 - num_destinations + 1); 232 } else if (traffic == TRANSPOSE_) { 233 dest_x = src_y; 234 dest_y = src_x; 235 destination = dest_y*radix + dest_x; 236 } else if (traffic == TORNADO_) { 237 dest_x = (src_x + (int) ceil(radix/2) - 1) % radix; 238 dest_y = src_y; 239 destination = dest_y*radix + dest_x; 240 } 241 else { 242 fatal("Unknown Traffic Type: %s!\n", traffic); 243 } 244 245 // The source of the packets is a cache. 246 // The destination of the packets is a directory. 247 // The destination bits are embedded in the address after byte-offset. 248 Addr paddr = destination; 249 paddr <<= blockSizeBits; 250 unsigned access_size = 1; // Does not affect Ruby simulation 251 252 // Modeling different coherence msg types over different msg classes. 253 // 254 // GarnetSyntheticTraffic assumes the Garnet_standalone coherence protocol 255 // which models three message classes/virtual networks. 256 // These are: request, forward, response. 257 // requests and forwards are "control" packets (typically 8 bytes), 258 // while responses are "data" packets (typically 72 bytes). 259 // 260 // Life of a packet from the tester into the network: 261 // (1) This function generatePkt() generates packets of one of the 262 // following 3 types (randomly) : ReadReq, INST_FETCH, WriteReq 263 // (2) mem/ruby/system/RubyPort.cc converts these to RubyRequestType_LD, 264 // RubyRequestType_IFETCH, RubyRequestType_ST respectively 265 // (3) mem/ruby/system/Sequencer.cc sends these to the cache controllers 266 // in the coherence protocol. 267 // (4) Network_test-cache.sm tags RubyRequestType:LD, 268 // RubyRequestType:IFETCH and RubyRequestType:ST as 269 // Request, Forward, and Response events respectively; 270 // and injects them into virtual networks 0, 1 and 2 respectively. 271 // It immediately calls back the sequencer. 272 // (5) The packet traverses the network (simple/garnet) and reaches its 273 // destination (Directory), and network stats are updated. 274 // (6) Network_test-dir.sm simply drops the packet. 275 // 276 MemCmd::Command requestType; 277 278 RequestPtr req = nullptr; 279 Request::Flags flags; 280 281 // Inject in specific Vnet 282 // Vnet 0 and 1 are for control packets (1-flit) 283 // Vnet 2 is for data packets (5-flit) 284 int injReqType = injVnet; 285 286 if (injReqType < 0 || injReqType > 2) 287 { 288 // randomly inject in any vnet 289 injReqType = random_mt.random(0, 2); 290 } 291 292 if (injReqType == 0) { 293 // generate packet for virtual network 0 294 requestType = MemCmd::ReadReq; 295 req = std::make_shared<Request>(paddr, access_size, flags, masterId); 296 } else if (injReqType == 1) { 297 // generate packet for virtual network 1 298 requestType = MemCmd::ReadReq; 299 flags.set(Request::INST_FETCH); 300 req = std::make_shared<Request>( 301 0, 0x0, access_size, flags, masterId, 0x0, 0); 302 req->setPaddr(paddr); 303 } else { // if (injReqType == 2) 304 // generate packet for virtual network 2 305 requestType = MemCmd::WriteReq; 306 req = std::make_shared<Request>(paddr, access_size, flags, masterId); 307 } 308 309 req->setContext(id); 310 311 //No need to do functional simulation 312 //We just do timing simulation of the network 313 314 DPRINTF(GarnetSyntheticTraffic, 315 "Generated packet with destination %d, embedded in address %x\n", 316 destination, req->getPaddr()); 317 318 PacketPtr pkt = new Packet(req, requestType); 319 pkt->dataDynamic(new uint8_t[req->getSize()]); 320 pkt->senderState = NULL; 321 322 sendPkt(pkt); 323} 324 325void 326GarnetSyntheticTraffic::initTrafficType() 327{ 328 trafficStringToEnum["bit_complement"] = BIT_COMPLEMENT_; 329 trafficStringToEnum["bit_reverse"] = BIT_REVERSE_; 330 trafficStringToEnum["bit_rotation"] = BIT_ROTATION_; 331 trafficStringToEnum["neighbor"] = NEIGHBOR_; 332 trafficStringToEnum["shuffle"] = SHUFFLE_; 333 trafficStringToEnum["tornado"] = TORNADO_; 334 trafficStringToEnum["transpose"] = TRANSPOSE_; 335 trafficStringToEnum["uniform_random"] = UNIFORM_RANDOM_; 336} 337 338void 339GarnetSyntheticTraffic::doRetry() 340{ 341 if (cachePort.sendTimingReq(retryPkt)) { 342 retryPkt = NULL; 343 } 344} 345 346void 347GarnetSyntheticTraffic::printAddr(Addr a) 348{ 349 cachePort.printAddr(a); 350} 351 352 353GarnetSyntheticTraffic * 354GarnetSyntheticTrafficParams::create() 355{ 356 return new GarnetSyntheticTraffic(this); 357}
|