GarnetSyntheticTraffic.cc (12129:879f7ad9e246) GarnetSyntheticTraffic.cc (12334:e0ab29a34764)
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
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/misc.hh"
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)
78 : MemObject(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(name()))
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
113BaseMasterPort &
114GarnetSyntheticTraffic::getMasterPort(const std::string &if_name, PortID idx)
115{
116 if (if_name == "test")
117 return cachePort;
118 else
119 return MemObject::getMasterPort(if_name, idx);
120}
121
122void
123GarnetSyntheticTraffic::init()
124{
125 numPacketsSent = 0;
126}
127
128
129void
130GarnetSyntheticTraffic::completeRequest(PacketPtr pkt)
131{
132 Request *req = pkt->req;
133
134 DPRINTF(GarnetSyntheticTraffic,
135 "Completed injection of %s packet for address %x\n",
136 pkt->isWrite() ? "write" : "read\n",
137 req->getPaddr());
138
139 assert(pkt->isResponse());
140 noResponseCycles = 0;
141 delete req;
142 delete pkt;
143}
144
145
146void
147GarnetSyntheticTraffic::tick()
148{
149 if (++noResponseCycles >= responseLimit) {
150 fatal("%s deadlocked at cycle %d\n", name(), curTick());
151 }
152
153 // make new request based on injection rate
154 // (injection rate's range depends on precision)
155 // - generate a random number between 0 and 10^precision
156 // - send pkt if this number is < injRate*(10^precision)
157 bool sendAllowedThisCycle;
158 double injRange = pow((double) 10, (double) precision);
159 unsigned trySending = random_mt.random<unsigned>(0, (int) injRange);
160 if (trySending < injRate*injRange)
161 sendAllowedThisCycle = true;
162 else
163 sendAllowedThisCycle = false;
164
165 // always generatePkt unless fixedPkts or singleSender is enabled
166 if (sendAllowedThisCycle) {
167 bool senderEnable = true;
168
169 if (numPacketsMax >= 0 && numPacketsSent >= numPacketsMax)
170 senderEnable = false;
171
172 if (singleSender >= 0 && id != singleSender)
173 senderEnable = false;
174
175 if (senderEnable)
176 generatePkt();
177 }
178
179 // Schedule wakeup
180 if (curTick() >= simCycles)
181 exitSimLoop("Network Tester completed simCycles");
182 else {
183 if (!tickEvent.scheduled())
184 schedule(tickEvent, clockEdge(Cycles(1)));
185 }
186}
187
188void
189GarnetSyntheticTraffic::generatePkt()
190{
191 int num_destinations = numDestinations;
192 int radix = (int) sqrt(num_destinations);
193 unsigned destination = id;
194 int dest_x = -1;
195 int dest_y = -1;
196 int source = id;
197 int src_x = id%radix;
198 int src_y = id/radix;
199
200 if (singleDest >= 0)
201 {
202 destination = singleDest;
203 } else if (traffic == UNIFORM_RANDOM_) {
204 destination = random_mt.random<unsigned>(0, num_destinations - 1);
205 } else if (traffic == BIT_COMPLEMENT_) {
206 dest_x = radix - src_x - 1;
207 dest_y = radix - src_y - 1;
208 destination = dest_y*radix + dest_x;
209 } else if (traffic == BIT_REVERSE_) {
210 unsigned int straight = source;
211 unsigned int reverse = source & 1; // LSB
212
213 int num_bits = (int) log2(num_destinations);
214
215 for (int i = 1; i < num_bits; i++)
216 {
217 reverse <<= 1;
218 straight >>= 1;
219 reverse |= (straight & 1); // LSB
220 }
221 destination = reverse;
222 } else if (traffic == BIT_ROTATION_) {
223 if (source%2 == 0)
224 destination = source/2;
225 else // (source%2 == 1)
226 destination = ((source/2) + (num_destinations/2));
227 } else if (traffic == NEIGHBOR_) {
228 dest_x = (src_x + 1) % radix;
229 dest_y = src_y;
230 destination = dest_y*radix + dest_x;
231 } else if (traffic == SHUFFLE_) {
232 if (source < num_destinations/2)
233 destination = source*2;
234 else
235 destination = (source*2 - num_destinations + 1);
236 } else if (traffic == TRANSPOSE_) {
237 dest_x = src_y;
238 dest_y = src_x;
239 destination = dest_y*radix + dest_x;
240 } else if (traffic == TORNADO_) {
241 dest_x = (src_x + (int) ceil(radix/2) - 1) % radix;
242 dest_y = src_y;
243 destination = dest_y*radix + dest_x;
244 }
245 else {
246 fatal("Unknown Traffic Type: %s!\n", traffic);
247 }
248
249 // The source of the packets is a cache.
250 // The destination of the packets is a directory.
251 // The destination bits are embedded in the address after byte-offset.
252 Addr paddr = destination;
253 paddr <<= blockSizeBits;
254 unsigned access_size = 1; // Does not affect Ruby simulation
255
256 // Modeling different coherence msg types over different msg classes.
257 //
258 // GarnetSyntheticTraffic assumes the Garnet_standalone coherence protocol
259 // which models three message classes/virtual networks.
260 // These are: request, forward, response.
261 // requests and forwards are "control" packets (typically 8 bytes),
262 // while responses are "data" packets (typically 72 bytes).
263 //
264 // Life of a packet from the tester into the network:
265 // (1) This function generatePkt() generates packets of one of the
266 // following 3 types (randomly) : ReadReq, INST_FETCH, WriteReq
267 // (2) mem/ruby/system/RubyPort.cc converts these to RubyRequestType_LD,
268 // RubyRequestType_IFETCH, RubyRequestType_ST respectively
269 // (3) mem/ruby/system/Sequencer.cc sends these to the cache controllers
270 // in the coherence protocol.
271 // (4) Network_test-cache.sm tags RubyRequestType:LD,
272 // RubyRequestType:IFETCH and RubyRequestType:ST as
273 // Request, Forward, and Response events respectively;
274 // and injects them into virtual networks 0, 1 and 2 respectively.
275 // It immediately calls back the sequencer.
276 // (5) The packet traverses the network (simple/garnet) and reaches its
277 // destination (Directory), and network stats are updated.
278 // (6) Network_test-dir.sm simply drops the packet.
279 //
280 MemCmd::Command requestType;
281
282 Request *req = nullptr;
283 Request::Flags flags;
284
285 // Inject in specific Vnet
286 // Vnet 0 and 1 are for control packets (1-flit)
287 // Vnet 2 is for data packets (5-flit)
288 int injReqType = injVnet;
289
290 if (injReqType < 0 || injReqType > 2)
291 {
292 // randomly inject in any vnet
293 injReqType = random_mt.random(0, 2);
294 }
295
296 if (injReqType == 0) {
297 // generate packet for virtual network 0
298 requestType = MemCmd::ReadReq;
299 req = new Request(paddr, access_size, flags, masterId);
300 } else if (injReqType == 1) {
301 // generate packet for virtual network 1
302 requestType = MemCmd::ReadReq;
303 flags.set(Request::INST_FETCH);
304 req = new Request(0, 0x0, access_size, flags, masterId, 0x0, 0);
305 req->setPaddr(paddr);
306 } else { // if (injReqType == 2)
307 // generate packet for virtual network 2
308 requestType = MemCmd::WriteReq;
309 req = new Request(paddr, access_size, flags, masterId);
310 }
311
312 req->setContext(id);
313
314 //No need to do functional simulation
315 //We just do timing simulation of the network
316
317 DPRINTF(GarnetSyntheticTraffic,
318 "Generated packet with destination %d, embedded in address %x\n",
319 destination, req->getPaddr());
320
321 PacketPtr pkt = new Packet(req, requestType);
322 pkt->dataDynamic(new uint8_t[req->getSize()]);
323 pkt->senderState = NULL;
324
325 sendPkt(pkt);
326}
327
328void
329GarnetSyntheticTraffic::initTrafficType()
330{
331 trafficStringToEnum["bit_complement"] = BIT_COMPLEMENT_;
332 trafficStringToEnum["bit_reverse"] = BIT_REVERSE_;
333 trafficStringToEnum["bit_rotation"] = BIT_ROTATION_;
334 trafficStringToEnum["neighbor"] = NEIGHBOR_;
335 trafficStringToEnum["shuffle"] = SHUFFLE_;
336 trafficStringToEnum["tornado"] = TORNADO_;
337 trafficStringToEnum["transpose"] = TRANSPOSE_;
338 trafficStringToEnum["uniform_random"] = UNIFORM_RANDOM_;
339}
340
341void
342GarnetSyntheticTraffic::doRetry()
343{
344 if (cachePort.sendTimingReq(retryPkt)) {
345 retryPkt = NULL;
346 }
347}
348
349void
350GarnetSyntheticTraffic::printAddr(Addr a)
351{
352 cachePort.printAddr(a);
353}
354
355
356GarnetSyntheticTraffic *
357GarnetSyntheticTrafficParams::create()
358{
359 return new GarnetSyntheticTraffic(this);
360}
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)
78 : MemObject(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(name()))
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
113BaseMasterPort &
114GarnetSyntheticTraffic::getMasterPort(const std::string &if_name, PortID idx)
115{
116 if (if_name == "test")
117 return cachePort;
118 else
119 return MemObject::getMasterPort(if_name, idx);
120}
121
122void
123GarnetSyntheticTraffic::init()
124{
125 numPacketsSent = 0;
126}
127
128
129void
130GarnetSyntheticTraffic::completeRequest(PacketPtr pkt)
131{
132 Request *req = pkt->req;
133
134 DPRINTF(GarnetSyntheticTraffic,
135 "Completed injection of %s packet for address %x\n",
136 pkt->isWrite() ? "write" : "read\n",
137 req->getPaddr());
138
139 assert(pkt->isResponse());
140 noResponseCycles = 0;
141 delete req;
142 delete pkt;
143}
144
145
146void
147GarnetSyntheticTraffic::tick()
148{
149 if (++noResponseCycles >= responseLimit) {
150 fatal("%s deadlocked at cycle %d\n", name(), curTick());
151 }
152
153 // make new request based on injection rate
154 // (injection rate's range depends on precision)
155 // - generate a random number between 0 and 10^precision
156 // - send pkt if this number is < injRate*(10^precision)
157 bool sendAllowedThisCycle;
158 double injRange = pow((double) 10, (double) precision);
159 unsigned trySending = random_mt.random<unsigned>(0, (int) injRange);
160 if (trySending < injRate*injRange)
161 sendAllowedThisCycle = true;
162 else
163 sendAllowedThisCycle = false;
164
165 // always generatePkt unless fixedPkts or singleSender is enabled
166 if (sendAllowedThisCycle) {
167 bool senderEnable = true;
168
169 if (numPacketsMax >= 0 && numPacketsSent >= numPacketsMax)
170 senderEnable = false;
171
172 if (singleSender >= 0 && id != singleSender)
173 senderEnable = false;
174
175 if (senderEnable)
176 generatePkt();
177 }
178
179 // Schedule wakeup
180 if (curTick() >= simCycles)
181 exitSimLoop("Network Tester completed simCycles");
182 else {
183 if (!tickEvent.scheduled())
184 schedule(tickEvent, clockEdge(Cycles(1)));
185 }
186}
187
188void
189GarnetSyntheticTraffic::generatePkt()
190{
191 int num_destinations = numDestinations;
192 int radix = (int) sqrt(num_destinations);
193 unsigned destination = id;
194 int dest_x = -1;
195 int dest_y = -1;
196 int source = id;
197 int src_x = id%radix;
198 int src_y = id/radix;
199
200 if (singleDest >= 0)
201 {
202 destination = singleDest;
203 } else if (traffic == UNIFORM_RANDOM_) {
204 destination = random_mt.random<unsigned>(0, num_destinations - 1);
205 } else if (traffic == BIT_COMPLEMENT_) {
206 dest_x = radix - src_x - 1;
207 dest_y = radix - src_y - 1;
208 destination = dest_y*radix + dest_x;
209 } else if (traffic == BIT_REVERSE_) {
210 unsigned int straight = source;
211 unsigned int reverse = source & 1; // LSB
212
213 int num_bits = (int) log2(num_destinations);
214
215 for (int i = 1; i < num_bits; i++)
216 {
217 reverse <<= 1;
218 straight >>= 1;
219 reverse |= (straight & 1); // LSB
220 }
221 destination = reverse;
222 } else if (traffic == BIT_ROTATION_) {
223 if (source%2 == 0)
224 destination = source/2;
225 else // (source%2 == 1)
226 destination = ((source/2) + (num_destinations/2));
227 } else if (traffic == NEIGHBOR_) {
228 dest_x = (src_x + 1) % radix;
229 dest_y = src_y;
230 destination = dest_y*radix + dest_x;
231 } else if (traffic == SHUFFLE_) {
232 if (source < num_destinations/2)
233 destination = source*2;
234 else
235 destination = (source*2 - num_destinations + 1);
236 } else if (traffic == TRANSPOSE_) {
237 dest_x = src_y;
238 dest_y = src_x;
239 destination = dest_y*radix + dest_x;
240 } else if (traffic == TORNADO_) {
241 dest_x = (src_x + (int) ceil(radix/2) - 1) % radix;
242 dest_y = src_y;
243 destination = dest_y*radix + dest_x;
244 }
245 else {
246 fatal("Unknown Traffic Type: %s!\n", traffic);
247 }
248
249 // The source of the packets is a cache.
250 // The destination of the packets is a directory.
251 // The destination bits are embedded in the address after byte-offset.
252 Addr paddr = destination;
253 paddr <<= blockSizeBits;
254 unsigned access_size = 1; // Does not affect Ruby simulation
255
256 // Modeling different coherence msg types over different msg classes.
257 //
258 // GarnetSyntheticTraffic assumes the Garnet_standalone coherence protocol
259 // which models three message classes/virtual networks.
260 // These are: request, forward, response.
261 // requests and forwards are "control" packets (typically 8 bytes),
262 // while responses are "data" packets (typically 72 bytes).
263 //
264 // Life of a packet from the tester into the network:
265 // (1) This function generatePkt() generates packets of one of the
266 // following 3 types (randomly) : ReadReq, INST_FETCH, WriteReq
267 // (2) mem/ruby/system/RubyPort.cc converts these to RubyRequestType_LD,
268 // RubyRequestType_IFETCH, RubyRequestType_ST respectively
269 // (3) mem/ruby/system/Sequencer.cc sends these to the cache controllers
270 // in the coherence protocol.
271 // (4) Network_test-cache.sm tags RubyRequestType:LD,
272 // RubyRequestType:IFETCH and RubyRequestType:ST as
273 // Request, Forward, and Response events respectively;
274 // and injects them into virtual networks 0, 1 and 2 respectively.
275 // It immediately calls back the sequencer.
276 // (5) The packet traverses the network (simple/garnet) and reaches its
277 // destination (Directory), and network stats are updated.
278 // (6) Network_test-dir.sm simply drops the packet.
279 //
280 MemCmd::Command requestType;
281
282 Request *req = nullptr;
283 Request::Flags flags;
284
285 // Inject in specific Vnet
286 // Vnet 0 and 1 are for control packets (1-flit)
287 // Vnet 2 is for data packets (5-flit)
288 int injReqType = injVnet;
289
290 if (injReqType < 0 || injReqType > 2)
291 {
292 // randomly inject in any vnet
293 injReqType = random_mt.random(0, 2);
294 }
295
296 if (injReqType == 0) {
297 // generate packet for virtual network 0
298 requestType = MemCmd::ReadReq;
299 req = new Request(paddr, access_size, flags, masterId);
300 } else if (injReqType == 1) {
301 // generate packet for virtual network 1
302 requestType = MemCmd::ReadReq;
303 flags.set(Request::INST_FETCH);
304 req = new Request(0, 0x0, access_size, flags, masterId, 0x0, 0);
305 req->setPaddr(paddr);
306 } else { // if (injReqType == 2)
307 // generate packet for virtual network 2
308 requestType = MemCmd::WriteReq;
309 req = new Request(paddr, access_size, flags, masterId);
310 }
311
312 req->setContext(id);
313
314 //No need to do functional simulation
315 //We just do timing simulation of the network
316
317 DPRINTF(GarnetSyntheticTraffic,
318 "Generated packet with destination %d, embedded in address %x\n",
319 destination, req->getPaddr());
320
321 PacketPtr pkt = new Packet(req, requestType);
322 pkt->dataDynamic(new uint8_t[req->getSize()]);
323 pkt->senderState = NULL;
324
325 sendPkt(pkt);
326}
327
328void
329GarnetSyntheticTraffic::initTrafficType()
330{
331 trafficStringToEnum["bit_complement"] = BIT_COMPLEMENT_;
332 trafficStringToEnum["bit_reverse"] = BIT_REVERSE_;
333 trafficStringToEnum["bit_rotation"] = BIT_ROTATION_;
334 trafficStringToEnum["neighbor"] = NEIGHBOR_;
335 trafficStringToEnum["shuffle"] = SHUFFLE_;
336 trafficStringToEnum["tornado"] = TORNADO_;
337 trafficStringToEnum["transpose"] = TRANSPOSE_;
338 trafficStringToEnum["uniform_random"] = UNIFORM_RANDOM_;
339}
340
341void
342GarnetSyntheticTraffic::doRetry()
343{
344 if (cachePort.sendTimingReq(retryPkt)) {
345 retryPkt = NULL;
346 }
347}
348
349void
350GarnetSyntheticTraffic::printAddr(Addr a)
351{
352 cachePort.printAddr(a);
353}
354
355
356GarnetSyntheticTraffic *
357GarnetSyntheticTrafficParams::create()
358{
359 return new GarnetSyntheticTraffic(this);
360}