changeset 94d6ffac1e9b in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=94d6ffac1e9b
description:
        mem: Auto-generate CommMonitor trace file names

        Splits the CommMonitor trace_file parameter into three parameters. 
Previously,
        the trace was only enabled if the trace_file parameter was set, and 
would be
        written to this file. This patch adds in a trace_enable and 
trace_compress
        parameter to the CommMonitor.

        No trace is generated if trace_enable is set to False. If it is set to 
True, the
        trace is written to a file based on the name of the SimObject in the 
simulation
        hierarchy. For example, system.cluster.il1_commmonitor.trc. This 
filename can be
        overridden by additionally specifying a file name to the trace_file 
parameter
        (more on this later).

        The trace_compress parameter will append .gz to any filename if set to 
True.
        This enables compression of the generated traces. If the file name 
already ends
        in .gz, then no changes are made.

        The trace_file parameter will override the name set by the trace_enable
        parameter. In the case that the specified name does not end in .gz but
        trace_compress is set to true, .gz is appended to the supplied file 
name.

diffstat:

 src/mem/CommMonitor.py           |   7 +++++++
 src/mem/comm_monitor.cc          |  27 ++++++++++++++++++++++-----
 tests/configs/tgen-simple-mem.py |   3 ++-
 3 files changed, 31 insertions(+), 6 deletions(-)

diffs (67 lines):

diff -r c09802451018 -r 94d6ffac1e9b src/mem/CommMonitor.py
--- a/src/mem/CommMonitor.py    Fri May 09 18:58:46 2014 -0400
+++ b/src/mem/CommMonitor.py    Fri May 09 18:58:46 2014 -0400
@@ -53,6 +53,13 @@
     master = MasterPort("Master port")
     slave = SlavePort("Slave port")
 
+    # Boolean to enable or disable the trace. Writes to an a file named based 
on
+    # SimObject hierarchy.
+    trace_enable = Param.Bool(False, "Enable trace capture")
+
+    # Boolean to compress the trace or not.
+    trace_compress = Param.Bool(True, "Enable trace compression")
+
     # packet trace output file, disabled by default
     trace_file = Param.String("", "Packet trace output file")
 
diff -r c09802451018 -r 94d6ffac1e9b src/mem/comm_monitor.cc
--- a/src/mem/comm_monitor.cc   Fri May 09 18:58:46 2014 -0400
+++ b/src/mem/comm_monitor.cc   Fri May 09 18:58:46 2014 -0400
@@ -58,11 +58,28 @@
       traceStream(NULL),
       system(params->system)
 {
-    // If we are using a trace file, then open the file,
-    if (params->trace_file != "") {
-        // If the trace file is not specified as an absolute path,
-        // append the current simulation output directory
-        std::string filename = simout.resolve(params->trace_file);
+    // If we are using a trace file, then open the file
+    if (params->trace_enable) {
+        std::string filename;
+        if (params->trace_file != "") {
+            // If the trace file is not specified as an absolute path,
+            // append the current simulation output directory
+            filename = simout.resolve(params->trace_file);
+
+            std::string suffix = ".gz";
+            // If trace_compress has been set, check the suffix. Append
+            // accordingly.
+            if (params->trace_compress &&
+                filename.compare(filename.size() - suffix.size(), 
suffix.size(),
+                                 suffix) != 0)
+                    filename = filename + suffix;
+        } else {
+            // Generate a filename from the name of the SimObject. Append .trc
+            // and .gz if we want compression enabled.
+            filename = simout.resolve(name() + ".trc" +
+                                      (params->trace_compress ? ".gz" : ""));
+        }
+
         traceStream = new ProtoOutputStream(filename);
 
         // Create a protobuf message for the header and write it to
diff -r c09802451018 -r 94d6ffac1e9b tests/configs/tgen-simple-mem.py
--- a/tests/configs/tgen-simple-mem.py  Fri May 09 18:58:46 2014 -0400
+++ b/tests/configs/tgen-simple-mem.py  Fri May 09 18:58:46 2014 -0400
@@ -55,7 +55,8 @@
                                             VoltageDomain()))
 
 # add a communication monitor, and also trace all the packets
-system.monitor = CommMonitor(trace_file = "monitor.ptrc.gz")
+system.monitor = CommMonitor(trace_file = "monitor.ptrc.gz",
+                             trace_enable = True)
 
 # connect the traffic generator to the bus via a communication monitor
 system.cpu.port = system.monitor.slave
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to