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.
This commit is contained in:
Tushar Krishna 2011-05-07 17:43:30 -04:00
parent 770f2ce330
commit 1267ff5949
4 changed files with 20 additions and 20 deletions

View file

@ -61,6 +61,9 @@ parser.add_option("--precision", type="int", default=3,
help="Number of digits of precision after decimal point\
for injection rate")
parser.add_option("--sim-cycles", type="int", default=1000,
help="Number of simulation cycles")
parser.add_option("--fixed-pkts", action="store_true",
help="Network_test: send only -p number of packets")
@ -88,8 +91,10 @@ if options.num_cpus > block_size:
% (options.num_cpus, block_size)
sys.exit(1)
cpus = [ NetworkTest(fixed_pkts=options.fixed_pkts, \
max_packets=options.maxpackets, \
sim_cycles=options.sim_cycles, \
traffic_type=options.synthetic, \
inj_rate=options.injectionrate, \
precision=options.precision, \

View file

@ -34,6 +34,7 @@ class NetworkTest(MemObject):
block_offset = Param.Int(6, "block offset in bits")
num_memories = Param.Int(1, "Num Memories")
memory_size = Param.Int(65536, "memory size")
sim_cycles = Param.Int(1000, "Number of simulation cycles")
fixed_pkts = Param.Bool(False, "Send fixed number of packets")
max_packets = Param.Counter(0, "Number of packets to send when in fixed_pkts mode")
traffic_type = Param.Counter(0, "Traffic type: uniform random, tornado, bit complement")

View file

@ -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,7 +212,6 @@ NetworkTest::generatePkt()
{
unsigned destination = id;
if (trafficType == 0) { // Uniform Random
while (destination == id)
destination = random() % numMemories;
} else if (trafficType == 1) { // Tornado
int networkDimension = (int) sqrt(numMemories);
@ -315,7 +310,6 @@ void
NetworkTest::doRetry()
{
if (cachePort.sendTiming(retryPkt)) {
accessRetry = false;
retryPkt = NULL;
}
}

View file

@ -125,7 +125,6 @@ class NetworkTest : public MemObject
};
PacketPtr retryPkt;
bool accessRetry;
unsigned size;
int id;
@ -134,6 +133,7 @@ class NetworkTest : public MemObject
Tick noResponseCycles;
int numMemories;
Tick simCycles;
bool fixedPkts;
int maxPackets;
int numPacketsSent;