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\ help="Number of digits of precision after decimal point\
for injection rate") 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", parser.add_option("--fixed-pkts", action="store_true",
help="Network_test: send only -p number of packets") help="Network_test: send only -p number of packets")
@ -88,8 +91,10 @@ if options.num_cpus > block_size:
% (options.num_cpus, block_size) % (options.num_cpus, block_size)
sys.exit(1) sys.exit(1)
cpus = [ NetworkTest(fixed_pkts=options.fixed_pkts, \ cpus = [ NetworkTest(fixed_pkts=options.fixed_pkts, \
max_packets=options.maxpackets, \ max_packets=options.maxpackets, \
sim_cycles=options.sim_cycles, \
traffic_type=options.synthetic, \ traffic_type=options.synthetic, \
inj_rate=options.injectionrate, \ inj_rate=options.injectionrate, \
precision=options.precision, \ precision=options.precision, \

View file

@ -34,6 +34,7 @@ class NetworkTest(MemObject):
block_offset = Param.Int(6, "block offset in bits") block_offset = Param.Int(6, "block offset in bits")
num_memories = Param.Int(1, "Num Memories") num_memories = Param.Int(1, "Num Memories")
memory_size = Param.Int(65536, "memory size") 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") 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") 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") traffic_type = Param.Counter(0, "Traffic type: uniform random, tornado, bit complement")

View file

@ -103,13 +103,10 @@ NetworkTest::CpuPort::recvRetry()
void void
NetworkTest::sendPkt(PacketPtr pkt) NetworkTest::sendPkt(PacketPtr pkt)
{ {
if (cachePort.sendTiming(pkt)) { if (!cachePort.sendTiming(pkt)) {
numPacketsSent++; retryPkt = pkt; // RubyPort will retry sending
accessRetry = false;
} else {
accessRetry = true;
retryPkt = pkt;
} }
numPacketsSent++;
} }
NetworkTest::NetworkTest(const Params *p) NetworkTest::NetworkTest(const Params *p)
@ -120,6 +117,7 @@ NetworkTest::NetworkTest(const Params *p)
size(p->memory_size), size(p->memory_size),
blockSizeBits(p->block_offset), blockSizeBits(p->block_offset),
numMemories(p->num_memories), numMemories(p->num_memories),
simCycles(p->sim_cycles),
fixedPkts(p->fixed_pkts), fixedPkts(p->fixed_pkts),
maxPackets(p->max_packets), maxPackets(p->max_packets),
trafficType(p->traffic_type), trafficType(p->traffic_type),
@ -135,8 +133,6 @@ NetworkTest::NetworkTest(const Params *p)
id = TESTER_NETWORK++; id = TESTER_NETWORK++;
DPRINTF(NetworkTest,"Config Created: Name = %s , and id = %d\n", DPRINTF(NetworkTest,"Config Created: Name = %s , and id = %d\n",
name(), id); name(), id);
accessRetry = false;
} }
Port * Port *
@ -174,19 +170,11 @@ NetworkTest::completeRequest(PacketPtr pkt)
void void
NetworkTest::tick() NetworkTest::tick()
{ {
if (!tickEvent.scheduled())
schedule(tickEvent, curTick() + ticks(1));
if (++noResponseCycles >= 500000) { if (++noResponseCycles >= 500000) {
cerr << name() << ": deadlocked at cycle " << curTick() << endl; cerr << name() << ": deadlocked at cycle " << curTick() << endl;
fatal(""); fatal("");
} }
if (accessRetry) {
sendPkt(retryPkt);
return;
}
// make new request based on injection rate // make new request based on injection rate
// (injection rate's range depends on precision) // (injection rate's range depends on precision)
// - generate a random number between 0 and 10^precision // - generate a random number between 0 and 10^precision
@ -209,6 +197,14 @@ NetworkTest::tick()
generatePkt(); generatePkt();
} }
} }
// Schedule wakeup
if (curTick() >= simCycles)
exitSimLoop("Network Tester completed simCycles");
else {
if (!tickEvent.scheduled())
schedule(tickEvent, curTick() + ticks(1));
}
} }
void void
@ -216,7 +212,6 @@ NetworkTest::generatePkt()
{ {
unsigned destination = id; unsigned destination = id;
if (trafficType == 0) { // Uniform Random if (trafficType == 0) { // Uniform Random
while (destination == id)
destination = random() % numMemories; destination = random() % numMemories;
} else if (trafficType == 1) { // Tornado } else if (trafficType == 1) { // Tornado
int networkDimension = (int) sqrt(numMemories); int networkDimension = (int) sqrt(numMemories);
@ -315,7 +310,6 @@ void
NetworkTest::doRetry() NetworkTest::doRetry()
{ {
if (cachePort.sendTiming(retryPkt)) { if (cachePort.sendTiming(retryPkt)) {
accessRetry = false;
retryPkt = NULL; retryPkt = NULL;
} }
} }

View file

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