base: Use M5_UNLIKELY with conditional DPRINTF family functions.
authorGabe Black <gabeblack@google.com>
Fri, 18 Sep 2020 03:50:27 +0000 (20:50 -0700)
committerGabe Black <gabeblack@google.com>
Sun, 20 Sep 2020 01:03:39 +0000 (01:03 +0000)
Most DPRINTFs will be skipped over most of the time, and when they
aren't they'll already have overhead from string handling, output to the
console and/or a file, etc, which will drown out the behavior of a
branch.

Change-Id: I5475d7b5add63b44f60c0a1d46b4b14e6bf30fd3
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/34818
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/base/trace.hh

index 3d8752cfc941dc1df0a138e0edbc763e2bc1227e..aafb9c8e434f5b31028403d3c8dce0297d82f45e 100644 (file)
@@ -182,14 +182,14 @@ class Named
 
 #define DDUMP(x, data, count) do {               \
     using namespace Debug;                       \
-    if (DTRACE(x))                               \
+    if (M5_UNLIKELY(DTRACE(x)))                  \
         Trace::getDebugLogger()->dump(           \
             curTick(), name(), data, count, #x); \
 } while (0)
 
 #define DPRINTF(x, ...) do {                     \
     using namespace Debug;                       \
-    if (DTRACE(x)) {                             \
+    if (M5_UNLIKELY(DTRACE(x))) {                \
         Trace::getDebugLogger()->dprintf_flag(   \
             curTick(), name(), #x, __VA_ARGS__); \
     }                                            \
@@ -197,7 +197,7 @@ class Named
 
 #define DPRINTFS(x, s, ...) do {                        \
     using namespace Debug;                              \
-    if (DTRACE(x)) {                                    \
+    if (M5_UNLIKELY(DTRACE(x))) {                       \
         Trace::getDebugLogger()->dprintf_flag(          \
                 curTick(), s->name(), #x, __VA_ARGS__); \
     }                                                   \
@@ -205,7 +205,7 @@ class Named
 
 #define DPRINTFR(x, ...) do {                          \
     using namespace Debug;                             \
-    if (DTRACE(x)) {                                   \
+    if (M5_UNLIKELY(DTRACE(x))) {                      \
         Trace::getDebugLogger()->dprintf_flag(         \
             (Tick)-1, std::string(), #x, __VA_ARGS__); \
     }                                                  \