changeset db269e704d07 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=db269e704d07
description:
        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:

 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(-)

diffs (144 lines):

diff -r 0990d8c19b64 -r db269e704d07 configs/example/ruby_network_test.py
--- a/configs/example/ruby_network_test.py      Sat May 07 17:28:15 2011 -0400
+++ b/configs/example/ruby_network_test.py      Sat May 07 17:43:30 2011 -0400
@@ -61,6 +61,9 @@
                   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 @@
            % (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 -r 0990d8c19b64 -r db269e704d07 src/cpu/testers/networktest/NetworkTest.py
--- a/src/cpu/testers/networktest/NetworkTest.py        Sat May 07 17:28:15 
2011 -0400
+++ b/src/cpu/testers/networktest/NetworkTest.py        Sat May 07 17:43:30 
2011 -0400
@@ -34,6 +34,7 @@
     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 -r 0990d8c19b64 -r db269e704d07 src/cpu/testers/networktest/networktest.cc
--- a/src/cpu/testers/networktest/networktest.cc        Sat May 07 17:28:15 
2011 -0400
+++ b/src/cpu/testers/networktest/networktest.cc        Sat May 07 17:43:30 
2011 -0400
@@ -103,13 +103,10 @@
 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 @@
       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 @@
     id = TESTER_NETWORK++;
     DPRINTF(NetworkTest,"Config Created: Name = %s , and id = %d\n",
             name(), id);
-
-    accessRetry = false;
 }
 
 Port *
@@ -174,19 +170,11 @@
 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 @@
             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 @@
 {
     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 @@
 NetworkTest::doRetry()
 {
     if (cachePort.sendTiming(retryPkt)) {
-        accessRetry = false;
         retryPkt = NULL;
     }
 }
diff -r 0990d8c19b64 -r db269e704d07 src/cpu/testers/networktest/networktest.hh
--- a/src/cpu/testers/networktest/networktest.hh        Sat May 07 17:28:15 
2011 -0400
+++ b/src/cpu/testers/networktest/networktest.hh        Sat May 07 17:43:30 
2011 -0400
@@ -125,7 +125,6 @@
     };
 
     PacketPtr retryPkt;
-    bool accessRetry;
     unsigned size;
     int id;
 
@@ -134,6 +133,7 @@
     Tick noResponseCycles;
 
     int numMemories;
+    Tick simCycles;
     bool fixedPkts;
     int maxPackets;
     int numPacketsSent;
_______________________________________________
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to