From 1267ff59499e1d3a0de9b05b84f58d65db684c1e Mon Sep 17 00:00:00 2001 From: Tushar Krishna Date: Sat, 7 May 2011 17:43:30 -0400 Subject: [PATCH] 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. --- configs/example/ruby_network_test.py | 5 ++++ src/cpu/testers/networktest/NetworkTest.py | 1 + src/cpu/testers/networktest/networktest.cc | 32 +++++++++------------- src/cpu/testers/networktest/networktest.hh | 2 +- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/configs/example/ruby_network_test.py b/configs/example/ruby_network_test.py index 6abf50561..ebc271208 100644 --- a/configs/example/ruby_network_test.py +++ b/configs/example/ruby_network_test.py @@ -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, \ diff --git a/src/cpu/testers/networktest/NetworkTest.py b/src/cpu/testers/networktest/NetworkTest.py index d4eef09c5..0a18ca938 100644 --- a/src/cpu/testers/networktest/NetworkTest.py +++ b/src/cpu/testers/networktest/NetworkTest.py @@ -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") 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; } } diff --git a/src/cpu/testers/networktest/networktest.hh b/src/cpu/testers/networktest/networktest.hh index 96daa5af2..6d9d1edad 100644 --- a/src/cpu/testers/networktest/networktest.hh +++ b/src/cpu/testers/networktest/networktest.hh @@ -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; -- 2.30.2