summaryrefslogtreecommitdiff
path: root/src/cpu/testers/networktest/networktest.cc
diff options
context:
space:
mode:
authorTushar Krishna <tushar@csail.mit.edu>2011-05-07 17:43:30 -0400
committerTushar Krishna <tushar@csail.mit.edu>2011-05-07 17:43:30 -0400
commit1267ff59499e1d3a0de9b05b84f58d65db684c1e (patch)
treeb6e4628abc815c428ee6eda44e0bbc5b24781483 /src/cpu/testers/networktest/networktest.cc
parent770f2ce3307d336f2f804dd035a58da2503adadb (diff)
downloadgem5-1267ff59499e1d3a0de9b05b84f58d65db684c1e.tar.xz
NetworkTest: added sim_cycles parameter to the network tester.
The network tester terminates after injecting for sim_cycles (default=1000), instead of having to explicitly pass --maxticks from the command line as before. If fixed_pkts is enabled, the tester only injects maxpackets number of packets, else it keeps injecting till sim_cycles. The tester also works with zero command line arguments now.
Diffstat (limited to 'src/cpu/testers/networktest/networktest.cc')
-rw-r--r--src/cpu/testers/networktest/networktest.cc32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/cpu/testers/networktest/networktest.cc b/src/cpu/testers/networktest/networktest.cc
index dcc47675b..d78f976be 100644
--- a/src/cpu/testers/networktest/networktest.cc
+++ b/src/cpu/testers/networktest/networktest.cc
@@ -103,13 +103,10 @@ NetworkTest::CpuPort::recvRetry()
void
NetworkTest::sendPkt(PacketPtr pkt)
{
- if (cachePort.sendTiming(pkt)) {
- numPacketsSent++;
- accessRetry = false;
- } else {
- accessRetry = true;
- retryPkt = pkt;
+ if (!cachePort.sendTiming(pkt)) {
+ retryPkt = pkt; // RubyPort will retry sending
}
+ numPacketsSent++;
}
NetworkTest::NetworkTest(const Params *p)
@@ -120,6 +117,7 @@ NetworkTest::NetworkTest(const Params *p)
size(p->memory_size),
blockSizeBits(p->block_offset),
numMemories(p->num_memories),
+ simCycles(p->sim_cycles),
fixedPkts(p->fixed_pkts),
maxPackets(p->max_packets),
trafficType(p->traffic_type),
@@ -135,8 +133,6 @@ NetworkTest::NetworkTest(const Params *p)
id = TESTER_NETWORK++;
DPRINTF(NetworkTest,"Config Created: Name = %s , and id = %d\n",
name(), id);
-
- accessRetry = false;
}
Port *
@@ -174,19 +170,11 @@ NetworkTest::completeRequest(PacketPtr pkt)
void
NetworkTest::tick()
{
- if (!tickEvent.scheduled())
- schedule(tickEvent, curTick() + ticks(1));
-
if (++noResponseCycles >= 500000) {
cerr << name() << ": deadlocked at cycle " << curTick() << endl;
fatal("");
}
- if (accessRetry) {
- sendPkt(retryPkt);
- return;
- }
-
// make new request based on injection rate
// (injection rate's range depends on precision)
// - generate a random number between 0 and 10^precision
@@ -209,6 +197,14 @@ NetworkTest::tick()
generatePkt();
}
}
+
+ // Schedule wakeup
+ if (curTick() >= simCycles)
+ exitSimLoop("Network Tester completed simCycles");
+ else {
+ if (!tickEvent.scheduled())
+ schedule(tickEvent, curTick() + ticks(1));
+ }
}
void
@@ -216,8 +212,7 @@ NetworkTest::generatePkt()
{
unsigned destination = id;
if (trafficType == 0) { // Uniform Random
- while (destination == id)
- destination = random() % numMemories;
+ destination = random() % numMemories;
} else if (trafficType == 1) { // Tornado
int networkDimension = (int) sqrt(numMemories);
int my_x = id%networkDimension;
@@ -315,7 +310,6 @@ void
NetworkTest::doRetry()
{
if (cachePort.sendTiming(retryPkt)) {
- accessRetry = false;
retryPkt = NULL;
}
}