ruby: guard usage of GPUCoalescer code in Profiler
authorTony Gutierrez <anthony.gutierrez@amd.com>
Thu, 19 Jan 2017 16:59:34 +0000 (11:59 -0500)
committerTony Gutierrez <anthony.gutierrez@amd.com>
Thu, 19 Jan 2017 16:59:34 +0000 (11:59 -0500)
the GPUCoalescer code is used in the ruby profiler regardless of
whether or not the coalescer code has been compiled, which can
lead to link/run time errors. here we add #ifdefs to guard the
usage of GPUCoalescer code. eventually we should refactor this
code to use probe points.

SConstruct
src/mem/ruby/profiler/Profiler.cc

index f8eac47e6d049a7d57b9c04a70c54abff91fc277..8a72419b4f54d9ce76d8b86fb28b17c916b7e105 100755 (executable)
@@ -1502,6 +1502,9 @@ for variant_path in variant_paths:
                 "target ISA combination"
             env['USE_KVM'] = False
 
+    if env['BUILD_GPU']:
+        env.Append(CPPDEFINES=['BUILD_GPU'])
+
     # Warn about missing optional functionality
     if env['USE_KVM']:
         if not main['HAVE_PERF_ATTR_EXCLUDE_HOST']:
index 04e8331c4edac167c80d5d4811ccccc99b6e6d46..900714e5d7d4feb0356a8095d5c0fb089c46620c 100644 (file)
 #include "mem/protocol/RubyRequest.hh"
 #include "mem/ruby/network/Network.hh"
 #include "mem/ruby/profiler/AddressProfiler.hh"
+
+/**
+ * the profiler uses GPUCoalescer code even
+ * though the GPUCoalescer is not built for
+ * all ISAs, which can lead to run/link time
+ * errors. here we guard the coalescer code
+ * with ifdefs as there is no easy way to
+ * refactor this code without removing
+ * GPUCoalescer stats from the profiler.
+ *
+ * eventually we should use probe points
+ * here, but until then these ifdefs will
+ * serve.
+ */
+#ifdef BUILD_GPU
 #include "mem/ruby/system/GPUCoalescer.hh"
+#endif
+
 #include "mem/ruby/system/Sequencer.hh"
 
 using namespace std;
@@ -361,10 +378,12 @@ Profiler::collateStats()
             if (seq != NULL) {
                 m_outstandReqHistSeqr.add(seq->getOutstandReqHist());
             }
+#ifdef BUILD_GPU
             GPUCoalescer *coal = ctr->getGPUCoalescer();
             if (coal != NULL) {
                 m_outstandReqHistCoalsr.add(coal->getOutstandReqHist());
             }
+#endif
         }
     }
 
@@ -423,7 +442,7 @@ Profiler::collateStats()
                     }
                 }
             }
-
+#ifdef BUILD_GPU
             GPUCoalescer *coal = ctr->getGPUCoalescer();
             if (coal != NULL) {
                 // add all the latencies
@@ -464,6 +483,7 @@ Profiler::collateStats()
                     }
                 }
             }
+#endif
         }
     }
 }